-
-
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/nscd: DynamicUser and other cleanups #64268
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
93f185d
nixos/nscd: no longer need to wait for readiness
jameysharp 597563d
nixos/nscd: let systemd manage directories
jameysharp de25170
nixos/nscd: run with a dynamic user
jameysharp 4c64375
nixos/nscd: delete redundant nscd.conf options
jameysharp c38fa99
nixos/nscd: don't need to specify username
jameysharp f7c7767
nixos/nscd: only drop privs after nss module init
jameysharp d79584c
nixos/nscd: document why it is configured this way
jameysharp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
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.
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.
So that means that systemd will no longer try to use nscd to check the dynamic user? How do they implement that?
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.
In theory,
DynamicUser
should only work whennscd
is on, asnscd
dispatches to the correctnss_systemd.so
. So this indeed sounds like something that is not gonna work, given thatnscd
is not running whennscd
is starting up :PHowever, note I think that
nscd
bypasses delegating tonscd
when doing anynss
related syscalls itself (for good reason; otherwise it would end up in an endless loop), so maybe all thenss
related syscalls in thenscd
binary hit the same codepath as requests from others programs that go through thenscd
socket? Because in that case, this will work.Non of this is documented so we could find out by reading the C source code... Or just disable
DynamicUser
fornscd
so that we're on the safe side.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.
glibc always has to be able to answer passwd queries and such whether nscd is running or not. How does it know? It tries opening the socket that nscd listens on, and if that fails, it does the lookup itself. (There's also a glibc-internal function which nscd itself calls to prevent even checking for the socket, as you noted.)
So this works fine: systemd does the lookup of a user and group named
nscd
before it has started the service, the socket doesn't work, so glibc falls back to havinglibnss_files.so
handle the query in-process. If you want to configure a static user for nscd, you can do it in/etc/passwd
and systemd will find it.Also: any code in the
systemd
package doesn't need nscd to find its own nsswitch modules, because they're already in its library path. So without nscd, systemd would only get the wrong answers for these passwd/group lookups on systems configured with nsswitch modules that are neither the glibc builtins nor systemd's extras.That means the real constraint here is that you can't override this
DynamicUser
setting by defining annscd
user in LDAP, Google OS Login, etc. Maybe that's worth documenting, but it's really a nonsense thing to even try doing...This does make me want to try getting the username
nscd
on some large LDAP-based network somewhere and see how much I can break though. 😈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.
Yes. Any service started under
DynamicUser
must have eitherlibnss_systemd.so
in itsLD_LIBRARY_PATH
or have access to thenscd
socket in order forDynamicUser
to work.My worry was because
nscd
itself doesn't access the socket it wouldn't work. But obviouslynscd
haslibnss_systemd.so
inLD_LIBRARY_PATH
so it will indeed work.So indeed, it seems we can leave
DynamicUser = true
with no issues.On a related note, I think you can drop the
User = nscd
option by the way. Because the service name isnscd.service
andDynamicUser = true
, systemd already automatically setsUser = nscd
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.
Good point about removing
User
, thanks! I've retested with that change and indeed the selected username is still "nscd", as expected.