Bug#1029161: systemd: Inconsistent values for %j specifier across service and drop-in units

Michael Biebl biebl at debian.org
Wed Jan 18 17:30:01 GMT 2023


Hi

Am 18.01.23 um 18:21 schrieb Mike:
> Package: systemd
> Version: 247.3-7+deb11u1
> Severity: normal
> X-Debbugs-Cc: mike.shaw.nz+debian at gmail.com
> 
> Dear Maintainer,
> 
> Under certain circumstances I'm seeing inconsistent values for the %j specifier used in service and drop-in units.
> To reproduce:
> 
> Create a systemd unit /lib/systemd/system/foo at .service as:
> 
>      [Unit]
>      Description=good old foo
> 
>      [Service]
>      Type=oneshot
>      ExecStart=/bin/env echo "%%i=[%i]   %%j=[%j] (from %n (foo at .service))"
> 
> Create a drop-in unit /etc/systemd/system/foo at .service.d/additional.conf as:
> 
>      [Service]
>      ExecStart=/bin/env echo "%%i=[%i]   %%j=[%j] (from %n (additional.conf))"
> 
> Reload the systemd units and run systemctl cat foo at .service.  The output shows the drop-in being correctly incorporated:
> 
>      # /lib/systemd/system/foo at .service
>      [Unit]
>      Description=good old foo
> 
>      [Service]
>      Type=oneshot
>      ExecStart=/bin/env echo "%%i=[%i]   %%j=[%j] (from %n (foo at .service))"
> 
>      # /etc/systemd/system/foo at .service.d/additional.conf
>      [Service]
>      ExecStart=/bin/env echo "%%i=[%i]   %%j=[%j] (from %n (additional.conf))"
> 
> Now create a symlink which contains a %j specifier:
> 
>      sudo ln -sv /lib/systemd/system/foo at .service /etc/systemd/system/foo-bar at .service
> 
> Reload the systemd units and run systemctl cat foo-bar at .service.  The output is identical to that of systemctl cat foo at .service
> Now start the service with a %i specifer:
> 
>      systemctl start foo-bar at baz.service
> 
> The output is:
> 
>foo at baz.service - good old foo
>           Loaded: loaded (/lib/systemd/system/foo at .service; static)
>           Drop-In: /etc/systemd/system/foo at .service.d
>                   └─additional.conf
>           Active: inactive (dead)
> 
>      Nov 01 12:10:31 Intel-NUC systemd[1]: Starting good old foo...
>      Nov 01 12:10:31 Intel-NUC env[56108]: %i=[baz]   %j=[bar] (from foo-bar at baz.service (foo at .service))
>      Nov 01 12:10:31 Intel-NUC env[56109]: %i=[baz]   %j=[foo] (from foo at baz.service (additional.conf))
>      Nov 01 12:10:31 Intel-NUC systemd[1]: foo at baz.service: Succeeded.
>      Nov 01 12:10:31 Intel-NUC systemd[1]: Finished good old foo.
> 
> This shows that - in a single invocation - the value for %i is constant but the value for %j changes from 'bar' to 'foo'.  I would have expected the value of %j to be 'bar' throughout.  This may not be a bug, but - IMHO - this changing of values is unintuitive and I have been unable to find documentation that states the expected behaviour in this situation.  Happy to accept that I have confused/abused systemd with my custom /etc/systemd/system/foo-bar at .service symlink.
> 

Ideally, such issues should be tested with the latest version of systemd 
(or at least v251) and then reported upstream.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <http://alioth-lists.debian.net/pipermail/pkg-systemd-maintainers/attachments/20230118/48d4f4c0/attachment.sig>


More information about the Pkg-systemd-maintainers mailing list