]>
Commit | Line | Data |
---|---|---|
17bafa6d SS |
1 | From 67820a0cbdc9d72a1074debf8b2bc72203c775cc Mon Sep 17 00:00:00 2001 |
2 | From: Michael Tremer <michael.tremer@ipfire.org> | |
3 | Date: Sun, 19 May 2013 13:45:48 +0000 | |
4 | Subject: systemctl: make systemctl is-enabled work for templated units | |
5 | ||
6 | Patch resolves the problem that 'systemctl is-enabled' does | |
7 | not work for templated units. | |
8 | ||
9 | Without this patch, systemctl is-enabled something@abc.service | |
10 | returned "No such file or directory", because it first checked | |
11 | if /usr/lib/systemd/system/something@abc.service, etc. exists. | |
12 | If systemctl is-enabled is called for templated units, this | |
13 | check should be omitted and it should search for symlinks in | |
14 | the .wants dirs right away. | |
15 | ||
16 | This patch fixes the broken behaviour and resolves | |
17 | https://bugs.freedesktop.org/show_bug.cgi?id=55318. | |
18 | ||
19 | [zj: fixed the patch to still check for broken symlinks and | |
20 | masked instances. Also removed untrue assumptions from | |
21 | the patch description.] | |
22 | --- | |
23 | diff --git a/src/shared/install.c b/src/shared/install.c | |
24 | index edf4d2a..8f27c6d 100644 | |
25 | --- a/src/shared/install.c | |
26 | +++ b/src/shared/install.c | |
27 | @@ -1609,24 +1609,29 @@ UnitFileState unit_file_get_state( | |
28 | if (!path) | |
29 | return -ENOMEM; | |
30 | ||
31 | + /* | |
32 | + * Search for a unit file in our default paths, to | |
33 | + * be sure, that there are no broken symlinks. | |
34 | + */ | |
35 | if (lstat(path, &st) < 0) { | |
36 | r = -errno; | |
37 | - if (errno == ENOENT) | |
38 | - continue; | |
39 | - | |
40 | - return -errno; | |
41 | - } | |
42 | + if (errno != ENOENT) | |
43 | + return r; | |
44 | ||
45 | - if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)) | |
46 | - return -ENOENT; | |
47 | + if (!unit_name_is_instance(name)) | |
48 | + continue; | |
49 | + } else { | |
50 | + if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode)) | |
51 | + return -ENOENT; | |
52 | ||
53 | - r = null_or_empty_path(path); | |
54 | - if (r < 0 && r != -ENOENT) | |
55 | - return r; | |
56 | - else if (r > 0) { | |
57 | - state = path_startswith(*i, "/run") ? | |
58 | - UNIT_FILE_MASKED_RUNTIME : UNIT_FILE_MASKED; | |
59 | - return state; | |
60 | + r = null_or_empty_path(path); | |
61 | + if (r < 0 && r != -ENOENT) | |
62 | + return r; | |
63 | + else if (r > 0) { | |
64 | + state = path_startswith(*i, "/run") ? | |
65 | + UNIT_FILE_MASKED_RUNTIME : UNIT_FILE_MASKED; | |
66 | + return state; | |
67 | + } | |
68 | } | |
69 | ||
70 | r = find_symlinks_in_scope(scope, root_dir, name, &state); | |
71 | -- | |
72 | cgit v0.9.0.2-2-gbebe |