lib: Add get_current_user_info_domain()
authorVolker Lendecke <vl@samba.org>
Wed, 30 Nov 2022 17:45:06 +0000 (18:45 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 12 Dec 2022 21:16:33 +0000 (21:16 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/lib/substitute.c
source3/lib/substitute.h
source3/modules/vfs_virusfilter_utils.c
source3/param/loadparm.c
source3/printing/printing.c
source3/smbd/smb1_message.c

index 24486b86f8e51ae92553fb6bde0faaa77fd4afbf..09cf898ddff11f47d5a8b38acc607e76945f3c00 100644 (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.
index ba903434ecac1133f91f7c1e4cc104d69c513abd..6596ffdbf0c8ccd9d5ed1d13407cff9db93faf53 100644 (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,
index a673894e3998c69abb79ea1bf529bd77979d26bc..4da0503eef031e93b4292505d560a32b8968e5ce 100644 (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;
 }
index 79041908e3d09f761857e2b2be1e538b8e2fe56b..f5ff1989998267371db4e5b6c4d8c654eb0c2b1e 100644 (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;
index dbe5a20e3822e7b0abae48bad3e317543e1028f6..f7911244398e177088b2d76f12e041b244ace565 100644 (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;
index 6894aa52ec02d649a53368c142352b82d10315a0..7d89cc45158552264b40a1eaa2d3765e0e8c8aa8 100644 (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;
        }