]> 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)
committerJeremy Allison <jra@samba.org>
Thu, 21 Jan 2021 21:48:30 +0000 (21:48 +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>
source3/include/proto.h
source3/lib/util_names.c
source3/winbindd/winbindd_util.c

index 6c9cf130d043a29d2a33e429a065f88f65793d3b..16cd587ed30ef7b97a10cd70b9ead15b71fd2b5f 100644 (file)
@@ -304,6 +304,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 15236c913dfa858068ed66eba82985aea4134809..630a25875c7b73ba83a34b852a4ba3e83066fde1 100644 (file)
@@ -182,3 +182,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 a5f5defcd8728e713eaf47dd2d75ed0b25bcfa17..414b770a2710c720b91909b88c1d9efb108c0716 100644 (file)
@@ -126,8 +126,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;
 
@@ -136,12 +134,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;
        }
 
        /*