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