2001-07-12 22:27:16 -04:00
|
|
|
|
Deal with _POSIX_SAVED_IDS when relinquishing privileges
|
|
|
|
|
use MAXHOSTNAMELEN
|
|
|
|
|
|
2012-04-13 10:12:52 -04:00
|
|
|
|
$OpenBSD: patch-unix_init_c,v 1.3 2012/04/13 14:12:52 naddy Exp $
|
|
|
|
|
--- unix/init.c.orig Thu May 29 08:08:49 2003
|
|
|
|
|
+++ unix/init.c Fri Apr 13 15:54:54 2012
|
|
|
|
|
@@ -49,6 +49,10 @@
|
|
|
|
|
#if ! HAVE_GETHOSTNAME && HAVE_UNAME
|
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
|
#endif
|
|
|
|
|
+#if HAVE_GETHOSTNAME
|
|
|
|
|
+/* Get a value for MAXHOSTNAMELEN. */
|
|
|
|
|
+#include <sys/param.h>
|
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
|
|
/* Use getcwd in preference to getwd; if we have neither, we will be
|
|
|
|
|
using a getcwd replacement. */
|
|
|
|
|
@@ -209,7 +213,7 @@ usysdep_initialize (puuconf,iflags)
|
2001-07-12 22:27:16 -04:00
|
|
|
|
if (iuuconf == UUCONF_NOT_FOUND)
|
|
|
|
|
{
|
|
|
|
|
#if HAVE_GETHOSTNAME
|
|
|
|
|
- char ab[256];
|
|
|
|
|
+ char ab[MAXHOSTNAMELEN];
|
|
|
|
|
|
|
|
|
|
if (gethostname (ab, sizeof ab - 1) < 0)
|
|
|
|
|
ulog (LOG_FATAL, "gethostname: %s", strerror (errno));
|
2012-04-13 10:12:52 -04:00
|
|
|
|
@@ -271,8 +275,10 @@ usysdep_initialize (puuconf,iflags)
|
2001-07-12 22:27:16 -04:00
|
|
|
|
&& geteuid () == 0)
|
|
|
|
|
{
|
|
|
|
|
q = getpwnam (OWNER);
|
|
|
|
|
- if (q != NULL)
|
|
|
|
|
+ if (q != NULL) {
|
|
|
|
|
+ seteuid (q->pw_uid);
|
|
|
|
|
setuid (q->pw_uid);
|
|
|
|
|
+ }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ((iflags & INIT_GETCWD) != 0)
|
2012-04-13 10:12:52 -04:00
|
|
|
|
@@ -370,8 +376,10 @@ usysdep_exit (fsuccess)
|
2001-07-12 22:27:16 -04:00
|
|
|
|
boolean fsysdep_other_config (z)
|
2003-12-13 20:39:18 -05:00
|
|
|
|
const char *z ATTRIBUTE_UNUSED;
|
2001-07-12 22:27:16 -04:00
|
|
|
|
{
|
|
|
|
|
- (void) setuid (getuid ());
|
|
|
|
|
+ (void) setegid (getgid ());
|
|
|
|
|
(void) setgid (getgid ());
|
|
|
|
|
+ (void) seteuid (getuid ());
|
|
|
|
|
+ (void) setuid (getuid ());
|
|
|
|
|
return TRUE;
|
|
|
|
|
}
|
|
|
|
|
|