]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbind: move "winbind:ignore domain" logic to a seperate function
authorRalph Boehme <slow@samba.org>
Mon, 11 Jan 2021 15:15:15 +0000 (16:15 +0100)
committerKarolin Seeger <kseeger@samba.org>
Thu, 28 Jan 2021 09:17:15 +0000 (09:17 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14602

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(cherry picked from commit 894caca79476d25a0268d89b2ad8a5758b7e31f3)

source3/include/proto.h
source3/lib/util_names.c
source3/winbindd/winbindd_util.c

index 5d5da28bbb59330c1c20dc4a289466a8e3978774..921b92830c2ff4d810c81bc42ae0b64133d561ab 100644 (file)
@@ -319,6 +319,7 @@ struct passwd *Get_Pwnam_alloc(TALLOC_CTX *mem_ctx, const char *user);
 /* The following definitions come from lib/util_names.c  */
 const char *get_global_sam_name(void);
 const char *my_sam_name(void);
+bool is_allowed_domain(const char *domain_name);
 
 /* The following definitions come from lib/util.c  */
 
index dc5c530346c7222f2b55057fe73082440c3478eb..efef88f4f7b1a8d8971f9981fb0f3507403f7561 100644 (file)
@@ -185,3 +185,23 @@ const char *my_sam_name(void)
 
        return lp_workgroup();
 }
+
+bool is_allowed_domain(const char *domain_name)
+{
+       const char **ignored_domains = NULL;
+       const char **dom = NULL;
+
+       ignored_domains = lp_parm_string_list(-1,
+                                             "winbind",
+                                             "ignore domains",
+                                             NULL);
+
+       for (dom = ignored_domains; dom != NULL && *dom != NULL; dom++) {
+               if (gen_fnmatch(*dom, domain_name) == 0) {
+                       DBG_NOTICE("Ignoring domain '%s'\n", domain_name);
+                       return false;
+               }
+       }
+
+       return true;
+}
index c2f02b74211e8b976d8405f45494e7a36c954881..bec706f87deaef04f7ee8dcebfc1bac8d0c053c2 100644 (file)
@@ -123,8 +123,6 @@ static NTSTATUS add_trusted_domain(const char *domain_name,
                                   struct winbindd_domain **_d)
 {
        struct winbindd_domain *domain = NULL;
-       const char **ignored_domains = NULL;
-       const char **dom = NULL;
        int role = lp_server_role();
        struct dom_sid_buf buf;
 
@@ -133,12 +131,8 @@ static NTSTATUS add_trusted_domain(const char *domain_name,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       ignored_domains = lp_parm_string_list(-1, "winbind", "ignore domains", NULL);
-       for (dom=ignored_domains; dom && *dom; dom++) {
-               if (gen_fnmatch(*dom, domain_name) == 0) {
-                       DEBUG(2,("Ignoring domain '%s'\n", domain_name));
-                       return NT_STATUS_NO_SUCH_DOMAIN;
-               }
+       if (!is_allowed_domain(domain_name)) {
+               return NT_STATUS_NO_SUCH_DOMAIN;
        }
 
        /*