prefer geteuid() over getuid() if it is found during configure

problem reported by jsyn@
This commit is contained in:
danh 2003-02-26 15:54:17 +00:00
parent fe4682c79f
commit f40489a572
6 changed files with 76 additions and 34 deletions

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-config_h_in,v 1.1.1.1 2003/02/23 21:27:28 danh Exp $
--- config.h.in.orig Wed Feb 19 10:04:51 2003
+++ config.h.in Wed Feb 19 10:05:59 2003
$OpenBSD: patch-config_h_in,v 1.2 2003/02/26 15:54:17 danh Exp $
--- config.h.in.orig Thu Feb 13 01:31:51 2003
+++ config.h.in Tue Feb 25 23:35:24 2003
@@ -327,6 +327,9 @@
/* Define to 1 if you have the `finite' function. */
#undef HAVE_FINITE
@ -11,13 +11,21 @@ $OpenBSD: patch-config_h_in,v 1.1.1.1 2003/02/23 21:27:28 danh Exp $
/* Define to 1 if you have the `getbootfile' function. */
#undef HAVE_GETBOOTFILE
@@ -335,6 +338,9 @@
@@ -336,11 +339,17 @@
/* Define to 1 if you have the `getdtablesize' function. */
#undef HAVE_GETDTABLESIZE
+
+/* Define if you have the `getifaddrs' function. */
+#undef HAVE_GETIFADDRS
+
/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
/* Define to 1 if you have the `hstrerror' function. */
#undef HAVE_HSTRERROR

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-configure_in,v 1.1.1.1 2003/02/23 21:27:28 danh Exp $
$OpenBSD: patch-configure_in,v 1.2 2003/02/26 15:54:17 danh Exp $
--- configure.in.orig Thu Feb 13 01:28:32 2003
+++ configure.in Sun Feb 23 14:43:02 2003
+++ configure.in Tue Feb 25 23:34:59 2003
@@ -223,23 +223,17 @@ AC_CHECK_LIB(kvm, main) dnl We already
AC_CHECK_LIB(ld, nlist)
AC_CHECK_LIB(mld, nlist)
@ -33,7 +33,15 @@ $OpenBSD: patch-configure_in,v 1.1.1.1 2003/02/23 21:27:28 danh Exp $
dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
@@ -682,6 +676,8 @@ case "$host" in
@@ -665,6 +659,7 @@ case "$host" in
*-pc-cygwin*)
;;
*) AC_CHECK_FUNCS(getuid)
+ AC_CHECK_FUNCS(geteuid)
;;
esac
AC_CHECK_FUNCS(hstrerror K_open kvm_open memcpy memmove memset)
@@ -682,6 +677,8 @@ case "$host" in
;;
*-*-irix[[45]]*)
# Just a stub in "old" Irix. Idiots.

View File

@ -1,16 +1,21 @@
$OpenBSD: patch-ntpd_ntpd_c,v 1.1.1.1 2003/02/23 21:27:28 danh Exp $
--- ntpd/ntpd.c.orig Sun Feb 23 14:22:07 2003
+++ ntpd/ntpd.c Sun Feb 23 14:23:32 2003
@@ -392,7 +392,11 @@ ntpdmain(
$OpenBSD: patch-ntpd_ntpd_c,v 1.2 2003/02/26 15:54:17 danh Exp $
--- ntpd/ntpd.c.orig Sat Feb 8 18:02:39 2003
+++ ntpd/ntpd.c Tue Feb 25 23:36:19 2003
@@ -392,11 +392,16 @@ ntpdmain(
}
#endif
-#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
+/*
+ * MPE lacks the concept of root;
+ * OpenBSD can use privilege escalation via systrace.
+ */
+#if defined(HAVE_GETUID) && !defined(MPE) && !defined(__OpenBSD__)
+#if (defined(HAVE_GETUID) || defined(HAVE_GETEUID)) \
+ && !defined(MPE) /* MPE lacks the concept of root */
{
uid_t uid;
+#if defined(HAVE_GETEUID)
+ uid = geteuid();
+#else
uid = getuid();
+#endif
if (uid)
{
msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);

View File

@ -1,7 +1,7 @@
$OpenBSD: patch-config_h_in,v 1.1.1.1 2003/02/23 21:27:33 danh Exp $
$OpenBSD: patch-config_h_in,v 1.2 2003/02/26 15:54:17 danh Exp $
--- config.h.in.orig Tue Dec 31 00:02:35 2002
+++ config.h.in Sun Feb 23 12:26:38 2003
@@ -334,6 +334,9 @@
+++ config.h.in Tue Feb 25 23:26:07 2003
@@ -334,11 +334,17 @@
/* Define to 1 if you have the `getdtablesize' function. */
#undef HAVE_GETDTABLESIZE
@ -11,3 +11,11 @@ $OpenBSD: patch-config_h_in,v 1.1.1.1 2003/02/23 21:27:33 danh Exp $
/* Define to 1 if you have the `getrusage' function. */
#undef HAVE_GETRUSAGE
/* Define to 1 if you have the `getuid' function. */
#undef HAVE_GETUID
+
+/* Define to 1 if you have the `geteuid' function. */
+#undef HAVE_GETEUID
/* Define to 1 if you have the `hstrerror' function. */
#undef HAVE_HSTRERROR

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-configure_in,v 1.1.1.1 2003/02/23 21:27:33 danh Exp $
$OpenBSD: patch-configure_in,v 1.2 2003/02/26 15:54:17 danh Exp $
--- configure.in.orig Mon Dec 30 23:58:34 2002
+++ configure.in Sun Feb 23 15:23:43 2003
+++ configure.in Tue Feb 25 23:25:37 2003
@@ -199,23 +199,16 @@ AC_CHECK_LIB(kvm, main) dnl We already
AC_CHECK_LIB(ld, nlist)
AC_CHECK_LIB(mld, nlist)
@ -32,7 +32,15 @@ $OpenBSD: patch-configure_in,v 1.1.1.1 2003/02/23 21:27:33 danh Exp $
dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
@@ -620,6 +613,8 @@ case "$host" in
@@ -603,6 +596,7 @@ case "$host" in
*-pc-cygwin*)
;;
*) AC_CHECK_FUNCS(getuid)
+ AC_CHECK_FUNCS(geteuid)
;;
esac
AC_CHECK_FUNCS(hstrerror K_open kvm_open memcpy memmove memset)
@@ -620,6 +614,8 @@ case "$host" in
;;
*-*-irix[[45]]*)
# Just a stub in "old" Irix. Idiots.

View File

@ -1,16 +1,21 @@
$OpenBSD: patch-ntpd_ntpd_c,v 1.1.1.1 2003/02/23 21:27:33 danh Exp $
--- ntpd/ntpd.c.orig Sun Feb 23 15:21:42 2003
+++ ntpd/ntpd.c Sun Feb 23 15:22:48 2003
@@ -361,7 +361,11 @@ ntpdmain(
$OpenBSD: patch-ntpd_ntpd_c,v 1.2 2003/02/26 15:54:17 danh Exp $
--- ntpd/ntpd.c.orig Fri Jun 28 01:55:53 2002
+++ ntpd/ntpd.c Tue Feb 25 23:29:29 2003
@@ -361,11 +361,16 @@ ntpdmain(
}
#endif
-#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
+ /*
+ * MPE lacks the concept of root;
+ * OpenBSD can use privilege escalation via systrace.
+ */
+#if defined(HAVE_GETUID) && !defined(MPE) && !defined(__OpenBSD__)
+#if (defined(HAVE_GETUID) || defined(HAVE_GETEUID)) \
+ && !defined(MPE) /* MPE lacks the concept of root */
{
uid_t uid;
+#if defined(HAVE_GETEUID)
+ uid = geteuid();
+#else
uid = getuid();
+#endif
if (uid)
{
msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);