41 lines
1.1 KiB
Plaintext
41 lines
1.1 KiB
Plaintext
|
Deal with _POSIX_SAVED_IDS when relinquishing privileges
|
|||
|
use MAXHOSTNAMELEN
|
|||
|
|
|||
|
$OpenBSD: patch-unix_init_c,v 1.1.1.1 2001/07/13 02:27:16 fgsch Exp $
|
|||
|
--- unix/init.c.orig Sun Aug 20 15:30:24 1995
|
|||
|
+++ unix/init.c Thu Jul 12 21:56:10 2001
|
|||
|
@@ -210,7 +210,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));
|
|||
|
@@ -272,8 +273,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)
|
|||
|
@@ -371,8 +374,10 @@ usysdep_exit (fsuccess)
|
|||
|
boolean fsysdep_other_config (z)
|
|||
|
const char *z;
|
|||
|
{
|
|||
|
- (void) setuid (getuid ());
|
|||
|
+ (void) setegid (getgid ());
|
|||
|
(void) setgid (getgid ());
|
|||
|
+ (void) seteuid (getuid ());
|
|||
|
+ (void) setuid (getuid ());
|
|||
|
return TRUE;
|
|||
|
}
|
|||
|
|