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

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