Author: idra Date: 2006-12-18 20:05:50 +0000 (Mon, 18 Dec 2006) New Revision: 20243
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20243 Log: Make lookup_name resolve both the mapped and the real unix group name Modified: branches/SAMBA_3_0/source/passdb/passdb.c Changeset: Modified: branches/SAMBA_3_0/source/passdb/passdb.c =================================================================== --- branches/SAMBA_3_0/source/passdb/passdb.c 2006-12-18 20:04:54 UTC (rev 20242) +++ branches/SAMBA_3_0/source/passdb/passdb.c 2006-12-18 20:05:50 UTC (rev 20243) @@ -550,7 +550,7 @@ Convert a name into a SID. Used in the lookup name rpc. ********************************************************************/ -BOOL lookup_global_sam_name(const char *user, int flags, uint32_t *rid, +BOOL lookup_global_sam_name(const char *name, int flags, uint32_t *rid, enum lsa_SidType *type) { GROUP_MAP map; @@ -561,7 +561,7 @@ name "None" on Windows. You will get an error that the group already exists. */ - if ( strequal( user, "None" ) ) { + if ( strequal( name, "None" ) ) { *rid = DOMAIN_GROUP_RID_USERS; *type = SID_NAME_DOM_GRP; @@ -581,7 +581,7 @@ } become_root(); - ret = pdb_getsampwnam(sam_account, user); + ret = pdb_getsampwnam(sam_account, name); unbecome_root(); if (ret) { @@ -593,7 +593,7 @@ if (ret) { if (!sid_check_is_in_our_domain(&user_sid)) { DEBUG(0, ("User %s with invalid SID %s in passdb\n", - user, sid_string_static(&user_sid))); + name, sid_string_static(&user_sid))); return False; } @@ -608,17 +608,33 @@ */ become_root(); - ret = pdb_getgrnam(&map, user); + ret = pdb_getgrnam(&map, name); unbecome_root(); if (!ret) { - return False; + /* try to see if we can lookup a mapped + * group with the unix group name */ + + struct group *grp; + + grp = getgrnam(name); + if (!grp) { + return False; + } + + become_root(); + ret = pdb_getgrgid(&map, grp->gr_gid); + unbecome_root(); + + if (!ret) { + return False; + } } /* BUILTIN groups are looked up elsewhere */ if (!sid_check_is_in_our_domain(&map.sid)) { DEBUG(10, ("Found group %s (%s) not in our domain -- " - "ignoring.", user, + "ignoring.", name, sid_string_static(&map.sid))); return False; }