$OpenBSD: patch-ntpd_ntpd_c,v 1.2 2006/01/24 19:58:58 sturm Exp $
--- ntpd/ntpd.c.orig	Wed Feb 25 06:58:13 2004
+++ ntpd/ntpd.c	Tue Jan 24 20:53:43 2006
@@ -399,11 +399,16 @@ ntpdmain(
 	}
 #endif
 
-#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
+#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);
@@ -881,7 +886,7 @@ getuser:	
 			} else {
 getgroup:	
 				if ((gr = getgrnam(group)) != NULL) {
-					sw_gid = pw->pw_gid;
+					sw_gid = gr->gr_gid;
 				} else {
 					errno = 0;
 					msyslog(LOG_ERR, "Cannot find group `%s'", group);
