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
"systemctl list-unit-files" doesn't work #1083
Comments
Can we just patch |
So I think this is from http://cgit.freedesktop.org/systemd/systemd/tree/src/shared/install.c#n485 (in the find_symlinks function). There's a bunch of places where O_NOFOLLOW is done, it seems to me that removing it here could not fix things entirely. It uses SYSTEM_CONFIG_UNIT_PATH to know where to look (via get_config_path), which the Makefile sets to $(pkgsysconfdir)/system. That could be set to /etc/static/ but then the whole configuration lives at /etc/static/systemd and not /etc/systemd which is unexpected. Another option would be to dereference /etc/systemd/system, making it a real dir and copying the symlinks. Then it's a real directory and systemd should work unchanged. One last approach is to symlink /etc/systemd elsewhere. Not sure which is preferable when system configs are rebuilt. |
I'd like to note that this is still happening on the latest git master as of 07/31/2014 EDIT: I can't seem to remove some systemd services because of this bug... |
Will this get fixed inside systemd or patched at NixOS? |
Still doesn’t work. Can this be patched? Is there an alternative? |
I think we can patch systemd for reading, should be safe. Lennart talks about enable/disable which creates/removes symlinks and may be unsafe in case of suspicious symlinks. But for listing, I think we're safe to patch it and even propose upstream. |
I think |
Are there any news on this? Any suggestions on how to fix it? Would you accept a patch with a patch to apply during the build of systemd? |
@musteresel Yes, we’d be happy to review and accept a patch for that if you want to contribute it. |
I can't reproduce:
I just find it strange that nearly all units are marked as |
It's apparently fixed in master, but not in release-15.09 (just checked it). |
What was the commit that fixed it? |
It's still not fixed (if I guess correctly that what I see is the same bug):
|
I also see all unit files listed as in a "bad" state. Is anyone working on this? I tracked the code down to https://github.com/NixOS/systemd/blob/nixos-v228/src/shared/install.c#L629 and if I remove the O_NOFOLLOW there, the command seems to work, at least when i run
i have not tested it in a full install. (edit: is-enabled appears to work as well) |
and perhaps this systemd commit is helpful explaining why the NOFOLLOWs: |
@mjhoy That's great! Maybe open a PR to NixOS/systemd? |
@abbradar yeah... I feel I don't quite understand the design of both systemd and nixos well enough yet, but I will try to spend some time researching it. For instance poettering says explicitly "we'd never read install information through symlinks" in that commit I linked to above which seems to rule this out? At yet symlinks under /usr are ok? Also... I don't know how |
If I understand correctly, symlinks were not allowed because they are ought to be added by That being said, I don't know much about internals of systemd and judge only by this commit message, so these thoughts are very potentially wrong. |
Under NixOS, the config_path /etc/systemd/system is a symlink to /etc/static/systemd/system. Commands such as `systemctl list-unit-files` and `systemctl is-enabled` did not work as the symlink was not followed. As a rule systemd does not follow symlinks when reading install information under /etc as that is reserved for configuration. It's unclear whether that could ever be a problem in this case, for NixOS. I am testing this locally now. Hopefully, this fixes NixOS/nixpkgs#1083
I'm now running systemd (v228, current on unstable) with this tiny change mjhoy/systemd@5e45c1d. It seems to fix both That said I hardly do anything fancy with systemd, nor do I understand the system very well. If you would like to try the patch yourself you can plug this into
I can submit a PR to nixos/systemd if people think this makes sense. I fully expect that I'm missing something big, though, and this is a bad patch. |
It looks fine to me; the code is a big blob with no documentation, and this is a minimal change for an edge case. I would submit it as a PR to the main systemd repository, to see if Lennart has an opinion on whether /etc/systemd/system can be a symlink. |
That's a really simple change. Definitely try a PR at systemd, and if they don't accept it, it surely can be made as a patch in NixOS. |
It does work for me on the current master. |
@Profpatsch Did you try |
@jgillich You are right, missed that one. |
@mjhoy Is there a PR for systemd I can watch? |
@rimmington i sent a query in to their mailing list but didn't hear back from anyone. i'm not comfortable submitting a PR as i don't think i really understand the design. someone else who knows more should! |
Instead of patching systemd we could bindmount /etc/systemd/{system,user} to its respective targets. This fixes Any objections? |
Please no. That sounds very hacky to me. |
@mjhoy I've opened a PR with systemd. I've kept the commit author as you; let me know if you're not happy/comfortable with that. |
just FYI, looks like they merged this into master. |
Fixed on master. |
It fails as follows:
Strace shows that this is because /etc/systemd/system is a symlink, and systemd doesn't expect that:
(Note the O_NOFOLLOW.)
The text was updated successfully, but these errors were encountered: