aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
authorPeter Seebach <seebs@eee12.(none)>2010-03-26 14:48:36 -0500
committerPeter Seebach <seebs@eee12.(none)>2010-03-26 14:50:04 -0500
commit80259da816b82c5bdfbf9515935823a157f5d0e9 (patch)
treef5120633e788d0d36ea2133d436d52c563d08d98 /guts
parentcaeebc0dd6ff538629687b55a5ce72554a7c3f34 (diff)
downloadpseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.tar.gz
pseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.tar.bz2
pseudo-80259da816b82c5bdfbf9515935823a157f5d0e9.zip
Track file open flags
This patch adds support for checking whether a file was opened for reading, writing, or both, as well as tracking append flags. It is not very well tested. This is preparation for improved host contamination checking.
Diffstat (limited to 'guts')
-rw-r--r--guts/__fxstat64.c2
-rw-r--r--guts/__fxstatat64.c2
-rw-r--r--guts/__xmknodat.c4
-rw-r--r--guts/chdir.c2
-rw-r--r--guts/chroot.c2
-rw-r--r--guts/close.c2
-rw-r--r--guts/dup.c2
-rw-r--r--guts/dup2.c4
-rw-r--r--guts/fchdir.c2
-rw-r--r--guts/fchmod.c4
-rw-r--r--guts/fchmodat.c6
-rw-r--r--guts/fchown.c6
-rw-r--r--guts/fchownat.c6
-rw-r--r--guts/fclose.c2
-rw-r--r--guts/fcntl.c2
-rw-r--r--guts/fopen.c6
-rw-r--r--guts/fopen64.c6
-rw-r--r--guts/freopen.c6
-rw-r--r--guts/freopen64.c6
-rw-r--r--guts/link.c4
-rw-r--r--guts/mkdirat.c2
-rw-r--r--guts/mkdtemp.c2
-rw-r--r--guts/mkstemp.c6
-rw-r--r--guts/openat.c6
-rw-r--r--guts/rename.c8
-rw-r--r--guts/rmdir.c2
-rw-r--r--guts/symlinkat.c2
-rw-r--r--guts/unlinkat.c2
28 files changed, 53 insertions, 53 deletions
diff --git a/guts/__fxstat64.c b/guts/__fxstat64.c
index 2e7919c..59f8a59 100644
--- a/guts/__fxstat64.c
+++ b/guts/__fxstat64.c
@@ -16,7 +16,7 @@
errno = save_errno;
return rc;
}
- msg = pseudo_client_op(OP_FSTAT, fd, -1, 0, buf);
+ msg = pseudo_client_op(OP_FSTAT, 0, fd, -1, 0, buf);
if (msg) {
if (msg->result == RESULT_SUCCEED)
pseudo_stat_msg(buf, msg);
diff --git a/guts/__fxstatat64.c b/guts/__fxstatat64.c
index b8054f2..349b48e 100644
--- a/guts/__fxstatat64.c
+++ b/guts/__fxstatat64.c
@@ -56,7 +56,7 @@
* note that symlink canonicalizing is now automatic, so we
* don't need to check for a symlink on this end
*/
- msg = pseudo_client_op(OP_STAT, -1, dirfd, path, buf);
+ msg = pseudo_client_op(OP_STAT, 0, -1, dirfd, path, buf);
if (msg) {
pseudo_stat_msg(buf, msg);
if (save_mode) {
diff --git a/guts/__xmknodat.c b/guts/__xmknodat.c
index 6bd0761..cca6a96 100644
--- a/guts/__xmknodat.c
+++ b/guts/__xmknodat.c
@@ -44,12 +44,12 @@
buf.st_mode = (PSEUDO_DB_MODE(buf.st_mode, mode) & 07777) |
(mode & ~07777);
buf.st_rdev = *dev;
- msg = pseudo_client_op(OP_MKNOD, -1, dirfd, path, &buf);
+ msg = pseudo_client_op(OP_MKNOD, 0, -1, dirfd, path, &buf);
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
+ errno = EPERM;
rc = -1;
} else {
rc = 0;
diff --git a/guts/chdir.c b/guts/chdir.c
index ca48738..2cc9019 100644
--- a/guts/chdir.c
+++ b/guts/chdir.c
@@ -13,7 +13,7 @@
rc = real_chdir(path);
if (rc != -1) {
- pseudo_client_op(OP_CHDIR, -1, -1, path, 0);
+ pseudo_client_op(OP_CHDIR, 0, -1, -1, path, 0);
}
/* return rc;
diff --git a/guts/chroot.c b/guts/chroot.c
index 5f68482..14f5043 100644
--- a/guts/chroot.c
+++ b/guts/chroot.c
@@ -4,7 +4,7 @@
* int rc = -1;
*/
pseudo_debug(2, "chroot: %s\n", path);
- if (!pseudo_client_op(OP_CHROOT, -1, -1, path, 0)) {
+ if (!pseudo_client_op(OP_CHROOT, 0, -1, -1, path, 0)) {
pseudo_debug(1, "chroot failed: %s\n", strerror(errno));
rc = -1;
} else {
diff --git a/guts/close.c b/guts/close.c
index 34b279e..8edbee9 100644
--- a/guts/close.c
+++ b/guts/close.c
@@ -6,7 +6,7 @@
/* this cleans up an internal table, and shouldn't even
* make it to the server.
*/
- pseudo_client_op(OP_CLOSE, fd, -1, 0, 0);
+ pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0);
rc = real_close(fd);
/* return rc;
diff --git a/guts/dup.c b/guts/dup.c
index 51ba15f..941a5d9 100644
--- a/guts/dup.c
+++ b/guts/dup.c
@@ -8,7 +8,7 @@
rc = real_dup(fd);
save_errno = errno;
pseudo_debug(2, "dup: %d->%d\n", fd, rc);
- pseudo_client_op(OP_DUP, fd, rc, 0, 0);
+ pseudo_client_op(OP_DUP, 0, fd, rc, 0, 0);
errno = save_errno;
/* return rc;
diff --git a/guts/dup2.c b/guts/dup2.c
index 59d5293..360c3ad 100644
--- a/guts/dup2.c
+++ b/guts/dup2.c
@@ -8,10 +8,10 @@
/* close existing one first - this also causes the socket to the
* server to get moved around if someone tries to overwrite it. */
pseudo_debug(2, "dup2: %d->%d\n", oldfd, newfd);
- pseudo_client_op(OP_CLOSE, newfd, -1, 0, 0);
+ pseudo_client_op(OP_CLOSE, 0, newfd, -1, 0, 0);
rc = real_dup2(oldfd, newfd);
save_errno = errno;
- pseudo_client_op(OP_DUP, oldfd, newfd, 0, 0);
+ pseudo_client_op(OP_DUP, 0, oldfd, newfd, 0, 0);
errno = save_errno;
/* return rc;
diff --git a/guts/fchdir.c b/guts/fchdir.c
index b255511..5289f4c 100644
--- a/guts/fchdir.c
+++ b/guts/fchdir.c
@@ -7,7 +7,7 @@
rc = real_fchdir(dirfd);
if (rc != -1) {
- pseudo_client_op(OP_CHDIR, -1, dirfd, 0, 0);
+ pseudo_client_op(OP_CHDIR, 0, -1, dirfd, 0, 0);
}
/* return rc;
diff --git a/guts/fchmod.c b/guts/fchmod.c
index 663a026..b479e8d 100644
--- a/guts/fchmod.c
+++ b/guts/fchmod.c
@@ -12,13 +12,13 @@
return -1;
}
buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777);
- msg = pseudo_client_op(OP_FCHMOD, fd, -1, 0, &buf);
+ msg = pseudo_client_op(OP_FCHMOD, 0, fd, -1, 0, &buf);
real_fchmod(fd, PSEUDO_FS_MODE(mode));
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
+ errno = EPERM;
rc = -1;
} else {
errno = save_errno;
diff --git a/guts/fchmodat.c b/guts/fchmodat.c
index 9804711..78637ee 100644
--- a/guts/fchmodat.c
+++ b/guts/fchmodat.c
@@ -33,7 +33,7 @@
/* purely for debugging purposes: check whether file
* is already in database.
*/
- msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
+ msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, &buf);
if (!msg || msg->result != RESULT_SUCCEED) {
pseudo_debug(2, "chmodat to 0%o on %d/%s, ino %llu, new file.\n",
mode, dirfd, path, (unsigned long long) buf.st_ino);
@@ -54,12 +54,12 @@
*/
buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777);
- msg = pseudo_client_op(OP_CHMOD, -1, dirfd, path, &buf);
+ msg = pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf);
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
+ errno = EPERM;
rc = -1;
} else {
rc = 0;
diff --git a/guts/fchown.c b/guts/fchown.c
index 4e717ea..433d359 100644
--- a/guts/fchown.c
+++ b/guts/fchown.c
@@ -15,7 +15,7 @@
return -1;
}
if (owner == (uid_t) -1 || group == (gid_t) -1) {
- msg = pseudo_client_op(OP_STAT, fd, -1, NULL, &buf);
+ msg = pseudo_client_op(OP_STAT, 0, fd, -1, NULL, &buf);
/* copy in any existing values... */
if (msg) {
if (msg->result == RESULT_SUCCEED) {
@@ -38,12 +38,12 @@
}
pseudo_debug(2, "fchown, fd %d: %d:%d -> %d:%d\n",
fd, owner, group, buf.st_uid, buf.st_gid);
- msg = pseudo_client_op(OP_FCHOWN, fd, -1, 0, &buf);
+ msg = pseudo_client_op(OP_FCHOWN, 0, fd, -1, 0, &buf);
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
+ errno = EPERM;
rc = -1;
} else {
rc = 0;
diff --git a/guts/fchownat.c b/guts/fchownat.c
index 23dac7b..fc81d4f 100644
--- a/guts/fchownat.c
+++ b/guts/fchownat.c
@@ -31,7 +31,7 @@
save_errno = errno;
if (owner == (uid_t) -1 || group == (gid_t) -1) {
- msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
+ msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, &buf);
/* copy in any existing values... */
if (msg) {
if (msg->result == RESULT_SUCCEED) {
@@ -50,12 +50,12 @@
if (group != (gid_t) -1) {
buf.st_gid = group;
}
- msg = pseudo_client_op(OP_CHOWN, -1, dirfd, path, &buf);
+ msg = pseudo_client_op(OP_CHOWN, 0, -1, dirfd, path, &buf);
if (!msg) {
errno = ENOSYS;
rc = -1;
} else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
+ errno = EPERM;
rc = -1;
} else {
rc = 0;
diff --git a/guts/fclose.c b/guts/fclose.c
index bcf4ace..e0c5681 100644
--- a/guts/fclose.c
+++ b/guts/fclose.c
@@ -9,7 +9,7 @@
return -1;
}
int fd = fileno(fp);
- pseudo_client_op(OP_CLOSE, fd, -1, 0, 0);
+ pseudo_client_op(OP_CLOSE, 0, fd, -1, 0, 0);
rc = real_fclose(fp);
/* return rc;
diff --git a/guts/fcntl.c b/guts/fcntl.c
index ec7277d..d03d40c 100644
--- a/guts/fcntl.c
+++ b/guts/fcntl.c
@@ -22,7 +22,7 @@
save_errno = errno;
if (rc != -1) {
pseudo_debug(2, "fcntl_dup: %d->%d\n", fd, rc);
- pseudo_client_op(OP_DUP, fd, rc, 0, 0);
+ pseudo_client_op(OP_DUP, 0, fd, rc, 0, 0);
}
errno = save_errno;
break;
diff --git a/guts/fopen.c b/guts/fopen.c
index 6495d69..69d9ce6 100644
--- a/guts/fopen.c
+++ b/guts/fopen.c
@@ -16,13 +16,13 @@
pseudo_debug(2, "fopen '%s': fd %d\n", path, fd);
if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
if (!existed) {
- pseudo_client_op(OP_CREAT, -1, -1, path, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf);
}
- pseudo_client_op(OP_OPEN, fd, -1, path, &buf);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, &buf);
} else {
pseudo_debug(1, "fopen (fd %d) succeeded, but fstat failed (%s).\n",
fd, strerror(errno));
- pseudo_client_op(OP_OPEN, fd, -1, path, 0);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, 0);
}
errno = save_errno;
}
diff --git a/guts/fopen64.c b/guts/fopen64.c
index c6de09c..c2286f2 100644
--- a/guts/fopen64.c
+++ b/guts/fopen64.c
@@ -17,13 +17,13 @@
pseudo_debug(2, "fopen64 '%s': fd %d\n", path, fd);
if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
if (!existed) {
- pseudo_client_op(OP_CREAT, -1, -1, path, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf);
}
- pseudo_client_op(OP_OPEN, fd, -1, path, &buf);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, &buf);
} else {
pseudo_debug(1, "fopen64 (fd %d) succeeded, but fstat failed (%s).\n",
fd, strerror(errno));
- pseudo_client_op(OP_OPEN, fd, -1, path, 0);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, 0);
}
errno = save_errno;
}
diff --git a/guts/freopen.c b/guts/freopen.c
index 92c9d87..2701926 100644
--- a/guts/freopen.c
+++ b/guts/freopen.c
@@ -16,13 +16,13 @@
pseudo_debug(2, "freopen '%s': fd %d\n", path, fd);
if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
if (!existed) {
- pseudo_client_op(OP_CREAT, -1, -1, path, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf);
}
- pseudo_client_op(OP_OPEN, fd, -1, path, &buf);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, &buf);
} else {
pseudo_debug(1, "fopen (fd %d) succeeded, but stat failed (%s).\n",
fd, strerror(errno));
- pseudo_client_op(OP_OPEN, fd, -1, path, 0);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, 0);
}
errno = save_errno;
}
diff --git a/guts/freopen64.c b/guts/freopen64.c
index 1f83b07..7487a7b 100644
--- a/guts/freopen64.c
+++ b/guts/freopen64.c
@@ -16,13 +16,13 @@
pseudo_debug(2, "freopen64 '%s': fd %d\n", path, fd);
if (real___fxstat64(_STAT_VER, fd, &buf) != -1) {
if (!existed) {
- pseudo_client_op(OP_CREAT, -1, -1, path, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, path, &buf);
}
- pseudo_client_op(OP_OPEN, fd, -1, path, &buf);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, &buf);
} else {
pseudo_debug(1, "fopen (fd %d) succeeded, but stat failed (%s).\n",
fd, strerror(errno));
- pseudo_client_op(OP_OPEN, fd, -1, path, 0);
+ pseudo_client_op(OP_OPEN, pseudo_access_fopen(mode), fd, -1, path, 0);
}
errno = save_errno;
}
diff --git a/guts/link.c b/guts/link.c
index a68a1c1..278edd7 100644
--- a/guts/link.c
+++ b/guts/link.c
@@ -17,11 +17,11 @@
* there is one. OP_LINK is also used to insert unseen
* files, though, so it can't be implicit.
*/
- msg = pseudo_client_op(OP_STAT, -1, -1, oldpath, &buf);
+ msg = pseudo_client_op(OP_STAT, 0, -1, -1, oldpath, &buf);
if (msg) {
pseudo_stat_msg(&buf, msg);
}
- pseudo_client_op(OP_LINK, -1, -1, newpath, &buf);
+ pseudo_client_op(OP_LINK, 0, -1, -1, newpath, &buf);
}
/* return rc;
diff --git a/guts/mkdirat.c b/guts/mkdirat.c
index 188e66b..80ca5a0 100644
--- a/guts/mkdirat.c
+++ b/guts/mkdirat.c
@@ -22,7 +22,7 @@
stat_rc = real___fxstatat64(_STAT_VER, dirfd, path, &buf, AT_SYMLINK_NOFOLLOW);
#endif
if (stat_rc != -1) {
- pseudo_client_op(OP_MKDIR, -1, dirfd, path, &buf);
+ pseudo_client_op(OP_MKDIR, 0, -1, dirfd, path, &buf);
} else {
pseudo_debug(1, "mkdir of %s succeeded, but stat failed: %s\n",
path, strerror(errno));
diff --git a/guts/mkdtemp.c b/guts/mkdtemp.c
index 32fe4ef..3c97118 100644
--- a/guts/mkdtemp.c
+++ b/guts/mkdtemp.c
@@ -27,7 +27,7 @@
save_errno = errno;
if (real___xstat64(_STAT_VER, rc, &buf) != -1) {
- pseudo_client_op(OP_CREAT, -1, -1, tmp_template, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf);
} else {
pseudo_debug(1, "mkstemp (path %s) succeeded, but fstat failed (%s).\n",
rc, strerror(errno));
diff --git a/guts/mkstemp.c b/guts/mkstemp.c
index a8f5915..ee8c742 100644
--- a/guts/mkstemp.c
+++ b/guts/mkstemp.c
@@ -27,12 +27,12 @@
save_errno = errno;
if (real___fxstat64(_STAT_VER, rc, &buf) != -1) {
- pseudo_client_op(OP_CREAT, -1, -1, tmp_template, &buf);
- pseudo_client_op(OP_OPEN, rc, -1, tmp_template, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, -1, tmp_template, &buf);
+ pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, rc, -1, tmp_template, &buf);
} else {
pseudo_debug(1, "mkstemp (fd %d) succeeded, but fstat failed (%s).\n",
rc, strerror(errno));
- pseudo_client_op(OP_OPEN, rc, -1, tmp_template, 0);
+ pseudo_client_op(OP_OPEN, PSA_READ | PSA_WRITE, rc, -1, tmp_template, 0);
}
errno = save_errno;
}
diff --git a/guts/openat.c b/guts/openat.c
index 801f1e3..20d8d8d 100644
--- a/guts/openat.c
+++ b/guts/openat.c
@@ -48,13 +48,13 @@
if (stat_rc != -1) {
buf.st_mode = PSEUDO_DB_MODE(buf.st_mode, mode);
if (!existed) {
- pseudo_client_op(OP_CREAT, -1, dirfd, path, &buf);
+ pseudo_client_op(OP_CREAT, 0, -1, dirfd, path, &buf);
}
- pseudo_client_op(OP_OPEN, rc, dirfd, path, &buf);
+ pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, dirfd, path, &buf);
} else {
pseudo_debug(1, "openat (fd %d, path %d/%s, flags %d) succeeded, but stat failed (%s).\n",
rc, dirfd, path, flags, strerror(errno));
- pseudo_client_op(OP_OPEN, rc, dirfd, path, 0);
+ pseudo_client_op(OP_OPEN, PSEUDO_ACCESS(flags), rc, dirfd, path, 0);
}
errno = save_errno;
}
diff --git a/guts/rename.c b/guts/rename.c
index 117eb78..4ed3527 100644
--- a/guts/rename.c
+++ b/guts/rename.c
@@ -53,10 +53,10 @@
*/
/* newpath must be removed. */
- pseudo_client_op(OP_UNLINK, -1, -1, newpath, &newbuf);
+ pseudo_client_op(OP_UNLINK, 0, -1, -1, newpath, &newbuf);
/* fill in "correct" details from server */
- msg = pseudo_client_op(OP_STAT, -1, -1, oldpath, &oldbuf);
+ msg = pseudo_client_op(OP_STAT, 0, -1, -1, oldpath, &oldbuf);
if (msg && msg->result == RESULT_SUCCEED) {
pseudo_stat_msg(&oldbuf, msg);
pseudo_debug(1, "renaming %s, got old mode of 0%o\n", oldpath, (int) msg->mode);
@@ -67,9 +67,9 @@
*/
pseudo_debug(1, "renaming new '%s' [%llu]\n",
oldpath, (unsigned long long) oldbuf.st_ino);
- pseudo_client_op(OP_LINK, -1, -1, oldpath, &oldbuf);
+ pseudo_client_op(OP_LINK, 0, -1, -1, oldpath, &oldbuf);
}
- pseudo_client_op(OP_RENAME, -1, -1, newpath, &oldbuf, oldpath);
+ pseudo_client_op(OP_RENAME, 0, -1, -1, newpath, &oldbuf, oldpath);
errno = save_errno;
/* return rc;
diff --git a/guts/rmdir.c b/guts/rmdir.c
index 94de46a..d69fb7e 100644
--- a/guts/rmdir.c
+++ b/guts/rmdir.c
@@ -13,7 +13,7 @@
rc = real_rmdir(path);
save_errno = errno;
if (rc != -1) {
- pseudo_client_op(OP_UNLINK, -1, -1, path, &buf);
+ pseudo_client_op(OP_UNLINK, 0, -1, -1, path, &buf);
}
errno = save_errno;
diff --git a/guts/symlinkat.c b/guts/symlinkat.c
index 577b1e7..ca12cd5 100644
--- a/guts/symlinkat.c
+++ b/guts/symlinkat.c
@@ -40,7 +40,7 @@
return rc;
}
/* just record the entry */
- pseudo_client_op(OP_SYMLINK, -1, dirfd, newpath, &buf);
+ pseudo_client_op(OP_SYMLINK, 0, -1, dirfd, newpath, &buf);
free(roldname);
diff --git a/guts/unlinkat.c b/guts/unlinkat.c
index 1c2868a..4f5b363 100644
--- a/guts/unlinkat.c
+++ b/guts/unlinkat.c
@@ -35,7 +35,7 @@
rc = real_unlinkat(dirfd, path, rflags);
#endif
if (rc != -1) {
- pseudo_client_op(OP_UNLINK, -1, dirfd, path, &buf);
+ pseudo_client_op(OP_UNLINK, 0, -1, dirfd, path, &buf);
}
/* return rc;