]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
shared/install: allow "enable" on linked unit files (#3790)
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 25 Jul 2016 14:20:16 +0000 (10:20 -0400)
committerLennart Poettering <lennart@poettering.net>
Mon, 25 Jul 2016 14:20:16 +0000 (16:20 +0200)
User expectations are broken when "systemctl enable /some/path/service.service"
behaves differently to "systemctl link ..." followed by "systemctl enable".
From user's POV, "enable" with the full path just combines the two steps into
one.

Fixes #3010.

src/shared/install.c
src/test/test-install-root.c

index 23cab96c5045f549949e6a66d96d8b4384f12aad..7b49e1ece9ee1a017164e5ef21e840886a61c81b 100644 (file)
@@ -2215,7 +2215,7 @@ int unit_file_enable(
         config_path = runtime ? paths.runtime_config : paths.persistent_config;
 
         STRV_FOREACH(f, files) {
-                r = install_info_discover(scope, &c, &paths, *f, SEARCH_LOAD, &i);
+                r = install_info_discover(scope, &c, &paths, *f, SEARCH_LOAD|SEARCH_FOLLOW_CONFIG_SYMLINKS, &i);
                 if (r < 0)
                         return r;
                 r = install_info_may_process(i, &paths, changes, n_changes);
index 4b9a74fca40645d7f278b420dca7f8c2dccfca62..db1c928660e1e4ebd2ebd6ca7528489c54c3738c 100644 (file)
@@ -301,7 +301,12 @@ static void test_linked_units(const char *root) {
         unit_file_changes_free(changes, n_changes);
         changes = NULL; n_changes = 0;
 
-        assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked3.service"), false, &changes, &n_changes) == -ELOOP);
+        assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("linked3.service"), false, &changes, &n_changes) >= 0);
+        assert_se(n_changes == 1);
+        assert_se(changes[0].type == UNIT_FILE_SYMLINK);
+        assert_se(startswith(changes[0].path, root));
+        assert_se(endswith(changes[0].path, "linked3.service"));
+        assert_se(streq(changes[0].source, "/opt/linked3.service"));
         unit_file_changes_free(changes, n_changes);
         changes = NULL; n_changes = 0;
 }