diff options
author | simon <simon@FreeBSD.org> | 2011-04-23 13:42:03 +0000 |
---|---|---|
committer | simon <simon@FreeBSD.org> | 2011-04-23 13:42:03 +0000 |
commit | ae749f8e80d4e6f1170a9c628011d93f837d9b6c (patch) | |
tree | d8c506ff035345dc353c055df31925a12849db14 | |
parent | 5cb5f5de18dbcc0e7a5fcc9fffe53bc388328ecb (diff) | |
download | FreeBSD-src-ae749f8e80d4e6f1170a9c628011d93f837d9b6c.zip FreeBSD-src-ae749f8e80d4e6f1170a9c628011d93f837d9b6c.tar.gz |
Check return code of setuid(), setgid(), and setgroups() in rwhod.
While they will not fail in normal circumstances, better safe than
sorry.
MFC after: 1 week
-rw-r--r-- | usr.sbin/rwhod/rwhod.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.sbin/rwhod/rwhod.c b/usr.sbin/rwhod/rwhod.c index 6b63843..30cc2cf 100644 --- a/usr.sbin/rwhod/rwhod.c +++ b/usr.sbin/rwhod/rwhod.c @@ -248,9 +248,18 @@ main(int argc, char *argv[]) syslog(LOG_ERR, "bind: %m"); exit(1); } - setgid(unpriv_gid); - setgroups(1, &unpriv_gid); /* XXX BOGUS groups[0] = egid */ - setuid(unpriv_uid); + if (setgid(unpriv_gid) != 0) { + syslog(LOG_ERR, "setgid: %m"); + exit(1); + } + if (setgroups(1, &unpriv_gid) != 0) { /* XXX BOGUS groups[0] = egid */ + syslog(LOG_ERR, "setgroups: %m"); + exit(1); + } + if (setuid(unpriv_uid) != 0) { + syslog(LOG_ERR, "setuid: %m"); + exit(1); + } if (!configure(s)) exit(1); if (!quiet_mode) { |