diff options
author | gad <gad@FreeBSD.org> | 2004-06-01 22:19:16 +0000 |
---|---|---|
committer | gad <gad@FreeBSD.org> | 2004-06-01 22:19:16 +0000 |
commit | b5aa4ee7064bba450be12b4a92673eb114377fc1 (patch) | |
tree | ca43fdf883416def4f2070255d2a6b509f884e9b /bin/ps | |
parent | a4a53235beef66c774060210b7d388fb90d02c5d (diff) | |
download | FreeBSD-src-b5aa4ee7064bba450be12b4a92673eb114377fc1.zip FreeBSD-src-b5aa4ee7064bba450be12b4a92673eb114377fc1.tar.gz |
A few more style-fixes from Bruce. The only non-cosmetic change
is to drop a call to setuid() which has not been needed for years.
Noticed by: bde
Diffstat (limited to 'bin/ps')
-rw-r--r-- | bin/ps/ps.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c index 3a445d2..14e360a 100644 --- a/bin/ps/ps.c +++ b/bin/ps/ps.c @@ -207,7 +207,7 @@ main(int argc, char *argv[]) init_list(&uidlist, addelem_uid, sizeof(uid_t), "user"); memf = nlistf = _PATH_DEVNULL; while ((ch = getopt(argc, argv, PS_ARGS)) != -1) - switch((char)ch) { + switch ((char)ch) { case 'A': /* * Exactly the same as `-ax'. This has been @@ -427,10 +427,8 @@ main(int argc, char *argv[]) * Discard setgid privileges if not the running kernel so that bad * guys can't print interesting stuff from kernel memory. */ - if (dropgid) { + if (dropgid) setgid(getgid()); - setuid(getuid()); - } kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); if (kd == 0) @@ -658,9 +656,8 @@ addelem_gid(struct listinfo *inf, const char *elem) if (grp == NULL) { warnx("No %s %s '%s'", inf->lname, nameorID, elem); optfatal = 1; - return (0); /* Do not add this value. */ + return (0); } - if (inf->count >= inf->maxcount) expand_list(inf); inf->l.gids[(inf->count)++] = grp->gr_gid; @@ -691,9 +688,8 @@ addelem_pid(struct listinfo *inf, const char *elem) } if (errno == ERANGE) { optfatal = 1; - return (0); /* Do not add this value. */ + return (0); } - if (inf->count >= inf->maxcount) expand_list(inf); inf->l.pids[(inf->count)++] = tempid; @@ -721,14 +717,13 @@ addelem_tty(struct listinfo *inf, const char *elem) if (stat(ttypath, &sb) == -1) { warn("%s", ttypath); optfatal = 1; - return (0); /* Do not add this value. */ + return (0); } if (!S_ISCHR(sb.st_mode)) { warn("%s: Not a terminal", ttypath); optfatal = 1; - return (0); /* Do not add this value. */ + return (0); } - if (inf->count >= inf->maxcount) expand_list(inf); inf->l.ttys[(inf->count)++] = sb.st_rdev; @@ -772,9 +767,8 @@ addelem_uid(struct listinfo *inf, const char *elem) * errors (and the command will be aborted). */ optfatal = 1; - return (0); /* Do not add this value. */ + return (0); } - if (inf->count >= inf->maxcount) expand_list(inf); inf->l.uids[(inf->count)++] = pwd->pw_uid; @@ -790,7 +784,7 @@ add_list(struct listinfo *inf, const char *argp) char elemcopy[PATH_MAX]; if (*argp == 0) - inf->addelem(inf, elemcopy); + inf->addelem(inf, elemcopy); while (*argp != '\0') { while (*argp != '\0' && strchr(W_SEP, *argp) != NULL) argp++; @@ -849,8 +843,7 @@ expand_list(struct listinfo *inf) newlist = realloc(inf->l.ptr, newmax * inf->elemsize); if (newlist == NULL) { free(inf->l.ptr); - errx(1, "realloc to %d %ss failed", newmax, - inf->lname); + errx(1, "realloc to %d %ss failed", newmax, inf->lname); } inf->maxcount = newmax; inf->l.ptr = newlist; |