Fix uid_to_sid mapping when the idmap cache is empty.
authorMichael Adam <obnox@samba.org>
Wed, 1 Oct 2008 06:30:15 +0000 (08:30 +0200)
committerMichael Adam <obnox@samba.org>
Wed, 1 Oct 2008 06:35:09 +0000 (08:35 +0200)
This failed for backends other than passed, since
idmap_backends_unixid_to_sid() always asked passdb first,
which returned Success no matter whether a mapping was
found or not.

One effect wast that getpwuid failed after "net cache flush".
Only after filling the cache with a getpwnam call it succeeded.

This fix makes the behaviour of idmap_backends_unixid_to_sid()
exactly the same as that of idmap_backends_sid_to_unixid()

Michael

source/winbindd/idmap.c

index c80f6f83bdc139e9fdd7d268e39dc2115ddce9b8..7485d3c2225d42e36405032a5ef7fbd5fec54cea 100644 (file)
@@ -722,14 +722,13 @@ NTSTATUS idmap_backends_unixid_to_sid(const char *domname, struct id_map *id)
        maps[0] = id;
        maps[1] = NULL;
 
-       /*
-        * Always give passdb a chance first
-        */
-
-       dom = idmap_init_passdb_domain(NULL);
-       if ((dom != NULL)
-           && NT_STATUS_IS_OK(dom->methods->unixids_to_sids(dom, maps))) {
-               return NT_STATUS_OK;
+       if (sid_check_is_in_builtin(id->sid)
+           || (sid_check_is_in_our_domain(id->sid))) {
+               dom = idmap_init_passdb_domain(NULL);
+               if (dom == NULL) {
+                       return NT_STATUS_NONE_MAPPED;
+               }
+               return dom->methods->unixids_to_sids(dom, maps);
        }
 
        dom = idmap_find_domain(domname);