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

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