From d073dea0a89c271fc4a769d5b3b2db395aa0239a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 8 Oct 2015 18:33:11 +0200 Subject: install: never log from install functions Instead, let the caller do that. Fix this by moving masked unit messages into the caller, by returning a clear error code (ESHUTDOWN) by which this may be detected. --- src/systemctl/systemctl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/systemctl') diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index e9d73ea9d0..83ec37d19b 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -5437,10 +5437,10 @@ static int enable_unit(int argc, char *argv[], void *userdata) { else assert_not_reached("Unknown verb"); - if (r < 0) { - log_error_errno(r, "Operation failed: %m"); - goto finish; - } + if (r == -ESHUTDOWN) + return log_error_errno(r, "Unit file is masked."); + if (r < 0) + return log_error_errno(r, "Operation failed: %m"); if (!arg_quiet) dump_unit_file_changes(changes, n_changes); @@ -5557,7 +5557,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) { r = acquire_bus(BUS_MANAGER, &bus); if (r < 0) - return r; + goto finish; new_args[0] = (char*) (streq(argv[0], "enable") ? "start" : "stop"); for (i = 0; i < n_changes; i++) @@ -5603,7 +5603,8 @@ static int add_dependency(int argc, char *argv[], void *userdata) { unsigned n_changes = 0; r = unit_file_add_dependency(arg_scope, arg_runtime, arg_root, names, target, dep, arg_force, &changes, &n_changes); - + if (r == -ESHUTDOWN) + return log_error_errno(r, "Unit file is masked."); if (r < 0) return log_error_errno(r, "Can't add dependency: %m"); -- cgit v1.2.3-54-g00ecf