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
This commit is contained in:
Garance A Drosehn 2004-06-01 22:19:16 +00:00
parent 44f79297b3
commit c23b00b7ca

View File

@ -207,7 +207,7 @@ main(int argc, char *argv[])
init_list(&uidlist, addelem_uid, sizeof(uid_t), "user"); init_list(&uidlist, addelem_uid, sizeof(uid_t), "user");
memf = nlistf = _PATH_DEVNULL; memf = nlistf = _PATH_DEVNULL;
while ((ch = getopt(argc, argv, PS_ARGS)) != -1) while ((ch = getopt(argc, argv, PS_ARGS)) != -1)
switch((char)ch) { switch ((char)ch) {
case 'A': case 'A':
/* /*
* Exactly the same as `-ax'. This has been * 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 * Discard setgid privileges if not the running kernel so that bad
* guys can't print interesting stuff from kernel memory. * guys can't print interesting stuff from kernel memory.
*/ */
if (dropgid) { if (dropgid)
setgid(getgid()); setgid(getgid());
setuid(getuid());
}
kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf); kd = kvm_openfiles(nlistf, memf, NULL, O_RDONLY, errbuf);
if (kd == 0) if (kd == 0)
@ -658,9 +656,8 @@ addelem_gid(struct listinfo *inf, const char *elem)
if (grp == NULL) { if (grp == NULL) {
warnx("No %s %s '%s'", inf->lname, nameorID, elem); warnx("No %s %s '%s'", inf->lname, nameorID, elem);
optfatal = 1; optfatal = 1;
return (0); /* Do not add this value. */ return (0);
} }
if (inf->count >= inf->maxcount) if (inf->count >= inf->maxcount)
expand_list(inf); expand_list(inf);
inf->l.gids[(inf->count)++] = grp->gr_gid; inf->l.gids[(inf->count)++] = grp->gr_gid;
@ -691,9 +688,8 @@ addelem_pid(struct listinfo *inf, const char *elem)
} }
if (errno == ERANGE) { if (errno == ERANGE) {
optfatal = 1; optfatal = 1;
return (0); /* Do not add this value. */ return (0);
} }
if (inf->count >= inf->maxcount) if (inf->count >= inf->maxcount)
expand_list(inf); expand_list(inf);
inf->l.pids[(inf->count)++] = tempid; inf->l.pids[(inf->count)++] = tempid;
@ -721,14 +717,13 @@ addelem_tty(struct listinfo *inf, const char *elem)
if (stat(ttypath, &sb) == -1) { if (stat(ttypath, &sb) == -1) {
warn("%s", ttypath); warn("%s", ttypath);
optfatal = 1; optfatal = 1;
return (0); /* Do not add this value. */ return (0);
} }
if (!S_ISCHR(sb.st_mode)) { if (!S_ISCHR(sb.st_mode)) {
warn("%s: Not a terminal", ttypath); warn("%s: Not a terminal", ttypath);
optfatal = 1; optfatal = 1;
return (0); /* Do not add this value. */ return (0);
} }
if (inf->count >= inf->maxcount) if (inf->count >= inf->maxcount)
expand_list(inf); expand_list(inf);
inf->l.ttys[(inf->count)++] = sb.st_rdev; 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). * errors (and the command will be aborted).
*/ */
optfatal = 1; optfatal = 1;
return (0); /* Do not add this value. */ return (0);
} }
if (inf->count >= inf->maxcount) if (inf->count >= inf->maxcount)
expand_list(inf); expand_list(inf);
inf->l.uids[(inf->count)++] = pwd->pw_uid; inf->l.uids[(inf->count)++] = pwd->pw_uid;
@ -790,7 +784,7 @@ add_list(struct listinfo *inf, const char *argp)
char elemcopy[PATH_MAX]; char elemcopy[PATH_MAX];
if (*argp == 0) if (*argp == 0)
inf->addelem(inf, elemcopy); inf->addelem(inf, elemcopy);
while (*argp != '\0') { while (*argp != '\0') {
while (*argp != '\0' && strchr(W_SEP, *argp) != NULL) while (*argp != '\0' && strchr(W_SEP, *argp) != NULL)
argp++; argp++;
@ -849,8 +843,7 @@ expand_list(struct listinfo *inf)
newlist = realloc(inf->l.ptr, newmax * inf->elemsize); newlist = realloc(inf->l.ptr, newmax * inf->elemsize);
if (newlist == NULL) { if (newlist == NULL) {
free(inf->l.ptr); free(inf->l.ptr);
errx(1, "realloc to %d %ss failed", newmax, errx(1, "realloc to %d %ss failed", newmax, inf->lname);
inf->lname);
} }
inf->maxcount = newmax; inf->maxcount = newmax;
inf->l.ptr = newlist; inf->l.ptr = newlist;