70 lines
1.4 KiB
Plaintext
70 lines
1.4 KiB
Plaintext
$OpenBSD: patch-src_util_c,v 1.15 2014/05/09 12:59:50 ajacoutot Exp $
|
|
|
|
XXX push upstream: we don't use /proc on OpenBSD
|
|
|
|
--- src/util.c.orig Tue Oct 15 22:25:19 2013
|
|
+++ src/util.c Fri May 9 14:54:31 2014
|
|
@@ -32,11 +32,17 @@
|
|
|
|
#include <polkit/polkit.h>
|
|
|
|
+#ifdef __OpenBSD__
|
|
+#include <errno.h>
|
|
+#include <sys/sysctl.h>
|
|
+#endif
|
|
+
|
|
#include "util.h"
|
|
|
|
static gchar *
|
|
get_cmdline_of_pid (GPid pid)
|
|
{
|
|
+#ifndef __OpenBSD__
|
|
gchar *ret = NULL;
|
|
gchar *filename;
|
|
gchar *contents;
|
|
@@ -70,7 +76,29 @@ get_cmdline_of_pid (GPid pid)
|
|
out:
|
|
g_free (filename);
|
|
g_free (contents);
|
|
+#else /* OpenBSD */
|
|
+ gchar *ret = NULL;
|
|
+ gchar **strs = NULL;
|
|
+ gsize len;
|
|
+ gint mib[] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
|
|
+
|
|
+ if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
|
|
+ goto out;
|
|
|
|
+ strs = g_malloc0 (len);
|
|
+
|
|
+ if (sysctl (mib, G_N_ELEMENTS (mib), strs, &len, NULL, 0) == -1) {
|
|
+ g_warning ("failed to get command line args: %d", errno);
|
|
+ goto out;
|
|
+ }
|
|
+
|
|
+ ret = g_strjoinv (" ", strs);
|
|
+ g_strstrip (ret);
|
|
+
|
|
+out:
|
|
+ g_free (strs);
|
|
+#endif
|
|
+
|
|
return ret;
|
|
}
|
|
|
|
@@ -230,12 +258,14 @@ compat_check_exit_status (int estatus,
|
|
static void
|
|
setup_loginuid (gpointer data)
|
|
{
|
|
+#ifndef __OpenBSD__
|
|
const char *id = data;
|
|
int fd;
|
|
|
|
fd = open ("/proc/self/loginuid", O_WRONLY);
|
|
write (fd, id, strlen (id));
|
|
close (fd);
|
|
+#endif
|
|
}
|
|
|
|
gboolean
|