Permalink
Browse files

Updates: Enable additional warnings, fix a number of things.

None of them seem to have been genuine problems, but it's prettier now,
and some were questionable.
  • Loading branch information...
1 parent 9a95df4 commit caeebc0dd6ff538629687b55a5ce72554a7c3f34 Peter Seebach committed Mar 26, 2010
Showing with 87 additions and 124 deletions.
  1. +2 −4 Makefile.in
  2. +3 −3 guts/fchown.c
  3. +13 −11 guts/fchownat.c
  4. +1 −1 guts/fts_open.c
  5. +2 −43 guts/lchown.c
  6. +1 −1 guts/realpath.c
  7. +4 −4 guts/setregid.c
  8. +6 −6 guts/setresgid.c
  9. +6 −6 guts/setresuid.c
  10. +4 −4 guts/setreuid.c
  11. +5 −1 makewrappers
  12. +1 −1 pseudo.c
  13. +9 −9 pseudo_client.c
  14. +8 −8 pseudo_client.h
  15. +2 −2 pseudo_db.c
  16. +5 −5 pseudo_ipc.c
  17. +1 −1 pseudo_server.c
  18. +2 −2 pseudo_util.c
  19. +1 −1 pseudodb.c
  20. +11 −11 pseudolog.c
View
@@ -29,7 +29,7 @@ LIBDIR=$(PREFIX)/lib$(MARK64)
BINDIR=$(PREFIX)/bin
DATADIR=$(PREFIX)/var/pseudo
-CFLAGS_BASE=-pipe -std=gnu99 -Wall
+CFLAGS_BASE=-pipe -std=gnu99 -Wall -W -Wextra
CFLAGS_CODE=-fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE -m$(BITS)
CFLAGS_DEFS=-DPSEUDO_PREFIX='"$(PREFIX)"' -DPSEUDO_SUFFIX='"$(SUFFIX)"' -DPSEUDO_VERSION='"$(VERSION)"'
CFLAGS_DEBUG=-O2 -g
@@ -92,8 +92,6 @@ pseudo_client.o: pseudo_client.h
pseudo_server.o: pseudo_server.h
-pseudo_wrappers.o: $(GUTS)
-
wrappers: wrapfuncs.in $(USE_64) makewrappers
./makewrappers wrapfuncs.in $(USE_64)
@@ -102,7 +100,7 @@ wrappers: wrapfuncs.in $(USE_64) makewrappers
pseudo_wrappers.c: wrappers
# no-strict-aliasing is needed for the function pointer trickery.
-pseudo_wrappers.o: pseudo_wrappers.c
+pseudo_wrappers.o: $(GUTS) pseudo_wrappers.c
$(CC) -fno-strict-aliasing $(CFLAGS) -D_GNU_SOURCE -c -o pseudo_wrappers.o pseudo_wrappers.c
offsets32:
View
@@ -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",
View
@@ -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);
View
@@ -4,7 +4,7 @@
* FTS * rc = NULL;
*/
char **rpath_argv;
- size_t args = 0;
+ int args = 0;
int errored = 0;
int i;
View
@@ -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;
* }
View
@@ -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;
View
@@ -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();
View
@@ -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();
View
@@ -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();
View
@@ -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();
View
@@ -163,6 +163,7 @@ do
set -- $args
IFS=$save_IFS
args=''
+ dummy_args=''
optional_arg=false
prepend=''
depth=0
@@ -207,6 +208,7 @@ do
...*)
optional_arg=true
args="$args${args:+, }..."
+ dummy_args="$dummy_args${dummy_args:+, }..."
arg=`expr "$arg" : '\.\.\.{\(.*\)}'`
argname=`expr "$arg" : '.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*\)$'`
argnames="$argnames${argnames:+, }$argname"
@@ -221,13 +223,15 @@ do
*\(*) # function pointer
argname=`expr "$arg" : '[^(]*(\*\([a-zA-Z0-9_]*\).*'`
args="$args${args:+, }$arg"
+ dummy_args="$dummy_args${dummy_args:+, }$arg __attribute__((unused))"
wrapargnames="$wrapargnames${wrapargnames:+, }$argname"
argnames="$argnames${argnames:+, }$argname"
prev_argname=$argname
;;
*)
argname=`expr "$arg" : '.*[^a-zA-Z0-9_](*\([a-zA-Z0-9_]*\))*(*)*$'`
args="$args${args:+, }$arg"
+ dummy_args="$dummy_args${dummy_args:+, }$arg __attribute__((unused))"
# special handling for canonicalization
# set this before changing path -> rpath, for guts files
wrapargnames="$wrapargnames${wrapargnames:+, }$argname"
@@ -278,7 +282,7 @@ Unknown type '$type'." ; exit 1 ;;
# first the dummy, and the function pointer:
cat >&5 <<EOF
static $type
-dummy_$name($args) {
+dummy_$name($dummy_args) {
pseudo_enosys("$name");
errno = ENOSYS;
return $default_value;
View
@@ -267,7 +267,7 @@ main(int argc, char *argv[]) {
int
pseudo_op(pseudo_msg_t *msg, const char *tag) {
pseudo_msg_t msg_header;
- pseudo_msg_t by_path = { 0 }, by_ino = { 0 };
+ pseudo_msg_t by_path = { .op = 0 }, by_ino = { .op = 0 };
pseudo_msg_t db_header;
char *path_by_ino = 0;
char *oldpath = 0;
View
@@ -51,18 +51,18 @@ char *pseudo_cwd_rel = 0;
static char **fd_paths = 0;
static int nfds = 0;
static int messages = 0;
-static struct timeval message_time = { 0 };
+static struct timeval message_time = { .tv_sec = 0 };
static int pseudo_inited = 0;
/* note: these are int, not uid_t/gid_t, so I can use 'em with scanf */
-int pseudo_ruid;
-int pseudo_euid;
-int pseudo_suid;
-int pseudo_fuid;
-int pseudo_rgid;
-int pseudo_egid;
-int pseudo_sgid;
-int pseudo_fgid;
+uid_t pseudo_ruid;
+uid_t pseudo_euid;
+uid_t pseudo_suid;
+uid_t pseudo_fuid;
+gid_t pseudo_rgid;
+gid_t pseudo_egid;
+gid_t pseudo_sgid;
+gid_t pseudo_fgid;
void
pseudo_client_touchuid(void) {
View
@@ -31,14 +31,14 @@ extern void pseudo_stat64_from32(struct stat64 *, struct stat *);
#define MOVE_FD 0
#define COPY_FD 1
#define PSEUDO_MIN_FD 20
-extern int pseudo_euid;
-extern int pseudo_fuid;
-extern int pseudo_suid;
-extern int pseudo_ruid;
-extern int pseudo_egid;
-extern int pseudo_sgid;
-extern int pseudo_rgid;
-extern int pseudo_fgid;
+extern uid_t pseudo_euid;
+extern uid_t pseudo_fuid;
+extern uid_t pseudo_suid;
+extern uid_t pseudo_ruid;
+extern gid_t pseudo_egid;
+extern gid_t pseudo_sgid;
+extern gid_t pseudo_rgid;
+extern gid_t pseudo_fgid;
extern int pseudo_dir_fd;
/* support related to chroot/getcwd/etc. */
View
@@ -801,7 +801,7 @@ frag(buffer *b, char *fmt, ...) {
va_start(ap, fmt);
rc = vsnprintf(b->tail, b->buflen - curlen, fmt, ap);
va_end(ap);
- if (rc >= (b->buflen - curlen)) {
+ if ((rc > 0) && ((size_t) rc >= (b->buflen - curlen))) {
size_t newlen = b->buflen;
while (newlen <= (rc + curlen))
newlen *= 2;
@@ -819,7 +819,7 @@ frag(buffer *b, char *fmt, ...) {
va_start(ap, fmt);
rc = vsnprintf(b->tail, b->buflen - curlen, fmt, ap);
va_end(ap);
- if (rc >= (b->buflen - curlen)) {
+ if ((rc > 0) && ((size_t) rc >= (b->buflen - curlen))) {
pseudo_diag("tried to reallocate larger buffer, failed. giving up.\n");
return -1;
}
Oops, something went wrong.

0 comments on commit caeebc0

Please sign in to comment.