nixos: add functions and documentation for escaping systemd Exec* directives#154113
Merged
pennae merged 1 commit intoNixOS:masterfrom Mar 13, 2022
pennae:systemd-escaping
Merged
nixos: add functions and documentation for escaping systemd Exec* directives#154113pennae merged 1 commit intoNixOS:masterfrom pennae:systemd-escaping
pennae merged 1 commit intoNixOS:masterfrom
pennae:systemd-escaping
Conversation
This was referenced Jan 10, 2022
LunNova
approved these changes
Mar 11, 2022
jtojnar
reviewed
Mar 11, 2022
nixos/tests/systemd-escaping.nix
Outdated
Member
There was a problem hiding this comment.
Should we maybe have .splitlines() here, to ensure it does not match e.g. semicolon in the middle of a line?
Contributor
Author
There was a problem hiding this comment.
that sounds sensible. there's a slight catch that toString for floats produces six fractional digits where one might expect less, but that's easy enough to work around.
…ectives
it's really easy to accidentally write the wrong systemd Exec* directive, ones
that works most of the time but fails when users include systemd metacharacters
in arguments that are interpolated into an Exec* directive. add a few functions
analogous to escapeShellArg{,s} and some documentation on how and when to use them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation for this change
we've seen a couple new modules recently that came with subtly wrong
ExecStartdirectives. while they'd work most of the time they could fail in surprising ways if users were to add a%or$in a module argument.to make it easier to avoid such problems this adds a few escaping functions specifically for systemd Exec directives and some documentation on how to use them.
Things done
sandbox = trueset innix.conf? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)nixos/doc/manual/md-to-db.shto update generated release notes