summaryrefslogtreecommitdiff
path: root/source3/auth
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-02-03 18:19:36 +1100
committerAndrew Bartlett <abartlet@samba.org>2012-03-04 23:33:05 +0100
commit50de3cf9c0b95483263583d6f4762a77531a3004 (patch)
treecbbde8d33de1e99f05772cee79ea1de13cc9a175 /source3/auth
parentd7bb961859a3501aec4d28842bfffb6190d19a73 (diff)
downloadsamba-50de3cf9c0b95483263583d6f4762a77531a3004.tar.gz
samba-50de3cf9c0b95483263583d6f4762a77531a3004.tar.bz2
samba-50de3cf9c0b95483263583d6f4762a77531a3004.zip
s3-auth Add make_session_info_from_pw to avoid multiple getpwnam() calls
Diffstat (limited to 'source3/auth')
-rw-r--r--source3/auth/auth_util.c46
1 files changed, 34 insertions, 12 deletions
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index e0665784f1..06aa9c5108 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -891,6 +891,35 @@ done:
return status;
}
+/****************************************************************************
+ Fake a auth_session_info just from a username (as a
+ session_info structure, with create_local_token() already called on
+ it.
+****************************************************************************/
+
+static NTSTATUS make_session_info_from_pw(TALLOC_CTX *mem_ctx,
+ struct passwd *pwd,
+ bool is_guest,
+ struct auth_session_info **session_info)
+{
+ struct auth_serversupplied_info *result;
+ NTSTATUS status;
+
+ status = make_server_info_pw(&result, pwd->pw_name, pwd);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ result->nss_token = true;
+ result->guest = is_guest;
+
+ /* Now turn the server_info into a session_info with the full token etc */
+ status = create_local_token(mem_ctx, result, NULL, pwd->pw_name, session_info);
+ talloc_free(result);
+ return status;
+}
+
/***************************************************************************
Make (and fill) a auth_session_info struct for a system user login.
This *must* succeed for smbd to start.
@@ -907,10 +936,10 @@ static NTSTATUS make_new_session_info_system(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_SUCH_USER;
}
- status = make_session_info_from_username(mem_ctx,
- pwd->pw_name,
- false,
- session_info);
+ status = make_session_info_from_pw(mem_ctx,
+ pwd,
+ false,
+ session_info);
TALLOC_FREE(pwd);
if (!NT_STATUS_IS_OK(status)) {
return status;
@@ -941,7 +970,6 @@ NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
bool is_guest,
struct auth_session_info **session_info)
{
- struct auth_serversupplied_info *result;
struct passwd *pwd;
NTSTATUS status;
@@ -950,20 +978,14 @@ NTSTATUS make_session_info_from_username(TALLOC_CTX *mem_ctx,
return NT_STATUS_NO_SUCH_USER;
}
- status = make_server_info_pw(&result, pwd->pw_name, pwd);
+ status = make_session_info_from_pw(mem_ctx, pwd, is_guest, session_info);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(pwd);
return status;
}
- result->nss_token = true;
- result->guest = is_guest;
-
- /* Now turn the server_info into a session_info with the full token etc */
- status = create_local_token(mem_ctx, result, NULL, pwd->pw_name, session_info);
TALLOC_FREE(pwd);
- talloc_free(result);
return status;
}