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
install: follow config_path symlink #3362
Conversation
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. This does not affect how symlinks are treated within the config_path directory.
CC @mjhoy |
Sorry. But this isnt right. we use symlinks for service enablement configuration. Thus when enumerating the installed unit files we dont follow symlinks on purpose: we are interested in the actually installed unit names and not under the names they were enabled under... just dropping o_follow really is too simple. |
@poettering But in this case isn't |
ah, uh, I missed that this was about the find_symlinks() code, so yeah this doesn't affect how the unit files themselves are opened. However, the problem I see with this is that dropping O_NOFOLLOW means the kernel will follow symlinks and not take our optionally specified root dir into account while doing so... And that's a bigger problem... Right now, if you use "systemctl --root=... list-unit-files" you get a failure with such a symlinked dir, but with your patch applied, then we might end up reading the host's unit files, not the --root= ones.... Note sure what to suggest about that... |
Maybe: open the path with O_NOFOLLOW, check for ELOOP on error, and, if that was the error, then read the symlink's target, prefix the root directory to that target, and open the result, in a loop until opening no longer gives ELOOP. |
What is the status of this PR? NixOS still suffers from this problem. |
Apologies for the delay, I've been quite busy and this slipped my mind. In the course of implementing @Mathnerd314's suggestion, I've run across some unexpected behaviour: with systemd 230, I'm not sure if this is expected behaviour and am not familiar enough with the systemd codebase to check, but it's made regression testing difficult. I'm still trying to track down where this all happens. |
@poettering Additional testing in an Ubuntu 16.04 VM (systemd 229) and NixOS unstable (systemd 230) indicates that Given the above, I believe this PR does not introduce any regression re |
It also occurs to me that, even given |
@rimmington
We should probably fix that, and then check that the patch in this PR does not regress things and apply it. |
Hm, no, actually this seems correct: the second path in readlinkat is the output parameter. |
OK, so this only changes the way we open |
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. This does not affect how symlinks are treated within the config_path directory. (cherry picked from commit 1cd1dab)
Under NixOS, the config_path /etc/systemd/system is a symlink to /etc/static/systemd/system. Commands such as
systemctl list-unit-files
andsystemctl is-enabled
did not work as the symlink was not followed.This does not affect how symlinks are treated within the config_path directory.
This fixes NixOS/nixpkgs#1083.