rpms/autofs/devel autofs-5.0.1-rc2-add-export-syntax-checks.patch, NONE, 1.1 autofs-5.0.1-rc2-hosts-check-exports-update.patch, NONE, 1.1 autofs.spec, 1.166, 1.167

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Sun Dec 10 07:56:24 UTC 2006


Author: ikent

Update of /cvs/dist/rpms/autofs/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv20352

Modified Files:
	autofs.spec 
Added Files:
	autofs-5.0.1-rc2-add-export-syntax-checks.patch 
	autofs-5.0.1-rc2-hosts-check-exports-update.patch 
Log Message:
* Sun Dec 10 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.33
- expand export access checks to include missing syntax options.
- make "-hosts" module try to be sensitive to exports list changes.


autofs-5.0.1-rc2-add-export-syntax-checks.patch:
 CHANGELOG      |    1 
 lib/rpc_subs.c |   76 ++++++++++++++++++++++++++++++++++-----------------------
 2 files changed, 47 insertions(+), 30 deletions(-)

--- NEW FILE autofs-5.0.1-rc2-add-export-syntax-checks.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 1d12402..989b7cb 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -45,6 +45,7 @@
   check for "port=" parameter.
 - correct semantics of "-null" map handling.
 - remove ability to use multiple indirect mount entries in master map.
+- expand export access checks to include missing syntax options.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/lib/rpc_subs.c b/lib/rpc_subs.c
index 342d33a..4982457 100644
--- a/lib/rpc_subs.c
+++ b/lib/rpc_subs.c
@@ -44,6 +44,8 @@ #endif
 
 #define MAX_ERR_BUF	512
 
+static char *ypdomain = NULL;
+
 /*
  * Create a UDP RPC client
  */
@@ -910,51 +912,62 @@ static int pattern_match(const char *s, 
 
 static int string_match(const char *myname, const char *pattern)
 {
-	struct hostent he;
-	struct hostent *phe = &he;
-	struct hostent *result;
-	char buf[HOST_ENT_BUF_SIZE];
-	int ret, ghn_errno;
+	struct addrinfo hints, *ni;
+	int ret;
 
-	memset(buf, 0, HOST_ENT_BUF_SIZE);
-	memset(&he, 0, sizeof(struct hostent));
+	memset(&hints, 0, sizeof(hints));
+	hints.ai_flags = AI_CANONNAME;
+	hints.ai_family = 0;
+	hints.ai_socktype = 0;
 
-	ret = gethostbyname_r(myname, phe,
-			buf, HOST_ENT_BUF_SIZE, &result, &ghn_errno);
-	if (ret || !result)
+	ret = getaddrinfo(myname, NULL, &hints, &ni);
+	if (ret) {
+		error(LOGOPT_ANY, "name lookup failed: %s", gai_strerror(ret));
 		return 0;
+	}
 
 	if (strchr(pattern, '*') || strchr(pattern, '?')) {
 		ret = pattern_match(myname, pattern);
 		if (!ret)
-			ret = pattern_match(phe->h_name, pattern);
+			ret = pattern_match(ni->ai_canonname, pattern);
 	} else {
-		if (strchr(pattern, '.'))
-			ret = !memcmp(phe->h_name, pattern, strlen(pattern));
-		else
-			ret = !memcmp(myname, pattern, strlen(pattern));
+		/* Match simple nane or FQDN */
+		ret = !memcmp(myname, pattern, strlen(pattern));
+		if (!ret)
+			ret = !memcmp(ni->ai_canonname, pattern, strlen(pattern));
+
+		/* Name could still be a netgroup (Solaris) */
+		if (!ret && ypdomain) {
+			ret = innetgr(pattern, myname, NULL, ypdomain);
+			if (!ret)
+				ret = innetgr(pattern,
+					 ni->ai_canonname, NULL, ypdomain);
+		}
+
 	}
+	freeaddrinfo(ni);
 	return ret;
 }
 
 static int host_match(char *pattern)
 {
-	static char *ypdomain = NULL;
-	static char myname[MAXHOSTNAMELEN + 1] = "\0";
+	unsigned int negate = (*pattern == '-');
+	const char *m_pattern = (negate ? pattern + 1 : pattern);
+	char myname[MAXHOSTNAMELEN + 1] = "\0";
 	struct in_addr tmp;
 	int ret = 0;
 
-	if (!*myname)
-		if (gethostname(myname, MAXHOSTNAMELEN))
-			return 0;
+	if (gethostname(myname, MAXHOSTNAMELEN))
+		return 0;
 
-	if (*pattern == '@') {
-		if (!ypdomain)
-			if (yp_get_default_domain(&ypdomain))
-				return 0;
-		ret = innetgr(pattern + 1, myname, (char *) 0, ypdomain);
-	} else if (inet_aton(pattern, &tmp) || strchr(pattern, '/')) {
-		size_t len = strlen(pattern) + 1;
+	if (yp_get_default_domain(&ypdomain))
+		ypdomain = NULL;
+
+	if (*m_pattern == '@') {
+		if (ypdomain)
+			ret = innetgr(m_pattern + 1, myname, NULL, ypdomain);
+	} else if (inet_aton(m_pattern, &tmp) || strchr(m_pattern, '/')) {
+		size_t len = strlen(m_pattern) + 1;
 		char *addr, *mask;
 
 		addr = alloca(len);
@@ -962,18 +975,21 @@ static int host_match(char *pattern)
 			return 0;
 
 		memset(addr, 0, len);
-		memcpy(addr, pattern, len - 1);
+		memcpy(addr, m_pattern, len - 1);
 		mask = strchr(addr, '/');
 		if (mask) {
 			*mask++ = '\0';
 			ret = masked_match(addr, mask);
 		} else
 			ret = masked_match(addr, "32");
-	} else if (!strcmp(pattern, "gss/krb5")) {
+	} else if (!strcmp(m_pattern, "gss/krb5")) {
 		/* Leave this to the GSS layer */
 		ret = 1;
 	} else
-		ret = string_match(myname, pattern);
+		ret = string_match(myname, m_pattern);
+
+	if (negate)
+		ret = !ret;
 
 	return ret;
 }

autofs-5.0.1-rc2-hosts-check-exports-update.patch:
 CHANGELOG              |    1 +
 modules/lookup_hosts.c |   31 ++++++++++++++++---------------
 2 files changed, 17 insertions(+), 15 deletions(-)

--- NEW FILE autofs-5.0.1-rc2-hosts-check-exports-update.patch ---
diff --git a/CHANGELOG b/CHANGELOG
index 989b7cb..f8583b8 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -46,6 +46,7 @@
 - correct semantics of "-null" map handling.
 - remove ability to use multiple indirect mount entries in master map.
 - expand export access checks to include missing syntax options.
+- make "-hosts" module try to be sensitive to exports list changes.
 
 1/9/2006 autofs-5.0.1 rc2
 -------------------------
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index 08ef278..1a16b96 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -123,7 +123,6 @@ int lookup_mount(struct autofs_point *ap
 	int mapent_len;
 	time_t now = time(NULL);
 	exports exp;
-	int status = NSS_STATUS_UNKNOWN;
 	int ret;
 
 	source = ap->entry->current;
@@ -135,6 +134,7 @@ int lookup_mount(struct autofs_point *ap
 	cache_readlock(mc);
 	me = cache_lookup_distinct(mc, name);
 	if (!me) {
+		cache_unlock(mc);
 		/*
 		 * We haven't read the list of hosts into the
 		 * cache so go straight to the lookup.
@@ -146,12 +146,11 @@ int lookup_mount(struct autofs_point *ap
 			 * so it's NOTFOUND otherwise this could be a
 			 * lookup for a new host.
 			 */
-			if (strchr(name, '/'))
-				status = NSS_STATUS_NOTFOUND;
+			if (*name != '/' && strchr(name, '/'))
+				return NSS_STATUS_NOTFOUND;
 			goto done;
 		}
 
-		pthread_cleanup_push(cache_lock_cleanup, mc);
 		if (*name == '/')
 			msg(MODPREFIX
 			      "can't find path in hosts map %s", name);
@@ -159,8 +158,9 @@ int lookup_mount(struct autofs_point *ap
 			msg(MODPREFIX
 			      "can't find path in hosts map %s/%s",
 			      ap->path, name);
-		pthread_cleanup_pop(0);
-		status = NSS_STATUS_NOTFOUND;
+
+		debug(ap->logopt,
+		      MODPREFIX "lookup failed - update exports list");
 		goto done;
 	}
 	/*
@@ -175,12 +175,8 @@ int lookup_mount(struct autofs_point *ap
 		pthread_cleanup_pop(0);
 		mapent[mapent_len] = '\0';
 	}
-done:
 	cache_unlock(mc);
 
-	if (status != NSS_STATUS_UNKNOWN)
-		return status;
-
 	if (mapent) {
 		master_source_current_wait(ap->entry);
 		ap->entry->current = source;
@@ -190,14 +186,14 @@ done:
 		ret = ctxt->parse->parse_mount(ap, name, name_len,
 				 mapent, ctxt->parse->context);
 
-		if (ret)
-			return NSS_STATUS_TRYAGAIN;
+		if (!ret)
+			return NSS_STATUS_SUCCESS;
 
-		return NSS_STATUS_SUCCESS;
+		debug(ap->logopt, MODPREFIX "mount failed - update exports list");
 	}
-
+done:
 	/*
-	 * Otherwise we need to get the exports list and add then
+	 * Otherwise we need to get the exports list and add update
 	 * the cache.
 	 */
 	debug(ap->logopt, MODPREFIX "fetchng export list for %s", name);
@@ -207,6 +203,7 @@ done:
 	/* Check exports for obvious ones we don't have access to */
 	exp = rpc_exports_prune(exp);
 
+	mapent = NULL;
 	while (exp) {
 		if (mapent) {
 			int len = strlen(mapent) + 1;
@@ -256,9 +253,13 @@ done:
 	cache_update(mc, name, mapent, now);
 	cache_unlock(mc);
 
+	debug(LOGOPT_ANY, "source wait");
+
 	master_source_current_wait(ap->entry);
 	ap->entry->current = source;
 
+	debug(LOGOPT_ANY, "do parse_mount");
+
 	ret = ctxt->parse->parse_mount(ap, name, name_len,
 				 mapent, ctxt->parse->context);
 	free(mapent);


Index: autofs.spec
===================================================================
RCS file: /cvs/dist/rpms/autofs/devel/autofs.spec,v
retrieving revision 1.166
retrieving revision 1.167
diff -u -r1.166 -r1.167
--- autofs.spec	7 Dec 2006 04:19:12 -0000	1.166
+++ autofs.spec	10 Dec 2006 07:56:21 -0000	1.167
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems.
 Name: autofs
 %define version 5.0.1
-%define release 0.rc2.32
+%define release 0.rc2.33
 Version: %{version}
 Release: %{release}
 Epoch: 1
@@ -53,6 +53,8 @@
 Patch39: autofs-5.0.1-rc2-nfs4-get-port.patch
 Patch40: autofs-5.0.1-rc2-fix-null-map-semantics.patch
 Patch41: autofs-5.0.1-rc2-disallow-multiple-indirect-mounts.patch
+Patch42: autofs-5.0.1-rc2-add-export-syntax-checks.patch
+Patch43: autofs-5.0.1-rc2-hosts-check-exports-update.patch
 Buildroot: /var/tmp/autofs-tmp
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
 Prereq: chkconfig
@@ -134,6 +136,8 @@
 %patch39 -p1
 %patch40 -p1
 %patch41 -p1
+%patch42 -p1
+%patch43 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -190,6 +194,10 @@
 %{_libdir}/autofs/*
 
 %changelog
+* Sun Dec 10 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.33
+- expand export access checks to include missing syntax options.
+- make "-hosts" module try to be sensitive to exports list changes.
+
 * Thu Dec 7 2006 Ian Kent <ikent at redhat.com> - 5.0.1-0.rc2.32
 - remove ability to use multiple indirect mount entries in master
   map (bz 218616).




More information about the fedora-cvs-commits mailing list