|
|
a1d4eb |
From be49ecd6ee3af4aa83572ca413aa457058e3573d Mon Sep 17 00:00:00 2001
|
|
|
a1d4eb |
From: Dave Reisner <dreisner@archlinux.org>
|
|
|
a1d4eb |
Date: Thu, 30 Oct 2014 20:12:05 -0400
|
|
|
a1d4eb |
Subject: [PATCH] shared/install: avoid prematurely rejecting "missing" units
|
|
|
a1d4eb |
|
|
|
a1d4eb |
f7101b7368df copied some logic to prevent enabling masked units, but
|
|
|
a1d4eb |
also added a check which causes attempts to enable templated units to
|
|
|
a1d4eb |
fail. Since we know the logic beyond this check will properly handle
|
|
|
a1d4eb |
units which truly do not exist, we can rely on the unit file state
|
|
|
a1d4eb |
comparison to suffice for expressing the intent of f7101b7368df.
|
|
|
a1d4eb |
|
|
|
a1d4eb |
ref: https://bugs.archlinux.org/task/42616
|
|
|
a1d4eb |
|
|
|
a1d4eb |
(Cherry-picked from 0ffce503cd6e5a5ff5ba5cd1cc23684cfb8bb9e3)
|
|
|
a1d4eb |
|
|
|
a1d4eb |
Resolves: #1199981
|
|
|
a1d4eb |
---
|
|
|
a1d4eb |
src/shared/install.c | 8 +++-----
|
|
|
a1d4eb |
1 file changed, 3 insertions(+), 5 deletions(-)
|
|
|
a1d4eb |
|
|
|
a1d4eb |
diff --git a/src/shared/install.c b/src/shared/install.c
|
|
|
a1d4eb |
index 7a29798..13db732 100644
|
|
|
a1d4eb |
--- a/src/shared/install.c
|
|
|
a1d4eb |
+++ b/src/shared/install.c
|
|
|
a1d4eb |
@@ -1522,12 +1522,10 @@ int unit_file_enable(
|
|
|
a1d4eb |
STRV_FOREACH(i, files) {
|
|
|
a1d4eb |
UnitFileState state;
|
|
|
a1d4eb |
|
|
|
a1d4eb |
+ /* We only want to know if this unit is masked, so we ignore
|
|
|
a1d4eb |
+ * errors from unit_file_get_state, deferring other checks.
|
|
|
a1d4eb |
+ * This allows templated units to be enabled on the fly. */
|
|
|
a1d4eb |
state = unit_file_get_state(scope, root_dir, *i);
|
|
|
a1d4eb |
- if (state < 0) {
|
|
|
a1d4eb |
- log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
|
|
|
a1d4eb |
- return state;
|
|
|
a1d4eb |
- }
|
|
|
a1d4eb |
-
|
|
|
a1d4eb |
if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) {
|
|
|
a1d4eb |
log_error("Failed to enable unit: Unit %s is masked", *i);
|
|
|
a1d4eb |
return -ENOTSUP;
|