nixos/users-groups: Enforce ASCII usernames and fix repeated doubling of activation script runtime#385904
Merged
infinisil merged 2 commits intoNixOS:masterfrom Mar 19, 2025
Merged
Conversation
Because with it only being single-UTF8-decoded, this lead to the file ~doubling in size whenever it contained any non-ascii characters!
Member
|
The rabbit hole calls 😂 Good that you dug that up! |
Prevents running into the problem from the parent commit in the first place.
ad97b6d to
b602f86
Compare
SuperSandro2000
approved these changes
Feb 28, 2025
Contributor
|
"Enforce non-ASCII usernames" in the PR title seems like the opposite of the goal :p |
Member
Author
|
Would anybody like to merge this? I'd rather avoid self-merges if possible :) |
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.
I unsuccessfully tried to specify a non-ascii username, all kinds of things broke, so I undid that. Only a bit later I'm running into a very weird problem: The NixOS activation script is taking ~twice as long to finish every time its run, now up to ~10 minutes!
After debugging, I figured out that it's taking so long to decode the
/var/lib/nixos/auto-subuid-map, which has grown to 24MB! Turns out, the users-groups script has been doubly-encoding that file as UTF-8, while only singly-decoding it. While this works fine if it's just ASCII, this leads to an exponential explosion for anything else. Here's a demo of this:In addition to avoiding this double encoding, this PR also adds an assertion to ensure that
users.users.*.nameonly matches what shadow considers valid, to save the trouble of users running into other issues with weird usernames.Note that Ubuntu by default limits usernames to the more strict
[a-z][-a-z0-9_]*, but that would break some configs.1Ping @adisbladis who originally introduced the code and @Mic92 who did some other UTF-8 fixes in the script.
Things done
/var/lib/nixos/auto-subuid-mapdon't get elongated anymore.users.users."猫"and ensured that an assertion is thrown:This work is funded by Antithesis and Tweag ✨
Add a 👍 reaction to pull requests you find important.
Footnotes
1 2 3 ↩