fix: sanitize sudoers filename for usernames containing dots#1719
Open
GarySkywalker-droid wants to merge 2 commits into
Open
fix: sanitize sudoers filename for usernames containing dots#1719GarySkywalker-droid wants to merge 2 commits into
GarySkywalker-droid wants to merge 2 commits into
Conversation
Open
3 tasks
kasc0206
approved these changes
Jun 14, 2026
kasc0206
left a comment
There was a problem hiding this comment.
审查意见 / Review
Clean and minimal fix for issue #1713.
优点
- Correct root cause: sudoers(5) manpage confirms filenames with
.are ignored - Minimal change: Shell parameter substitution
${CONTAINER_USER//./_}is elegant - Test updated: The test now expects the sanitized filename
注意
Line 46 (chmod 440 "/etc/sudoers.d/${CONTAINER_USER}") still uses the unsanitized filename — this should also use ${SUDOERS_FILE} for consistency, though chmod on a non-existent file would fail silently in the container. Consider fixing in a follow-up.
Reviewed-by: kasc0206
Code Review SummaryStrengths
Issue FoundLine 46 still uses -chmod 440 "/etc/sudoers.d/${CONTAINER_USER}"
+chmod 440 "/etc/sudoers.d/${SUDOERS_FILE}"The chmod will silently fail on the old path. 建议同步修复 chmod 行的变量引用。 Verification
Nice work! |
Author
oops, good catch I fixed it ! |
1a3b2c5 to
61756ac
Compare
kloodylemonh-tech
approved these changes
Jun 15, 2026
kloodylemonh-tech
approved these changes
Jun 15, 2026
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.
Type of Change
Motivation and Context
When a macOS username contains a dot (e.g. user.name), sudo silently ignores /etc/sudoers.d/user.name because sudo skips any drop in file whose name contains a dot. Fix by sanitizing the filename only, keeping the real username intact inside the rule. Fixes #1713
Testing