diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-03 18:29:36 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-02-06 22:51:20 +0900 |
commit | dd15e4cb57129b915e01495e113696bfe0b70214 (patch) | |
tree | 22fd8cba8d5b03da412bf35ceb039440cc726c4b | |
parent | 577a0fd59bf8fdf533bc8d120e350fe8a3f040bf (diff) | |
download | systemd-dd15e4cb57129b915e01495e113696bfe0b70214.tar.gz |
argv-util: also update program_invocation_short_name
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.
-rw-r--r-- | src/basic/argv-util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/basic/argv-util.c b/src/basic/argv-util.c index b8c371ede5..6c88dcc2ee 100644 --- a/src/basic/argv-util.c +++ b/src/basic/argv-util.c @@ -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 |