summaryrefslogtreecommitdiff
path: root/source3/auth/auth_util.c
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-12-14 15:30:54 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:16:28 -0500
commit35a3773a6df72fc4031b90fb94010193966dbdc0 (patch)
tree45af37ea31cad46e1cdc8c42e1630de90032d22b /source3/auth/auth_util.c
parent7f5fefb7bb65ef35916769988abbec8209889225 (diff)
downloadsamba-35a3773a6df72fc4031b90fb94010193966dbdc0.tar.gz
samba-35a3773a6df72fc4031b90fb94010193966dbdc0.tar.bz2
samba-35a3773a6df72fc4031b90fb94010193966dbdc0.zip
r20169: Support for fallback to legacy mapping code was not completely tested.
Add necessary fixes. (This used to be commit 4a81ee9608d45f95eaaccc78a080e717cb7d4682)
Diffstat (limited to 'source3/auth/auth_util.c')
-rw-r--r--source3/auth/auth_util.c34
1 files changed, 24 insertions, 10 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 709d77bb36..c1f58cfecd 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -984,6 +984,7 @@ NTSTATUS create_local_token(auth_serversupplied_info *server_info)
TALLOC_CTX *mem_ctx;
struct id_map *ids;
NTSTATUS status;
+ BOOL wb = True;
size_t i;
@@ -1037,20 +1038,33 @@ NTSTATUS create_local_token(auth_serversupplied_info *server_info)
if (!winbind_sids_to_unixids(ids, server_info->ptok->num_sids-1)) {
DEBUG(2, ("Query to map secondary SIDs failed!\n"));
+ if (!winbind_ping()) {
+ DEBUG(2, ("Winbindd is not running, will try to map SIDs one by one with legacy code\n"));
+ wb = False;
+ }
}
for (i = 0; i < server_info->ptok->num_sids-1; i++) {
- if ( ! ids[i].mapped) {
- DEBUG(10, ("Could not convert SID %s to gid, "
- "ignoring it\n", sid_string_static(ids[i].sid)));
- continue;
- }
- if ( ! ids[i].xid.type == ID_TYPE_UID) {
- DEBUG(10, ("SID %s is a User ID (%u) not a Group ID, "
- "ignoring it\n", sid_string_static(ids[i].sid), ids[i].xid.id));
- continue;
+ gid_t agid;
+
+ if (wb) {
+ if ( ! ids[i].mapped) {
+ DEBUG(10, ("Could not convert SID %s to gid, "
+ "ignoring it\n", sid_string_static(ids[i].sid)));
+ continue;
+ }
+ if (ids[i].xid.type == ID_TYPE_UID) {
+ DEBUG(10, ("SID %s is a User ID (%u) not a Group ID, "
+ "ignoring it\n", sid_string_static(ids[i].sid), ids[i].xid.id));
+ continue;
+ }
+ agid = (gid_t)ids[i].xid.id;
+ } else {
+ if (! sid_to_gid(ids[i].sid, &agid)) {
+ continue;
+ }
}
- if (!add_gid_to_array_unique(server_info, (gid_t)ids[i].xid.id, &server_info->groups,
+ if (!add_gid_to_array_unique(server_info, agid, &server_info->groups,
&server_info->n_groups)) {
TALLOC_FREE(mem_ctx);
return NT_STATUS_NO_MEMORY;