From d4a3f291e3955648ea1d29e674b0f8f9b1556257 Mon Sep 17 00:00:00 2001 From: Sven Eden Date: Mon, 12 Nov 2018 08:57:49 +0100 Subject: Prep v239.2: Handle program_invocation_short_name more properly (#92) With glibc, at least v2.28, program_invocation_short_name is not a string of its own, but simply points into program_invocation_name. When elogind is forked, the fork process gets a new name. Upstream has decided to change to long version, which is the correct thing to do. Unfortunately program_invocation_short_name is not adapted, and all further log messages using it might print anything. This patch manipulates program_invocation_short_name if its adress lies within program_invocation_name and its original length. Bug: #92 Closes: #92 Signed-off-by: Sven Eden --- src/basic/process-util.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/basic/process-util.c b/src/basic/process-util.c index 366aabba8..3930aa62b 100644 --- a/src/basic/process-util.c +++ b/src/basic/process-util.c @@ -308,6 +308,12 @@ int rename_process(const char name[]) { strncpy(program_invocation_name, name, k); if (l > k) truncated = true; + +#if 1 /// elogind takes care of situations where the short name points into the long. + if ( (program_invocation_short_name >= program_invocation_name) + && (program_invocation_short_name < program_invocation_name + k) ) + program_invocation_short_name = program_invocation_name; +#endif // 1 } /* Third step, completely replace the argv[] array the kernel maintains for us. This requires privileges, but -- cgit v1.2.3