Blame SOURCES/autofs-5.1.4-fix-directory-create-permission.patch

135b98
autofs-5.1.4 - fix directory create permission
135b98
135b98
From: Ian Kent <raven@themaw.net>
135b98
135b98
autofs mount point directory creation is done using a permission of
135b98
0555.
135b98
135b98
But it is necessary to create directories within autofs mount points
135b98
for some map entry types so write access should be set for the owner
135b98
on mount point directories.
135b98
135b98
Signed-off-by: Ian Kent <raven@themaw.net>
135b98
---
135b98
 CHANGELOG               |    1 +
135b98
 daemon/automount.c      |    2 ++
135b98
 daemon/direct.c         |    4 ++--
135b98
 daemon/indirect.c       |    2 +-
135b98
 daemon/lookup.c         |    2 +-
135b98
 include/automount.h     |    1 +
135b98
 modules/mount_bind.c    |    6 +++---
135b98
 modules/mount_changer.c |    2 +-
135b98
 modules/mount_ext2.c    |    2 +-
135b98
 modules/mount_generic.c |    2 +-
135b98
 modules/mount_nfs.c     |    2 +-
135b98
 modules/parse_amd.c     |    2 +-
135b98
 12 files changed, 16 insertions(+), 12 deletions(-)
135b98
135b98
diff --git a/CHANGELOG b/CHANGELOG
135b98
index d07d88ce..4faab510 100644
135b98
--- a/CHANGELOG
135b98
+++ b/CHANGELOG
135b98
@@ -1,5 +1,6 @@
135b98
 xx/xx/2018 autofs-5.1.5
135b98
 - fix flag file permission.
135b98
+- fix directory create permission.
135b98
 
135b98
 19/12/2017 autofs-5.1.4
135b98
 - fix spec file url.
135b98
diff --git a/daemon/automount.c b/daemon/automount.c
135b98
index 5c739617..dcdc19fb 100644
135b98
--- a/daemon/automount.c
135b98
+++ b/daemon/automount.c
135b98
@@ -51,6 +51,8 @@ const char *libdir = AUTOFS_LIB_DIR;	/* Location of library modules */
135b98
 const char *mapdir = AUTOFS_MAP_DIR;	/* Location of mount maps */
135b98
 const char *confdir = AUTOFS_CONF_DIR;	/* Location of autofs config file */
135b98
 
135b98
+unsigned int mp_mode = 0755;
135b98
+
135b98
 unsigned int nfs_mount_uses_string_options = 0;
135b98
 static struct nfs_mount_vers vers, check = {1, 1, 1};
135b98
 
135b98
diff --git a/daemon/direct.c b/daemon/direct.c
135b98
index 9a134351..3fdecdb8 100644
135b98
--- a/daemon/direct.c
135b98
+++ b/daemon/direct.c
135b98
@@ -424,7 +424,7 @@ int do_mount_autofs_direct(struct autofs_point *ap,
135b98
 	}
135b98
 
135b98
 	/* In case the directory doesn't exist, try to mkdir it */
135b98
-	if (mkdir_path(me->key, 0555) < 0) {
135b98
+	if (mkdir_path(me->key, mp_mode) < 0) {
135b98
 		if (errno != EEXIST && errno != EROFS) {
135b98
 			crit(ap->logopt,
135b98
 			     "failed to create mount directory %s", me->key);
135b98
@@ -739,7 +739,7 @@ int mount_autofs_offset(struct autofs_point *ap, struct mapent *me, const char *
135b98
 	strcat(mountpoint, offset);
135b98
 
135b98
 	/* In case the directory doesn't exist, try to mkdir it */
135b98
-	if (mkdir_path(mountpoint, 0555) < 0) {
135b98
+	if (mkdir_path(mountpoint, mp_mode) < 0) {
135b98
 		if (errno == EEXIST) {
135b98
 			/*
135b98
 			 * If the mount point directory is a real mount
135b98
diff --git a/daemon/indirect.c b/daemon/indirect.c
135b98
index ffb11b8c..03c081ed 100644
135b98
--- a/daemon/indirect.c
135b98
+++ b/daemon/indirect.c
135b98
@@ -133,7 +133,7 @@ static int do_mount_autofs_indirect(struct autofs_point *ap, const char *root)
135b98
 	}
135b98
 
135b98
 	/* In case the directory doesn't exist, try to mkdir it */
135b98
-	if (mkdir_path(root, 0555) < 0) {
135b98
+	if (mkdir_path(root, mp_mode) < 0) {
135b98
 		if (errno != EEXIST && errno != EROFS) {
135b98
 			crit(ap->logopt,
135b98
 			     "failed to create autofs directory %s",
135b98
diff --git a/daemon/lookup.c b/daemon/lookup.c
135b98
index cb67e7d9..6a722b3b 100644
135b98
--- a/daemon/lookup.c
135b98
+++ b/daemon/lookup.c
135b98
@@ -802,7 +802,7 @@ int lookup_ghost(struct autofs_point *ap, const char *root)
135b98
 				goto next;
135b98
 			}
135b98
 
135b98
-			ret = mkdir_path(fullpath, 0555);
135b98
+			ret = mkdir_path(fullpath, mp_mode);
135b98
 			if (ret < 0 && errno != EEXIST) {
135b98
 				char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 				warn(ap->logopt,
135b98
diff --git a/include/automount.h b/include/automount.h
135b98
index 2e2c2b02..e5c19d23 100644
135b98
--- a/include/automount.h
135b98
+++ b/include/automount.h
135b98
@@ -269,6 +269,7 @@ void reset_signals(void);
135b98
 int do_mount(struct autofs_point *ap, const char *root, const char *name,
135b98
 	     int name_len, const char *what, const char *fstype,
135b98
 	     const char *options);
135b98
+extern unsigned int mp_mode;
135b98
 int mkdir_path(const char *path, mode_t mode);
135b98
 int rmdir_path(struct autofs_point *ap, const char *path, dev_t dev);
135b98
 
135b98
diff --git a/modules/mount_bind.c b/modules/mount_bind.c
135b98
index 4864ea51..5effa880 100644
135b98
--- a/modules/mount_bind.c
135b98
+++ b/modules/mount_bind.c
135b98
@@ -151,7 +151,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 
135b98
 		debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
135b98
 
135b98
-		status = mkdir_path(fullpath, 0555);
135b98
+		status = mkdir_path(fullpath, mp_mode);
135b98
 		if (status && errno != EEXIST) {
135b98
 			char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 			error(ap->logopt,
135b98
@@ -203,7 +203,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 		} else {
135b98
 			debug(ap->logopt,
135b98
 			      MODPREFIX "calling mkdir_path %s", basepath);
135b98
-			if (mkdir_path(basepath, 0555) && errno != EEXIST) {
135b98
+			if (mkdir_path(basepath, mp_mode) && errno != EEXIST) {
135b98
 				char *estr;
135b98
 				estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 				error(ap->logopt,
135b98
@@ -219,7 +219,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 			      "failed to create symlink %s -> %s",
135b98
 			      fullpath, what);
135b98
 			if ((ap->flags & MOUNT_FLAG_GHOST) && !status) {
135b98
-				if (mkdir_path(fullpath, 0555) && errno != EEXIST) {
135b98
+				if (mkdir_path(fullpath, mp_mode) && errno != EEXIST) {
135b98
 					char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 					error(ap->logopt,
135b98
 					      MODPREFIX "mkdir_path %s failed: %s",
135b98
diff --git a/modules/mount_changer.c b/modules/mount_changer.c
135b98
index 798f23b2..7d44a720 100644
135b98
--- a/modules/mount_changer.c
135b98
+++ b/modules/mount_changer.c
135b98
@@ -87,7 +87,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 
135b98
 	debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
135b98
 
135b98
-	status = mkdir_path(fullpath, 0555);
135b98
+	status = mkdir_path(fullpath, mp_mode);
135b98
 	if (status && errno != EEXIST) {
135b98
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 		error(ap->logopt,
135b98
diff --git a/modules/mount_ext2.c b/modules/mount_ext2.c
135b98
index 90fc0876..3bbea95a 100644
135b98
--- a/modules/mount_ext2.c
135b98
+++ b/modules/mount_ext2.c
135b98
@@ -69,7 +69,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 
135b98
 	debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
135b98
 
135b98
-	status = mkdir_path(fullpath, 0555);
135b98
+	status = mkdir_path(fullpath, mp_mode);
135b98
 	if (status && errno != EEXIST) {
135b98
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 		error(ap->logopt,
135b98
diff --git a/modules/mount_generic.c b/modules/mount_generic.c
135b98
index ae637875..b1a3adbf 100644
135b98
--- a/modules/mount_generic.c
135b98
+++ b/modules/mount_generic.c
135b98
@@ -68,7 +68,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name, int
135b98
 
135b98
 	debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
135b98
 
135b98
-	status = mkdir_path(fullpath, 0555);
135b98
+	status = mkdir_path(fullpath, mp_mode);
135b98
 	if (status && errno != EEXIST) {
135b98
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 		error(ap->logopt,
135b98
diff --git a/modules/mount_nfs.c b/modules/mount_nfs.c
135b98
index bf712a93..77166544 100644
135b98
--- a/modules/mount_nfs.c
135b98
+++ b/modules/mount_nfs.c
135b98
@@ -277,7 +277,7 @@ dont_probe:
135b98
 
135b98
 	debug(ap->logopt, MODPREFIX "calling mkdir_path %s", fullpath);
135b98
 
135b98
-	status = mkdir_path(fullpath, 0555);
135b98
+	status = mkdir_path(fullpath, mp_mode);
135b98
 	if (status && errno != EEXIST) {
135b98
 		char *estr = strerror_r(errno, buf, MAX_ERR_BUF);
135b98
 		error(ap->logopt,
135b98
diff --git a/modules/parse_amd.c b/modules/parse_amd.c
135b98
index b40c1ad1..c4b3ef0b 100644
135b98
--- a/modules/parse_amd.c
135b98
+++ b/modules/parse_amd.c
135b98
@@ -1288,7 +1288,7 @@ static int do_program_mount(struct autofs_point *ap,
135b98
 		rv = 0;
135b98
 		ext_mount_add(&entry->ext_mount, entry->fs, 1);
135b98
 	} else {
135b98
-		rv = mkdir_path(entry->fs, 0555);
135b98
+		rv = mkdir_path(entry->fs, mp_mode);
135b98
 		if (rv && errno != EEXIST) {
135b98
 			char buf[MAX_ERR_BUF];
135b98
 			char *estr;