Skip to content

Install: correctly report symlink creations - #3016

Merged
poettering merged 1 commit into
systemd:masterfrom
martinpitt:systemctl-enable
Apr 12, 2016
Merged

poettering merged 1 commit into
systemd:masterfrom
martinpitt:systemctl-enable

Conversation

@martinpitt

Copy link
Copy Markdown
Contributor

All callers of create_symlink(), such as install_info_symlink_wants(), expect
that to return > 0 if it actually did something, and then return that number.
unit_file_enable() uses that to determine if any action was done
(carries_install_info != 0) and if not, show a "The unit files have no
[Install] section" warning.

Return 1 instead of 0 in the two code paths of create_symlink() when the link
was created or replaced with a new value.

This fixes getting a bogus "No [Install] section" warning when enabling a unit
with full path, like "systemctl enable /some/path/myunit.service".

This is also reproduced by the new test EnableTests.test_unit_enable_full_path in http://anonscm.debian.org/cgit/pkg-systemd/systemd.git/commit/?id=f2031001 . With current master the test does not fail as the actual symlink does get created correctly and systemctl enable exits with 0, but you do see the bogus error message.

This bug was discovered while examining issue #3010.

All callers of create_symlink(), such as install_info_symlink_wants(), expect
that to return > 0 if it actually did something, and then return that number.
unit_file_enable() uses that to determine if any action was done
(carries_install_info != 0) and if not, show a "The unit files have no
[Install] section" warning.

Return 1 instead of 0 in the two code paths of create_symlink() when the link
was created or replaced with a new value.

This fixes getting a bogus "No [Install] section" warning when enabling a unit
with full path, like "systemctl enable /some/path/myunit.service".
@poettering
poettering merged commit 1ade1cc into systemd:master Apr 12, 2016
manover pushed a commit to manover/systemd that referenced this pull request Apr 28, 2016
@martinpitt
martinpitt deleted the systemctl-enable branch September 13, 2016 07:10
xaiki pushed a commit to endlessm/systemd that referenced this pull request Feb 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants