added a new global option "hostname lookups = yes/no"
authorAndrew Tridgell <tridge@samba.org>
Thu, 13 Sep 2001 00:30:47 +0000 (00:30 +0000)
committerAndrew Tridgell <tridge@samba.org>
Thu, 13 Sep 2001 00:30:47 +0000 (00:30 +0000)
This should finally kill off the remaining places where we
attempt reverse lookups of the IP of the client. It may be that some
pam modules called via the session code will need "hostname lookups = yes"
but I've left it off by default as most sites don't need it and so
many sites have broken reverse maps
(This used to be commit 2b83ad03965d00bba88fe56452d2990099b75ef1)

source3/lib/util_sock.c
source3/param/loadparm.c

index 47f1d507ed0ff196b901ce4c5688124ab3cdfa21..9d7e5df303e8da173ab1e101d429f2ad623c7c37 100644 (file)
@@ -984,6 +984,14 @@ char *get_socket_name(int fd)
        struct hostent *hp;
        struct in_addr addr;
        char *p;
+
+       /* reverse lookups can be *very* expensive, and in many
+          situations won't work because many networks don't link dhcp
+          with dns. To avoid the delay we avoid the lookup if
+          possible */
+       if (!lp_hostname_lookups()) {
+               return get_socket_addr(fd);
+       }
        
        p = get_socket_addr(fd);
 
index 5e7bb60f69d828e7f266844c70d1dc9b8e372091..951bfa5ec2008e5644fa4c2a945ee1c8e965ae11 100644 (file)
@@ -265,6 +265,7 @@ typedef struct
        BOOL bHideLocalUsers;
        BOOL bUnicode;
        BOOL bUseMmap;
+       BOOL bHostnameLookups;
 }
 global;
 
@@ -812,6 +813,7 @@ static struct parm_struct parm_table[] = {
        {"strict sync", P_BOOL, P_LOCAL, &sDefault.bStrictSync, NULL, NULL, FLAG_SHARE},
        {"sync always", P_BOOL, P_LOCAL, &sDefault.bSyncAlways, NULL, NULL, FLAG_SHARE},
        {"use mmap", P_BOOL, P_GLOBAL, &Globals.bUseMmap, NULL, NULL, 0},
+       {"hostname lookups", P_BOOL, P_GLOBAL, &Globals.bHostnameLookups, NULL, NULL, 0},
        {"write cache size", P_INTEGER, P_LOCAL, &sDefault.iWriteCacheSize, NULL, NULL, FLAG_SHARE},
 
        {"Printing Options", P_SEP, P_SEPARATOR},
@@ -1289,6 +1291,10 @@ static void init_globals(void)
        Globals.bUseMmap = True;
 #endif
 
+       /* hostname lookups can be very expensive and are broken on
+          a large number of sites (tridge) */
+       Globals.bHostnameLookups = False;
+
 #ifdef WITH_LDAP
        /* default values for ldap */
        string_set(&Globals.szLdapServer, "localhost");
@@ -1565,6 +1571,7 @@ FN_GLOBAL_BOOL(lp_host_msdfs, &Globals.bHostMSDfs)
 FN_GLOBAL_BOOL(lp_kernel_oplocks, &Globals.bKernelOplocks)
 FN_GLOBAL_BOOL(lp_enhanced_browsing, &Globals.enhanced_browsing)
 FN_GLOBAL_BOOL(lp_use_mmap, &Globals.bUseMmap)
+FN_GLOBAL_BOOL(lp_hostname_lookups, &Globals.bHostnameLookups)
 FN_GLOBAL_INTEGER(lp_os_level, &Globals.os_level)
 FN_GLOBAL_INTEGER(lp_max_ttl, &Globals.max_ttl)
 FN_GLOBAL_INTEGER(lp_max_wins_ttl, &Globals.max_wins_ttl)