aboutsummaryrefslogtreecommitdiffstats
path: root/guts
diff options
context:
space:
mode:
Diffstat (limited to 'guts')
-rw-r--r--guts/fchown.c6
-rw-r--r--guts/fchownat.c24
-rw-r--r--guts/fts_open.c2
-rw-r--r--guts/lchown.c45
-rw-r--r--guts/realpath.c2
-rw-r--r--guts/setregid.c8
-rw-r--r--guts/setresgid.c12
-rw-r--r--guts/setresuid.c12
-rw-r--r--guts/setreuid.c8
9 files changed, 40 insertions, 79 deletions
diff --git a/guts/fchown.c b/guts/fchown.c
index 53a34de..4e717ea 100644
--- a/guts/fchown.c
+++ b/guts/fchown.c
@@ -14,7 +14,7 @@
errno = save_errno;
return -1;
}
- if (owner == -1 || group == -1) {
+ if (owner == (uid_t) -1 || group == (gid_t) -1) {
msg = pseudo_client_op(OP_STAT, fd, -1, NULL, &buf);
/* copy in any existing values... */
if (msg) {
@@ -30,10 +30,10 @@
}
}
/* now override with arguments */
- if (owner != -1) {
+ if (owner != (uid_t) -1) {
buf.st_uid = owner;
}
- if (group != -1) {
+ if (group != (gid_t) -1) {
buf.st_gid = group;
}
pseudo_debug(2, "fchown, fd %d: %d:%d -> %d:%d\n",
diff --git a/guts/fchownat.c b/guts/fchownat.c
index 181fa6d..23dac7b 100644
--- a/guts/fchownat.c
+++ b/guts/fchownat.c
@@ -30,22 +30,24 @@
}
save_errno = errno;
- msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
- /* copy in any existing values... */
- if (msg) {
- if (msg->result == RESULT_SUCCEED) {
- pseudo_stat_msg(&buf, msg);
- } else {
- pseudo_debug(2, "chownat to %d:%d on %d/%s, ino %llu, new file.\n",
- owner, group, dirfd, path,
- (unsigned long long) buf.st_ino);
+ if (owner == (uid_t) -1 || group == (gid_t) -1) {
+ msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
+ /* copy in any existing values... */
+ if (msg) {
+ if (msg->result == RESULT_SUCCEED) {
+ pseudo_stat_msg(&buf, msg);
+ } else {
+ pseudo_debug(2, "chownat to %d:%d on %d/%s, ino %llu, new file.\n",
+ owner, group, dirfd, path,
+ (unsigned long long) buf.st_ino);
+ }
}
}
/* now override with arguments */
- if (owner != -1) {
+ if (owner != (uid_t) -1) {
buf.st_uid = owner;
}
- if (group != -1) {
+ if (group != (gid_t) -1) {
buf.st_gid = group;
}
msg = pseudo_client_op(OP_CHOWN, -1, dirfd, path, &buf);
diff --git a/guts/fts_open.c b/guts/fts_open.c
index d244861..bd71a8e 100644
--- a/guts/fts_open.c
+++ b/guts/fts_open.c
@@ -4,7 +4,7 @@
* FTS * rc = NULL;
*/
char **rpath_argv;
- size_t args = 0;
+ int args = 0;
int errored = 0;
int i;
diff --git a/guts/lchown.c b/guts/lchown.c
index 2d0aff2..be06a8d 100644
--- a/guts/lchown.c
+++ b/guts/lchown.c
@@ -2,49 +2,8 @@
* static int
* wrap_lchown(const char *path, uid_t owner, gid_t group) {
*/
- pseudo_msg_t *msg;
- struct stat64 buf;
- if (!path) {
- errno = EFAULT;
- return -1;
- }
- pseudo_debug(2, "lchown(%s, %d, %d)\n",
- path ? path : "<nil>", owner, group);
- if (real___lxstat64(_STAT_VER, path, &buf) == -1) {
- return -1;
- }
- if (owner == -1 || group == -1) {
- msg = pseudo_client_op(OP_STAT, -1, -1, path, &buf);
- /* copy in any existing values... */
- if (msg) {
- if (msg->result == RESULT_SUCCEED) {
- pseudo_stat_msg(&buf, msg);
- } else {
- pseudo_debug(2, "lchown to %d:%d on %s, ino %llu, new file.\n",
- owner, group, path,
- (unsigned long long) buf.st_ino);
- }
- } else {
- pseudo_diag("stat within lchown of '%s' [%llu] failed.\n",
- path, (unsigned long long) buf.st_ino);
- }
- }
- if (owner != -1) {
- buf.st_uid = owner;
- }
- if (group != -1) {
- buf.st_gid = group;
- }
- msg = pseudo_client_op(OP_CHOWN, -1, -1, path, &buf);
- if (!msg) {
- errno = ENOSYS;
- rc = -1;
- } else if (msg->result != RESULT_SUCCEED) {
- errno = msg->xerrno;
- rc = -1;
- } else {
- rc = 0;
- }
+
+ rc = wrap_fchownat(AT_FDCWD, path, owner, group, AT_SYMLINK_NOFOLLOW);
/* return rc;
* }
diff --git a/guts/realpath.c b/guts/realpath.c
index 5b1a5f8..2f2dcf6 100644
--- a/guts/realpath.c
+++ b/guts/realpath.c
@@ -4,7 +4,7 @@
* char * rc = NULL;
*/
char *rname = PSEUDO_ROOT_PATH(AT_FDCWD, name, 0);
- size_t len;
+ ssize_t len;
if (!rname) {
errno = ENAMETOOLONG;
return NULL;
diff --git a/guts/setregid.c b/guts/setregid.c
index 2444390..0be0146 100644
--- a/guts/setregid.c
+++ b/guts/setregid.c
@@ -4,20 +4,20 @@
* int rc = -1;
*/
rc = 0;
- if (pseudo_euid != 0 && rgid != -1 &&
+ if (pseudo_euid != 0 && rgid != (gid_t) -1 &&
rgid != pseudo_egid && rgid != pseudo_rgid && rgid != pseudo_sgid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && egid != -1 &&
+ if (pseudo_euid != 0 && egid != (gid_t) -1 &&
egid != pseudo_egid && egid != pseudo_rgid && egid != pseudo_sgid) {
rc = -1;
errno = EPERM;
}
if (rc != -1) {
- if (rgid != -1)
+ if (rgid != (gid_t) -1)
pseudo_rgid = rgid;
- if (egid != -1)
+ if (egid != (gid_t) -1)
pseudo_egid = egid;
pseudo_fgid = pseudo_egid;
pseudo_client_touchuid();
diff --git a/guts/setresgid.c b/guts/setresgid.c
index 455fe62..b6491ad 100644
--- a/guts/setresgid.c
+++ b/guts/setresgid.c
@@ -4,27 +4,27 @@
* int rc = -1;
*/
rc = 0;
- if (pseudo_euid != 0 && rgid != -1 &&
+ if (pseudo_euid != 0 && rgid != (gid_t) -1 &&
rgid != pseudo_egid && rgid != pseudo_rgid && rgid != pseudo_sgid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && egid != -1 &&
+ if (pseudo_euid != 0 && egid != (gid_t) -1 &&
egid != pseudo_egid && egid != pseudo_rgid && egid != pseudo_sgid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && sgid != -1 &&
+ if (pseudo_euid != 0 && sgid != (gid_t) -1 &&
sgid != pseudo_egid && sgid != pseudo_rgid && sgid != pseudo_sgid) {
rc = -1;
errno = EPERM;
}
if (rc != -1) {
- if (rgid != -1)
+ if (rgid != (gid_t) -1)
pseudo_rgid = rgid;
- if (egid != -1)
+ if (egid != (gid_t) -1)
pseudo_egid = egid;
- if (sgid != -1)
+ if (sgid != (gid_t) -1)
pseudo_sgid = sgid;
pseudo_fgid = pseudo_egid;
pseudo_client_touchuid();
diff --git a/guts/setresuid.c b/guts/setresuid.c
index 41dd81d..9c07e4c 100644
--- a/guts/setresuid.c
+++ b/guts/setresuid.c
@@ -4,27 +4,27 @@
* int rc = -1;
*/
rc = 0;
- if (pseudo_euid != 0 && ruid != -1 &&
+ if (pseudo_euid != 0 && ruid != (uid_t) -1 &&
ruid != pseudo_euid && ruid != pseudo_ruid && ruid != pseudo_suid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && euid != -1 &&
+ if (pseudo_euid != 0 && euid != (uid_t) -1 &&
euid != pseudo_euid && euid != pseudo_ruid && euid != pseudo_suid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && suid != -1 &&
+ if (pseudo_euid != 0 && suid != (uid_t) -1 &&
suid != pseudo_euid && suid != pseudo_ruid && suid != pseudo_suid) {
rc = -1;
errno = EPERM;
}
if (rc != -1) {
- if (ruid != -1)
+ if (ruid != (uid_t) -1)
pseudo_ruid = ruid;
- if (euid != -1)
+ if (euid != (uid_t) -1)
pseudo_euid = euid;
- if (suid != -1)
+ if (suid != (uid_t) -1)
pseudo_suid = suid;
pseudo_fuid = pseudo_euid;
pseudo_client_touchuid();
diff --git a/guts/setreuid.c b/guts/setreuid.c
index 3669581..7b7fe52 100644
--- a/guts/setreuid.c
+++ b/guts/setreuid.c
@@ -4,20 +4,20 @@
* int rc = -1;
*/
rc = 0;
- if (pseudo_euid != 0 && ruid != -1 &&
+ if (pseudo_euid != 0 && ruid != (uid_t) -1 &&
ruid != pseudo_euid && ruid != pseudo_ruid && ruid != pseudo_suid) {
rc = -1;
errno = EPERM;
}
- if (pseudo_euid != 0 && euid != -1 &&
+ if (pseudo_euid != 0 && euid != (uid_t) -1 &&
euid != pseudo_euid && euid != pseudo_ruid && euid != pseudo_suid) {
rc = -1;
errno = EPERM;
}
if (rc != -1) {
- if (ruid != -1)
+ if (ruid != (uid_t) -1)
pseudo_ruid = ruid;
- if (euid != -1)
+ if (euid != (uid_t) -1)
pseudo_euid = euid;
pseudo_fuid = pseudo_euid;
pseudo_client_touchuid();