Visitar URL original
Resolve printf-style unit modifiers in systemd-run's `-p` · Issue #44275 · systemd/systemd · GitHub
Skip to content

Resolve printf-style unit modifiers in systemd-run's -p #44275

Open

Description

@Ma27

Component

systemd-run

Is your feature request related to a problem? Please describe

Note: I'm happy to try sending a patch myself. I'd like to find out first if there's reasons to not do this.

In NixOS we make heavy use of systemd features such as DynamicUser, StateDirectory et al..
Sometimes it's necessary to allow people to run commands in this environment. An example would be a Django application where you'd need to run manage.py in the exact same context.

One example of this is the NixOS module for LaSuite docs. The envArgs is essentially a string of -E FOO=bar. This string is generated from the Environment= statements of lasuite-docs.service.

Now, if there's a unit-modifier used (e.g. AWS_SECRET_ACCESS_KEY_FILE=%d/secret_key), this breaks because %d isn't interpolated to /run/credentials/<name of transient unit>.

Describe the solution you'd like

I'd essentially like to apply unit_full_printf_full over all properties supplied by systemd-run.
I'm not entirely sure yet if I can do this in systemd-run itself rather than on the DBus endpoint that creates the transient unit. Depending on this, transient units created via dbus are not affected by this change.

Describe alternatives you've considered

Leave the behavior as-is and tell people to not use unit-modifiers when having use-cases like this.

I'd be curious to learn about the motivation to do so if that's your preference, personally I'm not seeing downsides to this approach.

The systemd version you checked that didn't have the feature you are asking for

263

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁Request for Enhancement, i.e. a feature requestrun

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions