openbsd-ports/net/uucp/patches/patch-unix_init_c

41 lines
1.1 KiB
Plaintext
Raw Normal View History

Deal with _POSIX_SAVED_IDS when relinquishing privileges
use MAXHOSTNAMELEN
2003-12-13 20:39:18 -05:00
$OpenBSD: patch-unix_init_c,v 1.2 2003/12/14 01:39:18 naddy Exp $
--- unix/init.c.orig 2003-05-29 08:08:49.000000000 +0200
+++ unix/init.c 2003-11-11 21:28:58.000000000 +0100
@@ -209,7 +209,8 @@ usysdep_initialize (puuconf,iflags)
if (iuuconf == UUCONF_NOT_FOUND)
{
#if HAVE_GETHOSTNAME
- char ab[256];
+#include <sys/param.h>
+ char ab[MAXHOSTNAMELEN];
if (gethostname (ab, sizeof ab - 1) < 0)
ulog (LOG_FATAL, "gethostname: %s", strerror (errno));
2003-12-13 20:39:18 -05:00
@@ -271,8 +272,10 @@ usysdep_initialize (puuconf,iflags)
&& geteuid () == 0)
{
q = getpwnam (OWNER);
- if (q != NULL)
+ if (q != NULL) {
+ seteuid (q->pw_uid);
setuid (q->pw_uid);
+ }
}
if ((iflags & INIT_GETCWD) != 0)
2003-12-13 20:39:18 -05:00
@@ -370,8 +373,10 @@ usysdep_exit (fsuccess)
boolean fsysdep_other_config (z)
2003-12-13 20:39:18 -05:00
const char *z ATTRIBUTE_UNUSED;
{
- (void) setuid (getuid ());
+ (void) setegid (getgid ());
(void) setgid (getgid ());
+ (void) seteuid (getuid ());
+ (void) setuid (getuid ());
return TRUE;
}