Repository navigation
Description
Describe the bug
After bumping systemd from 253.6 to 254.3, a oneshot service using credentials no longer starts:
Oct 01 12:15:59 azazel systemd[1]: Starting Wallabag install service...
Oct 01 12:15:59 azazel (ll-start)[519003]: wallabag-install.service: Failed to set up credentials: Protocol error
Oct 01 12:15:59 azazel (ll-start)[519003]: wallabag-install.service: Failed at step CREDENTIALS spawning /nix/store/mlwk9kpwsvq82phwcwcq42da0giwsypr-unit-script-wallabag-install-start/bin/wallabag-install-start: Protocol error
Oct 01 12:16:00 azazel systemd[1]: wallabag-install.service: Main process exited, code=exited, status=243/CREDENTIALS
Oct 01 12:16:00 azazel systemd[1]: wallabag-install.service: Failed with result 'exit-code'.
Oct 01 12:16:00 azazel systemd[1]: Failed to start Wallabag install service.
Steps To Reproduce
Trying to switch to a configuration with this service: https://github.com/jtojnar/nixfiles/blob/384248379d6d6a8bddbc6f8334ecbea886671483/hosts/azazel/ogion.cz/bag/default.nix#L201-L204
wallabag-install.service
[Unit]
After=postgresql.service
Before=phpfpm-bag.service
Description=Wallabag install service
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/23j503pfa2gvdi4hgldsqkwzg80bdicn-glibc-locales-2.37-8/lib/locale/locale-archive"
Environment="PATH=/nix/store/y9gr7abwxvzcpg5g73vhnx1fpssr5frr-coreutils-9.3/bin:/nix/store/ysdsy30i42qbm0d4sl0illn52bam46rk-php-with-extensions-8.2.10/bin:/nix/store/binxgxrbqm8bavili2kr7vy1s2257mzv-composer-2.6.3/bin:/nix/store/y9gr7abwxvzcpg5g73vhnx1fpssr5frr-coreutils-9.3/bin:/nix/store/b6izr8wh0p7dyvh3cyg14wq2rn8d31ik-findutils-4.9.0/bin:/nix/store/xafzciap7acqhfx84dvqkp18bg4lrai3-gnugrep-3.11/bin:/nix/store/x23by79p38ll0js1alifmf3y56vqfs49-gnused-4.9/bin:/nix/store/1zmmnm0r0bdga398rl7fc7s4hkyqxjk4-systemd-254.3/bin:/nix/store/y9gr7abwxvzcpg5g73vhnx1fpssr5frr-coreutils-9.3/sbin:/nix/store/ysdsy30i42qbm0d4sl0illn52bam46rk-php-with-extensions-8.2.10/sbin:/nix/store/binxgxrbqm8bavili2kr7vy1s2257mzv-composer-2.6.3/sbin:/nix/store/y9gr7abwxvzcpg5g73vhnx1fpssr5frr-coreutils-9.3/sbin:/nix/store/b6izr8wh0p7dyvh3cyg14wq2rn8d31ik-findutils-4.9.0/sbin:/nix/store/xafzciap7acqhfx84dvqkp18bg4lrai3-gnugrep-3.11/sbin:/nix/store/x23by79p38ll0js1alifmf3y56vqfs49-gnused-4.9/sbin:/nix/store/1zmmnm0r0bdga398rl7fc7s4hkyqxjk4-systemd-254.3/sbin"
Environment="TZDIR=/nix/store/dk5vk3c9zknbjzzxmiglzv46qgv32gb0-tzdata-2023c/share/zoneinfo"
CacheDirectory=wallabag
CacheDirectoryMode=700
ConfigurationDirectory=wallabag
ExecStart=/nix/store/mlwk9kpwsvq82phwcwcq42da0giwsypr-unit-script-wallabag-install-start/bin/wallabag-install-start
LoadCredential=secret:/run/agenix/bag.ogion.cz-secret
LogsDirectory=wallabag
StateDirectory=wallabag
StateDirectoryMode=700
Type=oneshot
User=bagMore minimal steps TBD.
I tried building a minimal configuration in a VM but it worked there.
Expected behavior
The service should start without issue as before.
Additional context
I am using LoadCredential with agenix path owned by the user service:
$ ls -la /run/agenix/bag.ogion.cz-secret
-r-------- 1 bag bag 49 Oct 1 12:38 /run/agenix/bag.ogion.cz-secretIt fails with store path as well.
There are some credentials-related changes in 254: https://github.com/systemd/systemd/blob/174e8e9897c2d1c8b2c8324f07a6c784d7127410/NEWS#L304-L309
Notify maintainers
Metadata
This is running on VPSAdminOS so maybe there is something weird going on.
[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
- system: `"x86_64-linux"`
- host os: `Linux 6.5.4, NixOS, 23.11 (Tapir), 23.11.20230927.eb9b1d1`
- multi-user?: `no`
- sandbox: `yes`
- version: `nix-env (Nix) 2.15.1`
- channels(jtojnar): `""`
- channels(root): `""`
- nixpkgs: `not found`
Activity
ElvishJerricco commentedon Oct 1, 2023
Can you try this with systemd's
log_levelset to debug? Either boot withsystemd.log_level=debug, or runsystemctl log-level debugbefore starting the service.jtojnar commentedon Oct 1, 2023
I also tried applying the patch below to find out where it returns:
This is the line where EPROTO is returned:
https://github.com/systemd/systemd/blob/v254/src/core/execute.c#L3501
Debug patch
ElvishJerricco commentedon Oct 1, 2023
@jtojnar FYI, for that patch, you can shorthand a lot of those changes with
return log_error_errno(r, "foo bar: %m");, which will also print the human readable version of the error.azazel: Avoid systemd credentials
happysalada commentedon Oct 24, 2023
I had the same problem without specifying
Type="oneshot"to one of my services. I believe the default type is "simple". This doesn't seem related to the service type.aither64 commentedon Nov 1, 2023
The error is caused by AppArmor profile on vpsAdminOS denying mount of ramfs and then remount of /dev/shm. The denials can be seen in kernel logs on the host system. I haven't been able to fix the profile so far, I don't see what I'm missing. Anyways, vpsAdminOS is transitioning away from AppArmor in any case. Should anyone else encounter it on vpsFree.cz VPS, we can migrate the VPS to a node that is already without AppArmor. It's not possible to disable it at runtime and it can be a while until all nodes are rebooted.
@jtojnar, please feel free to ping me or @snajpa when you find issues related to vpsAdminOS.
happysalada commentedon Nov 1, 2023
Vpsadminos is only used in providers that use virtualization right ?
I encountered the error on hetzner baremetal instances so there might be another cause for the error.
t184256 commentedon Nov 1, 2023
aither64 commentedon Nov 1, 2023
@happysalada Yes, as far as I know, vpsAdminOS is only used for virtual servers (Linux containers actually) at vpsFree.cz. If you see this error elsewhere on baremetal or fully virtualized servers, then the cause is different and my comment above is not relevant.
wahjava commentedon Nov 1, 2023
In my case, I received following spurious error (whole log):
happysalada commentedon Nov 20, 2023
This is fixed for me on master.
wahjava commentedon Nov 20, 2023
@happysalada do you know which commit ? Thanks!
happysalada commentedon Nov 20, 2023
Its latest nixpkgs-unstable.
This is weird though, i thought that systemd was updated, but it doesnt look like it was.
Let me know if this works for you too.
wahjava commentedon Nov 20, 2023
Nope, doesn't work on
nixpkgs-unstable:happysalada commentedon Nov 20, 2023
Very weird. The next thing to track then is the 254-6 merge of systemd, if that doesnt work after that then it will take a lot longer until the release of 255.
Very weird that my service worked.
wahjava commentedon Nov 20, 2023
Also tried master branch (revision ed5e926), and that didn't work either.
wahjava commentedon Jan 28, 2024
And it still happens with
systemd 255.2:con-f-use commentedon Feb 2, 2024
This might be because of
PrivateDevices=trueor similar systemd directives. The credential-backend need access to stuff like/dev/tpm0in some situations. Also there's just been systemd/systemd#31197ElvishJerricco commentedon Feb 4, 2024
Thanks to @wahjava for figuring out that this can be caused by having credentials that are larger than half the maximum size (1M) when using
ExecStartPre. This causes systemd to write the credentials twice (once forExecStartPreand once forExecStart), which runs out of space and causesFailed to set up credentials: Protocol error. That's a great find.However, it's not a perfect explanation. The original issue said:
But the PR which introduced this double-credential-writing behavior was released in 252. So the problem should have been evident before then? The size limit of 1M had been there long before that PR was introduced.
PetarKirov commentedon Feb 12, 2024
I haven't had the chance to carefully follow the discussion here and on the SystemD GH repo side, but I wonder if this change would fix the issue: systemd/systemd#31202
wahjava commentedon Feb 12, 2024
@PetarKirov yes, but it needs to be backported to systemd 255.2 (which is nixos-unstable atm), or wait for new release. I submitted wahjava/systemd@af57967 which was rejected, but it's what I'm using in my setup until a new systemd release with the fix makes it to nixpkgs.
nixos/rosenpass: move preStart into script to workaround systemd bug
in-pursuit-of-ash commentedon Aug 6, 2024
Not the same issue as OP's, but since this page comes up as the first thing on search engines and the symptoms are very similar, another issue with the same error message will be fixed in the next systemd release: systemd/systemd#32612. tldr;
Type = simplewithLoadCredentialis unreliable andType = execshould be used instead.davispuh commentedon May 10, 2025
I encountered different issue with same error message. This is completely unrelated to NixOS but this thread seems good place for future reference and others 😄
Thanks to @aither64 comment above I found my issue is similar with his AppArmor profile issue.
In my case I'm running LXC container with openSUSE on Proxmox and inside LXC
agettyfails to start withIn Proxmox dmesg I see
So looks like it fails because trying to mount
/dev/shmwith different flags.One weird thing is that I have another openSUSE LXC with same software versions but it doesn't happen there.
I found that in failing LXC I have
/run/systemd/system/service.d/zzz-lxc-service.confSo here that
LoadCredentialcomes from. In working LXC this file is not present. Also in[email protected]there isType=idleso it seems different thing than above issue.I figured out that LXC with
Features: nested=1causeszzz-lxc-service.confto not be present while without it's present.Another thing I realized is that this used work fine before updating from
systemd 254 (254.15+suse.93.g957aeb6452)(works fine) tosystemd 254 (254.24+suse.148.g83b9060b6e)(stuff breaks)Right now I don't know how to actually fix it other than using
nested=1workaround.avsdev-cw commentedon Sep 24, 2025
This is one of the top results for issues with containers so I'm adding a bump with some of my own details (below). I don't know how specific to versions of systemd/lxc/etc this is. If there is a more appropriate place to put this (lxc/proxmox/systemd) then by all means, copy/paste/link to it.
Using Proxmox v9.0.9 the issue is present and it does seem that the cause revolves around
nested=0|1.When
1there seem to be no issues however when0then apparmor issues start occurring:This leads to numerous startup issues, particularly with systemd and, more annoyingly, getty services which result in no console for the container (also no journal service so there's no log in the container to show what the container is crashing out on):