|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From 85fa479ca5358d9472245eb0da6a86b5d644ccf9 Mon Sep 17 00:00:00 2001
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
From: Jan Synacek <jsynacek@redhat.com>
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Date: Tue, 7 Oct 2014 13:35:41 +0200
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
Subject: [PATCH] core: don't allow enabling if unit is masked
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
---
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
src/shared/install.c | 13 +++++++++++++
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
1 file changed, 13 insertions(+)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
diff --git a/src/shared/install.c b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
index fa064c230f..945bb2748d 100644
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
--- a/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+++ b/src/shared/install.c
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
@@ -1516,6 +1516,19 @@ int unit_file_enable(
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
STRV_FOREACH(i, files) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ UnitFileState state;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ state = unit_file_get_state(scope, root_dir, *i);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (state < 0) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return state;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ if (state == UNIT_FILE_MASKED || state == UNIT_FILE_MASKED_RUNTIME) {
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ log_error("Failed to enable unit: Unit %s is masked", *i);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ return -ENOTSUP;
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+ }
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
+
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
r = install_info_add_auto(&c, *i);
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
if (r < 0)
|
|
Zbigniew Jędrzejewski-Szmek |
62fe94 |
return r;
|