add '-n' option to the server, which REQUIRES all IP addresses
authoraland <aland>
Thu, 23 Dec 1999 21:20:16 +0000 (21:20 +0000)
committeraland <aland>
Thu, 23 Dec 1999 21:20:16 +0000 (21:20 +0000)
to be given numerically, and NOT by host name.

Added support in library to NOT call any 'gethostbyFOO' functions
if we have DNS turned off.

Added complaints in 'files.c' to error out if we fail to look
up a host name.

src/lib/misc.c
src/main/files.c
src/main/radiusd.c

index 9659920..1c9dd85 100644 (file)
@@ -38,6 +38,14 @@ char * ip_hostname(UINT4 ipaddr)
        struct          hostent *hp;
        static char     hstname[128];
 
+       /*
+        *      No DNS: don't look up host names
+        */
+       if (!librad_dodns) {
+               ip_ntoa(hstname, ipaddr);
+               return(hstname);
+       }
+
        hp = gethostbyaddr((char *)&ipaddr, sizeof (struct in_addr), AF_INET);
        if (hp == 0) {
                ip_ntoa(hstname, ipaddr);
@@ -59,6 +67,13 @@ UINT4 ip_getaddr(const char *host)
        if ((a = ip_addr(host)) != 0)
                return a;
 
+       /*
+        *      No DNS: don't look up host names
+        */
+       if (!librad_dodns) {
+               return 0;
+       }
+
        if ((hp = gethostbyname(host)) == NULL)
                return (UINT4)0;
 
index 4b2da46..4322bb0 100644 (file)
@@ -360,6 +360,11 @@ int read_clients_file(const char *file)
                }
 
                c->ipaddr = ip_getaddr(hostnm);
+               if (c->ipaddr == 0) {
+                       log(L_CONS|L_ERR, "%s[%d]: Failed to look up hostname %s",
+                           file, lineno, hostnm);
+                       return -1;
+               }
                strcpy(c->secret, secret);
                strcpy(c->shortname, shortnm);
                strcpy(c->longname, ip_hostname(c->ipaddr));
@@ -478,6 +483,11 @@ static int read_realms_file(const char *file)
                }
                if (strcmp(hostnm, "LOCAL") != 0)
                        c->ipaddr = ip_getaddr(hostnm);
+               if (c->ipaddr == 0) {
+                       log(L_CONS|L_ERR, "%s[%d]: Failed to look up hostname %s",
+                           file, lineno, hostnm);
+                       return -1;
+               }
 
                /*
                 *      Double-check lengths to be sure they're sane
index 9689539..167e344 100644 (file)
@@ -222,7 +222,7 @@ int main(int argc, char **argv)
        /*
         *      Process the options.
         */
-       while((argval = getopt(argc, argv, "ASa:ci:l:d:bfp:svxyz")) != EOF) {
+       while((argval = getopt(argc, argv, "ASa:ci:l:d:bfnp:svxyz")) != EOF) {
 
                switch(argval) {
 
@@ -262,7 +262,11 @@ int main(int argc, char **argv)
                case 'l':
                        radlog_dir = optarg;
                        break;
-               
+
+               case 'n':
+                       librad_dodns = 0;
+                       break;
+
                case 'S':
                        log_stripped_names++;
                        break;