diff options
Diffstat (limited to 'ports/unix/guts/fchmodat.c')
-rw-r--r-- | ports/unix/guts/fchmodat.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/ports/unix/guts/fchmodat.c b/ports/unix/guts/fchmodat.c index a14d1b1..59a92ce 100644 --- a/ports/unix/guts/fchmodat.c +++ b/ports/unix/guts/fchmodat.c @@ -1,14 +1,13 @@ /* - * Copyright (c) 2008-2010, 2012 Wind River Systems; see + * Copyright (c) 2008-2010, 2012, 2013 Wind River Systems; see * guts/COPYRIGHT for information. * * static int * wrap_fchmodat(int dirfd, const char *path, mode_t mode, int flags) { * int rc = -1; */ - pseudo_msg_t *msg; PSEUDO_STATBUF buf; - int save_errno; + int save_errno = errno; #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS if (dirfd != AT_FDCWD) { @@ -33,8 +32,13 @@ } save_errno = errno; +#if 0 + pseudo_msg_t *msg; /* purely for debugging purposes: check whether file - * is already in database. + * is already in database. We don't need the resulting + * information for anything. This is currently ifdefed + * out because it's only useful when trying to track where + * files are coming from. */ msg = pseudo_client_op(OP_STAT, 0, -1, -1, path, &buf); if (!msg || msg->result != RESULT_SUCCEED) { @@ -42,6 +46,7 @@ mode, dirfd, path, (unsigned long long) buf.st_ino); } +#endif /* user bits added so "root" can always access files. */ #ifdef PSEUDO_NO_REAL_AT_FUNCTIONS @@ -53,18 +58,18 @@ #endif /* we ignore a failure from underlying fchmod, because pseudo * may believe you are permitted to change modes that the filesystem - * doesn't. + * doesn't. Note that we also don't need to know whether the + * file might be a (pseudo) block device or some such; pseudo + * will only modify permission bits based on an OP_CHMOD, and does + * not care about device/file type mismatches, only directory/file + * or symlink/file. */ buf.st_mode = (buf.st_mode & ~07777) | (mode & 07777); - msg = pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf); - if (msg && msg->result != RESULT_SUCCEED) { - errno = EPERM; - rc = -1; - } else { - /* if server is down, just pretend we worked */ - rc = 0; - } + pseudo_client_op(OP_CHMOD, 0, -1, dirfd, path, &buf); + /* don't change errno from what it was originally */ + errno = save_errno; + rc = 0; /* return rc; * } |