summaryrefslogtreecommitdiff
path: root/source3/nsswitch/winbindd_user.c
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2005-06-20 13:42:29 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:57:20 -0500
commitb62247f1eee94cadcf293084ce747c4b58aa1ac5 (patch)
tree9c32eda3836675166c7d791cfcef365d99dec5ce /source3/nsswitch/winbindd_user.c
parente6ef7ba7a4bc79dbc98119abc5cb9bd72d43c2a4 (diff)
downloadsamba-b62247f1eee94cadcf293084ce747c4b58aa1ac5.tar.gz
samba-b62247f1eee94cadcf293084ce747c4b58aa1ac5.tar.bz2
samba-b62247f1eee94cadcf293084ce747c4b58aa1ac5.zip
r7785: This looks much larger than it is. It changes the top-level functions of the
parent winbind not to return winbindd_result. This is to hopefully fix all the problems where a result has been scheduled for write twice. The problematic ones have been the functions that might have been delayed as well as under other circumstances immediately gets answered from the cache. Now a request needs to be explicitly replied to with a request_error() or request_ok(). Volker (This used to be commit 7365c9accf98ec1dd78a59dd7f62462bbb8528d4)
Diffstat (limited to 'source3/nsswitch/winbindd_user.c')
-rw-r--r--source3/nsswitch/winbindd_user.c109
1 files changed, 61 insertions, 48 deletions
diff --git a/source3/nsswitch/winbindd_user.c b/source3/nsswitch/winbindd_user.c
index d8d7dbb502..55b63a8182 100644
--- a/source3/nsswitch/winbindd_user.c
+++ b/source3/nsswitch/winbindd_user.c
@@ -189,8 +189,7 @@ static void winbindd_getpwsid(struct winbindd_cli_state *state,
return;
error:
- s->state->response.result = WINBINDD_ERROR;
- request_finished(state);
+ request_error(state);
}
static void getpwsid_queryuser_recv(void *private, BOOL success,
@@ -203,8 +202,7 @@ static void getpwsid_queryuser_recv(void *private, BOOL success,
if (!success) {
DEBUG(5, ("Could not query user %s\\%s\n", s->domain->name,
s->username));
- s->state->response.result = WINBINDD_ERROR;
- request_finished(s->state);
+ request_error(s->state);
return;
}
@@ -225,8 +223,7 @@ static void getpwsid_sid2uid_recv(void *private, BOOL success, uid_t uid)
if (!success) {
DEBUG(5, ("Could not query user's %s\\%s uid\n",
s->domain->name, s->username));
- s->state->response.result = WINBINDD_ERROR;
- request_finished(s->state);
+ request_error(s->state);
return;
}
@@ -244,12 +241,10 @@ static void getpwsid_sid2gid_recv(void *private, BOOL success, gid_t gid)
char *homedir;
char *shell;
- s->state->response.result = WINBINDD_ERROR;
-
if (!success) {
DEBUG(5, ("Could not query user's %s\\%s\n gid",
s->domain->name, s->username));
- goto done;
+ goto failed;
}
s->gid = gid;
@@ -274,7 +269,7 @@ static void getpwsid_sid2gid_recv(void *private, BOOL success, gid_t gid)
s->domain->name, pw->pw_uid, pw->pw_gid);
if (homedir == NULL) {
DEBUG(5, ("Could not compose homedir\n"));
- goto done;
+ goto failed;
}
safe_strcpy(pw->pw_dir, homedir, sizeof(pw->pw_dir) - 1);
SAFE_FREE(homedir);
@@ -283,7 +278,7 @@ static void getpwsid_sid2gid_recv(void *private, BOOL success, gid_t gid)
s->domain->name, pw->pw_uid, pw->pw_gid);
if (shell == NULL) {
DEBUG(5, ("Could not compose shell\n"));
- goto done;
+ goto failed;
}
safe_strcpy(pw->pw_shell, shell, sizeof(pw->pw_shell) - 1);
SAFE_FREE(shell);
@@ -293,10 +288,11 @@ static void getpwsid_sid2gid_recv(void *private, BOOL success, gid_t gid)
safe_strcpy(pw->pw_passwd, "x", sizeof(pw->pw_passwd) - 1);
- s->state->response.result = WINBINDD_OK;
+ request_ok(s->state);
+ return;
- done:
- request_finished(s->state);
+ failed:
+ request_error(s->state);
}
/* Return a password structure from a username. */
@@ -304,7 +300,7 @@ static void getpwsid_sid2gid_recv(void *private, BOOL success, gid_t gid)
static void getpwnam_name2sid_recv(void *private, BOOL success,
const DOM_SID *sid, enum SID_NAME_USE type);
-enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
+void winbindd_getpwnam(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
fstring domname, username;
@@ -319,7 +315,8 @@ enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
username)) {
DEBUG(0, ("Could not parse domain user: %s\n",
state->request.data.username));
- return WINBINDD_ERROR;
+ request_error(state);
+ return;
}
/* Get info for the domain */
@@ -329,20 +326,21 @@ enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
if (domain == NULL) {
DEBUG(7, ("could not find domain entry for domain %s\n",
domname));
- return WINBINDD_ERROR;
+ request_error(state);
+ return;
}
if ( strequal(domname, lp_workgroup()) && lp_winbind_trusted_domains_only() ) {
DEBUG(7,("winbindd_getpwnam: My domain -- rejecting getpwnam() for %s\\%s.\n",
domname, username));
- return WINBINDD_ERROR;
+ request_error(state);
+ return;
}
/* Get rid and name type from name. The following costs 1 packet */
winbindd_lookupname_async(state->mem_ctx, domname, username,
getpwnam_name2sid_recv, state);
- return WINBINDD_PENDING;
}
static void getpwnam_name2sid_recv(void *private, BOOL success,
@@ -353,15 +351,13 @@ static void getpwnam_name2sid_recv(void *private, BOOL success,
if (!success) {
DEBUG(5, ("Could not lookup name for user %s\n",
state->request.data.username));
- state->response.result = WINBINDD_ERROR;
- request_finished(state);
+ request_error(state);
return;
}
if ((type != SID_NAME_USER) && (type != SID_NAME_COMPUTER)) {
DEBUG(5, ("%s is not a user\n", state->request.data.username));
- state->response.result = WINBINDD_ERROR;
- request_finished(state);
+ request_error(state);
return;
}
@@ -370,7 +366,7 @@ static void getpwnam_name2sid_recv(void *private, BOOL success,
/* Return a password structure given a uid number */
-enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
+void winbindd_getpwuid(struct winbindd_cli_state *state)
{
DOM_SID user_sid;
NTSTATUS status;
@@ -378,8 +374,10 @@ enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
/* Bug out if the uid isn't in the winbind range */
if ((state->request.data.uid < server_state.uid_low ) ||
- (state->request.data.uid > server_state.uid_high))
- return WINBINDD_ERROR;
+ (state->request.data.uid > server_state.uid_high)) {
+ request_error(state);
+ return;
+ }
DEBUG(3, ("[%5lu]: getpwuid %lu\n", (unsigned long)state->pid,
(unsigned long)state->request.data.uid));
@@ -390,11 +388,11 @@ enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(5, ("Could not find SID for uid %lu\n",
(unsigned long)state->request.data.uid));
- return WINBINDD_ERROR;
+ request_error(state);
+ return;
}
winbindd_getpwsid(state, &user_sid);
- return WINBINDD_PENDING;
}
/*
@@ -403,7 +401,7 @@ enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
/* Rewind file pointer for ntdom passwd database */
-enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
+void winbindd_setpwent(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
@@ -411,8 +409,10 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
/* Check user has enabled this */
- if (!lp_winbind_enum_users())
- return WINBINDD_ERROR;
+ if (!lp_winbind_enum_users()) {
+ request_error(state);
+ return;
+ }
/* Free old static data if it exists */
@@ -451,8 +451,11 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
/* Create a state record for this domain */
- if ((domain_state = SMB_MALLOC_P(struct getent_state)) == NULL)
- return WINBINDD_ERROR;
+ if ((domain_state = SMB_MALLOC_P(struct getent_state)) == NULL) {
+ DEBUG(0, ("malloc failed\n"));
+ request_error(state);
+ return;
+ }
ZERO_STRUCTP(domain_state);
@@ -464,21 +467,19 @@ enum winbindd_result winbindd_setpwent(struct winbindd_cli_state *state)
}
state->getpwent_initialized = True;
-
- return WINBINDD_OK;
+ request_ok(state);
}
/* Close file pointer to ntdom passwd database */
-enum winbindd_result winbindd_endpwent(struct winbindd_cli_state *state)
+void winbindd_endpwent(struct winbindd_cli_state *state)
{
DEBUG(3, ("[%5lu]: endpwent\n", (unsigned long)state->pid));
free_getent_state(state->getpwent_state);
state->getpwent_initialized = False;
state->getpwent_state = NULL;
-
- return WINBINDD_OK;
+ request_ok(state);
}
/* Get partial list of domain users for a domain. We fill in the sam_entries,
@@ -572,7 +573,7 @@ static BOOL get_sam_user_entries(struct getent_state *ent, TALLOC_CTX *mem_ctx)
#define MAX_GETPWENT_USERS 500
-enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state)
+void winbindd_getpwent(struct winbindd_cli_state *state)
{
struct getent_state *ent;
struct winbindd_pw *user_list;
@@ -582,15 +583,19 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state)
/* Check user has enabled this */
- if (!lp_winbind_enum_users())
- return WINBINDD_ERROR;
+ if (!lp_winbind_enum_users()) {
+ request_error(state);
+ return;
+ }
/* Allocate space for returning a chunk of users */
num_users = MIN(MAX_GETPWENT_USERS, state->request.data.num_entries);
- if ((state->response.extra_data = SMB_MALLOC_ARRAY(struct winbindd_pw, num_users)) == NULL)
- return WINBINDD_ERROR;
+ if ((state->response.extra_data = SMB_MALLOC_ARRAY(struct winbindd_pw, num_users)) == NULL) {
+ request_error(state);
+ return;
+ }
memset(state->response.extra_data, 0, num_users *
sizeof(struct winbindd_pw));
@@ -600,8 +605,10 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state)
if (!state->getpwent_initialized)
winbindd_setpwent(state);
- if (!(ent = state->getpwent_state))
- return WINBINDD_ERROR;
+ if (!(ent = state->getpwent_state)) {
+ request_error(state);
+ return;
+ }
/* Start sending back users */
@@ -664,12 +671,15 @@ enum winbindd_result winbindd_getpwent(struct winbindd_cli_state *state)
/* Out of domains */
- return (user_list_ndx > 0) ? WINBINDD_OK : WINBINDD_ERROR;
+ if (user_list_ndx > 0)
+ request_ok(state);
+ else
+ request_error(state);
}
/* List domain users without mapping to unix ids */
-enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
+void winbindd_list_users(struct winbindd_cli_state *state)
{
struct winbindd_domain *domain;
WINBIND_USERINFO *info;
@@ -756,5 +766,8 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
done:
- return rv;
+ if (rv == WINBINDD_OK)
+ request_ok(state);
+ else
+ request_error(state);
}