summaryrefslogtreecommitdiff
path: root/source3/nsswitch
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2002-01-10 06:20:03 +0000
committerTim Potter <tpot@samba.org>2002-01-10 06:20:03 +0000
commit610f530aee4da9b63cb1cb9005650d27e4846bc0 (patch)
treed31aebd3c8ce9d5dafc22fb31d9615707056898c /source3/nsswitch
parentcd1ad031a66118149bffb4e4ded9720ce9605742 (diff)
downloadsamba-610f530aee4da9b63cb1cb9005650d27e4846bc0.tar.gz
samba-610f530aee4da9b63cb1cb9005650d27e4846bc0.tar.bz2
samba-610f530aee4da9b63cb1cb9005650d27e4846bc0.zip
A big tidyup while thinking about getting trusted domains being re-read
when they are added or removed on the PDC. - renamed GETPWNAM_FROM_{UID,USER} constants and functions to GETPW{NAM,UID} - renamed GETGRNAM_FROM_{GID,GROUP} constants and functions to GETGR{NAM,GID} - use SIGUSR2 in winbindd for debugging/logging instead of SIGUSR1 in preparation for moving to smbcontrol type messages (not sure whether to ditch this altogether or not) - tidy debugging messages in top level winbind user and group routines - convert talloc_init() to talloc_init_named() - make enumerations of the domain list use the same local variable names (This used to be commit eeb8af9c1a66bfcd80823d7b406acbab79857a16)
Diffstat (limited to 'source3/nsswitch')
-rw-r--r--source3/nsswitch/winbind_nss.c12
-rw-r--r--source3/nsswitch/winbindd.c27
-rw-r--r--source3/nsswitch/winbindd_group.c114
-rw-r--r--source3/nsswitch/winbindd_nss.h8
-rw-r--r--source3/nsswitch/winbindd_proto.h9
-rw-r--r--source3/nsswitch/winbindd_rpc.c8
-rw-r--r--source3/nsswitch/winbindd_user.c57
-rw-r--r--source3/nsswitch/winbindd_util.c39
8 files changed, 142 insertions, 132 deletions
diff --git a/source3/nsswitch/winbind_nss.c b/source3/nsswitch/winbind_nss.c
index 4579d167d2..efb52f35c3 100644
--- a/source3/nsswitch/winbind_nss.c
+++ b/source3/nsswitch/winbind_nss.c
@@ -888,8 +888,7 @@ _nss_winbind_getpwuid_r(uid_t uid, struct passwd *result, char *buffer,
request.data.uid = uid;
- ret = winbindd_request(WINBINDD_GETPWNAM_FROM_UID, &request,
- &response);
+ ret = winbindd_request(WINBINDD_GETPWUID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw,
@@ -951,8 +950,7 @@ _nss_winbind_getpwnam_r(const char *name, struct passwd *result, char *buffer,
request.data.username
[sizeof(request.data.username) - 1] = '\0';
- ret = winbindd_request(WINBINDD_GETPWNAM_FROM_USER, &request,
- &response);
+ ret = winbindd_request(WINBINDD_GETPWNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_pwent(result, &response.data.pw, &buffer,
@@ -1148,8 +1146,7 @@ _nss_winbind_getgrnam_r(const char *name,
request.data.groupname
[sizeof(request.data.groupname) - 1] = '\0';
- ret = winbindd_request(WINBINDD_GETGRNAM_FROM_GROUP,
- &request, &response);
+ ret = winbindd_request(WINBINDD_GETGRNAM, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
ret = fill_grent(result, &response.data.gr,
@@ -1211,8 +1208,7 @@ _nss_winbind_getgrgid_r(gid_t gid,
request.data.gid = gid;
- ret = winbindd_request(WINBINDD_GETGRNAM_FROM_GID, &request,
- &response);
+ ret = winbindd_request(WINBINDD_GETGRGID, &request, &response);
if (ret == NSS_STATUS_SUCCESS) {
diff --git a/source3/nsswitch/winbindd.c b/source3/nsswitch/winbindd.c
index a877bf9e0a..7da20d8b01 100644
--- a/source3/nsswitch/winbindd.c
+++ b/source3/nsswitch/winbindd.c
@@ -169,11 +169,11 @@ static void termination_handler(int signum)
do_sigterm = True;
}
-static BOOL do_sigusr1;
+static BOOL do_sigusr2;
-static void sigusr1_handler(int signum)
+static void sigusr2_handler(int signum)
{
- do_sigusr1 = True;
+ do_sigusr2 = True;
}
static BOOL do_sighup;
@@ -285,8 +285,8 @@ static struct dispatch_table dispatch_table[] = {
/* User functions */
- { WINBINDD_GETPWNAM_FROM_USER, winbindd_getpwnam_from_user, "GETPWNAM_FROM_USER" },
- { WINBINDD_GETPWNAM_FROM_UID, winbindd_getpwnam_from_uid, "GETPWNAM_FROM_UID" },
+ { WINBINDD_GETPWNAM, winbindd_getpwnam, "GETPWNAM" },
+ { WINBINDD_GETPWUID, winbindd_getpwuid, "GETPWUID" },
{ WINBINDD_SETPWENT, winbindd_setpwent, "SETPWENT" },
{ WINBINDD_ENDPWENT, winbindd_endpwent, "ENDPWENT" },
@@ -296,8 +296,8 @@ static struct dispatch_table dispatch_table[] = {
/* Group functions */
- { WINBINDD_GETGRNAM_FROM_GROUP, winbindd_getgrnam_from_group, "GETGRNAM_FROM_GROUP" },
- { WINBINDD_GETGRNAM_FROM_GID, winbindd_getgrnam_from_gid, "GETGRNAM_FROM_GID" },
+ { WINBINDD_GETGRNAM, winbindd_getgrnam, "GETGRNAM" },
+ { WINBINDD_GETGRGID, winbindd_getgrgid, "GETGRGID" },
{ WINBINDD_SETGRENT, winbindd_setgrent, "SETGRENT" },
{ WINBINDD_ENDGRENT, winbindd_endgrent, "ENDGRENT" },
{ WINBINDD_GETGRENT, winbindd_getgrent, "GETGRENT" },
@@ -715,9 +715,9 @@ static void process_loop(int accept_sock)
do_sighup = False;
}
- if (do_sigusr1) {
+ if (do_sigusr2) {
print_winbindd_status();
- do_sigusr1 = False;
+ do_sigusr2 = False;
}
}
}
@@ -737,9 +737,9 @@ int main(int argc, char **argv)
int opt, new_debuglevel = -1;
/* glibc (?) likes to print "User defined signal 1" and exit if a
- SIGUSR1 is received before a handler is installed */
+ SIGUSR2 is received before a handler is installed */
- CatchSignal(SIGUSR1, SIG_IGN);
+ CatchSignal(SIGUSR2, SIG_IGN);
fault_setup((void (*)(void *))fault_quit );
@@ -857,7 +857,7 @@ int main(int argc, char **argv)
BlockSignals(False, SIGINT);
BlockSignals(False, SIGQUIT);
BlockSignals(False, SIGTERM);
- BlockSignals(False, SIGUSR1);
+ BlockSignals(False, SIGUSR2);
BlockSignals(False, SIGHUP);
/* Setup signal handlers */
@@ -867,8 +867,9 @@ int main(int argc, char **argv)
CatchSignal(SIGTERM, termination_handler);
CatchSignal(SIGPIPE, SIG_IGN); /* Ignore sigpipe */
+ CatchSignal(SIGUSR1, SIG_IGN); /* Samba messages */
- CatchSignal(SIGUSR1, sigusr1_handler); /* Debugging sigs */
+ CatchSignal(SIGUSR2, sigusr2_handler); /* Debugging sigs */
CatchSignal(SIGHUP, sighup_handler);
/* Create UNIX domain socket */
diff --git a/source3/nsswitch/winbindd_group.c b/source3/nsswitch/winbindd_group.c
index 6e22a8b559..ff15611fba 100644
--- a/source3/nsswitch/winbindd_group.c
+++ b/source3/nsswitch/winbindd_group.c
@@ -60,19 +60,19 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx;
NTSTATUS status;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("fill_grent_mem(%s)", domain->name)))
return False;
/* Initialise group membership information */
- DEBUG(10, ("fill_grent_mem(): group %s rid 0x%x\n",
- domain ? domain->name : "NULL", group_rid));
+ DEBUG(10, ("group %s rid 0x%x\n", domain ? domain->name : "NULL",
+ group_rid));
*num_gr_mem = 0;
if (group_name_type != SID_NAME_DOM_GRP) {
- DEBUG(1, ("fill_grent_mem(): rid %d in domain %s isn't a "
- "domain group\n", group_rid, domain->name));
+ DEBUG(1, ("rid %d in domain %s isn't a " "domain group\n",
+ group_rid, domain->name));
goto done;
}
@@ -80,14 +80,13 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
status = domain->methods->lookup_groupmem(domain, mem_ctx, group_rid, &num_names,
&rid_mem, &names, &name_types);
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("fill_grent_mem(): could not lookup membership "
- "for group rid %d in domain %s\n",
+ DEBUG(1, ("could not lookup membership for group rid %d in domain %s\n",
group_rid, domain->name));
goto done;
}
- DEBUG(10, ("fill_grent_mem(): looked up %d names\n", num_names));
+ DEBUG(10, ("looked up %d names\n", num_names));
if (DEBUGLEVEL >= 10) {
for (i = 0; i < num_names; i++)
@@ -109,24 +108,21 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
the_name = names[i];
- DEBUG(10, ("fill_grent_mem(): processing name %s\n",
- the_name));
+ DEBUG(10, ("processing name %s\n", the_name));
/* FIXME: need to cope with groups within groups. These
occur in Universal groups on a Windows 2000 native mode
server. */
if (name_types[i] != SID_NAME_USER) {
- DEBUG(3, ("fill_grent_mem(): name %s isn't a domain "
- "user\n", the_name));
+ DEBUG(3, ("name %s isn't a domain user\n", the_name));
continue;
}
/* Don't bother with machine accounts */
if (the_name[strlen(the_name) - 1] == '$') {
- DEBUG(10, ("fill_grent_mem(): %s is machine account\n",
- the_name));
+ DEBUG(10, ("%s is machine account\n", the_name));
continue;
}
@@ -142,11 +138,9 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
if (!buf) {
buf_len += len + 1; /* List is comma separated */
(*num_gr_mem)++;
- DEBUG(10, ("fill_grent_mem(): buf_len + %d = %d\n", len + 1,
- buf_len));
+ DEBUG(10, ("buf_len + %d = %d\n", len + 1, buf_len));
} else {
- DEBUG(10, ("fill_grent_mem(): appending %s at index %d\n",
- name, len));
+ DEBUG(10, ("appending %s at ndx %d\n", name, len));
safe_strcpy(&buf[buf_ndx], name, len);
buf_ndx += len;
buf[buf_ndx] = ',';
@@ -158,7 +152,7 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
if (!buf) {
if (!(buf = malloc(buf_len))) {
- DEBUG(1, ("fill_grent_mem(): out of memory\n"));
+ DEBUG(1, ("out of memory\n"));
result = False;
goto done;
}
@@ -173,23 +167,22 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
*gr_mem = buf;
*gr_mem_len = buf_len;
- DEBUG(10, ("fill_grent_mem(): num_mem = %d, len = %d, mem = %s\n",
- *num_gr_mem, buf_len, *num_gr_mem ? buf : "NULL"));
-
+ DEBUG(10, ("num_mem = %d, len = %d, mem = %s\n", *num_gr_mem,
+ buf_len, *num_gr_mem ? buf : "NULL"));
result = True;
done:
talloc_destroy(mem_ctx);
- DEBUG(10, ("fill_grent_mem(): returning %d\n", result));
+ DEBUG(10, ("fill_grent_mem returning %d\n", result));
return result;
}
/* Return a group structure from a group name */
-enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *state)
+enum winbindd_result winbindd_getgrnam(struct winbindd_cli_state *state)
{
DOM_SID group_sid;
struct winbindd_domain *domain;
@@ -214,8 +207,8 @@ enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *sta
/* Get info for the domain */
if ((domain = find_domain_from_name(name_domain)) == NULL) {
- DEBUG(0, ("getgrname_from_group(): could not get domain "
- "sid for domain %s\n", name_domain));
+ DEBUG(0, ("could not get domain sid for domain %s\n",
+ name_domain));
return WINBINDD_ERROR;
}
@@ -223,15 +216,16 @@ enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *sta
/* Get rid and name type from name */
- if (!winbindd_lookup_sid_by_name(domain, name, &group_sid, &name_type)) {
+ if (!winbindd_lookup_sid_by_name(domain, name, &group_sid,
+ &name_type)) {
DEBUG(1, ("group %s in domain %s does not exist\n",
name_group, name_domain));
return WINBINDD_ERROR;
}
if ((name_type != SID_NAME_ALIAS) && (name_type != SID_NAME_DOM_GRP)) {
- DEBUG(1, ("from_group: name '%s' is not a local or domain "
- "group: %d\n", name_group, name_type));
+ DEBUG(1, ("name '%s' is not a local or domain group: %d\n",
+ name_group, name_type));
return WINBINDD_ERROR;
}
@@ -240,7 +234,7 @@ enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *sta
sid_split_rid(&group_sid, &group_rid);
if (!winbindd_idmap_get_gid_from_rid(domain->name, group_rid, &gid)) {
- DEBUG(1, ("error sursing unix gid for sid\n"));
+ DEBUG(1, ("error converting unix gid to sid\n"));
return WINBINDD_ERROR;
}
@@ -264,8 +258,7 @@ enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *sta
/* Return a group structure from a gid number */
-enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
- *state)
+enum winbindd_result winbindd_getgrgid(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
DOM_SID group_sid;
@@ -288,7 +281,7 @@ enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
if (!winbindd_idmap_get_rid_from_gid(state->request.data.gid,
&group_rid, &domain)) {
- DEBUG(1, ("Could not convert gid %d to rid\n",
+ DEBUG(1, ("could not convert gid %d to rid\n",
state->request.data.gid));
return WINBINDD_ERROR;
}
@@ -299,7 +292,7 @@ enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
sid_append_rid(&group_sid, group_rid);
if (!winbindd_lookup_name_by_sid(&group_sid, group_name, &name_type)) {
- DEBUG(1, ("Could not lookup sid\n"));
+ DEBUG(1, ("could not lookup sid\n"));
return WINBINDD_ERROR;
}
@@ -309,8 +302,8 @@ enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
if (!((name_type == SID_NAME_ALIAS) ||
(name_type == SID_NAME_DOM_GRP))) {
- DEBUG(1, ("from_gid: name '%s' is not a local or domain "
- "group: %d\n", group_name, name_type));
+ DEBUG(1, ("name '%s' is not a local or domain group: %d\n",
+ group_name, name_type));
return WINBINDD_ERROR;
}
@@ -341,7 +334,7 @@ enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state)
{
- struct winbindd_domain *tmp;
+ struct winbindd_domain *domain;
DEBUG(3, ("[%5d]: setgrent\n", state->pid));
@@ -362,14 +355,14 @@ enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state)
if (domain_list == NULL)
get_domain_info();
- for (tmp = domain_list; tmp != NULL; tmp = tmp->next) {
+ for (domain = domain_list; domain != NULL; domain = domain->next) {
struct getent_state *domain_state;
/* Skip domains other than WINBINDD_DOMAIN environment
variable */
if ((strcmp(state->request.domain, "") != 0) &&
- !check_domain_env(state->request.domain, tmp->name))
+ !check_domain_env(state->request.domain, domain->name))
continue;
/* Create a state record for this domain */
@@ -380,7 +373,7 @@ enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state)
ZERO_STRUCTP(domain_state);
- domain_state->domain = tmp;
+ domain_state->domain = domain;
/* Add to list of open domains */
@@ -421,7 +414,8 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
if (ent->got_sam_entries)
return False;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("get_sam_group_entries(%s)",
+ ent->domain->name)))
return False;
/* Free any existing group info */
@@ -510,7 +504,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
tryagain:
- DEBUG(10, ("getgrent(): entry_index = %d, num_entries = %d\n",
+ DEBUG(10, ("entry_index = %d, num_entries = %d\n",
ent->sam_entry_index, ent->num_sam_entries));
if (ent->num_sam_entries == ent->sam_entry_index) {
@@ -518,8 +512,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
while(ent && !get_sam_group_entries(ent)) {
struct getent_state *next_ent;
- DEBUG(10, ("getgrent(): freeing state info for "
- "domain %s\n", ent->domain->name));
+ DEBUG(10, ("freeing state info for domain %s\n", ent->domain->name));
/* Free state information for this domain */
@@ -547,14 +540,14 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
name_list[ent->sam_entry_index].rid,
&group_gid)) {
- DEBUG(1, ("getgrent(): could not look up gid for group %s\n",
+ DEBUG(1, ("could not look up gid for group %s\n",
name_list[ent->sam_entry_index].acct_name));
ent->sam_entry_index++;
goto tryagain;
}
- DEBUG(10, ("getgrent(): got gid %d for group %x\n", group_gid,
+ DEBUG(10, ("got gid %d for group %x\n", group_gid,
name_list[ent->sam_entry_index].rid));
/* Fill in group entry */
@@ -585,13 +578,13 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
gr_mem_list_len + gr_mem_len);
if (!new_gr_mem_list && (group_list[group_list_ndx].num_gr_mem != 0)) {
- DEBUG(0, ("getgrent(): out of memory\n"));
+ DEBUG(0, ("out of memory\n"));
SAFE_FREE(gr_mem_list);
gr_mem_list_len = 0;
break;
}
- DEBUG(10, ("getgrent(): list_len = %d, mem_len = %d\n",
+ DEBUG(10, ("list_len = %d, mem_len = %d\n",
gr_mem_list_len, gr_mem_len));
gr_mem_list = new_gr_mem_list;
@@ -613,7 +606,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
if (result) {
- DEBUG(10, ("getgrent(): adding group num_entries = %d\n",
+ DEBUG(10, ("adding group num_entries = %d\n",
state->response.data.num_entries));
group_list_ndx++;
@@ -656,7 +649,7 @@ enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state)
state->response.length += gr_mem_list_len;
- DEBUG(10, ("getgrent(): returning %d groups, length = %d\n",
+ DEBUG(10, ("returning %d groups, length = %d\n",
group_list_ndx, gr_mem_list_len));
/* Out of domains */
@@ -714,8 +707,7 @@ enum winbindd_result winbindd_list_groups(struct winbindd_cli_state *state)
ted = Realloc(extra_data, sizeof(fstring) * total_entries);
if (!ted) {
- DEBUG(0,("winbindd_list_groups: failed to enlarge "
- "buffer!\n"));
+ DEBUG(0,("failed to enlarge buffer!\n"));
SAFE_FREE(extra_data);
return WINBINDD_ERROR;
} else
@@ -773,7 +765,8 @@ enum winbindd_result winbindd_getgroups(struct winbindd_cli_state *state)
DEBUG(3, ("[%5d]: getgroups %s\n", state->pid,
state->request.data.username));
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("winbindd_getgroups(%s)",
+ state->request.data.username)))
return WINBINDD_ERROR;
/* Parse domain and username */
@@ -794,14 +787,15 @@ enum winbindd_result winbindd_getgroups(struct winbindd_cli_state *state)
/* Get rid and name type from name. The following costs 1 packet */
- if (!winbindd_lookup_sid_by_name(domain, name, &user_sid, &name_type)) {
+ if (!winbindd_lookup_sid_by_name(domain, name, &user_sid,
+ &name_type)) {
DEBUG(1, ("user '%s' does not exist\n", name_user));
goto done;
}
if (name_type != SID_NAME_USER) {
- DEBUG(1, ("name '%s' is not a user name: %d\n", name_user,
- name_type));
+ DEBUG(1, ("name '%s' is not a user name: %d\n",
+ name_user, name_type));
goto done;
}
@@ -819,8 +813,12 @@ enum winbindd_result winbindd_getgroups(struct winbindd_cli_state *state)
goto done;
for (i = 0; i < num_groups; i++) {
- if (!winbindd_idmap_get_gid_from_rid(domain->name, user_gids[i], &gid_list[num_gids])) {
- DEBUG(1, ("unable to convert group rid %d to gid\n", user_gids[i]));
+ if (!winbindd_idmap_get_gid_from_rid(domain->name,
+ user_gids[i],
+ &gid_list[num_gids])) {
+
+ DEBUG(1, ("unable to convert group rid %d to gid\n",
+ user_gids[i]));
continue;
}
diff --git a/source3/nsswitch/winbindd_nss.h b/source3/nsswitch/winbindd_nss.h
index 4fb9458c14..07c67dd558 100644
--- a/source3/nsswitch/winbindd_nss.h
+++ b/source3/nsswitch/winbindd_nss.h
@@ -41,10 +41,10 @@ enum winbindd_cmd {
/* Get users and groups */
- WINBINDD_GETPWNAM_FROM_USER,
- WINBINDD_GETPWNAM_FROM_UID,
- WINBINDD_GETGRNAM_FROM_GROUP,
- WINBINDD_GETGRNAM_FROM_GID,
+ WINBINDD_GETPWNAM,
+ WINBINDD_GETPWUID,
+ WINBINDD_GETGRNAM,
+ WINBINDD_GETGRGID,
WINBINDD_GETGROUPS,
/* Enumerate users and groups */
diff --git a/source3/nsswitch/winbindd_proto.h b/source3/nsswitch/winbindd_proto.h
index f0badc4331..ac72768ea4 100644
--- a/source3/nsswitch/winbindd_proto.h
+++ b/source3/nsswitch/winbindd_proto.h
@@ -40,9 +40,8 @@ void winbindd_cm_status(void);
/* The following definitions come from nsswitch/winbindd_group.c */
-enum winbindd_result winbindd_getgrnam_from_group(struct winbindd_cli_state *state);
-enum winbindd_result winbindd_getgrnam_from_gid(struct winbindd_cli_state
- *state);
+enum winbindd_result winbindd_getgrnam(struct winbindd_cli_state *state);
+enum winbindd_result winbindd_getgrgid(struct winbindd_cli_state *state);
enum winbindd_result winbindd_setgrent(struct winbindd_cli_state *state);
enum winbindd_result winbindd_endgrent(struct winbindd_cli_state *state);
enum winbindd_result winbindd_getgrent(struct winbindd_cli_state *state);
@@ -90,8 +89,8 @@ enum winbindd_result winbindd_gid_to_sid(struct winbindd_cli_state *state);
/* The following definitions come from nsswitch/winbindd_user.c */
-enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *state) ;
-enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state);
+enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state) ;
+enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state);
enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state);
enum winbindd_result winbindd_endpwent(struct winbindd_cli_state *state);
enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state);
diff --git a/source3/nsswitch/winbindd_rpc.c b/source3/nsswitch/winbindd_rpc.c
index 87656d7ae2..18186b629a 100644
--- a/source3/nsswitch/winbindd_rpc.c
+++ b/source3/nsswitch/winbindd_rpc.c
@@ -135,7 +135,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
uint32 count = 0, start = *num_entries;
TALLOC_CTX *mem_ctx2;
- mem_ctx2 = talloc_init();
+ mem_ctx2 = talloc_init_named("enum_dom_groups[rpc]");
status = cli_samr_enum_dom_groups(hnd->cli, mem_ctx2, &dom_pol,
&start,
@@ -178,7 +178,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
uint32 *types = NULL;
int num_sids;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("name_to_sid[rpc]")))
return NT_STATUS_NO_MEMORY;
if (!(hnd = cm_get_lsa_handle(domain->name)))
@@ -465,7 +465,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
*seq = DOM_SEQUENCE_NONE;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("sequence_number[rpc]")))
return NT_STATUS_NO_MEMORY;
/* Get sam handle */
@@ -539,7 +539,7 @@ static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
CLI_POLICY_HND *hnd;
fstring level5_dom;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("domain_sid[rpc]")))
return NT_STATUS_NO_MEMORY;
/* Get sam handle */
diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c
index 6f38b13548..b5f9436de5 100644
--- a/source3/nsswitch/winbindd_user.c
+++ b/source3/nsswitch/winbindd_user.c
@@ -93,7 +93,7 @@ static BOOL winbindd_fill_pwent(char *domain_name, char *name,
/* Return a password structure from a username. */
-enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *state)
+enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
{
uint32 user_rid;
WINBIND_USERINFO user_info;
@@ -114,7 +114,7 @@ enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *stat
return WINBINDD_ERROR;
if ((domain = find_domain_from_name(name_domain)) == NULL) {
- DEBUG(5, ("No such domain: %s\n", name_domain));
+ DEBUG(5, ("no such domain: %s\n", name_domain));
return WINBINDD_ERROR;
}
@@ -137,24 +137,28 @@ enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *stat
from the winbind_lookup_by_name() call and use it in a
winbind_lookup_userinfo() */
- if (!(mem_ctx = talloc_init())) {
+ if (!(mem_ctx = talloc_init_named("winbindd_getpwnam(%s)",
+ name_user))) {
DEBUG(1, ("out of memory\n"));
return WINBINDD_ERROR;
}
sid_split_rid(&user_sid, &user_rid);
- status = domain->methods->query_user(domain, mem_ctx, user_rid, &user_info);
+ status = domain->methods->query_user(domain, mem_ctx, user_rid,
+ &user_info);
+
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("pwnam_from_user(): error getting user info for "
- "user '%s'\n", name_user));
+ DEBUG(1, ("error getting user info for user '%s'\n",
+ name_user));
talloc_destroy(mem_ctx);
return WINBINDD_ERROR;
}
/* Now take all this information and fill in a passwd structure */
if (!winbindd_fill_pwent(name_domain, state->request.data.username,
- user_rid, user_info.group_rid, user_info.full_name,
+ user_rid, user_info.group_rid,
+ user_info.full_name,
&state->response.data.pw)) {
talloc_destroy(mem_ctx);
return WINBINDD_ERROR;
@@ -167,7 +171,7 @@ enum winbindd_result winbindd_getpwnam_from_user(struct winbindd_cli_state *stat
/* Return a password structure given a uid number */
-enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state)
+enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
{
DOM_SID user_sid;
struct winbindd_domain *domain;
@@ -192,7 +196,7 @@ enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state
if (!winbindd_idmap_get_rid_from_uid(state->request.data.uid,
&user_rid, &domain)) {
- DEBUG(1, ("Could not convert uid %d to rid\n",
+ DEBUG(1, ("could not convert uid %d to rid\n",
state->request.data.uid));
return WINBINDD_ERROR;
}
@@ -206,7 +210,7 @@ enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state
fstring temp;
sid_to_string(temp, &user_sid);
- DEBUG(1, ("Could not lookup sid %s\n", temp));
+ DEBUG(1, ("could not lookup sid %s\n", temp));
return WINBINDD_ERROR;
}
@@ -216,15 +220,19 @@ enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state
/* Get some user info */
- if (!(mem_ctx = talloc_init())) {
+ if (!(mem_ctx = talloc_init_named("winbind_getpwuid(%d)",
+ state->request.data.uid))) {
+
DEBUG(1, ("out of memory\n"));
return WINBINDD_ERROR;
}
- status = domain->methods->query_user(domain, mem_ctx, user_rid, &user_info);
+ status = domain->methods->query_user(domain, mem_ctx, user_rid,
+ &user_info);
+
if (!NT_STATUS_IS_OK(status)) {
- DEBUG(1, ("pwnam_from_uid(): error getting user info for "
- "user '%s'\n", user_name));
+ DEBUG(1, ("error getting user info for user '%s'\n",
+ user_name));
return WINBINDD_ERROR;
}
@@ -255,7 +263,7 @@ enum winbindd_result winbindd_getpwnam_from_uid(struct winbindd_cli_state *state
enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
{
- struct winbindd_domain *tmp;
+ struct winbindd_domain *domain;
DEBUG(3, ("[%5d]: setpwent\n", state->pid));
@@ -276,7 +284,7 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
if (domain_list == NULL)
get_domain_info();
- for(tmp = domain_list; tmp != NULL; tmp = tmp->next) {
+ for(domain = domain_list; domain != NULL; domain = domain->next) {
struct getent_state *domain_state;
/*
@@ -285,17 +293,19 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
*/
if ((strcmp(state->request.domain, "") != 0) &&
- !check_domain_env(state->request.domain, tmp->name))
+ !check_domain_env(state->request.domain,
+ domain->name))
continue;
/* Create a state record for this domain */
- if ((domain_state = (struct getent_state *)malloc(sizeof(struct getent_state))) == NULL)
+ if ((domain_state = (struct getent_state *)
+ malloc(sizeof(struct getent_state))) == NULL)
return WINBINDD_ERROR;
ZERO_STRUCTP(domain_state);
- domain_state->domain = tmp;
+ domain_state->domain = domain;
/* Add to list of open domains */
@@ -338,7 +348,8 @@ static BOOL get_sam_user_entries(struct getent_state *ent)
if (ent->num_sam_entries)
return False;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("get_sam_user_entries(%s)",
+ ent->domain->name)))
return False;
methods = ent->domain->methods;
@@ -363,7 +374,7 @@ static BOOL get_sam_user_entries(struct getent_state *ent)
num_entries));
if (!tnl) {
- DEBUG(0,("get_sam_user_entries: Realloc failed.\n"));
+ DEBUG(0,("get_sam_user_entries realloc failed.\n"));
SAFE_FREE(name_list);
goto done;
} else
@@ -531,7 +542,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
DEBUG(3, ("[%5d]: list users\n", state->pid));
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("winbindd_list_users")))
return WINBINDD_ERROR;
/* Enumerate over trusted domains */
@@ -566,7 +577,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
ted = Realloc(extra_data, sizeof(fstring) * total_entries);
if (!ted) {
- DEBUG(0,("winbindd_list_users: failed to enlarge buffer!\n"));
+ DEBUG(0,("failed to enlarge buffer!\n"));
SAFE_FREE(extra_data);
goto done;
} else
diff --git a/source3/nsswitch/winbindd_util.c b/source3/nsswitch/winbindd_util.c
index 2f21f81ea8..3086795a49 100644
--- a/source3/nsswitch/winbindd_util.c
+++ b/source3/nsswitch/winbindd_util.c
@@ -47,17 +47,17 @@ struct winbindd_domain *domain_list = NULL;
struct winbindd_domain *find_domain_from_name(char *domain_name)
{
- struct winbindd_domain *tmp;
+ struct winbindd_domain *domain;
if (domain_list == NULL)
get_domain_info();
/* Search through list */
- for (tmp = domain_list; tmp != NULL; tmp = tmp->next) {
- if (strcasecmp(domain_name, tmp->name) == 0 ||
- strcasecmp(domain_name, tmp->full_name) == 0)
- return tmp;
+ for (domain = domain_list; domain != NULL; domain = domain->next) {
+ if (strcasecmp(domain_name, domain->name) == 0 ||
+ strcasecmp(domain_name, domain->full_name) == 0)
+ return domain;
}
/* Not found */
@@ -69,15 +69,15 @@ struct winbindd_domain *find_domain_from_name(char *domain_name)
struct winbindd_domain *find_domain_from_sid(DOM_SID *sid)
{
- struct winbindd_domain *tmp;
+ struct winbindd_domain *domain;
if (domain_list == NULL)
get_domain_info();
/* Search through list */
- for (tmp = domain_list; tmp != NULL; tmp = tmp->next) {
- if (sid_compare_domain(sid, &tmp->sid) == 0)
- return tmp;
+ for (domain = domain_list; domain != NULL; domain = domain->next) {
+ if (sid_compare_domain(sid, &domain->sid) == 0)
+ return domain;
}
/* Not found */
@@ -90,22 +90,26 @@ struct winbindd_domain *find_domain_from_sid(DOM_SID *sid)
static struct winbindd_domain *add_trusted_domain(char *domain_name,
struct winbindd_methods *methods)
{
- struct winbindd_domain *domain, *tmp;
+ struct winbindd_domain *domain;
- for (tmp = domain_list; tmp != NULL; tmp = tmp->next) {
- if (strcmp(domain_name, tmp->name) == 0) {
- DEBUG(3, ("domain %s already in domain list\n", domain_name));
- return tmp;
+ for (domain = domain_list; domain; domain = domain->next) {
+ if (strcmp(domain_name, domain->name) == 0) {
+ DEBUG(3, ("domain %s already in domain list\n",
+ domain_name));
+ return domain;
}
}
/* Create new domain entry */
- if ((domain = (struct winbindd_domain *)malloc(sizeof(*domain))) == NULL)
+
+ if ((domain = (struct winbindd_domain *)
+ malloc(sizeof(*domain))) == NULL)
return NULL;
/* Fill in fields */
ZERO_STRUCTP(domain);
+
fstrcpy(domain->name, domain_name);
domain->methods = methods;
domain->sequence_number = DOM_SEQUENCE_NONE;
@@ -130,7 +134,7 @@ BOOL get_domain_info(void)
char **names;
int num_domains = 0;
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("get_domain_info")))
return False;
domain = add_trusted_domain(lp_workgroup(), &cache_methods);
@@ -222,6 +226,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
struct winbindd_domain *domain;
domain = find_domain_from_sid(sid);
+
if (!domain) {
DEBUG(1,("Can't find domain from sid\n"));
return False;
@@ -229,7 +234,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
/* Lookup name */
- if (!(mem_ctx = talloc_init()))
+ if (!(mem_ctx = talloc_init_named("winbindd_lookup_name_by_sid")))
return False;
result = domain->methods->sid_to_name(domain, mem_ctx, sid, &names, type);