Author: idra
Date: 2007-05-21 20:51:15 +0000 (Mon, 21 May 2007)
New Revision: 23051

WebSVN: 
http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23051

Log:

sid_to_[ug]id fixes for smbd


Modified:
   branches/SAMBA_3_0/source/passdb/lookup_sid.c
   branches/SAMBA_3_0_26/source/passdb/lookup_sid.c


Changeset:
Modified: branches/SAMBA_3_0/source/passdb/lookup_sid.c
===================================================================
--- branches/SAMBA_3_0/source/passdb/lookup_sid.c       2007-05-21 20:47:22 UTC 
(rev 23050)
+++ branches/SAMBA_3_0/source/passdb/lookup_sid.c       2007-05-21 20:51:15 UTC 
(rev 23051)
@@ -1208,12 +1208,6 @@
        enum lsa_SidType type;
        uint32 rid;
 
-       if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
-               uid_t uid = rid;
-               *puid = uid;
-               goto done;
-       }
-
        if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
                union unid_t id;
                BOOL ret;
@@ -1259,12 +1253,6 @@
        union unid_t id;
        enum lsa_SidType type;
 
-       if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
-               gid_t gid = rid;
-               *pgid = gid;
-               goto done;
-       }
-
        if ((sid_check_is_in_builtin(psid) ||
             sid_check_is_in_wellknown_domain(psid))) {
                BOOL ret;
@@ -1379,6 +1367,7 @@
 
 BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid)
 {
+       uint32 rid;
        gid_t gid;
 
        if (fetch_uid_from_cache(puid, psid))
@@ -1388,6 +1377,18 @@
                return False;
        }
 
+       /* Optimize for the Unix Users Domain
+        * as the conversion is straightforward */
+       if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
+               uid_t uid = rid;
+               *puid = uid;
+
+               /* return here, don't cache */
+               DEBUG(10,("sid %s -> uid %u\n", sid_string_static(psid),
+                       (unsigned int)*puid ));
+               return True;
+       }
+
        if (!winbind_sid_to_uid(puid, psid)) {
                if (!winbind_ping()) {
                        return legacy_sid_to_uid(psid, puid);
@@ -1415,6 +1416,7 @@
 
 BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 {
+       uint32 rid;
        uid_t uid;
 
        if (fetch_gid_from_cache(pgid, psid))
@@ -1423,6 +1425,18 @@
        if (fetch_uid_from_cache(&uid, psid))
                return False;
 
+       /* Optimize for the Unix Groups Domain
+        * as the conversion is straightforward */
+       if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
+               gid_t gid = rid;
+               *pgid = gid;
+
+               /* return here, don't cache */
+               DEBUG(10,("sid %s -> gid %u\n", sid_string_static(psid),
+                       (unsigned int)*pgid ));
+               return True;
+       }
+
        /* Ask winbindd if it can map this sid to a gid.
         * (Idmap will check it is a valid SID and of the right type) */
 

Modified: branches/SAMBA_3_0_26/source/passdb/lookup_sid.c
===================================================================
--- branches/SAMBA_3_0_26/source/passdb/lookup_sid.c    2007-05-21 20:47:22 UTC 
(rev 23050)
+++ branches/SAMBA_3_0_26/source/passdb/lookup_sid.c    2007-05-21 20:51:15 UTC 
(rev 23051)
@@ -1209,12 +1209,6 @@
        enum lsa_SidType type;
        uint32 rid;
 
-       if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
-               uid_t uid = rid;
-               *puid = uid;
-               goto done;
-       }
-
        if (sid_peek_check_rid(get_global_sam_sid(), psid, &rid)) {
                union unid_t id;
                BOOL ret;
@@ -1260,12 +1254,6 @@
        union unid_t id;
        enum lsa_SidType type;
 
-       if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
-               gid_t gid = rid;
-               *pgid = gid;
-               goto done;
-       }
-
        if ((sid_check_is_in_builtin(psid) ||
             sid_check_is_in_wellknown_domain(psid))) {
                BOOL ret;
@@ -1380,6 +1368,7 @@
 
 BOOL sid_to_uid(const DOM_SID *psid, uid_t *puid)
 {
+       uint32 rid;
        gid_t gid;
 
        if (fetch_uid_from_cache(puid, psid))
@@ -1389,6 +1378,18 @@
                return False;
        }
 
+       /* Optimize for the Unix Users Domain
+        * as the conversion is straightforward */
+       if (sid_peek_check_rid(&global_sid_Unix_Users, psid, &rid)) {
+               uid_t uid = rid;
+               *puid = uid;
+
+               /* return here, don't cache */
+               DEBUG(10,("sid %s -> uid %u\n", sid_string_static(psid),
+                       (unsigned int)*puid ));
+               return True;
+       }
+
        if (!winbind_sid_to_uid(puid, psid)) {
                if (!winbind_ping()) {
                        return legacy_sid_to_uid(psid, puid);
@@ -1416,6 +1417,7 @@
 
 BOOL sid_to_gid(const DOM_SID *psid, gid_t *pgid)
 {
+       uint32 rid;
        uid_t uid;
 
        if (fetch_gid_from_cache(pgid, psid))
@@ -1424,6 +1426,18 @@
        if (fetch_uid_from_cache(&uid, psid))
                return False;
 
+       /* Optimize for the Unix Groups Domain
+        * as the conversion is straightforward */
+       if (sid_peek_check_rid(&global_sid_Unix_Groups, psid, &rid)) {
+               gid_t gid = rid;
+               *pgid = gid;
+
+               /* return here, don't cache */
+               DEBUG(10,("sid %s -> gid %u\n", sid_string_static(psid),
+                       (unsigned int)*pgid ));
+               return True;
+       }
+
        /* Ask winbindd if it can map this sid to a gid.
         * (Idmap will check it is a valid SID and of the right type) */
 

Reply via email to