r22204: Workaround to quickly close bug #4508
authorSimo Sorce <idra@samba.org>
Thu, 12 Apr 2007 21:10:06 +0000 (21:10 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 17:19:19 +0000 (12:19 -0500)
This hack makes thing work, but we will need to try again to
make the getpw* calls fully async, that's the real fix.
(This used to be commit 2552859b3d9e28d5f25b339f5d24a8d2dc36b46b)

source3/nsswitch/idmap.c
source3/nsswitch/winbindd.c
source3/nsswitch/winbindd_dual.c

index de98c81f5a9724cc056833b44b83697da0611dc6..3a3c2bf05f233ea8ef3cad8ceccc84ed0a4fb0ef 100644 (file)
@@ -84,6 +84,24 @@ static struct idmap_alloc_methods *get_alloc_methods(struct idmap_alloc_backend
        return NULL;
 }
 
+/* part of a quick hack to avoid loops, need to be sorted out correctly later on */
+static BOOL idmap_in_own_child;
+
+static BOOL idmap_is_in_own_child(void)
+{
+       return idmap_in_own_child;
+}
+
+void reset_idmap_in_own_child(void)
+{
+       idmap_in_own_child = False;
+}
+
+void set_idmap_in_own_child(void)
+{
+       idmap_in_own_child = True;
+}
+
 /**********************************************************************
  Allow a module to register itself as a method.
 **********************************************************************/
@@ -801,12 +819,17 @@ static NTSTATUS idmap_new_mapping(TALLOC_CTX *ctx, struct id_map *map)
        if ( ! NT_STATUS_IS_OK(ret)) {
                return NT_STATUS_NONE_MAPPED;
        }
-       
-       /* by default calls to winbindd are disabled
-          the following call will not recurse so this is safe */
-       winbind_on();
-       wbret = winbind_lookup_sid(ctx, map->sid, &domname, &name, &sid_type);
-       winbind_off();
+
+       /* quick hack to make things work, will need proper fix later on */     
+       if (idmap_is_in_own_child()) {
+               /* by default calls to winbindd are disabled
+                  the following call will not recurse so this is safe */
+               winbind_on();
+               wbret = winbind_lookup_sid(ctx, map->sid, &domname, &name, &sid_type);
+               winbind_off();
+       } else {
+               wbret = winbindd_lookup_name_by_sid(ctx, map->sid, &domname, &name, &sid_type);
+       }
 
        /* check if this is a valid SID and then map it */
        if (wbret) {
@@ -1395,3 +1418,4 @@ char *idmap_fetch_secret(const char *backend, bool alloc,
 
        return ret;
 }
+
index 0edf3664b7b02ca6bfb5eca80d98c757c35b94e9..39bd66989c0d029ad6b94551c3596294c2c49ff3 100644 (file)
@@ -1010,6 +1010,9 @@ int main(int argc, char **argv, char **envp)
 
        namecache_enable();
 
+       /* quick hack to avoid a loop in idmap, proper fix later */
+       reset_idmap_in_own_child();
+
        /* Winbind daemon initialisation */
 
        if ( ! NT_STATUS_IS_OK(idmap_init_cache()) ) {
index 26debd26745b9304e71dc7794c0eba360a8628e3..20cf55b51d012e179c4fd8797d8013bc94c0a554 100644 (file)
@@ -921,6 +921,9 @@ static BOOL fork_domain_child(struct winbindd_child *child)
                        child);
        }
 
+       /* quick hack to avoid a loop in idmap, proper fix later */
+       set_idmap_in_own_child();
+
        while (1) {
 
                int ret;