openbsd-ports/net/ircd-hybrid/patches/patch-src_ircd_c
2012-11-05 23:45:30 +00:00

34 lines
820 B
Plaintext

$OpenBSD: patch-src_ircd_c,v 1.3 2012/11/05 23:45:30 brad Exp $
--- src/ircd.c.orig Sat Jul 21 16:39:18 2012
+++ src/ircd.c Sat Jul 21 18:03:14 2012
@@ -132,7 +132,6 @@ make_daemon(void)
}
else if (pid > 0)
{
- print_startup(pid);
exit(EXIT_SUCCESS);
}
@@ -482,8 +481,19 @@ main(int argc, char *argv[])
*/
if (geteuid() == 0)
{
- fprintf(stderr, "Don't run ircd as root!!!\n");
- return -1;
+ struct passwd *pw;
+
+ if ((pw = getpwnam(IRCD_USER)) == NULL)
+ {
+ fprintf(stderr, "Don't run ircd as root!!!\n");
+ return -1;
+ }
+
+ if (setusercontext(NULL, pw, pw->pw_uid, LOGIN_SETALL) < 0)
+ {
+ fprintf(stderr, "Can's set user context to %s!\n", IRCD_USER);
+ return -1;
+ }
}
/* Setup corefile size immediately after boot -kre */