From: Rasmus Villemoes Date: Mon, 20 Jul 2026 13:04:21 +0000 (+0200) Subject: profile/systemd-osc-context: do not zero-pad pid value X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=10a356629ad038eaa8e723e3cb9b99a18f87ae03;p=thirdparty%2Fsystemd.git profile/systemd-osc-context: do not zero-pad pid value The %.20d specifier was introduced in 2d738a0aee ("profile/systemd-osc-context: Enforce length limits"). But, for numeric conversions, the precision is not an upper bound, but rather a lower bound on the output width, padding as necessary with 0 on the left. So as-is, this does not in fact limit the output to at most 20 characters. Of course, in practice, pids on linux are never greater than 2^22, and certainly never larger than what would fit in a 20-digit decimal. On the other hand, that more or less guarantees that the pid= field is always emitted with 12+ leadings zeroes, which is a bit silly. Moreover, a leading 0 can cause a parser to treat it as octal. Since $$ does expand to the PID in decimal, just print that as a string, with the enforced 20 character limit. --- diff --git a/profile.d/80-systemd-osc-context.sh b/profile.d/80-systemd-osc-context.sh index 9bbb71285fa..6e6812ce4db 100644 --- a/profile.d/80-systemd-osc-context.sh +++ b/profile.d/80-systemd-osc-context.sh @@ -52,7 +52,7 @@ __systemd_osc_context_common() { if [ -f /etc/machine-id ]; then printf ";machineid=%.36s" "$(