1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

lib: Add get_current_user_info_domain()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Volker Lendecke 2022-11-30 18:45:06 +01:00 committed by Jeremy Allison
parent 46ce8a4710
commit 8cc0489c80
6 changed files with 17 additions and 11 deletions

View File

@ -186,6 +186,11 @@ const char *get_current_username(void)
return current_user_info.smb_name;
}
const char *get_current_user_info_domain(void)
{
return current_user_info.domain;
}
/*******************************************************************
Given a pointer to a %$(NAME) in p and the whole string in str
expand it as an environment variable.

View File

@ -32,6 +32,7 @@ void set_current_user_info(const char *smb_name,
const char *unix_name,
const char *domain);
const char *get_current_username(void);
const char *get_current_user_info_domain(void);
void standard_sub_basic(const char *smb_name,
const char *domain_name,
char *str,

View File

@ -1005,7 +1005,7 @@ int virusfilter_shell_set_conn_env(
virusfilter_env_set(mem_ctx, env_list, "VIRUSFILTER_USER_NAME",
get_current_username());
virusfilter_env_set(mem_ctx, env_list, "VIRUSFILTER_USER_DOMAIN",
current_user_info.domain);
get_current_user_info_domain());
return 0;
}

View File

@ -1051,14 +1051,14 @@ static char *loadparm_s3_global_substitution_fn(
ret = talloc_sub_basic(mem_ctx,
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
s);
if (trim_char(ret, '\"', '\"')) {
if (strchr(ret,'\"') != NULL) {
TALLOC_FREE(ret);
ret = talloc_sub_basic(mem_ctx,
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
s);
}
}
@ -2411,7 +2411,7 @@ bool lp_file_list_changed(void)
n2 = talloc_sub_basic(talloc_tos(),
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
f->name);
if (!n2) {
return false;
@ -2499,7 +2499,7 @@ bool lp_include(struct loadparm_context *lp_ctx, struct loadparm_service *servic
}
fname = talloc_sub_basic(talloc_tos(), get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
pszParmValue);
add_to_file_list(NULL, &file_lists, pszParmValue, fname);
@ -4002,7 +4002,7 @@ static bool lp_load_ex(const char *pszFname,
if (lp_config_backend_is_file()) {
n2 = talloc_sub_basic(talloc_tos(), get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
pszFname);
if (!n2) {
smb_panic("lp_load_ex: out of memory");
@ -4318,7 +4318,7 @@ int lp_servicenumber(const char *pszServiceName)
*/
fstrcpy(serviceName, ServicePtrs[iService]->szService);
standard_sub_basic(get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
serviceName,sizeof(serviceName));
if (strequal(serviceName, pszServiceName)) {
break;

View File

@ -1592,7 +1592,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
"",
get_current_gid(NULL),
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
lpqcommand);
if (!lpqcommand) {
return;
@ -1612,7 +1612,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
"",
get_current_gid(NULL),
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
lprmcommand);
if (!lprmcommand) {
return;
@ -2850,7 +2850,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
"",
get_current_gid(NULL),
get_current_username(),
current_user_info.domain,
get_current_user_info_domain(),
lpq_cmd);
if (lpq_cmd == NULL) {
status = NT_STATUS_PRINT_CANCELLED;

View File

@ -123,7 +123,7 @@ static void msg_deliver(struct msg_state *state)
}
s = talloc_sub_basic(talloc_tos(), current_user_info.smb_name,
current_user_info.domain, s);
get_current_user_info_domain(), s);
if (s == NULL) {
goto done;
}