summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Cabrero <scabrero@samba.org>2022-06-03 17:48:21 +0200
committerJule Anger <janger@samba.org>2022-06-12 10:17:00 +0000
commit9bab57ae404cb31a9714d371e87622cc098704ef (patch)
tree22d24823d73d354d7d7cfb71be19bd27d909de50
parent87f5949434512562e51fec1ff4fb84182ace7f0c (diff)
downloadsamba-9bab57ae404cb31a9714d371e87622cc098704ef.tar.gz
Revert "lib:util: Remove NIS support from string_match()"
This partly reverts commit 620de975f147ac9427b51ea0e1e3eabda443d4b6. Drop chunk including system/nis.h, drop wscript_build modifications, use getdomainname() from glibc instead of yp_get_default_domain() from libnsl. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15087 Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit b3034f1209a6c45873882415c4291dde7eee76db) Autobuild-User(v4-16-test): Jule Anger <janger@samba.org> Autobuild-Date(v4-16-test): Sun Jun 12 10:17:00 UTC 2022 on sn-devel-184
-rw-r--r--lib/util/access.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/lib/util/access.c b/lib/util/access.c
index 5b53894b2ce..b1b4bffaeaa 100644
--- a/lib/util/access.c
+++ b/lib/util/access.c
@@ -114,6 +114,62 @@ static bool string_match(const char *tok,const char *s)
&& strequal_m(tok, s + str_len - tok_len)) {
return true;
}
+ } else if (tok[0] == '@') { /* netgroup: look it up */
+#ifdef HAVE_NETGROUP
+ DATA_BLOB tmp;
+ char *mydomain = NULL;
+ char *hostname = NULL;
+ bool netgroup_ok = false;
+ char nis_domain_buf[256];
+
+ if (memcache_lookup(
+ NULL, SINGLETON_CACHE,
+ data_blob_string_const_null("yp_default_domain"),
+ &tmp)) {
+
+ SMB_ASSERT(tmp.length > 0);
+ mydomain = (tmp.data[0] == '\0')
+ ? NULL : (char *)tmp.data;
+ } else {
+ if (getdomainname(nis_domain_buf,
+ sizeof(nis_domain_buf)) == 0) {
+ mydomain = &nis_domain_buf[0];
+ memcache_add(NULL,
+ SINGLETON_CACHE,
+ data_blob_string_const_null(
+ "yp_default_domain"),
+ data_blob_string_const_null(
+ mydomain));
+ } else {
+ mydomain = NULL;
+ }
+ }
+
+ if (!mydomain) {
+ DEBUG(0,("Unable to get default yp domain. "
+ "Try without it.\n"));
+ }
+ if (!(hostname = smb_xstrdup(s))) {
+ DEBUG(1,("out of memory for strdup!\n"));
+ return false;
+ }
+
+ netgroup_ok = innetgr(tok + 1, hostname, (char *) 0, mydomain);
+
+ DBG_INFO("%s %s of domain %s in netgroup %s\n",
+ netgroup_ok ? "Found" : "Could not find",
+ hostname,
+ mydomain?mydomain:"(ANY)",
+ tok+1);
+
+ SAFE_FREE(hostname);
+
+ if (netgroup_ok)
+ return true;
+#else
+ DEBUG(0,("access: netgroup support is not configured\n"));
+ return false;
+#endif
} else if (strequal_m(tok, "ALL")) { /* all: match any */
return true;
} else if (strequal_m(tok, "FAIL")) { /* fail: match any */