From 0f75d9274cff7095dfab251307231a5a911f0c8d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 10 Dec 2012 13:22:10 -0800 Subject: [PATCH] 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 Reviewed-by: Michael Adam Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Tue Dec 11 20:04:25 CET 2012 on sn-devel-104 --- source3/auth/token_util.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/source3/auth/token_util.c b/source3/auth/token_util.c index 9b740b7bc91..ac242f17f04 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; -- 2.11.4.GIT