1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

s3:winbindd: simplify winbindd_sids_to_xids_recv() a bit.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
This commit is contained in:
Michael Adam 2012-11-09 13:54:20 +01:00 committed by Stefan Metzmacher
parent 3f0c31fbd3
commit b435e668aa

View File

@ -240,62 +240,47 @@ NTSTATUS winbindd_sids_to_xids_recv(struct tevent_req *req,
for (i=0; i<state->num_sids; i++) {
char type = '\0';
uint32_t unix_id = UINT32_MAX;
bool found = true;
struct unixid xid;
xid.id = UINT32_MAX;
if (state->cached[i].sid != NULL) {
unix_id = state->cached[i].xid.id;
switch (state->cached[i].xid.type) {
case ID_TYPE_UID:
type = 'U';
break;
case ID_TYPE_GID:
type = 'G';
break;
case ID_TYPE_BOTH:
type = 'B';
break;
default:
found = false;
break;
}
xid = state->cached[i].xid;
} else {
struct unixid id;
xid.id = state->ids.ids[num_non_cached].unix_id;
xid.type = state->ids.ids[num_non_cached].type;
unix_id = state->ids.ids[num_non_cached].unix_id;
id.id = unix_id;
id.type = state->ids.ids[num_non_cached].type;
idmap_cache_set_sid2unixid(
&state->non_cached[num_non_cached],
&id);
&xid);
switch (id.type) {
case ID_TYPE_UID:
type = 'U';
break;
case ID_TYPE_GID:
type = 'G';
break;
case ID_TYPE_BOTH:
type = 'B';
break;
default:
found = false;
break;
}
num_non_cached += 1;
}
if (unix_id == UINT32_MAX) {
switch (xid.type) {
case ID_TYPE_UID:
type = 'U';
break;
case ID_TYPE_GID:
type = 'G';
break;
case ID_TYPE_BOTH:
type = 'B';
break;
default:
found = false;
break;
}
if (xid.id == UINT32_MAX) {
found = false;
}
if (found) {
result = talloc_asprintf_append_buffer(
result, "%c%lu\n", type,
(unsigned long)unix_id);
(unsigned long)xid.id);
} else {
result = talloc_asprintf_append_buffer(result, "\n");
}