Debian Codegraph @

src/xdp-utils.c

raw symbols SCIP
1 /*
2 * Copyright © 2014 Red Hat, Inc
3 *
4 * SPDX-License-Identifier: LGPL-2.1-or-later
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Authors:
20 * Alexander Larsson <[email protected]>
21 */
22
23 #include "config.h"cxx . . $ `<file>/build/config.h`/
24
25 #include <json-glib/json-glib.h>
26
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <stdint.h>
30 #include <stdio.h>
31 #include <string.h>
32
33 #include <gio/gio.h>
34 #include <gio/gunixoutputstream.h>
35
36 #include "xdp-utils.h"cxx . . $ `<file>/src/xdp-utils.h`/
37
38 #define DBUS_NAME_DBUScxx . . $ `src/xdp-utils.c:38:9`! "org.freedesktop.DBus"
39 #define DBUS_INTERFACE_DBUScxx . . $ `src/xdp-utils.c:39:9`! DBUS_NAME_DBUScxx . . $ `src/xdp-utils.c:38:9`!
40 #define DBUS_PATH_DBUScxx . . $ `src/xdp-utils.c:40:9`! "/org/freedesktop/DBus"
41
42 /* Based on g_mkstemp from glib */
43 gintcxx . . $ gint#
44 xdp_mkstempatcxx . . $ xdp_mkstempat(711c6947cb9bcc7a). (int dir_fd,
45 gcharcxx . . $ gchar# *tmpl,
46 int flags,
47 int mode)
48 {
49 char *XXXXXX;
50 int count, fd;
51 static const char letters[] =
52 "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
53 static const int NLETTERS = sizeof (letters) - 1;
54 gint64cxx . . $ gint64# value;
55 gint64cxx . . $ gint64# current_time;
56 static int counter = 0;
57
58 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (tmpl != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, -1);
59
60 /* find the last occurrence of "XXXXXX" */
61 XXXXXX = g_strrstrcxx . . $ g_strrstr(a713fe7b9a57cf96). (tmpl, "XXXXXX");
62
63 if (!XXXXXX || strncmpcxx . . $ strncmp(fd278af2f295fa2e). (XXXXXX, "XXXXXX", 6))
64 {
65 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EINVALcxx . . $ `<external>/8987895939074593727/errno-base.h:26:9`!;
66 return -1;
67 }
68
69 /* Get some more or less random data. */
70 current_time = g_get_real_timecxx . . $ g_get_real_time(da6335ded91d79c2). ();
71 value = ((current_time % G_USEC_PER_SECcxx . . $ `<external>/15991247088948160287/gtimer.h:44:9`!) ^ (current_time / G_USEC_PER_SECcxx . . $ `<external>/15991247088948160287/gtimer.h:44:9`!)) + counter++;
72
73 for (count = 0; count < 100; value += 7777, ++count)
74 {
75 gint64cxx . . $ gint64# v = value;
76
77 /* Fill in the random bits. */
78 XXXXXX[0] = letters[v % NLETTERS];
79 v /= NLETTERS;
80 XXXXXX[1] = letters[v % NLETTERS];
81 v /= NLETTERS;
82 XXXXXX[2] = letters[v % NLETTERS];
83 v /= NLETTERS;
84 XXXXXX[3] = letters[v % NLETTERS];
85 v /= NLETTERS;
86 XXXXXX[4] = letters[v % NLETTERS];
87 v /= NLETTERS;
88 XXXXXX[5] = letters[v % NLETTERS];
89
90 fd = openatcxx . . $ openat(5e925858040f3251). (dir_fd, tmpl, flags | O_CREATcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:47:10`! | O_EXCLcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:50:10`!, mode);
91
92 if (fd >= 0)
93 return fd;
94 else if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!)
95 /* Any other error will apply also to other names we might
96 * try, and there are 2^32 or so of them, so give up now.
97 */
98 return -1;
99 }
100
101 /* We got out of the loop because we ran out of combinations to try. */
102 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = EEXISTcxx . . $ `<external>/8987895939074593727/errno-base.h:21:9`!;
103 return -1;
104 }
105
106 static gbooleancxx . . $ gboolean#
107 needs_quotingcxx . . $ needs_quoting(5c4306d8553b3696). (const char *arg)
108 {
109 while (*arg != 0)
110 {
111 char c = *arg;
112 if (!g_ascii_isalnumcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:61:9`! (c) &&
113 !(c == '-' || c == '/' || c == '~' ||
114 c == ':' || c == '.' || c == '_' ||
115 c == '=' || c == '@'))
116 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
117 arg++;
118 }
119 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
120 }
121
122 static void
123 name_owner_changedcxx . . $ name_owner_changed(72eba080aa42f612). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
124 const gcharcxx . . $ gchar# *sender_name,
125 const gcharcxx . . $ gchar# *object_path,
126 const gcharcxx . . $ gchar# *interface_name,
127 const gcharcxx . . $ gchar# *signal_name,
128 GVariantcxx . . $ GVariant# *parameters,
129 gpointercxx . . $ gpointer# user_data)
130 {
131 const char *name, *from, *to;
132 XdpPeerDiedCallbackcxx . . $ XdpPeerDiedCallback# peer_died_cb = user_data;
133
134 if (!peer_died_cb)
135 return;
136
137 g_variant_getcxx . . $ g_variant_get(671e9cd8f09cd612). (parameters, "(&s&s&s)", &name, &from, &to);
138
139 if (name[0] != ':' ||
140 strcmpcxx . . $ strcmp(5ae29d726ae57f88). (name, from) != 0 ||
141 strcmpcxx . . $ strcmp(5ae29d726ae57f88). (to, "") != 0)
142 return;
143
144 peer_died_cb (name);
145 }
146
147 void
148 xdp_connection_track_name_ownerscxx . . $ xdp_connection_track_name_owners(ab8c569ccc4a109e). (GDBusConnectioncxx . . $ GDBusConnection# *connection,
149 XdpPeerDiedCallbackcxx . . $ XdpPeerDiedCallback# peer_died_cb)
150 {
151 g_dbus_connection_signal_subscribecxx . . $ g_dbus_connection_signal_subscribe(a9766be2c69144e0). (connection,
152 DBUS_NAME_DBUScxx . . $ `src/xdp-utils.c:38:9`!,
153 DBUS_INTERFACE_DBUScxx . . $ `src/xdp-utils.c:39:9`!,
154 "NameOwnerChanged",
155 DBUS_PATH_DBUScxx . . $ `src/xdp-utils.c:40:9`!,
156 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
157 G_DBUS_SIGNAL_FLAGS_NONEcxx . . $ G_DBUS_SIGNAL_FLAGS_NONE.,
158 name_owner_changedcxx . . $ name_owner_changed(72eba080aa42f612).,
159 peer_died_cb, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
160 }
161
162 gbooleancxx . . $ gboolean#
163 xdp_filter_optionscxx . . $ xdp_filter_options(d63f67045969ba55). (GVariantcxx . . $ GVariant# *options,
164 GVariantBuildercxx . . $ GVariantBuilder# *filtered,
165 const XdpOptionKeycxx . . $ XdpOptionKey# *supported_options,
166 int n_supported_options,
167 GErrorcxx . . $ GError# **error)
168 {
169 int i;
170 gbooleancxx . . $ gboolean# ret = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
171
172 for (i = 0; i < n_supported_options; i++)
173 {
174 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) value = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
175
176 value = g_variant_lookup_valuecxx . . $ g_variant_lookup_value(4ff0ed89f370fedc). (options,
177 supported_options[i].keycxx . . $ $anonymous_type_8e225346ad0b2bac_1#key.,
178 supported_options[i].typecxx . . $ $anonymous_type_8e225346ad0b2bac_1#type.);
179 if (!value)
180 {
181 value = g_variant_lookup_valuecxx . . $ g_variant_lookup_value(4ff0ed89f370fedc). (options, supported_options[i].keycxx . . $ $anonymous_type_8e225346ad0b2bac_1#key., NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
182 if (value)
183 {
184 if (error && *error == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
185 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, XDG_DESKTOP_PORTAL_ERRORcxx . . $ `src/xdp-utils.h:98:9`!, XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENTcxx . . $ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT.,
186 "Expected type '%s' for option '%s', got '%s'",
187 g_variant_type_peek_stringcxx . . $ g_variant_type_peek_string(55c94811bc4a70dd). (supported_options[i].typecxx . . $ $anonymous_type_8e225346ad0b2bac_1#type.),
188 supported_options[i].keycxx . . $ $anonymous_type_8e225346ad0b2bac_1#key.,
189 g_variant_type_peek_stringcxx . . $ g_variant_type_peek_string(55c94811bc4a70dd). (g_variant_get_typecxx . . $ g_variant_get_type(29884eeeb88ad977). (value)));
190 ret = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
191 }
192
193 continue;
194 }
195
196 if (supported_options[i].validatecxx . . $ $anonymous_type_8e225346ad0b2bac_1#validate.)
197 {
198 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) local_error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
199
200 if (!supported_options[i].validatecxx . . $ $anonymous_type_8e225346ad0b2bac_1#validate. (supported_options[i].keycxx . . $ $anonymous_type_8e225346ad0b2bac_1#key., value, options, &local_error))
201 {
202 if (error && *error == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
203 g_propagate_errorcxx . . $ g_propagate_error(902e08a176509aff). (error, g_steal_pointercxx . . $ `<external>/1123956534522462559/gmem.h:250:9`! (&local_error));
204 ret = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
205
206 continue;
207 }
208 }
209
210 g_variant_builder_addcxx . . $ g_variant_builder_add(a422658e2ec2035a). (filtered, "{sv}", supported_options[i].keycxx . . $ $anonymous_type_8e225346ad0b2bac_1#key., value);
211 }
212
213 return ret;
214 }
215
216 static const GDBusErrorEntrycxx . . $ GDBusErrorEntry# xdg_desktop_portal_error_entriescxx . . $ xdg_desktop_portal_error_entries.[] = {
217 { XDG_DESKTOP_PORTAL_ERROR_FAILEDcxx . . $ XDG_DESKTOP_PORTAL_ERROR_FAILED., "org.freedesktop.portal.Error.Failed" },
218 { XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENTcxx . . $ XDG_DESKTOP_PORTAL_ERROR_INVALID_ARGUMENT., "org.freedesktop.portal.Error.InvalidArgument" },
219 { XDG_DESKTOP_PORTAL_ERROR_NOT_FOUNDcxx . . $ XDG_DESKTOP_PORTAL_ERROR_NOT_FOUND., "org.freedesktop.portal.Error.NotFound" },
220 { XDG_DESKTOP_PORTAL_ERROR_EXISTScxx . . $ XDG_DESKTOP_PORTAL_ERROR_EXISTS., "org.freedesktop.portal.Error.Exists" },
221 { XDG_DESKTOP_PORTAL_ERROR_NOT_ALLOWEDcxx . . $ XDG_DESKTOP_PORTAL_ERROR_NOT_ALLOWED., "org.freedesktop.portal.Error.NotAllowed" },
222 { XDG_DESKTOP_PORTAL_ERROR_CANCELLEDcxx . . $ XDG_DESKTOP_PORTAL_ERROR_CANCELLED., "org.freedesktop.portal.Error.Cancelled" },
223 { XDG_DESKTOP_PORTAL_ERROR_WINDOW_DESTROYEDcxx . . $ XDG_DESKTOP_PORTAL_ERROR_WINDOW_DESTROYED., "org.freedesktop.portal.Error.WindowDestroyed" }
224 };
225
226 GQuarkcxx . . $ GQuark#
227 xdg_desktop_portal_error_quarkcxx . . $ xdg_desktop_portal_error_quark(db52760e79bf9054). (void)
228 {
229 static volatile gsizecxx . . $ gsize# quark_volatile = 0;
230
231 g_dbus_error_register_error_domaincxx . . $ g_dbus_error_register_error_domain(970625dfbce980e9). ("xdg-desktop-portal-error-quark",
232 &quark_volatile,
233 xdg_desktop_portal_error_entriescxx . . $ xdg_desktop_portal_error_entries.,
234 G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (xdg_desktop_portal_error_entries));
235 return (GQuarkcxx . . $ GQuark#) quark_volatile;
236 }
237
238 static char *documents_mountpointcxx . . $ documents_mountpoint. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
239
240 void
241 xdp_set_documents_mountpointcxx . . $ xdp_set_documents_mountpoint(85c52e162fed56f9). (const char *path)
242 {
243 g_clear_pointercxx . . $ `<external>/1123956534522462559/gmem.h:135:9`! (&documents_mountpoint, g_free);
244 documents_mountpointcxx . . $ documents_mountpoint. = g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (path);
245 }
246
247 const char *
248 xdp_get_documents_mountpointcxx . . $ xdp_get_documents_mountpoint(33a1f659e94feb42). (void)
249 {
250 return documents_mountpointcxx . . $ documents_mountpoint.;
251 }
252
253 /* alternate_document_path converts a file path */
254 char *
255 xdp_get_alternate_document_pathcxx . . $ xdp_get_alternate_document_path(a713fe7b9a57cf96). (const char *path,
256 const char *app_id)
257 {
258 int len;
259
260 if (g_str_equalcxx . . $ `<external>/7714589265505779806/ghash.h:175:9`! (app_id, ""))
261 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
262
263 /* If we don't know where the document portal is mounted, then there
264 * is no alternate path */
265 if (documents_mountpointcxx . . $ documents_mountpoint. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
266 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
267
268 /* If the path is not within the document portal, then there is no
269 * alternative path */
270 len = strlencxx . . $ strlen(751346f8406fd082). (documents_mountpointcxx . . $ documents_mountpoint.);
271 if (!g_str_has_prefixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:159:9`! (path, documents_mountpoint) || path[len] != '/')
272 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
273
274 return g_strconcatcxx . . $ g_strconcat(a849077ff1b8d812). (documents_mountpointcxx . . $ documents_mountpoint., "/by-app/", app_id, &path[len], NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
275 }
276
277 static gbooleancxx . . $ gboolean#
278 is_valid_name_charactercxx . . $ is_valid_name_character(9b79fb6aee4c0440). (gintcxx . . $ gint# c, gbooleancxx . . $ gboolean# allow_dash)
279 {
280 return
281 (c >= 'A' && c <= 'Z') ||
282 (c >= 'a' && c <= 'z') ||
283 (c >= '0' && c <= '9') ||
284 (c == '_') || (allow_dash && c == '-');
285 }
286
287 /* This is the same as flatpak apps, except we also allow
288 names to start with digits, and two-element names so that ids of the form
289 snap.$snapname is allowed for all snap names. */
290 gbooleancxx . . $ gboolean#
291 xdp_is_valid_app_idcxx . . $ xdp_is_valid_app_id(5c4306d8553b3696). (const char *string)
292 {
293 guintcxx . . $ guint# len;
294 const gcharcxx . . $ gchar# *s;
295 const gcharcxx . . $ gchar# *end;
296 const gcharcxx . . $ gchar# *last_dot;
297 int dot_count;
298 gbooleancxx . . $ gboolean# last_element;
299
300 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (string != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
301
302 len = strlencxx . . $ strlen(751346f8406fd082). (string);
303 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (len == 0))
304 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
305
306 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (len > 255))
307 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
308
309 end = string + len;
310
311 last_dot = strrchrcxx . . $ strrchr(2050848944e00d54). (string, '.');
312 last_element = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
313
314 s = string;
315 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (*s == '.'))
316 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!; /* Name can't start with a period */
317
318 dot_count = 0;
319 while (s != end)
320 {
321 if (*s == '.')
322 {
323 if (s == last_dot)
324 last_element = TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
325 s += 1;
326 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (s == end))
327 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
328 dot_count++;
329 }
330
331 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (!is_valid_name_character (*s, last_element)))
332 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
333 s += 1;
334 }
335
336 if (G_UNLIKELYcxx . . $ `<external>/12741050725406041920/gmacros.h:1288:9`! (dot_count < 1))
337 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
338
339 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
340 }
341
342 char *
343 xdp_get_app_id_from_desktop_idcxx . . $ xdp_get_app_id_from_desktop_id(a8b8e32347182212). (const char *desktop_id)
344 {
345 const gcharcxx . . $ gchar# *suffix = ".desktop";
346 if (g_str_has_suffixcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:183:9`! (desktop_id, suffix))
347 return g_strndupcxx . . $ g_strndup(eabdfdef77619b3d). (desktop_id, strlencxx . . $ strlen(751346f8406fd082). (desktop_id) - strlencxx . . $ strlen(751346f8406fd082). (suffix));
348 else
349 return g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (desktop_id);
350 }
351
352 char *
353 xdp_maybe_quotecxx . . $ xdp_maybe_quote(2050848944e00d54). (const char *arg,
354 gbooleancxx . . $ gboolean# quote_escape)
355 {
356 if (quote_escape && needs_quotingcxx . . $ needs_quoting(5c4306d8553b3696). (arg))
357 return g_shell_quotecxx . . $ g_shell_quote(a8b8e32347182212). (arg);
358 else
359 return g_strdupcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:324:9`! (arg);
360 }
361
362 char *
363 xdp_maybe_quote_argvcxx . . $ xdp_maybe_quote_argv(ad8dedb09956fee3). (const char *argv[],
364 gbooleancxx . . $ gboolean# quote_escape)
365 {
366 GStringcxx . . $ GString# *res = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). ("");
367 int i;
368
369 for (i = 0; argv[i] != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; i++)
370 {
371 if (i != 0)
372 g_string_append_ccxx . . $ `<external>/2906017559248664336/gstring.h:215:9`! (res, ' ');
373
374 if (quote_escape && needs_quotingcxx . . $ needs_quoting(5c4306d8553b3696). (argv[i]))
375 {
376 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *quoted = g_shell_quotecxx . . $ g_shell_quote(a8b8e32347182212). (argv[i]);
377 g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (res, quoted);
378 }
379 else
380 g_string_appendcxx . . $ `<external>/2906017559248664336/gstring.h:270:9`! (res, argv[i]);
381 }
382
383 return g_string_freecxx . . $ g_string_free(7da339bd3f7b00e8). (res, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
384 }
385
386 typedef structcxx . . $ $anonymous_type_f2f4806bd856827d_0#
387 {
388 GErrorcxx . . $ GError# *errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#error.;
389 GErrorcxx . . $ GError# *splice_errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#splice_error.;
390 GMainLoopcxx . . $ GMainLoop# *loopcxx . . $ $anonymous_type_f2f4806bd856827d_0#loop.;
391 int refscxx . . $ $anonymous_type_f2f4806bd856827d_0#refs.;
392 } SpawnDatacxx . . $ SpawnData#;
393
394 static void
395 spawn_data_exitcxx . . $ spawn_data_exit(3dd90fa6288c8698). (SpawnDatacxx . . $ SpawnData# *data)
396 {
397 data->refscxx . . $ $anonymous_type_f2f4806bd856827d_0#refs.--;
398 if (data->refscxx . . $ $anonymous_type_f2f4806bd856827d_0#refs. == 0)
399 g_main_loop_quitcxx . . $ g_main_loop_quit(a750781b61f2e711). (data->loopcxx . . $ $anonymous_type_f2f4806bd856827d_0#loop.);
400 }
401
402 static void
403 spawn_output_spliced_cbcxx . . $ spawn_output_spliced_cb(aa1d200d824d915d). (GObjectcxx . . $ GObject# *obj,
404 GAsyncResultcxx . . $ GAsyncResult# *result,
405 gpointercxx . . $ gpointer# user_data)
406 {
407 SpawnDatacxx . . $ SpawnData# *data = user_data;
408
409 g_output_stream_splice_finishcxx . . $ g_output_stream_splice_finish(b971013a7a3f5e1). (G_OUTPUT_STREAMcxx . . $ `<external>/12960712863927311157/goutputstream.h:35:9`! (obj), result, &data->splice_errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#splice_error.);
410 spawn_data_exitcxx . . $ spawn_data_exit(3dd90fa6288c8698). (data);
411 }
412
413 static void
414 spawn_exit_cbcxx . . $ spawn_exit_cb(aa1d200d824d915d). (GObjectcxx . . $ GObject# *obj,
415 GAsyncResultcxx . . $ GAsyncResult# *result,
416 gpointercxx . . $ gpointer# user_data)
417 {
418 SpawnDatacxx . . $ SpawnData# *data = user_data;
419
420 g_subprocess_wait_check_finishcxx . . $ g_subprocess_wait_check_finish(6afbbde92822d105). (G_SUBPROCESScxx . . $ `<external>/10716612145435083613/gsubprocess.h:35:9`! (obj), result, &data->errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#error.);
421 spawn_data_exitcxx . . $ spawn_data_exit(3dd90fa6288c8698). (data);
422 }
423
424 char *
425 xdp_spawncxx . . $ xdp_spawn(7346b297b379bb8a). (GErrorcxx . . $ GError# **error,
426 const char *argv0,
427 ...)
428 {
429 GPtrArraycxx . . $ GPtrArray# *args;
430 const char *arg;
431 va_listcxx . . $ va_list# ap;
432 char *output;
433
434 va_startcxx . . $ `<external>/8105065126723003039/stdarg.h:50:9`! (ap, argv0);
435 args = g_ptr_array_newcxx . . $ g_ptr_array_new(61b5db61367ab387). ();
436 g_ptr_array_addcxx . . $ g_ptr_array_add(3cd73f70a4ada9). (args, (char *) argv0);
437 while ((arg = va_argcxx . . $ `<external>/8105065126723003039/stdarg.h:53:9`! (ap, const char *)))
438 g_ptr_array_addcxx . . $ g_ptr_array_add(3cd73f70a4ada9). (args, (char *) arg);
439 g_ptr_array_addcxx . . $ g_ptr_array_add(3cd73f70a4ada9). (args, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
440 va_endcxx . . $ `<external>/8105065126723003039/stdarg.h:52:9`! (ap);
441
442 output = xdp_spawn_fullcxx . . $ xdp_spawn_full(45b3cf19a9373672). ((const char * const *) args->pdatacxx . . $ _GPtrArray#pdata., -1, -1, error);
443
444 g_ptr_array_freecxx . . $ g_ptr_array_free(fb5c4b2755cb4a51). (args, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
445
446 return output;
447 }
448
449 char *
450 xdp_spawn_fullcxx . . $ xdp_spawn_full(45b3cf19a9373672). (const char * const *argv,
451 int source_fd,
452 int target_fd,
453 GErrorcxx . . $ GError# **error)
454 {
455 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GSubprocessLauncher) launcher = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
456 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GSubprocess) subp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
457 GInputStreamcxx . . $ GInputStream# *in;
458 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GOutputStream) out = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
459 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GMainLoop) loop = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
460 SpawnDatacxx . . $ SpawnData# data = {0};
461 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *commandline = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
462
463 launcher = g_subprocess_launcher_newcxx . . $ g_subprocess_launcher_new(b3059771d74666d1). (G_SUBPROCESS_FLAGS_STDOUT_PIPEcxx . . $ G_SUBPROCESS_FLAGS_STDOUT_PIPE.);
464
465 if (source_fd != -1)
466 g_subprocess_launcher_take_fdcxx . . $ g_subprocess_launcher_take_fd(2689994f86206350). (launcher, source_fd, target_fd);
467
468 commandline = xdp_maybe_quote_argvcxx . . $ xdp_maybe_quote_argv(ad8dedb09956fee3). ((const char **)argv, TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!);
469 g_debugcxx . . $ `<external>/5169755362661750954/gmessages.h:371:9`! ("Running: %s", commandline);
470
471 subp = g_subprocess_launcher_spawnvcxx . . $ g_subprocess_launcher_spawnv(d07f9c841b942c44). (launcher, argv, error);
472
473 if (subp == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
474 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
475
476 loop = g_main_loop_newcxx . . $ g_main_loop_new(5401090483a6c170). (NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
477
478 data.loopcxx . . $ $anonymous_type_f2f4806bd856827d_0#loop. = loop;
479 data.refscxx . . $ $anonymous_type_f2f4806bd856827d_0#refs. = 2;
480
481 in = g_subprocess_get_stdout_pipecxx . . $ g_subprocess_get_stdout_pipe(6cd50eee412f95e3). (subp);
482 out = g_memory_output_stream_new_resizablecxx . . $ g_memory_output_stream_new_resizable(937a4dd9141c33c9). ();
483 g_output_stream_splice_asynccxx . . $ g_output_stream_splice_async(e4877396f3e433df). (out,
484 in,
485 G_OUTPUT_STREAM_SPLICE_NONEcxx . . $ G_OUTPUT_STREAM_SPLICE_NONE.,
486 0,
487 NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!,
488 spawn_output_spliced_cbcxx . . $ spawn_output_spliced_cb(aa1d200d824d915d).,
489 &data);
490
491 g_subprocess_wait_asynccxx . . $ g_subprocess_wait_async(c85ae9209d2ae39d). (subp, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, spawn_exit_cbcxx . . $ spawn_exit_cb(aa1d200d824d915d)., &data);
492
493 g_main_loop_runcxx . . $ g_main_loop_run(a750781b61f2e711). (loop);
494
495 if (data.errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#error.)
496 {
497 g_propagate_errorcxx . . $ g_propagate_error(902e08a176509aff). (error, g_steal_pointercxx . . $ `<external>/1123956534522462559/gmem.h:250:9`! (&data.error));
498 g_clear_errorcxx . . $ g_clear_error(19f343512d040fc2). (&data.splice_errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#splice_error.);
499 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
500 }
501
502 if (out)
503 {
504 if (data.splice_errorcxx . . $ $anonymous_type_f2f4806bd856827d_0#splice_error.)
505 {
506 g_propagate_errorcxx . . $ g_propagate_error(902e08a176509aff). (error, g_steal_pointercxx . . $ `<external>/1123956534522462559/gmem.h:250:9`! (&data.splice_error));
507 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
508 }
509
510 /* Null terminate */
511 g_output_stream_writecxx . . $ g_output_stream_write(6a212f6d19c93115). (out, "\0", 1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
512 g_output_stream_closecxx . . $ g_output_stream_close(9a028ff89e05cae6). (out, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
513 return g_memory_output_stream_steal_datacxx . . $ g_memory_output_stream_steal_data(de1ecf9fe1ad5287). (G_MEMORY_OUTPUT_STREAMcxx . . $ `<external>/16534567971107647114/gmemoryoutputstream.h:35:9`! (out));
514 }
515
516 return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
517 }
518
519 char *
520 xdp_canonicalize_filenamecxx . . $ xdp_canonicalize_filename(a8b8e32347182212). (const char *path)
521 {
522 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GFile) file = g_file_new_for_pathcxx . . $ g_file_new_for_path(ba1fd5950b7d7bd5). (path);
523 return g_file_get_pathcxx . . $ g_file_get_path(bd69fa69840f32a9). (file);
524 }
525
526 gbooleancxx . . $ gboolean#
527 xdp_has_path_prefixcxx . . $ xdp_has_path_prefix(5ae29d726ae57f88). (const char *str,
528 const char *prefix)
529 {
530 while (TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!)
531 {
532 /* Skip consecutive slashes to reach next path
533 element */
534 while (*str == '/')
535 str++;
536 while (*prefix == '/')
537 prefix++;
538
539 /* No more prefix path elements? Done! */
540 if (*prefix == 0)
541 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
542
543 /* Compare path element */
544 while (*prefix != 0 && *prefix != '/')
545 {
546 if (*str != *prefix)
547 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
548 str++;
549 prefix++;
550 }
551
552 /* Matched prefix path element,
553 must be entire str path element */
554 if (*str != '/' && *str != 0)
555 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
556 }
557 }
558
559 #define VALIDATOR_INPUT_FDcxx . . $ `src/xdp-utils.c:559:9`! 3
560 #define ICON_VALIDATOR_GROUPcxx . . $ `src/xdp-utils.c:560:9`! "Icon Validator"
561 #define SOUND_VALIDATOR_GROUPcxx . . $ `src/xdp-utils.c:561:9`! "Sound Validator"
562
563 static const char *
564 icon_type_to_stringcxx . . $ icon_type_to_string(48aff6d3d70a0d50). (XdpIconTypecxx . . $ XdpIconType# icon_type)
565 {
566 switch (icon_type)
567 {
568 case XDP_ICON_TYPE_DESKTOPcxx . . $ XDP_ICON_TYPE_DESKTOP.:
569 return "desktop";
570
571 case XDP_ICON_TYPE_NOTIFICATIONcxx . . $ XDP_ICON_TYPE_NOTIFICATION.:
572 return "notification";
573
574 default:
575 g_assert_not_reachedcxx . . $ `<external>/15287032793271088244/gtestutils.h:274:9`! ();
576 }
577 }
578
579 gbooleancxx . . $ gboolean#
580 xdp_validate_iconcxx . . $ xdp_validate_icon(d2530f8b074c20c3). (XdpSealedFdcxx . . $ XdpSealedFd# *icon,
581 XdpIconTypecxx . . $ XdpIconType# icon_type,
582 char **out_format,
583 char **out_size)
584 {
585 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *format = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
586 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
587 const char *icon_validator = LIBEXECDIRcxx . . $ `build/config.h:36:9`! "/xdg-desktop-portal-validate-icon";
588 const char *args[7];
589 int size;
590 size_t i;
591 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *output = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
592 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GKeyFile) key_file = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
593
594 if (g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_ICON"))
595 icon_validator = g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_ICON");
596
597 if (!g_file_testcxx . . $ g_file_test(d991f72152d535bf). (icon_validator, G_FILE_TEST_EXISTScxx . . $ G_FILE_TEST_EXISTS.))
598 {
599 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Icon validation: %s not found, rejecting icon by default.", icon_validator);
600 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
601 }
602
603 i = 0;
604 args[i++] = icon_validator;
605
606 if (g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_ICON_INSECURE") == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
607 args[i++] = "--sandbox";
608
609 args[i++] = "--fd";
610 args[i++] = G_STRINGIFYcxx . . $ `<external>/12741050725406041920/gmacros.h:899:9`! (VALIDATOR_INPUT_FDcxx . . $ `src/xdp-utils.c:559:9`!);
611 args[i++] = "--ruleset";
612 args[i++] = icon_type_to_stringcxx . . $ icon_type_to_string(48aff6d3d70a0d50). (icon_type);
613 g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (args));
614 args[i++] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
615
616 output = xdp_spawn_fullcxx . . $ xdp_spawn_full(45b3cf19a9373672). (args, xdp_sealed_fd_dup_fdcxx . . $ xdp_sealed_fd_dup_fd(e41b30277faed9bf). (icon), VALIDATOR_INPUT_FDcxx . . $ `src/xdp-utils.c:559:9`!, &error);
617 if (!output)
618 {
619 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Icon validation: Rejecting icon because validator failed: %s", error->message);
620 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
621 }
622
623 key_file = g_key_file_newcxx . . $ g_key_file_new(9306a185df8cc356). ();
624 if (!g_key_file_load_from_datacxx . . $ g_key_file_load_from_data(df81ac01d9816af1). (key_file, output, -1, G_KEY_FILE_NONEcxx . . $ G_KEY_FILE_NONE., &error))
625 {
626 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Icon validation: %s", error->message);
627 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
628 }
629 if (!(format = g_key_file_get_stringcxx . . $ g_key_file_get_string(30132561f3054bb4). (key_file, ICON_VALIDATOR_GROUPcxx . . $ `src/xdp-utils.c:560:9`!, "format", &error)))
630 {
631 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Icon validation: %s", error->message);
632 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
633 }
634 if (!(size = g_key_file_get_integercxx . . $ g_key_file_get_integer(86fb9b993951271). (key_file, ICON_VALIDATOR_GROUPcxx . . $ `src/xdp-utils.c:560:9`!, "width", &error)))
635 {
636 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Icon validation: %s", error->message);
637 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
638 }
639
640 if (out_format)
641 *out_format = g_steal_pointercxx . . $ `<external>/1123956534522462559/gmem.h:250:9`! (&format);
642 if (out_size)
643 *out_size = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%d", size);
644
645 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
646 }
647
648 gbooleancxx . . $ gboolean#
649 xdp_validate_soundcxx . . $ xdp_validate_sound(e41b30277faed9bf). (XdpSealedFdcxx . . $ XdpSealedFd# *sound)
650 {
651 const char *args[5];
652 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GError) error = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
653 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GKeyFile) key_file = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
654 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *output = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
655 const char *sound_validator = LIBEXECDIRcxx . . $ `build/config.h:36:9`! "/xdg-desktop-portal-validate-sound";
656 gsizecxx . . $ gsize# i;
657
658 if (g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_SOUND"))
659 sound_validator = g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_SOUND");
660
661 if (!g_file_testcxx . . $ g_file_test(d991f72152d535bf). (sound_validator, G_FILE_TEST_EXISTScxx . . $ G_FILE_TEST_EXISTS.))
662 {
663 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Sound validation: %s not found, rejecting sound by default.", sound_validator);
664 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
665 }
666
667 i = 0;
668 args[i++] = sound_validator;
669
670 if (g_getenvcxx . . $ g_getenv(fb58d2e09a2a1ce6). ("XDP_VALIDATE_SOUND_INSECURE") == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
671 args[i++] = "--sandbox";
672
673 args[i++] = "--fd";
674 args[i++] = G_STRINGIFYcxx . . $ `<external>/12741050725406041920/gmacros.h:899:9`! (VALIDATOR_INPUT_FDcxx . . $ `src/xdp-utils.c:559:9`!);
675 g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (i < G_N_ELEMENTScxx . . $ `<external>/12741050725406041920/gmacros.h:993:9`! (args));
676 args[i++] = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
677
678 output = xdp_spawn_fullcxx . . $ xdp_spawn_full(45b3cf19a9373672). (args, xdp_sealed_fd_dup_fdcxx . . $ xdp_sealed_fd_dup_fd(e41b30277faed9bf). (sound), VALIDATOR_INPUT_FDcxx . . $ `src/xdp-utils.c:559:9`!, &error);
679 if (!output)
680 {
681 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Sound validation: Rejecting sound because validator failed: %s", error->message);
682 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
683 }
684
685 key_file = g_key_file_newcxx . . $ g_key_file_new(9306a185df8cc356). ();
686 if (!g_key_file_load_from_datacxx . . $ g_key_file_load_from_data(df81ac01d9816af1). (key_file, output, -1, G_KEY_FILE_NONEcxx . . $ G_KEY_FILE_NONE., &error))
687 {
688 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Sound validation: %s", error->message);
689 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
690 }
691
692 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
693 }
694
695 gbooleancxx . . $ gboolean#
696 xdp_variant_contains_keycxx . . $ xdp_variant_contains_key(3acb228297ef692c). (GVariantcxx . . $ GVariant# *dictionary,
697 const char *key)
698 {
699 GVariantItercxx . . $ GVariantIter# iter;
700
701 g_variant_iter_initcxx . . $ g_variant_iter_init(83d0c9c646e4f22c). (&iter, dictionary);
702 while (TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!)
703 {
704 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) entry = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
705 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GVariant) entry_key = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
706
707 entry = g_variant_iter_next_valuecxx . . $ g_variant_iter_next_value(45397e10577d0db). (&iter);
708 if (!entry)
709 break;
710
711 entry_key = g_variant_get_child_valuecxx . . $ g_variant_get_child_value(8aa5a571b04b0b30). (entry, 0);
712 if (g_strcmp0cxx . . $ g_strcmp0(5ae29d726ae57f88). (g_variant_get_stringcxx . . $ g_variant_get_string(5d5cac9792ea78b8). (entry_key, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!), key) == 0)
713 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
714 }
715
716 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
717 }
718
719 static int
720 parse_pidcxx . . $ parse_pid(7436bf38bddd805d). (const char *str,
721 pid_tcxx . . $ pid_t# *pid)
722 {
723 char *end;
724 guint64cxx . . $ guint64# v;
725 pid_tcxx . . $ pid_t# p;
726
727 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
728 v = g_ascii_strtoullcxx . . $ g_ascii_strtoull(5d2901629bb0ffe1). (str, &end, 0);
729 if (end == str)
730 return -ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!;
731 else if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0)
732 return -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
733
734 p = (pid_tcxx . . $ pid_t#) v;
735
736 if (p < 1 || (guint64cxx . . $ guint64#) p != v)
737 return -ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!;
738
739 if (pid)
740 *pid = p;
741
742 return 0;
743 }
744
745 static int
746 parse_status_field_pidcxx . . $ parse_status_field_pid(7436bf38bddd805d). (const char *val,
747 pid_tcxx . . $ pid_t# *pid)
748 {
749 const char *t;
750
751 /* Takes "Pid: 12345" */
752 t = strrchrcxx . . $ strrchr(2050848944e00d54). (val, '\t');
753 g_assertcxx . . $ `<external>/15287032793271088244/gtestutils.h:275:9`! (t);
754
755 return parse_pidcxx . . $ parse_pid(7436bf38bddd805d). (t, pid);
756 }
757
758
759 static int
760 parse_status_field_nspidcxx . . $ parse_status_field_nspid(7436bf38bddd805d). (const char *val,
761 pid_tcxx . . $ pid_t# *pid)
762 {
763 const char *t;
764
765 /* This is a tab separated list of namespaces.
766 * We only want the innermost namespace. */
767 t = strrchrcxx . . $ strrchr(2050848944e00d54). (val, '\t');
768 if (t != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
769 val = t;
770
771 return parse_pidcxx . . $ parse_pid(7436bf38bddd805d). (val, pid);
772 }
773
774 static pid_tcxx . . $ pid_t#
775 pidfd_to_pidcxx . . $ pidfd_to_pid(a0bc2edf0646dac6). (int fdinfo,
776 const int pidfd,
777 GErrorcxx . . $ GError# **error)
778 {
779 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *name = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
780 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *key = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
781 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
782 gbooleancxx . . $ gboolean# found = FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
783 FILEcxx . . $ FILE# *f = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
784 size_t keylen = 0;
785 size_t vallen = 0;
786 ssize_tcxx . . $ ssize_t# n;
787 int fd;
788 int r = 0;
789 pid_tcxx . . $ pid_t# pid = -1;
790
791 name = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("%d", pidfd);
792
793 fd = openatcxx . . $ openat(5e925858040f3251). (fdinfo, name, O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! | O_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:142:10`! | O_NOCTTYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:53:10`!);
794
795 if (fd != -1)
796 f = fdopencxx . . $ fdopen(8f4e2d7350ebd077). (fd, "r");
797
798 if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
799 {
800 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, g_io_error_from_errnocxx . . $ g_io_error_from_errno(b47e8a466716fd56). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
801 "Unable to open /proc/self/fdinfo/%d: %s",
802 fd, g_strerrorcxx . . $ g_strerror(f7ae7e56280f18ae). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
803 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
804 }
805
806 do {
807 n = getdelimcxx . . $ getdelim(e7d526449d33abf8). (&key, &keylen, ':', f);
808 if (n == -1)
809 {
810 r = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
811 break;
812 }
813
814 n = getdelimcxx . . $ getdelim(e7d526449d33abf8). (&val, &vallen, '\n', f);
815 if (n == -1)
816 {
817 r = errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
818 break;
819 }
820
821 g_strstripcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:248:9`! (key);
822
823 if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e). (key, "Pid", 3))
824 {
825 r = parse_status_field_pidcxx . . $ parse_status_field_pid(7436bf38bddd805d). (val, &pid);
826 found = r > -1;
827 }
828
829 } while (r == 0 && !found);
830
831 fclosecxx . . $ fclose(89bc1efcdac0ca22). (f);
832
833 if (r < 0)
834 {
835 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
836 "Could not parse fdinfo::%s: %s",
837 key, g_strerrorcxx . . $ g_strerror(f7ae7e56280f18ae). (-r));
838 }
839 else if (!found)
840 {
841 g_set_error_literalcxx . . $ g_set_error_literal(af35e45b47ff535e). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_FAILEDcxx . . $ G_IO_ERROR_FAILED.,
842 "Could not parse fdinfo: Pid field missing");
843 }
844
845 return pid;
846 }
847
848 static int
849 open_fdinfo_dircxx . . $ open_fdinfo_dir(99147cdc3c1dad38). (GErrorcxx . . $ GError# **error)
850 {
851 int fd;
852
853 fd = opencxx . . $ open(e156e3aa1e5c4ad1). ("/proc/self/fdinfo", O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! | O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`! | O_DIRECTORYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:140:10`! | O_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:142:10`! | O_NOCTTYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:53:10`!);
854
855 if (fd < 0)
856 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, g_io_error_from_errnocxx . . $ g_io_error_from_errno(b47e8a466716fd56). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
857 "Could not to open /proc/self/fdinfo: %s",
858 g_strerrorcxx . . $ g_strerror(f7ae7e56280f18ae). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
859
860 return fd;
861 }
862
863 pid_tcxx . . $ pid_t#
864 xdp_pidfd_to_pidcxx . . $ xdp_pidfd_to_pid(aa2d95a526319da2). (int pidfd,
865 GErrorcxx . . $ GError# **error)
866 {
867 int fdinfo = -1;
868 pid_tcxx . . $ pid_t# pid;
869
870 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pidfd >= 0, -1);
871
872 fdinfo = open_fdinfo_dircxx . . $ open_fdinfo_dir(99147cdc3c1dad38). (error);
873 if (fdinfo == -1)
874 return -1;
875
876 pid = pidfd_to_pidcxx . . $ pidfd_to_pid(a0bc2edf0646dac6). (fdinfo, pidfd, error);
877 (void) closecxx . . $ close(7864480464b09eea). (fdinfo);
878
879 return pid;
880 }
881
882 gbooleancxx . . $ gboolean#
883 xdp_pidfds_to_pidscxx . . $ xdp_pidfds_to_pids(94ca259b32cf3f78). (const int *pidfds,
884 pid_tcxx . . $ pid_t# *pids,
885 gintcxx . . $ gint# count,
886 GErrorcxx . . $ GError# **error)
887 {
888 int fdinfo = -1;
889 int i;
890
891 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pidfds != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
892 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pids != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
893
894 fdinfo = open_fdinfo_dircxx . . $ open_fdinfo_dir(99147cdc3c1dad38). (error);
895 if (fdinfo == -1)
896 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
897
898 for (i = 0; i < count; i++)
899 {
900 pids[i] = pidfd_to_pidcxx . . $ pidfd_to_pid(a0bc2edf0646dac6). (fdinfo, pidfds[i], error);
901 if (pids[i] < 0)
902 break;
903 }
904
905 (void) closecxx . . $ close(7864480464b09eea). (fdinfo);
906
907 return i == count;
908 }
909
910 gbooleancxx . . $ gboolean#
911 xdp_pidfd_get_namespacecxx . . $ xdp_pidfd_get_namespace(40904b3abaf3a9b1). (int pidfd,
912 ino_tcxx . . $ ino_t# *ns,
913 GErrorcxx . . $ GError# **error)
914 {
915 struct statcxx . . $ stat# st;
916 int r;
917
918 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pidfd >= 0, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
919 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (ns != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
920
921 r = fstatatcxx . . $ fstatat(ecc91238199c517e). (pidfd, "ns/pid", &st, 0);
922 if (r == -1)
923 {
924 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, g_io_error_from_errnocxx . . $ g_io_error_from_errno(b47e8a466716fd56). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
925 "Could not fstatat ns/pid: %s",
926 g_strerrorcxx . . $ g_strerror(f7ae7e56280f18ae). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
927 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
928 }
929
930 /* The inode number (together with the device ID) encode
931 * the identity of the pid namespace, see namespaces(7)
932 */
933 *ns = st.st_inocxx . . $ stat#st_ino.;
934 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
935 }
936
937 static int
938 parse_status_field_uidcxx . . $ parse_status_field_uid(6974107818eeb505). (const char *val,
939 uid_tcxx . . $ uid_t# *uid)
940 {
941 const char *t;
942 char *end;
943 guint64cxx . . $ guint64# v;
944 uid_tcxx . . $ uid_t# u;
945
946 t = strrchrcxx . . $ strrchr(2050848944e00d54). (val, '\t');
947 if (t == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
948 return -ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!;
949
950 errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! = 0;
951 v = g_ascii_strtoullcxx . . $ g_ascii_strtoull(5d2901629bb0ffe1). (t, &end, 0);
952 if (end == val)
953 return -ENOENTcxx . . $ `<external>/8987895939074593727/errno-base.h:6:9`!;
954 else if (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`! != 0)
955 return -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
956
957 u = (uid_tcxx . . $ uid_t#) v;
958
959 if ((guint64cxx . . $ guint64#) u != v)
960 return -ERANGEcxx . . $ `<external>/8987895939074593727/errno-base.h:38:9`!;
961
962 if (uid)
963 *uid = u;
964
965 return 0;
966 }
967
968 static int
969 parse_status_filecxx . . $ parse_status_file(22b6caaa6fb3018b). (int pid_fd,
970 pid_tcxx . . $ pid_t# *pid_out,
971 uid_tcxx . . $ uid_t# *uid_out)
972 {
973 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *key = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
974 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *val = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
975 gbooleancxx . . $ gboolean# have_pid = pid_out == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
976 gbooleancxx . . $ gboolean# have_uid = uid_out == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
977 FILEcxx . . $ FILE# *f;
978 size_t keylen = 0;
979 size_t vallen = 0;
980 ssize_tcxx . . $ ssize_t# n;
981 int fd;
982 int r = 0;
983
984 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pid_fd > -1, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
985
986 fd = openatcxx . . $ openat(5e925858040f3251). (pid_fd, "status", O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! | O_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:142:10`! | O_NOCTTYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:53:10`!);
987 if (fd == -1)
988 return -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
989
990 f = fdopencxx . . $ fdopen(8f4e2d7350ebd077). (fd, "r");
991
992 if (f == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
993 return -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
994
995 fd = -1; /* fd is now owned by f */
996
997 do {
998 n = getdelimcxx . . $ getdelim(e7d526449d33abf8). (&key, &keylen, ':', f);
999 if (n == -1)
1000 {
1001 r = -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
1002 break;
1003 }
1004
1005 n = getdelimcxx . . $ getdelim(e7d526449d33abf8). (&val, &vallen, '\n', f);
1006 if (n == -1)
1007 {
1008 r = -errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!;
1009 break;
1010 }
1011
1012 g_strstripcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:248:9`! (key);
1013 g_strstripcxx . . $ `<external>/7822753393113922331/gstrfuncs.h:248:9`! (val);
1014
1015 if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e). (key, "NSpid", strlencxx . . $ strlen(751346f8406fd082). ("NSpid")))
1016 {
1017 r = parse_status_field_nspidcxx . . $ parse_status_field_nspid(7436bf38bddd805d). (val, pid_out);
1018 have_pid = r > -1;
1019 }
1020 else if (!strncmpcxx . . $ strncmp(fd278af2f295fa2e). (key, "Uid", strlencxx . . $ strlen(751346f8406fd082). ("Uid")))
1021 {
1022 r = parse_status_field_uidcxx . . $ parse_status_field_uid(6974107818eeb505). (val, uid_out);
1023 have_uid = r > -1;
1024 }
1025
1026 if (r < 0)
1027 g_warningcxx . . $ `<external>/5169755362661750954/gmessages.h:365:9`! ("Failed to parse 'status::%s': %s",
1028 key, g_strerror (-r));
1029
1030 } while (r == 0 && (!have_uid || !have_pid));
1031
1032 fclosecxx . . $ fclose(89bc1efcdac0ca22). (f);
1033
1034 if (r != 0)
1035 return r;
1036 else if (!have_uid || !have_pid)
1037 return -ENXIOcxx . . $ `<external>/8987895939074593727/errno-base.h:10:9`!; /* ENOENT for the fields */
1038
1039 return 0;
1040 }
1041
1042 static inline gbooleancxx . . $ gboolean#
1043 find_pidcxx . . $ find_pid(b1b6768152daa642). (pid_tcxx . . $ pid_t# *pids,
1044 guintcxx . . $ guint# n_pids,
1045 pid_tcxx . . $ pid_t# want,
1046 guintcxx . . $ guint# *idx)
1047 {
1048 for (guintcxx . . $ guint# i = 0; i < n_pids; i++)
1049 {
1050 if (pids[i] == want)
1051 {
1052 *idx = i;
1053 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
1054 }
1055 }
1056
1057 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
1058 }
1059
1060 gbooleancxx . . $ gboolean#
1061 xdp_map_pids_fullcxx . . $ xdp_map_pids_full(3e57b5d6b165cf51). (DIRcxx . . $ DIR# *proc,
1062 ino_tcxx . . $ ino_t# pidns,
1063 pid_tcxx . . $ pid_t# *pids,
1064 guintcxx . . $ guint# n_pids,
1065 uid_tcxx . . $ uid_t# target_uid,
1066 GErrorcxx . . $ GError# **error)
1067 {
1068 pid_tcxx . . $ pid_t# *res = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1069 struct direntcxx . . $ dirent# *de;
1070 guintcxx . . $ guint# count = 0;
1071
1072 res = g_allocacxx . . $ `<external>/2019178843399655176/galloca.h:99:9`! (sizeof (pid_t) * n_pids);
1073 memsetcxx . . $ memset(d1de1e4fb215f1c6). (res, 0, sizeof (pid_tcxx . . $ pid_t#) * n_pids);
1074
1075 while ((de = readdircxx . . $ readdir(ffbaae344e1a615a). (proc)) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1076 {
1077 g_autofdcxx . . $ `<external>/6704587548159124736/gstdio.h:291:9`! int pid_fd = -1;
1078 pid_tcxx . . $ pid_t# outside = 0;
1079 pid_tcxx . . $ pid_t# inside = 0;
1080 uid_tcxx . . $ uid_t# uid = 0;
1081 guintcxx . . $ guint# idx;
1082 ino_tcxx . . $ ino_t# ns = 0;
1083 int r;
1084
1085 if (de->d_typecxx . . $ dirent#d_type. != DT_DIRcxx . . $ `<external>/7464718065909436613/dirent.h:106:10`!)
1086 continue;
1087
1088 pid_fd = openatcxx . . $ openat(5e925858040f3251). (dirfdcxx . . $ dirfd(ac30a447bc7c2f80). (proc), de->d_namecxx . . $ dirent#d_name., O_RDONLYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:43:9`! | O_NONBLOCKcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:62:10`! | O_DIRECTORYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:140:10`! | O_CLOEXECcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:142:10`! | O_NOCTTYcxx . . $ `<external>/14578502075116107718/fcntl-linux.h:53:10`!);
1089 if (pid_fd == -1)
1090 continue;
1091
1092 if (!xdp_pidfd_get_namespacecxx . . $ xdp_pidfd_get_namespace(40904b3abaf3a9b1). (pid_fd, &ns, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!))
1093 continue;
1094
1095 if (pidns != ns)
1096 continue;
1097
1098 r = parse_pidcxx . . $ parse_pid(7436bf38bddd805d). (de->d_namecxx . . $ dirent#d_name., &outside);
1099 if (r < 0)
1100 continue;
1101
1102 r = parse_status_filecxx . . $ parse_status_file(22b6caaa6fb3018b). (pid_fd, &inside, &uid);
1103 if (r < 0)
1104 continue;
1105
1106 if (!find_pidcxx . . $ find_pid(b1b6768152daa642). (pids, n_pids, inside, &idx))
1107 continue;
1108
1109 /* We got a match, let's make sure the real uids match as well */
1110 if (uid != target_uid)
1111 {
1112 g_set_error_literalcxx . . $ g_set_error_literal(af35e45b47ff535e). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_PERMISSION_DENIEDcxx . . $ G_IO_ERROR_PERMISSION_DENIED.,
1113 "Matching pid doesn't belong to the target user");
1114 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
1115 }
1116
1117 /* this handles the first occurrence, already identified by find_pid,
1118 * as well as duplicate entries */
1119 for (guintcxx . . $ guint# i = idx; i < n_pids; i++)
1120 {
1121 if (pids[i] == inside)
1122 {
1123 res[idx] = outside;
1124 count++;
1125 }
1126 }
1127 }
1128
1129 if (count != n_pids)
1130 {
1131 g_autoptrcxx . . $ `<external>/12741050725406041920/gmacros.h:1424:9`!(GString) str = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1132
1133 str = g_string_newcxx . . $ g_string_new(e8737c02110bb79b). ("Process ids could not be found: ");
1134
1135 for (guintcxx . . $ guint# i = 0; i < n_pids; i++)
1136 if (res[i] == 0)
1137 g_string_append_printfcxx . . $ g_string_append_printf(eeccf837eb821d11). (str, "%d, ", (guint32cxx . . $ guint32#) pids[i]);
1138
1139 g_string_truncatecxx . . $ `<external>/2906017559248664336/gstring.h:265:9`! (str, str->len - 2);
1140 g_set_error_literalcxx . . $ g_set_error_literal(af35e45b47ff535e). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, G_IO_ERROR_NOT_FOUNDcxx . . $ G_IO_ERROR_NOT_FOUND., str->strcxx . . $ _GString#str.);
1141
1142 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
1143 }
1144
1145 memcpycxx . . $ memcpy(cc817cb175f282d). (pids, res, sizeof (pid_tcxx . . $ pid_t#) * n_pids);
1146
1147 return TRUEcxx . . $ `<external>/12741050725406041920/gmacros.h:971:9`!;
1148 }
1149
1150 static gbooleancxx . . $ gboolean#
1151 map_pids_proccxx . . $ map_pids_proc(82edefe25ca87034). (ino_tcxx . . $ ino_t# pidns,
1152 pid_tcxx . . $ pid_t# *pids,
1153 guintcxx . . $ guint# n_pids,
1154 const char *proc_dir,
1155 GErrorcxx . . $ GError# **error)
1156 {
1157 gbooleancxx . . $ gboolean# ok;
1158 DIRcxx . . $ DIR# *proc;
1159 uid_tcxx . . $ uid_t# uid;
1160
1161 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pidns > 0, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
1162 g_return_val_if_failcxx . . $ `<external>/5169755362661750954/gmessages.h:665:9`! (pids != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!);
1163
1164 proc = opendircxx . . $ opendir(f465d4b65cec8dd2). (proc_dir);
1165 if (proc == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
1166 {
1167 g_set_errorcxx . . $ g_set_error(ca0c191bc68fc328). (error, G_IO_ERRORcxx . . $ `<external>/13894955190784973534/gioerror.h:42:9`!, g_io_error_from_errnocxx . . $ g_io_error_from_errno(b47e8a466716fd56). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!),
1168 "Could not open '%s': %s", proc_dir, g_strerrorcxx . . $ g_strerror(f7ae7e56280f18ae). (errnocxx . . $ `<external>/17633486526465735210/errno.h:38:10`!));
1169 return FALSEcxx . . $ `<external>/12741050725406041920/gmacros.h:967:9`!;
1170 }
1171
1172 uid = getuidcxx . . $ getuid(db52760e79bf9054). ();
1173
1174 ok = xdp_map_pids_fullcxx . . $ xdp_map_pids_full(3e57b5d6b165cf51). (proc, pidns, pids, n_pids, uid, error);
1175 closedircxx . . $ closedir(ac30a447bc7c2f80). (proc);
1176
1177 return ok;
1178 }
1179
1180 gbooleancxx . . $ gboolean#
1181 xdp_map_pidscxx . . $ xdp_map_pids(5f334dc0f459180). (ino_tcxx . . $ ino_t# pidns,
1182 pid_tcxx . . $ pid_t# *pids,
1183 guintcxx . . $ guint# n_pids,
1184 GErrorcxx . . $ GError# **error)
1185 {
1186 return map_pids_proccxx . . $ map_pids_proc(82edefe25ca87034). (pidns, pids, n_pids, "/proc", error);
1187 }
1188
1189 gbooleancxx . . $ gboolean#
1190 xdp_map_tidscxx . . $ xdp_map_tids(766ff89140cb637c). (ino_tcxx . . $ ino_t# pidns,
1191 pid_tcxx . . $ pid_t# owner_pid,
1192 pid_tcxx . . $ pid_t# *tids,
1193 guintcxx . . $ guint# n_tids,
1194 GErrorcxx . . $ GError# **error)
1195 {
1196 g_autofreecxx . . $ `<external>/12741050725406041920/gmacros.h:1429:9`! char *proc_dir = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
1197
1198 proc_dir = g_strdup_printfcxx . . $ g_strdup_printf(a849077ff1b8d812). ("/proc/%u/task", (guintcxx . . $ guint#) owner_pid);
1199
1200 return map_pids_proccxx . . $ map_pids_proc(82edefe25ca87034). (pidns, tids, n_tids, proc_dir, error);
1201 }