$OpenBSD: patch-sysdeps_openbsd_open_c,v 1.4 2014/02/03 13:50:32 ajacoutot Exp $

RM at next release.

--- sysdeps/openbsd/open.c.orig	Sat Jul 27 14:40:23 2013
+++ sysdeps/openbsd/open.c	Sun Feb  2 12:54:19 2014
@@ -22,74 +22,17 @@
 */
 
 #include <config.h>
+#include <sys/types.h>
 #include <glibtop.h>
-#include <glibtop/error.h>
 #include <glibtop/open.h>
-#include <glibtop/init_hooks.h>
 
-/* !!! THIS FUNCTION RUNS SUID ROOT - CHANGE WITH CAUTION !!! */
+#include <glibtop_private.h>
 
-void
-glibtop_init_p (glibtop *server, const unsigned long features,
-		const unsigned flags)
-{
-	const _glibtop_init_func_t *init_fkt;
 
-	if (server == NULL)
-		glibtop_error_r (NULL, "glibtop_init_p (server == NULL)");
-
-	/* Do the initialization, but only if not already initialized. */
-
-	if ((server->flags & _GLIBTOP_INIT_STATE_SYSDEPS) == 0) {
-		glibtop_open_p (server, "glibtop", features, flags);
-
-		for (init_fkt = _glibtop_init_hook_p; *init_fkt; init_fkt++)
-			(*init_fkt) (server);
-
-		server->flags |= _GLIBTOP_INIT_STATE_SYSDEPS;
-	}
-}
-
 void
-glibtop_open_p (glibtop *server, const char *program_name,
+glibtop_open_s (glibtop *server, const char *program_name,
 		const unsigned long features,
 		const unsigned flags)
 {
-#ifdef DEBUG
-	fprintf (stderr, "DEBUG (%d): glibtop_open_p ()\n", getpid ());
-#endif
-
-	/* !!! WE ARE ROOT HERE - CHANGE WITH CAUTION !!! */
-
-	server->machine.uid = getuid ();
-	server->machine.euid = geteuid ();
-	server->machine.gid = getgid ();
-	server->machine.egid = getegid ();
-
 	server->os_version_code = OpenBSD;
-
-	/* Setup machine-specific data */
-	server->machine.kd = kvm_open (NULL, NULL, NULL, O_RDONLY, "kvm_open");
-
-	if (server->machine.kd == NULL)
-		glibtop_error_io_r (server, "kvm_open");
-
-	/* Drop priviledges. */
-
-	if (setreuid (server->machine.euid, server->machine.uid))
-		_exit (1);
-
-	if (setregid (server->machine.egid, server->machine.gid))
-		_exit (1);
-
-	/* !!! END OF SUID ROOT PART !!! */
-
-	/* Our effective uid is now those of the user invoking the server,
-	 * so we do no longer have any priviledges. */
-
-	/* NOTE: On FreeBSD, we do not need to be suid root, we just need to
-	 * be sgid kmem.
-	 *
-	 * The server will only use setegid() to get back it's priviledges,
-	 * so it will fail if it is suid root and not sgid kmem. */
 }
