bump version
[buildroot.git] / package / portmap / portmap-4.0-cleanup.patch
blob2e005afe28e449d8549ac804bf49f6e06d45d95a
1 Some cleanup for my last patch.
4 --
5 H.J. Lu (hjl@gnu.org)
6 --
7 --- portmap_4/pmap_check.c.hostname Wed May 10 10:23:35 2000
8 +++ portmap_4/pmap_check.c Wed May 10 11:03:22 2000
9 @@ -35,6 +35,7 @@
10 static char sccsid[] = "@(#) pmap_check.c 1.6 93/11/21 20:58:59";
11 #endif
12 #include <unistd.h>
13 +#include <string.h>
14 #include <rpc/rpc.h>
15 #include <rpc/pmap_prot.h>
16 #include <syslog.h>
17 @@ -69,8 +70,6 @@ int deny_severity = LOG_WARNING;
18 /* coming from libwrap.a (tcp_wrappers) */
19 extern int hosts_ctl(char *daemon, char *name, char *addr, char *user);
21 -#define good_client(a) hosts_ctl("portmap", "", inet_ntoa(a->sin_addr), "")
23 #define reserved_port(p) (IPPORT_RESERVED/2 < (p) && (p) < IPPORT_RESERVED)
25 #define unreserved_port(p) (IPPORT_RESERVED <= (p) && (p) != NFS_PORT)
26 @@ -88,6 +87,59 @@ extern int hosts_ctl(char *daemon, char
28 #define log_client(addr, proc, prog) \
29 logit(allow_severity, addr, proc, prog, "")
31 +#ifdef HOSTS_ACCESS
32 +static int
33 +good_client(addr)
34 +struct sockaddr_in *addr;
36 + struct hostent *hp;
37 + char **sp;
38 + char *tmpname;
40 + /* Check the IP address first. */
41 + if (hosts_ctl("portmap", "", inet_ntoa(addr->sin_addr), ""))
42 + return 1;
44 + /* Check the hostname. */
45 + hp = gethostbyaddr ((const char *) &(addr->sin_addr),
46 + sizeof (addr->sin_addr), AF_INET);
48 + if (!hp)
49 + return 0;
51 + /* must make sure the hostent is authorative. */
52 + tmpname = alloca (strlen (hp->h_name) + 1);
53 + strcpy (tmpname, hp->h_name);
54 + hp = gethostbyname(tmpname);
55 + if (hp) {
56 + /* now make sure the "addr->sin_addr" is on the list */
57 + for (sp = hp->h_addr_list ; *sp ; sp++) {
58 + if (memcmp(*sp, &(addr->sin_addr), hp->h_length)==0)
59 + break;
60 + }
61 + if (!*sp)
62 + /* it was a FAKE. */
63 + return 0;
64 + }
65 + else
66 + /* never heard of it. misconfigured DNS? */
67 + return 0;
69 + /* Check the official name first. */
70 + if (hosts_ctl("portmap", "", hp->h_name, ""))
71 + return 1;
73 + /* Check aliases. */
74 + for (sp = hp->h_aliases; *sp ; sp++) {
75 + if (hosts_ctl("portmap", "", *sp, ""))
76 + return 1;
77 + }
79 + /* No match */
80 + return 0;
82 +#endif
84 /* check_startup - additional startup code */