From ae749f8e80d4e6f1170a9c628011d93f837d9b6c Mon Sep 17 00:00:00 2001 From: simon Date: Sat, 23 Apr 2011 13:42:03 +0000 Subject: 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 --- usr.sbin/rwhod/rwhod.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'usr.sbin/rwhod') 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) { -- cgit v1.1