Blob Blame History Raw
autofs-5.0.7 - fix bad mkdir permission on create

From: Ian Kent <raven@themaw.net>

Reported by Gordon Lack (gordon[dot]m[dot]lack[at]gsk[dot]com).

If the automount daemon needs to create a directory (hierarchy) for an
automount and it is started up with a umask of 027 (or similar) then it
creates unusable directories (permission == 550).
---
 CHANGELOG          |    1 +
 daemon/automount.c |    5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

--- autofs-5.0.7.orig/CHANGELOG
+++ autofs-5.0.7/CHANGELOG
@@ -88,6 +88,7 @@
 - check for bind onto self in mount_bind.c.
 - fix symlink expire.
 - fix master map type check.
+- fix bad mkdir permission on create.
 
 25/07/2012 autofs-5.0.7
 =======================
--- autofs-5.0.7.orig/daemon/automount.c
+++ autofs-5.0.7/daemon/automount.c
@@ -122,7 +122,10 @@ static int do_mkdir(const char *parent,
 		status = statfs(parent, &fs);
 	if ((status != -1 && fs.f_type == (__SWORD_TYPE) AUTOFS_SUPER_MAGIC) ||
 	    contained_in_local_fs(path)) {
-		if (mkdir(path, mode) == -1) {
+		mode_t mask = umask(0022);
+		int ret = mkdir(path, mode);
+		(void) umask(mask);
+		if (ret == -1) {
 			errno = EACCES;
 			return 0;
 		}