From 93ac516e15ab771b6ed4eeacc556a2ec916387bb Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 14 Apr 2010 15:15:32 +0200 Subject: s3-auth: Added a function to get the server_info from the system user. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Günther Deschner --- source3/auth/auth_util.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'source3/auth/auth_util.c') diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c index 7869637bd1..bccec8080b 100644 --- a/source3/auth/auth_util.c +++ b/source3/auth/auth_util.c @@ -756,6 +756,27 @@ static NTSTATUS make_new_server_info_guest(struct auth_serversupplied_info **ser return NT_STATUS_OK; } +/*************************************************************************** + Make (and fill) a user_info struct for a system user login. + This *must* succeed for smbd to start. +***************************************************************************/ + +static NTSTATUS make_new_server_info_system(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info **server_info) +{ + struct passwd *pwd; + + pwd = getpwuid_alloc(mem_ctx, sec_initial_uid()); + if (pwd == NULL) { + return NT_STATUS_NO_MEMORY; + } + + return make_serverinfo_from_username(mem_ctx, + pwd->pw_name, + false, + server_info); +} + /**************************************************************************** Fake a auth_serversupplied_info just from a username ****************************************************************************/ @@ -888,6 +909,24 @@ NTSTATUS make_server_info_guest(TALLOC_CTX *mem_ctx, return (*server_info != NULL) ? NT_STATUS_OK : NT_STATUS_NO_MEMORY; } +static struct auth_serversupplied_info *system_info = NULL; + +bool init_system_info(void) +{ + if (system_info != NULL) + return True; + + return NT_STATUS_IS_OK(make_new_server_info_system(talloc_autofree_context(), &system_info)); +} + +NTSTATUS make_server_info_system(TALLOC_CTX *mem_ctx, + struct auth_serversupplied_info **server_info) +{ + if (system_info == NULL) return NT_STATUS_UNSUCCESSFUL; + *server_info = copy_serverinfo(mem_ctx, system_info); + return (*server_info != NULL) ? NT_STATUS_OK : NT_STATUS_NO_MEMORY; +} + bool copy_current_user(struct current_user *dst, struct current_user *src) { gid_t *groups; -- cgit