]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
argv-util: also update program_invocation_short_name 26324/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 3 Feb 2023 09:29:36 +0000 (18:29 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 6 Feb 2023 13:51:20 +0000 (22:51 +0900)
Our logging uses program_invocation_short_name. Without this patch,
logs from forked client may become broken; spuriously truncated or
the short invocation name is not completely shown in the log.

src/basic/argv-util.c

index b8c371ede5b255f5f59f8f646eff87790a4ecff0..6c88dcc2ee98d7d4967219ccaafad59c01be031b 100644 (file)
@@ -192,6 +192,10 @@ int rename_process(const char name[]) {
                 strncpy(program_invocation_name, name, k);
                 if (l > k)
                         truncated = true;
+
+                /* Also update the short name. */
+                char *p = strrchr(program_invocation_name, '/');
+                program_invocation_short_name = p ? p + 1 : program_invocation_name;
         }
 
         /* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but