swarm-logs-auth: run as a static user so nginx reaches its socket
With DynamicUser=true and RuntimeDirectoryPreserve=yes, systemd creates the unit's runtime directory under /run/private/ (0700 root:root) and symlinks /run/swarm-logs-auth to it (systemd.exec(5), RuntimeDirectoryPreserve=). nginx runs as the unprivileged nginx user, so its connect() to /run/swarm-logs-auth/auth.sock failed with EACCES, the auth subrequest ended in a 502, and auth_request answered every agent bearer on /select/logsql/ with a 500. The unit now runs as a static swarm-logs-auth system user and group, the shape swarm-controller already uses for its 0751 + Preserve socket dir. RestrictSUIDSGID and RemoveIPC, which DynamicUser implied and the unit did not set itself, are set explicitly. module-eval-core-toggle gains a case that fails when any unit creating the runtime directory of a unix: upstream of nginx combines DynamicUser with RuntimeDirectoryPreserve. docs/process/gotchas.md records the trap. Fixes #5235
This commit is contained in:
parent
41404598f5
commit
b807189692
3 changed files with 66 additions and 1 deletions
|
|
@ -372,6 +372,13 @@ in
|
|||
# The agents' check on `/select/logsql/`. On the host rather than in the
|
||||
# store's container: it needs nothing of the store, only nginx's reach to
|
||||
# its socket and its own store identity.
|
||||
users.users.${logsAuthUnit} = {
|
||||
isSystemUser = true;
|
||||
group = logsAuthUnit;
|
||||
description = "swarm log store auth_request responder";
|
||||
};
|
||||
users.groups.${logsAuthUnit} = { };
|
||||
|
||||
systemd.services.${logsAuthUnit} = {
|
||||
description = "swarm log store auth_request responder for agent credentials";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
|
@ -391,7 +398,11 @@ in
|
|||
];
|
||||
# Paths only: `argv` is world-readable via /proc/<pid>/cmdline.
|
||||
LoadCredential = lib.mapAttrsToList (id: path: "${id}:${path}") logsAuthStoreFiles;
|
||||
DynamicUser = true;
|
||||
# ⚠️ A static user, never `DynamicUser`: with `RuntimeDirectoryPreserve`
|
||||
# systemd puts a dynamic user's runtime directory under
|
||||
# `/run/private/` (0700 root:root), which nginx cannot traverse.
|
||||
User = logsAuthUnit;
|
||||
Group = logsAuthUnit;
|
||||
RuntimeDirectory = logsAuthUnit;
|
||||
# Traverse-only for others, so nginx reaches the socket path.
|
||||
RuntimeDirectoryMode = "0751";
|
||||
|
|
@ -406,6 +417,8 @@ in
|
|||
PrivateTmp = true;
|
||||
PrivateDevices = true;
|
||||
NoNewPrivileges = true;
|
||||
RestrictSUIDSGID = true;
|
||||
RemoveIPC = true;
|
||||
};
|
||||
environment = {
|
||||
BAO_ADDR = "https://${baoCfg.domain}:${toString baoCfg.port}";
|
||||
|
|
|
|||
Loading…
Reference in a new issue