rpms/autofs/F-7 autofs-5.0.1-fix-offset-dir-create.patch, NONE, 1.1 autofs-5.0.2-quote-exports.patch, NONE, 1.1 autofs.spec, 1.204, 1.205

Ian Kent (iankent) fedora-extras-commits at redhat.com
Mon Jul 16 06:16:37 UTC 2007


Author: iankent

Update of /cvs/pkgs/rpms/autofs/F-7
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv31571

Modified Files:
	autofs.spec 
Added Files:
	autofs-5.0.1-fix-offset-dir-create.patch 
	autofs-5.0.2-quote-exports.patch 
Log Message:
* Mon Jul 16 2007 Ian Kent <ikent at redhat.com> - 5.0.1-0.14
- fix mount point directory creation for bind mounts.
- add quoting for exports gathered by hosts map.


autofs-5.0.1-fix-offset-dir-create.patch:

--- NEW FILE autofs-5.0.1-fix-offset-dir-create.patch ---
--- autofs-5.0.1/include/automount.h.fix-offset-dir-create	2007-07-16 14:05:19.000000000 +0800
+++ autofs-5.0.1/include/automount.h	2007-07-16 14:05:41.000000000 +0800
@@ -469,7 +469,7 @@ void *expire_proc_direct(void *);
 int expire_offsets_direct(struct autofs_point *ap, struct mapent *me, int now);
 int mount_autofs_indirect(struct autofs_point *ap);
 int mount_autofs_direct(struct autofs_point *ap);
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs);
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me);
 void submount_signal_parent(struct autofs_point *ap, unsigned int success);
 int umount_autofs(struct autofs_point *ap, int force);
 int umount_autofs_indirect(struct autofs_point *ap);
--- autofs-5.0.1/daemon/automount.c.fix-offset-dir-create	2007-07-16 14:05:19.000000000 +0800
+++ autofs-5.0.1/daemon/automount.c	2007-07-16 14:05:41.000000000 +0800
@@ -104,11 +104,14 @@ static int do_mkdir(const char *parent, 
 		status = statfs(parent, &fs);
 	if ((status != -1 && fs.f_type == AUTOFS_SUPER_MAGIC) ||
 	    contained_in_local_fs(path)) {
-		if (mkdir(path, mode) == -1)
+		if (mkdir(path, mode) == -1) {
+			errno = EACCES;
 			return 0;
+		}
 		return 1;
 	}
 
+	errno = EACCES;
 	return 0;
 }
 
--- autofs-5.0.1/daemon/direct.c.fix-offset-dir-create	2007-07-16 14:05:19.000000000 +0800
+++ autofs-5.0.1/daemon/direct.c	2007-07-16 14:05:41.000000000 +0800
@@ -604,6 +604,14 @@ int umount_autofs_offset(struct autofs_p
 		}
 		ioctlfd = me->ioctlfd;
 	} else {
+		/* offset isn't mounted, return success and try to recover */
+		if (!is_mounted(_PROC_MOUNTS, me->key, MNTS_AUTOFS)) {
+			debug(ap->logopt,
+			      "offset %s unexpectedly not mounted",
+			      me->key);
+			return 0;
+		}
+
 		ioctlfd = open(me->key, O_RDONLY);
 		if (ioctlfd != -1) {
 			if ((cl_flags = fcntl(ioctlfd, F_GETFD, 0)) != -1) {
@@ -689,11 +697,19 @@ force_umount:
 	} else
 		msg("umounted offset mount %s", me->key);
 
+	if (!rv && me->dir_created) {
+		if  (rmdir(me->key) == -1) {
+			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
+			warn(ap->logopt, "failed to remove dir %s: %s",
+			     me->key, estr);
+		}
+	}
 	return rv;
 }
 
-int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, int is_autofs_fs)
+int mount_autofs_offset(struct autofs_point *ap, struct mapent *me)
 {
+	char buf[MAX_ERR_BUF];
 	struct mnt_params *mp;
 	time_t timeout = ap->exp_timeout;
 	struct stat st;
@@ -740,36 +756,38 @@ int mount_autofs_offset(struct autofs_po
 			return 0;
 	}
 
-	if (is_autofs_fs) {
-		/* In case the directory doesn't exist, try to mkdir it */
-		if (mkdir_path(me->key, 0555) < 0) {
-			if (errno != EEXIST) {
-				crit(ap->logopt,
-				     "failed to create mount directory %s %d",
-				     me->key, errno);
-				return -1;
-			}
+	/* In case the directory doesn't exist, try to mkdir it */
+	if (mkdir_path(me->key, 0555) < 0) {
+		if (errno == EEXIST) {
 			/* 
 			 * If we recieve an error, and it's EEXIST
 			 * we know the directory was not created.
 			 */
 			me->dir_created = 0;
+		} else if (errno == EACCES) {
+			/*
+			 * We require the mount point directory to exist when
+			 * installing multi-mount triggers into a host
+			 * filesystem.
+			 *
+			 * If it doesn't exist it is not a valid part of the
+			 * mount heirachy.
+			 */
+			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
+			debug(ap->logopt,
+			     "can't create mount directory: %s, %s",
+			     me->key, estr);
+			return -1;
 		} else {
-			/* No errors so the directory was successfully created */
-			me->dir_created = 1;
+			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
+			crit(ap->logopt,
+			     "failed to create mount directory: %s, %s",
+			     me->key, estr);
+			return -1;
 		}
 	} else {
-		me->dir_created = 0;
-
-		/*
-		 * We require the mount point directory to exist when
-		 * installing multi-mount triggers into a host filesystem.
-		 *
-		 * If it doesn't exist it is not a valid part of the
-		 * mount heirachy so we silently succeed here.
-		 */
-		if (stat(me->key, &st) == -1 && errno == ENOENT)
-			return 0;
+		/* No errors so the directory was successfully created */
+		me->dir_created = 1;
 	}
 
 	debug(ap->logopt,
@@ -832,10 +850,8 @@ out_close:
 out_umount:
 	umount(me->key);
 out_err:
-	if (is_autofs_fs) {
-		if (stat(me->key, &st) == 0 && me->dir_created)
-			 rmdir_path(ap, me->key, st.st_dev);
-	}
+	if (stat(me->key, &st) == 0 && me->dir_created)
+		 rmdir_path(ap, me->key, st.st_dev);
 
 	return -1;
 }
--- autofs-5.0.1/lib/parse_subs.c.fix-offset-dir-create	2007-07-16 14:05:19.000000000 +0800
+++ autofs-5.0.1/lib/parse_subs.c	2007-07-16 14:06:41.000000000 +0800
@@ -388,10 +388,8 @@ int mount_multi_triggers(struct autofs_p
 	struct mapent *oe;
 	struct list_head *pos = NULL;
 	unsigned int fs_path_len;
-	struct statfs fs;
-	struct stat st;
-	unsigned int mounted, is_autofs_fs;
-	int ret, start;
+	unsigned int mounted;
+	int start;
 
 	fs_path_len = strlen(root) + strlen(base);
 	if (fs_path_len > PATH_MAX)
@@ -399,15 +397,6 @@ int mount_multi_triggers(struct autofs_p
 
 	strcpy(path, root);
 	strcat(path, base);
-	ret = statfs(path, &fs);
-	if (ret == -1) {
-		/* There's no mount yet - it must be autofs */
-		if (errno == ENOENT)
-			is_autofs_fs = 1;
-		else
-			return -1;
-	} else
-		is_autofs_fs = fs.f_type == AUTOFS_SUPER_MAGIC ? 1 : 0;
 
 	mounted = 0;
 	start = strlen(root);
@@ -424,20 +413,9 @@ int mount_multi_triggers(struct autofs_p
 		if (!oe)
 			goto cont;
 
-		/*
-		 * If the host filesystem is not an autofs fs
-		 * we require the mount point directory exist
-		 * and that permissions are OK.
-		 */
-		if (!is_autofs_fs) {
-			ret = stat(oe->key, &st);
-			if (ret == -1)
-				goto cont;
-		}
-
 		debug(ap->logopt, "mount offset %s", oe->key);
 
-		if (mount_autofs_offset(ap, oe, is_autofs_fs) < 0)
+		if (mount_autofs_offset(ap, oe) < 0)
 			warn(ap->logopt, "failed to mount offset");
 		else
 			mounted++;

autofs-5.0.2-quote-exports.patch:

--- NEW FILE autofs-5.0.2-quote-exports.patch ---
diff --git a/modules/lookup_hosts.c b/modules/lookup_hosts.c
index a9a4c75..1f8fa15 100644
--- a/modules/lookup_hosts.c
+++ b/modules/lookup_hosts.c
@@ -215,7 +215,7 @@ done:
 		if (mapent) {
 			int len = strlen(mapent) + 1;
 
-			len += strlen(name) + 2*strlen(exp->ex_dir) + 3;
+			len += strlen(name) + 2*(strlen(exp->ex_dir) + 2) + 3;
 			mapent = realloc(mapent, len);
 			if (!mapent) {
 				char *estr;
@@ -224,10 +224,11 @@ done:
 				rpc_exports_free(exp);
 				return NSS_STATUS_UNAVAIL;
 			}
-			strcat(mapent, " ");
+			strcat(mapent, " \"");
 			strcat(mapent, exp->ex_dir);
+			strcat(mapent, "\"");
 		} else {
-			int len = 2*strlen(exp->ex_dir) + strlen(name) + 3;
+			int len = 2*(strlen(exp->ex_dir) + 2) + strlen(name) + 3;
 
 			mapent = malloc(len);
 			if (!mapent) {
@@ -237,12 +238,15 @@ done:
 				rpc_exports_free(exp);
 				return NSS_STATUS_UNAVAIL;
 			}
-			strcpy(mapent, exp->ex_dir);
+			strcpy(mapent, "\"");
+			strcat(mapent, exp->ex_dir);
+			strcat(mapent, "\"");
 		}
-		strcat(mapent, " ");
+		strcat(mapent, " \"");
 		strcat(mapent, name);
 		strcat(mapent, ":");
 		strcat(mapent, exp->ex_dir);
+		strcat(mapent, "\"");
 
 		exp = exp->ex_next;
 	}
@@ -260,13 +264,9 @@ done:
 	cache_update(mc, source, 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/pkgs/rpms/autofs/F-7/autofs.spec,v
retrieving revision 1.204
retrieving revision 1.205
diff -u -r1.204 -r1.205
--- autofs.spec	7 Jun 2007 07:47:54 -0000	1.204
+++ autofs.spec	16 Jul 2007 06:16:04 -0000	1.205
@@ -4,7 +4,7 @@
 Summary: A tool for automatically mounting and unmounting filesystems
 Name: autofs
 Version: 5.0.1
-Release: 13
+Release: 14
 Epoch: 1
 License: GPL
 Group: System Environment/Daemons
@@ -30,6 +30,8 @@
 Patch18: autofs-5.0.1-allow-dot-in-master-macro.patch
 Patch19: autofs-5.0.1-correct-logic-test-wild-lookup.patch
 Patch20: autofs-5.0.1-alarm-deadlock.patch
+Patch21: autofs-5.0.1-fix-offset-dir-create.patch
+Patch22: autofs-5.0.2-quote-exports.patch
 Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
 BuildRequires: autoconf, hesiod-devel, openldap-devel, bison, flex, libxml2-devel, cyrus-sasl-devel, openssl-devel
 Conflicts: kernel < 2.6.17
@@ -91,6 +93,8 @@
 %patch18 -p1
 %patch19 -p1
 %patch20 -p1
+%patch21 -p1
+%patch22 -p1
 
 %build
 #CFLAGS="$RPM_OPT_FLAGS" ./configure --prefix=/usr --libdir=%{_libdir}
@@ -143,6 +147,10 @@
 %{_libdir}/autofs/
 
 %changelog
+* Mon Jul 16 2007 Ian Kent <ikent at redhat.com> - 5.0.1-0.14
+- fix mount point directory creation for bind mounts.
+- add quoting for exports gathered by hosts map.
+
 * Thu Jun 7 2007 Ian Kent <ikent at redhat.com> - 5.0.1-0.13
 - fix deadlock in alarm manager module.
 




More information about the scm-commits mailing list