summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2012-12-10 13:22:10 -0800
committerAndreas Schneider <asn@cryptomilk.org>2012-12-11 20:04:25 +0100
commit0f75d9274cff7095dfab251307231a5a911f0c8d (patch)
treeb4243074f3edf1f2f5197c37322a3890150bd59c
parenta20c47410fb74716c0c8b2583fd4d0ae0145fd7d (diff)
downloadsamba-0f75d9274cff7095dfab251307231a5a911f0c8d.tar.gz
samba-0f75d9274cff7095dfab251307231a5a911f0c8d.tar.bz2
samba-0f75d9274cff7095dfab251307231a5a911f0c8d.zip
s3:auth: Tidy up some of the API confusion in create_token_from_XXX() calls.
Based on Michaels example, split out the return of NT_STATUS_NO_MEMORY on talloc fail from other possible errors. Allow the NTSTATUS return to be the only valid indication of success in these calls. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Tue Dec 11 20:04:25 CET 2012 on sn-devel-104
-rw-r--r--source3/auth/token_util.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c
index 9b740b7bc9..ac242f17f0 100644
--- a/source3/auth/token_util.c
+++ b/source3/auth/token_util.c
@@ -837,16 +837,19 @@ NTSTATUS create_token_from_username(TALLOC_CTX *mem_ctx, const char *username,
goto done;
}
+ /*
+ * If result == NT_STATUS_OK then
+ * we know we have a valid token. Ensure
+ * we also have a valid username to match.
+ */
+
if (*found_username == NULL) {
*found_username = talloc_strdup(mem_ctx, username);
+ if (*found_username == NULL) {
+ result = NT_STATUS_NO_MEMORY;
+ }
}
- if ((*token == NULL) || (*found_username == NULL)) {
- result = NT_STATUS_NO_MEMORY;
- goto done;
- }
-
- result = NT_STATUS_OK;
done:
TALLOC_FREE(tmp_ctx);
return result;