aboutsummaryrefslogtreecommitdiff
path: root/bin/ps/ps.c
diff options
context:
space:
mode:
authorGarance A Drosehn <gad@FreeBSD.org>2004-06-01 22:19:16 +0000
committerGarance A Drosehn <gad@FreeBSD.org>2004-06-01 22:19:16 +0000
commitc23b00b7ca8be830f5d4306d39d07f3c046d4a34 (patch)
treeca43fdf883416def4f2070255d2a6b509f884e9b /bin/ps/ps.c
parent44f79297b3ff0c682b5e6f3a91ea5f4e72404221 (diff)
downloadsrc-c23b00b7ca8be830f5d4306d39d07f3c046d4a34.tar.gz
src-c23b00b7ca8be830f5d4306d39d07f3c046d4a34.zip
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
Notes
Notes: svn path=/head/; revision=129967
Diffstat (limited to 'bin/ps/ps.c')
-rw-r--r--bin/ps/ps.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/bin/ps/ps.c b/bin/ps/ps.c
index 3a445d2edd43..14e360ab0ab2 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;