diff options
author | Andrew Bartlett <abartlet@samba.org> | 2010-05-29 04:14:27 +1000 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2010-05-29 09:22:53 -0400 |
commit | b455c5e155f7e7ba4cc07cd4415a304163213e0f (patch) | |
tree | 9cb0aadce86473dea4900cad75fd39fd2e951b55 | |
parent | a8d308faff760ee56f7aa4a97ccaab60bf965849 (diff) | |
download | samba-b455c5e155f7e7ba4cc07cd4415a304163213e0f.tar.gz samba-b455c5e155f7e7ba4cc07cd4415a304163213e0f.tar.bz2 samba-b455c5e155f7e7ba4cc07cd4415a304163213e0f.zip |
s3:auth Fix segfault when the user cannot be found by getpwnam()
Add comment to notify when getpwnam() fails.
Reviewed-by: Simo Sorce <idra@samba.org>
-rw-r--r-- | source3/auth/auth_util.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index bccec8080b..1f9bc7b6d7 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -964,7 +964,6 @@ static NTSTATUS check_account(TALLOC_CTX *mem_ctx, const char *domain, bool *username_was_mapped) { struct smbd_server_connection *sconn = smbd_server_conn; - NTSTATUS nt_status; fstring dom_user, lower_username; fstring real_username; struct passwd *passwd; @@ -979,8 +978,12 @@ static NTSTATUS check_account(TALLOC_CTX *mem_ctx, const char *domain, *username_was_mapped = map_username(sconn, dom_user); - if ( !(passwd = smb_getpwnam( NULL, dom_user, real_username, True )) ) + passwd = smb_getpwnam( NULL, dom_user, real_username, True ); + if (!passwd) { + DEBUG(3, ("Failed to find authenticated user %s via " + "getpwnam(), denying access.\n", dom_user)); return NT_STATUS_NO_SUCH_USER; + } *uid = passwd->pw_uid; *gid = passwd->pw_gid; @@ -995,7 +998,7 @@ static NTSTATUS check_account(TALLOC_CTX *mem_ctx, const char *domain, TALLOC_FREE(passwd); - return nt_status; + return NT_STATUS_OK; } /**************************************************************************** @@ -1154,6 +1157,10 @@ NTSTATUS make_server_info_info3(TALLOC_CTX *mem_ctx, &found_username, &uid, &gid, &username_was_mapped); + if (!NT_STATUS_IS_OK(nt_status)) { + return nt_status; + } + result = make_server_info(NULL); if (result == NULL) { DEBUG(4, ("make_server_info failed!\n")); |