nix-daemon fails to lookup dynamically allocated users #1029

Open
opened 2025-11-07 01:30:12 +00:00 by mweinelt · 5 comments
Member

Describe the bug

I have services that from dynamically allocated users (via systemd) make calls to the nix-daemon. Every once in a while nix-daemon starts denying access and logs that the uid is not allowed to connect.

I only ever configured the usernames as trusted, so if it cannot look up the username any more, then rip.

The stopping happens when I switch into a new generation.

# cat /etc/nsswitch.conf 
passwd:    files systemd
group:     files [success=merge] systemd
shadow:    files
sudoers:   files

hosts:     mymachines files myhostname dns
networks:  files

ethers:    files
services:  files
protocols: files
rpc:       files
# getent passwd 63182
gitea-runner:x:63182:63182:Dynamic User:/:/nix/store/nhs0ppna5rf03hrdd7nz34jagbxddk5q-util-linux-minimal-2.41.1-login/bin/nologin
Nov 02 18:19:36 pallas nix-daemon[2736]: accepted connection from pid 1889485, user gitea-runner (trusted)
Nov 02 18:20:21 pallas nix-daemon[2736]: accepted connection from pid 1889532, user gitea-runner (trusted)
Nov 02 20:05:55 pallas nix-daemon[2736]: accepted connection from pid 1898261, user gitea-runner (trusted)
Nov 02 20:06:16 pallas nix-daemon[2736]: accepted connection from pid 1898467, user gitea-runner (trusted)
Nov 03 07:39:54 pallas systemd[1]: Stopping Nix Daemon...
Nov 07 01:04:54 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon
Nov 07 01:04:56 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon
Nov 07 01:04:58 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon
Nov 07 01:05:00 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon
Nov 07 01:05:02 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon
Nov 07 01:07:24 pallas systemd[1]: Stopping Nix Daemon...
Nov 07 01:07:24 pallas systemd[1]: nix-daemon.service: Deactivated successfully.
Nov 07 01:07:24 pallas systemd[1]: Stopped Nix Daemon.
Nov 07 01:07:24 pallas systemd[1]: Started Nix Daemon.
Nov 07 01:07:32 pallas nix-daemon[2088798]: accepted connection from pid 2088910, user gitea-runner (trusted)
Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091827, user gitea-runner (trusted)
Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091825, user gitea-runner (trusted)
Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091824, user gitea-runner (trusted)

Happens on multiple machines and the shared configuration is DynamicUser=.

Nov 02 23:08:06 juno nix-daemon[8071]: accepted connection from pid 101518, user mach-symbols-upload
Nov 02 23:10:03 juno nix-daemon[8071]: accepted connection from pid 101542, user mach-symbols-upload
Nov 02 23:11:55 juno nix-daemon[8071]: accepted connection from pid 101557, user mach-symbols-upload
Nov 02 23:13:55 juno nix-daemon[8071]: accepted connection from pid 101577, user mach-symbols-upload
Nov 03 05:06:42 juno systemd[1]: Stopping Nix Daemon...
Nov 03 12:00:29 juno nix-daemon[106712]: error: error processing connection: user '64495' is not allowed to connect to the Nix daemon
Nov 03 12:36:49 juno nix-daemon[106712]: error: error processing connection: user '64495' is not allowed to connect to the Nix daemon
Nov 03 12:37:12 juno systemd[1]: Stopping Nix Daemon...
Nov 03 12:37:12 juno systemd[1]: nix-daemon.service: Deactivated successfully.
Nov 03 12:37:12 juno systemd[1]: Stopped Nix Daemon.
Nov 03 12:37:12 juno systemd[1]: nix-daemon.service: Consumed 99ms CPU time, 40M memory peak, 31.2M read from disk.
Nov 03 12:37:12 juno systemd[1]: Started Nix Daemon.
Nov 03 12:37:16 juno nix-daemon[112201]: accepted connection from pid 112208, user mach-symbols-upload
Nov 03 12:39:43 juno nix-daemon[112201]: accepted connection from pid 112246, user mach-symbols-upload
Nov 03 12:42:04 juno nix-daemon[112201]: accepted connection from pid 112277, user mach-symbols-upload

Steps To Reproduce

  1. Configure a systemd service with DynamicUser=
  2. Make that systemd service access the nix-daemon
  3. Configure automatic updates
  4. Wait until the service cannot access the nix-daemon anymore

Expected behavior

Looking up transient users that systemd creates should be reliable.

nix --version output

nix (Lix, like Nix) 2.91.3

Additional context

## Describe the bug I have services that from dynamically allocated users (via systemd) make calls to the nix-daemon. Every once in a while nix-daemon starts denying access and logs that the uid is not allowed to connect. I only ever configured the usernames as trusted, so if it cannot look up the username any more, then rip. The stopping happens when I switch into a new generation. ``` # cat /etc/nsswitch.conf passwd: files systemd group: files [success=merge] systemd shadow: files sudoers: files hosts: mymachines files myhostname dns networks: files ethers: files services: files protocols: files rpc: files ``` ``` # getent passwd 63182 gitea-runner:x:63182:63182:Dynamic User:/:/nix/store/nhs0ppna5rf03hrdd7nz34jagbxddk5q-util-linux-minimal-2.41.1-login/bin/nologin ``` ``` Nov 02 18:19:36 pallas nix-daemon[2736]: accepted connection from pid 1889485, user gitea-runner (trusted) Nov 02 18:20:21 pallas nix-daemon[2736]: accepted connection from pid 1889532, user gitea-runner (trusted) Nov 02 20:05:55 pallas nix-daemon[2736]: accepted connection from pid 1898261, user gitea-runner (trusted) Nov 02 20:06:16 pallas nix-daemon[2736]: accepted connection from pid 1898467, user gitea-runner (trusted) Nov 03 07:39:54 pallas systemd[1]: Stopping Nix Daemon... Nov 07 01:04:54 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon Nov 07 01:04:56 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon Nov 07 01:04:58 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon Nov 07 01:05:00 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon Nov 07 01:05:02 pallas nix-daemon[1934485]: error: error processing connection: user '63182' is not allowed to connect to the Nix daemon Nov 07 01:07:24 pallas systemd[1]: Stopping Nix Daemon... Nov 07 01:07:24 pallas systemd[1]: nix-daemon.service: Deactivated successfully. Nov 07 01:07:24 pallas systemd[1]: Stopped Nix Daemon. Nov 07 01:07:24 pallas systemd[1]: Started Nix Daemon. Nov 07 01:07:32 pallas nix-daemon[2088798]: accepted connection from pid 2088910, user gitea-runner (trusted) Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091827, user gitea-runner (trusted) Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091825, user gitea-runner (trusted) Nov 07 01:08:00 pallas nix-daemon[2088798]: accepted connection from pid 2091824, user gitea-runner (trusted) ``` Happens on multiple machines and the shared configuration is `DynamicUser=`. ``` Nov 02 23:08:06 juno nix-daemon[8071]: accepted connection from pid 101518, user mach-symbols-upload Nov 02 23:10:03 juno nix-daemon[8071]: accepted connection from pid 101542, user mach-symbols-upload Nov 02 23:11:55 juno nix-daemon[8071]: accepted connection from pid 101557, user mach-symbols-upload Nov 02 23:13:55 juno nix-daemon[8071]: accepted connection from pid 101577, user mach-symbols-upload Nov 03 05:06:42 juno systemd[1]: Stopping Nix Daemon... Nov 03 12:00:29 juno nix-daemon[106712]: error: error processing connection: user '64495' is not allowed to connect to the Nix daemon Nov 03 12:36:49 juno nix-daemon[106712]: error: error processing connection: user '64495' is not allowed to connect to the Nix daemon Nov 03 12:37:12 juno systemd[1]: Stopping Nix Daemon... Nov 03 12:37:12 juno systemd[1]: nix-daemon.service: Deactivated successfully. Nov 03 12:37:12 juno systemd[1]: Stopped Nix Daemon. Nov 03 12:37:12 juno systemd[1]: nix-daemon.service: Consumed 99ms CPU time, 40M memory peak, 31.2M read from disk. Nov 03 12:37:12 juno systemd[1]: Started Nix Daemon. Nov 03 12:37:16 juno nix-daemon[112201]: accepted connection from pid 112208, user mach-symbols-upload Nov 03 12:39:43 juno nix-daemon[112201]: accepted connection from pid 112246, user mach-symbols-upload Nov 03 12:42:04 juno nix-daemon[112201]: accepted connection from pid 112277, user mach-symbols-upload ``` ## Steps To Reproduce 1. Configure a systemd service with `DynamicUser=` 2. Make that systemd service access the nix-daemon 3. Configure automatic updates 4. Wait until the service cannot access the nix-daemon anymore ## Expected behavior Looking up transient users that systemd creates should be reliable. ## `nix --version` output nix (Lix, like Nix) 2.91.3 ## Additional context
Owner

probably a glibc bug. glibc caches nscd failure, so once nscd is unavailable when the daemon wants to ask it something it'll never retry. there's nothing we can about this (that we know of), but lix head will not be affected by this since it runs these specific queries in a subprocess

probably a glibc bug. glibc caches nscd *failure*, so once nscd is unavailable when the daemon wants to ask it something it'll never retry. there's nothing we can about this (that we know of), but lix head will not be affected by this since it runs these specific queries in a subprocess
Author
Member

But probably not before 2.94.0, so not the default lix in 25.11, right?

But probably not before 2.94.0, so not the default lix in 25.11, right?
Owner

that change is only in 2.94 so far, but we could probably backport that specific change to 2.93. not sure it's a great idea though since it does change how daemons are launched :/

that change is only in 2.94 so far, but we could probably backport that specific change to 2.93. not sure it's a great idea though since it does change how daemons are launched :/
Owner

not sure we'll get to actually doing this. it may make sense to add systemd ordering constraint to the daemon/nscd link to mitigate this in the meantime

not sure we'll get to actually doing this. it may make sense to add systemd ordering constraint to the daemon/nscd link to mitigate this in the meantime
Author
Member

I can mitigate this on my own until 2.94.0, no biggie.

I can mitigate this on my own until 2.94.0, no biggie.
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lix-project/lix#1029
No description provided.