From: Lennart Poettering Date: Mon, 13 Jul 2026 08:42:28 +0000 (+0200) Subject: nsresource: port from PR_GET_NAME to pid_get_comm() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2d639050964b519aa840107d227dcfd4c8a5d1c9;p=thirdparty%2Fsystemd.git nsresource: port from PR_GET_NAME to pid_get_comm() 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. --- diff --git a/src/shared/nsresource.c b/src/shared/nsresource.c index b783cb80b78..5aa87c48b58 100644 --- a/src/shared/nsresource.c +++ b/src/shared/nsresource.c @@ -1,7 +1,6 @@ /* SPDX-License-Identifier: LGPL-2.1-or-later */ #include -#include #include "sd-varlink.h" @@ -25,13 +24,15 @@ 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());