summaryrefslogtreecommitdiff
path: root/source4/auth
diff options
context:
space:
mode:
authorBjörn Baumbach <bb@sernet.de>2020-06-04 15:41:34 +0200
committerRalph Boehme <slow@samba.org>2020-06-05 10:32:31 +0000
commitbde136a280291354c06b528f1ef9e002d265b2a2 (patch)
tree2baef6112f5c060d056b144c3e3ac90f393eb416 /source4/auth
parentd159b4c0a506162f8644943f7a66c590efd0df55 (diff)
downloadsamba-bde136a280291354c06b528f1ef9e002d265b2a2.tar.gz
s4-auth/unix_token: add new function auth_session_info_set_unix()
Used to fill the unix info in a struct auth_session_info similar to auth_session_info_fill_unix(). The new auth_session_info_set_unix() receives the uid and gid for the unix token as an parameter. It does not query the unix token from winbind (via security_token_to_unix_token()). This is useful to fill a user session info manually if winbind is not available. Bug: https://bugzilla.samba.org/show_bug.cgi?id=14400 Signed-off-by: Björn Baumbach <bb@sernet.de> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source4/auth')
-rw-r--r--source4/auth/unix_token.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/source4/auth/unix_token.c b/source4/auth/unix_token.c
index 6cd09aee954..b3396b852df 100644
--- a/source4/auth/unix_token.c
+++ b/source4/auth/unix_token.c
@@ -191,3 +191,38 @@ NTSTATUS auth_session_info_fill_unix(struct loadparm_context *lp_ctx,
return NT_STATUS_OK;
}
+
+/*
+ * Set the given auth_user_info_unix and auth_unix_token elements in a
+ * struct session_info, similar auth_session_info_fill_unix().
+ * Receives the uid and gid for the unix token as parameters and does
+ * not query the unix token from winbind (via security_token_to_unix_token()).
+ * This is useful to fill a user session info manually if winbind is not
+ * available.
+ */
+NTSTATUS auth_session_info_set_unix(struct loadparm_context *lp_ctx,
+ const char *original_user_name,
+ int uid,
+ int gid,
+ struct auth_session_info *session_info)
+{
+ NTSTATUS status;
+
+ session_info->unix_token = talloc_zero(session_info,
+ struct security_unix_token);
+ if (session_info->unix_token == NULL) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ session_info->unix_token->uid = uid;
+ session_info->unix_token->gid = gid;
+
+ status = fill_unix_info(lp_ctx,
+ original_user_name,
+ session_info);
+ if (!NT_STATUS_IS_OK(status)) {
+ return status;
+ }
+
+ return NT_STATUS_OK;
+}