You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
systemctl link should refuse when target is inside systemd own's hierarchy #24605
Symlinked units can be used just like in previous releases, for instance 241.
Unexpected behaviour you saw
Symlinked unit files are considered "bad" by systemctl, can "not be found" and consequently not be enabled or started.
Steps to reproduce the problem
mkdir /etc/systemd/system/mydir
cat > /etc/systemd/system/mydir/test.service <<EOF
[Unit]
Description=Test
[Service]
ExecStart=/bin/sleep infinity
[Install]
WantedBy=multi-user.target
EOF
systemctl link /etc/systemd/system/mydir/test.service
#Created symlink /etc/systemd/system/test.service → /etc/systemd/system/mydir/test.service.
systemctl daemon-reload
#Nothing bad in the journal
systemctl list-unit-files
systemctl start test
#Failed to start test.service: Unit test.service not found.
systemctl enable test
#Failed to enable unit: Refusing to operate on alias name or linked unit file: test.service
Additional program output to the terminal or log subsystem illustrating the issue
Personally, I feel that https://github.com/systemd/systemd/issues/22000 was not resolved and that this report is a duplicate.
-bash-5.1# journalctl -b -o short-monotonic --grep bar.service
[3683340.083172] H systemd[1]: bar.service: Failed to load configuration: No such file or directory
[3683340.083404] H systemd[1]: bar.service: Collecting.
[3683346.358175] H systemd[1]: bar.service: unit self-alias: bar.service → bar.service, ignoring.
[3683356.750922] H systemd[1]: bar.service: unit self-alias: bar.service → bar.service, ignoring.
[3683363.780780] H systemd[1]: bar.service: Failed to load configuration: No such file or directory
[3683363.780992] H systemd[1]: bar.service: Collecting.
-bash-5.1# systemctl status bar.service
Unit bar.service could not be found.
-bash-5.1# systemctl start bar.service
Failed to start bar.service: Unit bar.service not found.
-bash-5.1# systemctl enable bar.service
Failed to enable unit: Refusing to operate on alias name or linked unit file: bar.service
Shouldn't this use full path comparison instead of just startswith? Since /etc/systemd/system/foo/bar.service is not in our search path, as we don't go through subdirs, but it's going to match against /etc/systemd/system/ in this case.
While we should have a better error message on enable, and refuse the link operation, we cannot support a model where users have their own custom hierarchies within the systemd directories. It is of course possible to store units outside the systemd directories and link them in, that should be supported.
changed the title [-]Linked unit files are not found[/-][+]systemctl link should refuse when target is inside systemd own's hierarchy[/+]on Oct 18, 2022
Activity
mrc0mmand commentedon Sep 8, 2022
Behaves the same with the latest main:
mrc0mmand commentedon Sep 8, 2022
systemd/src/basic/unit-file.c
Lines 331 to 340 in bbb71e5
Shouldn't this use full path comparison instead of just startswith? Since
/etc/systemd/system/foo/bar.serviceis not in our search path, as we don't go through subdirs, but it's going to match against/etc/systemd/system/in this case./cc @keszybz
bluca commentedon Oct 18, 2022
While we should have a better error message on
enable, and refuse thelinkoperation, we cannot support a model where users have their own custom hierarchies within the systemd directories. It is of course possible to store units outside the systemd directories and link them in, that should be supported.[-]Linked unit files are not found[/-][+]systemctl link should refuse when target is inside systemd own's hierarchy[/+]systemctl,manager: refuse linking unit files in the search paths
systemctl,manager: refuse linking unit files in the search paths
systemctl,manager: refuse linking unit files in the search paths
systemctl,manager: refuse linking unit files underneath the search paths