Check return code of setuid() and setgid() in finger.

While they will not fail in normal circumstances, better safe than
sorry.

MFC after:	1 week
This commit is contained in:
simon 2011-04-23 14:19:26 +00:00
parent 20f7936c44
commit 89abec7a17

View File

@ -164,11 +164,15 @@ main(int argc, char **argv)
if (getuid() == 0 || geteuid() == 0) {
invoker_root = 1;
if ((pw = getpwnam(UNPRIV_NAME)) && pw->pw_uid > 0) {
setgid(pw->pw_gid);
setuid(pw->pw_uid);
if (setgid(pw->pw_gid) != 0)
err(1, "setgid()");
if (setuid(pw->pw_uid) != 0)
err(1, "setuid()");
} else {
setgid(UNPRIV_UGID);
setuid(UNPRIV_UGID);
if (setgid(UNPRIV_UGID) != 0)
err(1, "setgid()");
if (setuid(UNPRIV_UGID) != 0)
err(1, "setuid()");
}
}