]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use ERFKILL instead of ESHUTDOWN for "unit masked"
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 16 Apr 2016 22:41:34 +0000 (18:41 -0400)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 16 Apr 2016 22:41:34 +0000 (18:41 -0400)
If the error code ever leaks (we print the strerror error instead of providing
our own), the message for ESHUTDOWN is "Cannot send after transport endpoint
shutdown", which can be misleading. In particular it suggest that some
mishandling of the dbus connection occured. Let's change that to ERFKILL which
has the advantage that a) it sounds implausible as actual error, b) has the
connotation of disabling something manually.

src/core/dbus-manager.c
src/core/transaction.c
src/shared/install.c
src/systemctl/systemctl.c
src/sysv-generator/sysv-generator.c
src/test/test-install-root.c

index 2392ed6c168a7002e6fe202617091f9001d5f8cb..0b12aae2ef63a6d3c390fa05e6be7ed1a15f7203 100644 (file)
@@ -1610,7 +1610,7 @@ fail:
 static int install_error(sd_bus_error *error, int c) {
         assert(c < 0);
 
-        if (c == -ESHUTDOWN)
+        if (c == -ERFKILL)
                 return sd_bus_error_setf(error, BUS_ERROR_UNIT_MASKED, "Unit file is masked.");
         if (c == -EADDRNOTAVAIL)
                 return sd_bus_error_setf(error, BUS_ERROR_UNIT_GENERATED, "Unit file is transient or generated.");
index dad387749c7e1ebae9854fa658c02fba9fb03a07..d5370b2a1451018894f5d412ead31752e8482ec9 100644 (file)
@@ -939,7 +939,7 @@ int transaction_add_job_and_dependencies(
                                 if (r < 0) {
                                         /* unit masked, job type not applicable and unit not found are not considered as errors. */
                                         log_unit_full(dep,
-                                                      IN_SET(r, -ESHUTDOWN, -EBADR, -ENOENT) ? LOG_DEBUG : LOG_WARNING,
+                                                      IN_SET(r, -ERFKILL, -EBADR, -ENOENT) ? LOG_DEBUG : LOG_WARNING,
                                                       r, "Cannot add dependency job, ignoring: %s",
                                                       bus_error_message(e, r));
                                         sd_bus_error_free(e);
index 8d9f96553b3885d3fd9f82c7e2a4c68369181885..35d83dd16c7f475ba527f1874849681c036076cc 100644 (file)
@@ -754,7 +754,7 @@ static int install_info_may_process(UnitFileInstallInfo *i, const LookupPaths *p
          * not subject to enable/disable operations. */
 
         if (i->type == UNIT_FILE_TYPE_MASKED)
-                return -ESHUTDOWN;
+                return -ERFKILL;
         if (path_is_generator(paths, i->path))
                 return -EADDRNOTAVAIL;
         if (path_is_transient(paths, i->path))
index 9310a0f4301ae9d5607cdf478f5c6d4fe77671fd..4942dbb6ad946c82e993ee7594480bd0cbb0739b 100644 (file)
@@ -5272,7 +5272,7 @@ static int enable_sysv_units(const char *verb, char **args) {
                         continue;
 
                 j = unit_file_exists(arg_scope, &paths, name);
-                if (j < 0 && !IN_SET(j, -ELOOP, -ESHUTDOWN, -EADDRNOTAVAIL))
+                if (j < 0 && !IN_SET(j, -ELOOP, -ERFKILL, -EADDRNOTAVAIL))
                         return log_error_errno(j, "Failed to lookup unit file state: %m");
                 found_native = j != 0;
 
@@ -5442,7 +5442,7 @@ static int enable_unit(int argc, char *argv[], void *userdata) {
                 else
                         assert_not_reached("Unknown verb");
 
-                if (r == -ESHUTDOWN)
+                if (r == -ERFKILL)
                         return log_error_errno(r, "Unit file is masked.");
                 if (r == -EADDRNOTAVAIL)
                         return log_error_errno(r, "Unit file is transient or generated.");
@@ -5617,7 +5617,7 @@ 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)
+                if (r == -ERFKILL)
                         return log_error_errno(r, "Unit file is masked.");
                 if (r == -EADDRNOTAVAIL)
                         return log_error_errno(r, "Unit file is transient or generated.");
index 9392a3d2b56d23f0568e2bc6ea9b28c7a7c0f6b6..fe4bbeeb75ff15d8bdc4e8da34b5f95b93e39424 100644 (file)
@@ -807,7 +807,7 @@ static int enumerate_sysv(const LookupPaths *lp, Hashmap *all_services) {
                                 continue;
 
                         r = unit_file_exists(UNIT_FILE_SYSTEM, lp, name);
-                        if (r < 0 && !IN_SET(r, -ELOOP, -ESHUTDOWN, -EADDRNOTAVAIL)) {
+                        if (r < 0 && !IN_SET(r, -ELOOP, -ERFKILL, -EADDRNOTAVAIL)) {
                                 log_debug_errno(r, "Failed to detect whether %s exists, skipping: %m", name);
                                 continue;
                         } else if (r != 0) {
index 2138655e291589f5014ce59eac82aa515c8f2984..998c345a1add8a19e99e01b10fe1ba2380568e1e 100644 (file)
@@ -80,7 +80,7 @@ static void test_basic_mask_and_enable(const char *root) {
         assert_se(unit_file_get_state(UNIT_FILE_SYSTEM, root, "d.service", &state) >= 0 && state == UNIT_FILE_MASKED);
 
         /* Enabling a masked unit should fail! */
-        assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == -ESHUTDOWN);
+        assert_se(unit_file_enable(UNIT_FILE_SYSTEM, false, root, STRV_MAKE("a.service"), false, &changes, &n_changes) == -ERFKILL);
         unit_file_changes_free(changes, n_changes);
         changes = NULL; n_changes = 0;