aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2015-09-03 18:12:27 -0500
committerPeter Seebach <peter.seebach@windriver.com>2015-09-03 18:12:27 -0500
commit0b3080ba90d58249c853f1ddd1a24c54f383a31f (patch)
tree580a737a60ddef6644936c9fcd7327a6bc3638df
parenta49c56fbf1fdff5a3050d30b47851c52b4e35fc2 (diff)
downloadpseudo-0b3080ba90d58249c853f1ddd1a24c54f383a31f.tar.gz
pseudo-0b3080ba90d58249c853f1ddd1a24c54f383a31f.tar.bz2
pseudo-0b3080ba90d58249c853f1ddd1a24c54f383a31f.zip
Finish (I hope) working around 0700 umasks.
There's some changes to allow things to work even if umask is 0700; originally this was just regarded as a broken state, but it became necessary to fix it in order for the xattrdb code to work, only the fix could result in files having a raw filesystem mode that lacked execute bits it should have had. Signed-off-by: Peter Seebach <peter.seebach@windriver.com>
-rw-r--r--ChangeLog.txt6
-rw-r--r--ports/darwin/guts/open.c2
-rw-r--r--ports/linux/guts/__xmknodat.c1
-rw-r--r--ports/linux/guts/openat.c2
-rw-r--r--ports/unix/guts/mkdirat.c5
-rw-r--r--ports/unix/guts/mkfifoat.c2
-rw-r--r--ports/unix/guts/mknodat.c1
-rw-r--r--pseudo_client.h3
8 files changed, 17 insertions, 5 deletions
diff --git a/ChangeLog.txt b/ChangeLog.txt
index acc4ce7..4f08e17 100644
--- a/ChangeLog.txt
+++ b/ChangeLog.txt
@@ -1,3 +1,9 @@
+2015-09-03:
+ * (seebs) Use original mode, not 0600, for the chmods used to
+ ensure that an 0700 umask didn't prevent writing.
+ * (seebs) remove the comment saying that 0700 umasks were expected
+ to break things.
+
2015-09-02:
* (seebs) call this 1.7.1, since that seems to be all the bugs
I can immediately find.
diff --git a/ports/darwin/guts/open.c b/ports/darwin/guts/open.c
index 0979c54..f34b0d3 100644
--- a/ports/darwin/guts/open.c
+++ b/ports/darwin/guts/open.c
@@ -41,7 +41,7 @@
if (stat_rc != -1) {
buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
if (!existed) {
- real_fchmod(rc, PSEUDO_FS_MODE(0600, 0));
+ real_fchmod(rc, PSEUDO_FS_MODE(mode, 0));
pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf);
}
pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, -1, path, &buf);
diff --git a/ports/linux/guts/__xmknodat.c b/ports/linux/guts/__xmknodat.c
index 0888b8a..296918a 100644
--- a/ports/linux/guts/__xmknodat.c
+++ b/ports/linux/guts/__xmknodat.c
@@ -43,6 +43,7 @@
if (rc == -1) {
return -1;
}
+ real_fchmod(rc, PSEUDO_FS_MODE(mode, 0));
real___fxstat64(_STAT_VER, rc, &buf);
/* mknod does not really open the file. We don't have
* to use wrap_close because we've never exposed this file
diff --git a/ports/linux/guts/openat.c b/ports/linux/guts/openat.c
index 338bd45..eb7c0b5 100644
--- a/ports/linux/guts/openat.c
+++ b/ports/linux/guts/openat.c
@@ -75,7 +75,7 @@
if (stat_rc != -1) {
buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
if (!existed) {
- real_fchmod(rc, PSEUDO_FS_MODE(0600, 0));
+ real_fchmod(rc, PSEUDO_FS_MODE(mode, 0));
pseudo_client_op(OP_CREAT, 0, -1, dirfd, path, &buf);
}
pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, dirfd, path, &buf);
diff --git a/ports/unix/guts/mkdirat.c b/ports/unix/guts/mkdirat.c
index 5f80b50..668d6ac 100644
--- a/ports/unix/guts/mkdirat.c
+++ b/ports/unix/guts/mkdirat.c
@@ -30,6 +30,11 @@
if (stat_rc != -1) {
buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf);
+#ifdef PSEUDO_NO_REAL_AT_FUNCTIONS
+ real_fchmod(path, PSEUDO_FS_MODE(mode, 1));
+#else
+ real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, 1), AT_SYMLINK_NOFOLLOW);
+#endif
} else {
pseudo_debug(PDBGF_OP, "mkdir of %s succeeded, but stat failed: %s\n",
path, strerror(errno));
diff --git a/ports/unix/guts/mkfifoat.c b/ports/unix/guts/mkfifoat.c
index 4101a72..4546ba3 100644
--- a/ports/unix/guts/mkfifoat.c
+++ b/ports/unix/guts/mkfifoat.c
@@ -34,12 +34,14 @@
return -1;
}
rc = base_stat(path, &buf);
+ real_chmod(path, PSEUDO_FS_MODE(mode, 0));
#else
rc = real_mkfifoat(dirfd, path, PSEUDO_FS_MODE(mode, 0));
if (rc == -1) {
return -1;
}
rc = base_fstatat(dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
+ real_fchmodat(dirfd, path, PSEUDO_FS_MODE(mode, 0), AT_SYMLINK_NOFOLLOW);
#endif
/* if the stat failed, we are going to give up and nuke
* any file we may have created, and hope for the best.
diff --git a/ports/unix/guts/mknodat.c b/ports/unix/guts/mknodat.c
index 5d8d47c..76e4dd9 100644
--- a/ports/unix/guts/mknodat.c
+++ b/ports/unix/guts/mknodat.c
@@ -37,6 +37,7 @@
if (rc == -1) {
return -1;
}
+ real_fchmod(rc, PSEUDO_FS_MODE(mode, 0));
base_fstat(rc, &buf);
/* mknod does not really open the file. We don't have
* to use wrap_close because we've never exposed this file
diff --git a/pseudo_client.h b/pseudo_client.h
index 9fcb2f5..e732bae 100644
--- a/pseudo_client.h
+++ b/pseudo_client.h
@@ -83,9 +83,6 @@ extern int pseudo_umask;
* When doing anything which actually writes to the filesystem, we add in
* the user read/write/execute bits. When storing to the database, though,
* we mask out any such bits which weren't in the original mode.
- *
- * None of this will behave very sensibly if umask has 0700 bits in it;
- * this is a known limitation.
*/
#define PSEUDO_FS_MODE(mode, isdir) (((mode) | S_IRUSR | S_IWUSR | ((isdir) ? S_IXUSR : 0)) & ~(S_IWGRP | S_IWOTH))
#define PSEUDO_DB_MODE(fs_mode, user_mode) (((fs_mode) & ~0722) | ((user_mode & 0722)))