summaryrefslogtreecommitdiff
path: root/x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c
diff options
context:
space:
mode:
Diffstat (limited to 'x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c')
-rw-r--r--x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c159
1 files changed, 159 insertions, 0 deletions
diff --git a/x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c b/x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c
new file mode 100644
index 0000000..4c805e1
--- /dev/null
+++ b/x11/gtk+2/patches/patch-gtk_gtkmountoperation-x11_c
@@ -0,0 +1,159 @@
1From 7d8be1c1ffc31523e2de09d4829169b78dd391e4 Mon Sep 17 00:00:00 2001
2From: Antoine Jacoutot <ajacoutot@openbsd.org>
3Date: Fri, 17 May 2019 11:55:16 +0000
4Subject: [PATCH] pid_get_parent: fix potential leak of kp
5
6From 0334ea1c889331adb02d361670e24b3f85b5b0d6 Mon Sep 17 00:00:00 2001
7From: Antoine Jacoutot <ajacoutot@gnome.org>
8Date: Mon, 13 May 2019 20:47:46 +0200
9Subject: [PATCH] pid_get_parent: fix for OpenBSD
10
11From ad9da2727d3e3243fd052c9feb0c55645e87d384 Mon Sep 17 00:00:00 2001
12From: Jonathan Matthew <jmatthew@openbsd.org>
13Date: Fri, 8 Jul 2011 10:24:32 +1000
14Subject: GMountOperation::show-processes support for OpenBSD using kvm(3)
15
16From 3d165c1a902fc0a5f32898e406a79e53ed4bcc97 Mon Sep 17 00:00:00 2001
17From: Antoine Jacoutot <ajacoutot@openbsd.org>
18Date: Tue, 20 Sep 2011 11:57:49 +0200
19Subject: gtkmountoperation-x11: unbreak compilation on OpenBSD.
20
21From d987a01d80126ee351727d1603a599c4edb66eca Mon Sep 17 00:00:00 2001
22From: Antoine Jacoutot <ajacoutot@openbsd.org>
23Date: Sat, 15 Oct 2011 11:27:47 +0200
24Subject: GMountOperation on OpenBSD: remove the need for kvm(3)
25
26From 974212ec825d8d50bdea8ab955b6f19b8ed1672f Mon Sep 17 00:00:00 2001
27From: Antoine Jacoutot <ajacoutot@gnome.org>
28Date: Mon, 9 Jul 2012 18:20:34 +0200
29Subject: OpenBSD: use G_N_ELEMENTS instead of nitems
30
31From 8935d2f123878c31af69b6c6034069ad540b13c7 Mon Sep 17 00:00:00 2001
32From: Antoine Jacoutot <ajacoutot@gnome.org>
33Date: Fri, 25 Apr 2014 14:37:59 +0200
34Subject: openbsd: properly set len for gtkmountoperation-x11
35
36Index: gtk/gtkmountoperation-x11.c
37--- gtk/gtkmountoperation-x11.c.orig
38+++ gtk/gtkmountoperation-x11.c
39@@ -43,9 +43,6 @@
40 #include <errno.h>
41
42 #if defined(__OpenBSD__)
43-#include <sys/param.h>
44-#include <kvm.h>
45-#include <fcntl.h>
46 #include <sys/sysctl.h>
47 #endif
48
49@@ -724,6 +721,110 @@ pid_get_command_line (GPid pid)
50 }
51
52 /* ---------------------------------------------------------------------------------------------------- */
53+
54+#elif defined(__OpenBSD__)
55+
56+/* ---------------------------------------------------------------------------------------------------- */
57+
58+static GPid
59+pid_get_parent (GPid pid)
60+{
61+ struct kinfo_proc *kp = NULL;
62+ size_t len;
63+ GPid ppid = 0;
64+
65+ /* fail if trying to get the parent of the init process (no such thing) */
66+ if (pid == 1)
67+ goto out;
68+
69+ int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PID, pid,
70+ sizeof(struct kinfo_proc), 0 };
71+
72+ if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
73+ goto out;
74+
75+ mib[5] = (len / sizeof(struct kinfo_proc));
76+
77+ kp = g_malloc0 (len);
78+
79+ if (sysctl (mib, G_N_ELEMENTS (mib), kp, &len, NULL, 0) < 0)
80+ goto out;
81+
82+ ppid = kp->p_ppid;
83+
84+out:
85+ if (kp)
86+ g_free (kp);
87+ return ppid;
88+}
89+
90+static gchar *
91+pid_get_env (GPid pid, const gchar *key)
92+{
93+ size_t len;
94+ char **strs;
95+ char *ret = NULL;
96+ char *end;
97+ int key_len;
98+ int i;
99+
100+ int mib[] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ENV };
101+
102+ if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
103+ return ret;
104+
105+ strs = g_malloc0 (len);
106+
107+ key_len = strlen (key);
108+
109+ if (sysctl (mib, G_N_ELEMENTS (mib), strs, &len, NULL, 0) != -1)
110+ {
111+ for (i = 0; strs[i] != NULL; i++)
112+ {
113+ if (g_str_has_prefix (strs[i], key) && (*(strs[i] + key_len) == '='))
114+ {
115+ ret = g_strdup (strs[i] + key_len + 1);
116+
117+ /* skip invalid UTF-8 */
118+ if (!g_utf8_validate (ret, -1, (const gchar **) &end))
119+ *end = '\0';
120+ break;
121+ }
122+ }
123+ }
124+
125+ g_free (strs);
126+ return ret;
127+}
128+
129+static gchar *
130+pid_get_command_line (GPid pid)
131+{
132+ size_t len;
133+ char **strs;
134+ char *ret, *end;
135+
136+ int mib[] = { CTL_KERN, KERN_PROC_ARGS, pid, KERN_PROC_ARGV };
137+
138+ if (sysctl (mib, G_N_ELEMENTS (mib), NULL, &len, NULL, 0) == -1)
139+ return NULL;
140+
141+ strs = g_malloc0 (len);
142+
143+ if (sysctl (mib, G_N_ELEMENTS (mib), strs, &len, NULL, 0) == -1) {
144+ g_free (strs);
145+ return NULL;
146+ }
147+
148+ ret = g_strjoinv (" ", strs);
149+ /* skip invalid UTF-8 */
150+ if (!g_utf8_validate (ret, -1, (const gchar **) &end))
151+ *end = '\0';
152+
153+ g_free (strs);
154+ return ret;
155+}
156+
157 #else
158
159 /* TODO: please implement for your OS - must return valid UTF-8 */