]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
nsresource: port from PR_GET_NAME to pid_get_comm()
authorLennart Poettering <lennart@amutable.com>
Mon, 13 Jul 2026 08:42:28 +0000 (10:42 +0200)
committerLennart Poettering <lennart@amutable.com>
Mon, 13 Jul 2026 13:39:17 +0000 (15:39 +0200)
SImilar reasons as for the memfd change: let's normalize behaviour and
always use pid_get_comm().

This adds escaping here for the first time, which is a good thing.

src/shared/nsresource.c

index b783cb80b78aeb6035dc46fb23f31dd11e3d5eb5..5aa87c48b5888f1982f088b1bace817d60b4d308 100644 (file)
@@ -1,7 +1,6 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 
 #include <sched.h>
-#include <sys/prctl.h>
 
 #include "sd-varlink.h"
 
 assert_cc(TASK_COMM_LEN == NAMESPACE_NAME_MAX);
 
 static int make_pid_name(char **ret) {
-        char comm[TASK_COMM_LEN];
         static uint64_t counter = 0;
+        int r;
 
         assert(ret);
 
-        if (prctl(PR_GET_NAME, comm) < 0)
-                return -errno;
+        _cleanup_free_ char *comm = NULL;
+        r = pid_get_comm(0, &comm);
+        if (r < 0)
+                return r;
 
         char spid[DECIMAL_STR_MAX(pid_t)];
         xsprintf(spid, PID_FMT, getpid_cached());