r14868: I will not write code when changing to Daylight Savings Time.
authorGerald Carter <jerry@samba.org>
Sun, 2 Apr 2006 19:45:42 +0000 (19:45 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:15:52 +0000 (11:15 -0500)
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.
I will not write code when changing to Daylight Savings Time.

...

Fix my brain dead inverted logic for turning winbindd on and off
when run on a DC or when calling pdb functions from within winbindd.
(This used to be commit 021b3dc2db9fb422ede4657a1f27ef7ef2d22cee)

source3/lib/system_smbd.c
source3/nsswitch/wb_common.c
source3/nsswitch/winbindd.c
source3/passdb/pdb_interface.c

index ac7a096295cafb16c71dee5a21190a2006b3399a..afa64489cfda324d67a7e94a2a87c740ee1d484a 100644 (file)
@@ -132,13 +132,7 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp
         * always determined by the info3 coming back from auth3 or the
         * PAC. */
 
-       if ( !winbind_putenv("0") ) {
-               DEBUG(0,("sys_getgroup_list: Insufficient environment space "
-                        "for %s\n", WINBINDD_DONT_ENV));
-       } else {
-               DEBUG(10,("sys_getgrouplist(): disabled winbindd for group "
-                         "lookup [user == %s]\n", user));
-       }
+       winbind_off() ;
 
 #ifdef HAVE_GETGROUPLIST
        retval = getgrouplist(user, gid, groups, grpcnt);
@@ -148,10 +142,12 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp
        unbecome_root();
 #endif
 
-       /* allow winbindd lookups */
+       /* allow winbindd lookups , but only if they were not already disabled */
+
+       if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+               winbind_on();
+       }
 
-       winbind_putenv( winbindd_env ? winbindd_env : "1" );
-       
        return retval;
 }
 
index 05f080e73a98f96dade17734bd876846311a846b..91ec912b7d0fa8495564312f9def0c7a55da6007 100644 (file)
@@ -618,15 +618,17 @@ NSS_STATUS winbindd_request_response(int req_type,
 /* Use putenv() instead of setenv() in these functions as not all
    environments have the latter. */
 
-BOOL winbind_putenv( const char *s )
+BOOL winbind_off( void )
 {
-       fstring env;
+       static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=1");
 
-       if ( !s ) {
-               return False;
-       }
+       return putenv(s) != -1;
+}
 
-       snprintf( env, sizeof(env), "%s=%s", WINBINDD_DONT_ENV, s );
+BOOL winbind_on( void )
+{
+       static char *s = CONST_DISCARD(char *, WINBINDD_DONT_ENV "=0");
 
-       return putenv(env) != -1;
+       return putenv(s) != -1;
 }
+
index 51a7c1f6b0d754f2c059000f34678447165742a1..ad2774eea6ea4dc7c585fa4011c8baeab1505e61 100644 (file)
@@ -945,7 +945,7 @@ int main(int argc, char **argv)
        /* Set environment variable so we don't recursively call ourselves.
           This may also be useful interactively. */
 
-       if ( !winbind_putenv("0") ) {
+       if ( !winbind_off() ) {
                DEBUG(0,("Failed to disable recusive winbindd calls.  Exiting.\n"));
                exit(1);
        }
index 88cf38783824ad0e82eb8f5f15af0a8718c61450..b6e635cca190774c52b7831f76b0f766d0916dd6 100644 (file)
@@ -1509,11 +1509,13 @@ static BOOL get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
        /* We only look at our own sam, so don't care about imported stuff */
 
        winbindd_env = getenv(WINBINDD_DONT_ENV);
-       winbind_putenv("0");
+       winbind_off();
 
        if ((grp = getgrgid(gid)) == NULL) {
-               /* allow winbindd lookups */
-               winbind_putenv( winbindd_env ? winbindd_env : "1" );
+               /* allow winbindd lookups, but only if they weren't already disabled */
+               if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+                       winbind_on();
+               }
 
                return False;
        }
@@ -1539,8 +1541,11 @@ static BOOL get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
                add_uid_to_array_unique(mem_ctx, pw->pw_uid, pp_uids, p_num);
        }
 
-       /* allow winbindd lookups */
-       winbind_putenv( winbindd_env ? winbindd_env : "1" );
+       /* allow winbindd lookups, but only if they weren't already disabled */
+
+       if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+               winbind_on();
+       }
 
        return True;
 }