From: Björn Baumbach Date: Thu, 4 Jun 2020 13:41:34 +0000 (+0200) Subject: s4-auth/unix_token: add new function auth_session_info_set_unix() X-Git-Tag: ldb-2.2.0~176 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bde136a280291354c06b528f1ef9e002d265b2a2;p=thirdparty%2Fsamba.git 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 Reviewed-by: Ralph Boehme --- 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; +}