-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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
Make escapeSystemdPath implement the correct systemd escaping algorithm #177273
Conversation
Just commenting so this isn't only documented on matrix. I also tried to fix this recently, in #176115. So far, we've figured out that this PR here properly translates characters, while mine handles the I don't really have any preference over which PR should be merged into which one or how else to proceed, as long as we have an implementation that's as complete as possible, in the end. |
71dbed9
to
dc8223a
Compare
Can we add tests to make the behavior more clear and to document use cases? Also can help fixing any issues we find after getting this in, by improving the tests then. |
@Mindavi We don't seem to have any testing infrastructure for I feel like the |
An issue should be opened in nix to provide a built-in for string formatting. So much of this would be a simple |
lib/strings.nix
Outdated
@@ -305,6 +330,18 @@ rec { | |||
*/ | |||
escape = list: replaceChars list (map (c: "\\${c}") list); | |||
|
|||
/* Escape occurence of the element of `list` in `string` by | |||
converting to it's ASCII value and prefixing it with \\x. |
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.
mention that it only works with printable ascii characters. For non printable ones, I wonder if it is correct to map the caracter 7 to \x7
instead of \x07
.
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.
I've now documented that it only works for printable characters, You're quite right about the non-printable ones as well, but I think we would need a nix builtin to deal with those anyways
eab9341
to
83ac459
Compare
@GrahamcOfBorg test systemd |
(note that github does not always send notifications on force-push, so when you address a review, please post a full-fledged comment) |
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 breaks nixosTest.systemd (it looks "currently building" but the test vm is just stuck failing to boot)
problem is: the vm uses the autoformat feature, but the unit running mkfs does not run, I don't know why.
dedupes extranous /'s in filepaths Co-authored-by: Daniel Olsen <[email protected]>
…ping names in systemd units Co-authored-by: ajs124 <[email protected]>
d20b62c
to
23c1754
Compare
@GrahamcOfBorg test systemd |
thank you! |
Only seems to be a problem when running nixosTests remotely? Works again after reverting 3251123. |
If this happens only when evaluating on Darwin but not on linux it's probably a discrepancy between the glicxx and libcxx implem of std::regex in nix. I don't have a darwin system to investigate further, could you do it as you seem to have both kinds of systems, @zowoq ?
22 oct. 2022 02:49:17 zowoq ***@***.***>:
… *nix-build -A nixosTests.simple --max-jobs 0 --eval-store auto --store ssh-ng://**** --system x86_64-linux
error: invalid regular expression ''
at /Users/zowoq/src/nixpkgs/lib/strings.nix:540:51:
539| s = builtins.unsafeDiscardStringContext _s;
540| splits = builtins.filter builtins.isString (builtins.split (escapeRegex sep) s);
| ^
541| in
(use '--show-trace' to show detailed location information)
*
Only seems to be a problem when running nixosTests remotely? Works again after reverting 3251123[3251123].
—
Reply to this email directly, view it on GitHub[#177273 (comment)], or unsubscribe[https://github.com/notifications/unsubscribe-auth/ADADGA5TE4MX7KLM2FEUGJDWEM2YJANCNFSM5YP4G32Q].
You are receiving this because you modified the open/close state.[Image de pistage][https://github.com/notifications/beacon/ADADGA3IR2CHNXZM7D3FT43WEM2YJA5CNFSM5YP4G322YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOJS7KMMA.gif]
|
Yeah, only seems to be darwin->linux. If it is a nix bug I doubt it will be quick or simple to fix. I'd like to revert this PR until it is resolved. |
I'd be okay with that if we also reverted #152372 I don't want to maintain a nixpkgs channel with this patch for this coming release as well |
So the code in this PR does not involve regex at all except with the hard coded regex "/" and "" which are valid, could you report the error with a stacktrace and possibly with --debugger so that we know the value of the faulty regex? |
(besides this is a bugfix in nixos code that is only faulty when evaluating code on mac, which is more niche than the use cases it fixes imo, so I'd rather fix this than revert it). |
Can you suggest another workaround apart from reverting this locally on every branch that I'm working on? I don't see that it matters if we revert it for a bit so we aren't introducing new breakage. |
This fixes a (at the time new) breakage on actual NixOS systems which IMO probably takes priority over evaluating nixos tests from darwin. I believe one can just ssh to a Linux box and run tests there in the mean time. This exposing something broken in nix on darwin hopefully incentives someone who has access and cares about darwin to investigate and follow up the bug. |
It is old code that has been broken for months, there certainly didn't seem to be any urgency in merging this PR. I don't see the problem with reverting it for a bit.
Doesn't seem to be that simple as would need to sync code as well?
Yes, I'll try to do that. Not having my current workflows broken would mean I have more time to try to fix it? |
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes NixOS#177273 (comment)
The discrepancy is problematic so I opened NixOS/nix#7208 |
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes #177273 (comment)
Seems this is a recurring problem.
|
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes NixOS/nixpkgs#177273 (comment)
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes NixOS/nixpkgs#177273 (comment)
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes NixOS/nixpkgs#177273 (comment)
presumably due to using libc++'s regex lib instead of libstdc++ on linux Fixes NixOS/nixpkgs#177273 (comment)
Description of changes
There's a regression in regards to systemd mount units on 22.05:
Since #152372 we validate unit names but that validation isn't the same as what
escapeSystemdPath
does, notably it doesn't replace ( ) in my casefilesSystems
usesescapeSystemdPath
to convert the mountpoint to the unit name.I've added a few functions to help convert the paths to the proper C escapes implementing the algorithm described in
man systemd.unit
But this is my first time working or changing anything significant in lib, so I'd be really happy for pointers on how to do this better utilizing functions we maybe already have?I tested this on my configuration (cherry-picked to 22.05) and it seems fine... but this is a basically-8 year old function I'm changing which is pretty scary...
I also only did ASCII special chars, but without something like a builtins function for the UTF-8 conversion stuff I don't know if it's possible to generalize
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