-
-
Notifications
You must be signed in to change notification settings - Fork 14.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos: add functions and documentation for escaping systemd Exec* directives #154113
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very good to have.
I think we should have a safe, submodule representation. Here's a design if you're interested #154123
nixos/tests/systemd-escaping.nix
Outdated
testScript = '' | ||
machine.wait_for_unit("multi-user.target") | ||
machine.succeed("systemctl start echo.service") | ||
logs = machine.succeed("journalctl -u echo.service -o cat") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we maybe have .splitlines()
here, to ensure it does not match e.g. semicolon in the middle of a line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Motivation for this change
we've seen a couple new modules recently that came with subtly wrong
ExecStart
directives. 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 = true
set 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.sh
to update generated release notes