r19419: BUG 4109: Patch from Timur Bakeyev. Fix bug causing smbd to turn off
authorGerald Carter <jerry@samba.org>
Thu, 19 Oct 2006 22:34:58 +0000 (22:34 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:15:34 +0000 (12:15 -0500)
winbindd and fail to disable the _NO_WINBIND environment.
(This used to be commit a6366b40b3967853c20ca5399021108f09ffd505)

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

index afa64489cfda324d67a7e94a2a87c740ee1d484a..fc506c901db624dc41f50ea787e9b271d4c301fc 100644 (file)
@@ -120,19 +120,15 @@ static int getgrouplist_internals(const char *user, gid_t gid, gid_t *groups,
 static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grpcnt)
 {
        int retval;
-       char *winbindd_env;
+       BOOL winbind_env;
 
        DEBUG(10,("sys_getgrouplist: user [%s]\n", user));
 
-       /* Save the winbindd state and not just blindly turn it back on */
-
-       winbindd_env = getenv(WINBINDD_DONT_ENV);
-       
        /* This is only ever called for Unix users, remote memberships are
         * always determined by the info3 coming back from auth3 or the
         * PAC. */
-
-       winbind_off() ;
+       winbind_env = winbind_env_set();
+       winbind_off();
 
 #ifdef HAVE_GETGROUPLIST
        retval = getgrouplist(user, gid, groups, grpcnt);
@@ -142,9 +138,8 @@ static int sys_getgrouplist(const char *user, gid_t gid, gid_t *groups, int *grp
        unbecome_root();
 #endif
 
-       /* allow winbindd lookups , but only if they were not already disabled */
-
-       if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+       /* allow winbindd lookups, but only if they were not already disabled */
+       if (!winbind_env) {
                winbind_on();
        }
 
index e665a0ffd525c08fb6f1bc4833301b1591ab0b6d..05238f16fbd3d89ab8299219d54eaa37a693ba99 100644 (file)
@@ -525,15 +525,11 @@ int read_reply(struct winbindd_response *response)
 NSS_STATUS winbindd_send_request(int req_type, struct winbindd_request *request)
 {
        struct winbindd_request lrequest;
-       char *env;
-       int  value;
-       
+
        /* Check for our tricky environment variable */
 
-       if ( (env = getenv(WINBINDD_DONT_ENV)) != NULL ) {
-               value = atoi(env);
-               if ( value == 1 )
-                       return NSS_STATUS_NOTFOUND;
+       if (winbind_env_set()) {
+               return NSS_STATUS_NOTFOUND;
        }
 
        if (!request) {
@@ -632,3 +628,14 @@ BOOL winbind_on( void )
        return putenv(s) != -1;
 }
 
+BOOL winbind_env_set( void )
+{
+       char *env;
+       
+       if ((env=getenv(WINBINDD_DONT_ENV)) != NULL) {
+               if(strequal(env, "1")) {
+                       return True;
+               }
+       }
+       return False;
+}
index 73f538214de96def71b4ce0047d82887a0e8b79a..607a8b91d38132e1c0eedf0d94efc5ce2f86b21e 100644 (file)
@@ -1295,27 +1295,25 @@ static BOOL get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
        struct group *grp;
        char **gr;
        struct passwd *pwd;
-       char *winbindd_env;
+       BOOL winbind_env;
  
        *pp_uids = NULL;
        *p_num = 0;
 
        /* We only look at our own sam, so don't care about imported stuff */
-
-       winbindd_env = getenv(WINBINDD_DONT_ENV);
+       winbind_env = winbind_env_set();
        winbind_off();
 
        if ((grp = getgrgid(gid)) == NULL) {
                /* allow winbindd lookups, but only if they weren't already disabled */
-               if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+               if (!winbind_env) {
                        winbind_on();
                }
-
+               
                return False;
        }
 
        /* Primary group members */
-
        setpwent();
        while ((pwd = getpwent()) != NULL) {
                if (pwd->pw_gid == gid) {
@@ -1326,7 +1324,6 @@ static BOOL get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
        endpwent();
 
        /* Secondary group members */
-
        for (gr = grp->gr_mem; (*gr != NULL) && ((*gr)[0] != '\0'); gr += 1) {
                struct passwd *pw = getpwnam(*gr);
 
@@ -1336,11 +1333,10 @@ static BOOL get_memberuids(TALLOC_CTX *mem_ctx, gid_t gid, uid_t **pp_uids, size
        }
 
        /* allow winbindd lookups, but only if they weren't already disabled */
-
-       if ( !(winbindd_env && strequal(winbindd_env, "1")) ) {
+       if (!winbind_env) {
                winbind_on();
        }
-
+       
        return True;
 }