]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
run: prefix unit description with our own process name
authorLennart Poettering <lennart@poettering.net>
Thu, 24 Oct 2024 10:07:24 +0000 (12:07 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 25 Oct 2024 15:32:19 +0000 (17:32 +0200)
I think we should try to communicate clearly if something is a run0
session, or a systemd-run invocation. Hence, let's initialize the
description so that the command is prefixed by
program_invocation_short_name.

Effectively this means that our run0 sessions now appear as services
with a description of "[run0] -/bin/bash"

src/run/run.c

index 42eb756fa9c7dffb1e27d7f9343a5df7aeb832d0..d4eb148cf64e1fb09270de15ce93601aaf667a71 100644 (file)
@@ -2435,7 +2435,7 @@ static int run(int argc, char* argv[]) {
         }
 
         if (!arg_description) {
-                char *t;
+                _cleanup_free_ char *t = NULL;
 
                 if (strv_isempty(arg_cmdline))
                         t = strdup(arg_unit);
@@ -2444,7 +2444,9 @@ static int run(int argc, char* argv[]) {
                 if (!t)
                         return log_oom();
 
-                free_and_replace(arg_description, t);
+                arg_description = strjoin("[", program_invocation_short_name, "] ", t);
+                if (!arg_description)
+                        return log_oom();
         }
 
         /* For backward compatibility reasons env var expansion is disabled by default for scopes, and