X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=dd835aa37a3b0286d4996370ecc4d2a408710443;hp=2e0aaaa9fadbba410b781e1b35ab78e7b7a5c446;hb=37370d0cbe7c79d3f5b44a9ddbfac87c59dc09dd;hpb=c67de56f50b83ec0d34308a6de80f6c65879b1b5 diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 2e0aaaa9f..dd835aa37 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -74,7 +74,6 @@ static bool arg_no_block = false; static bool arg_no_legend = false; static bool arg_no_pager = false; static bool arg_no_wtmp = false; -static bool arg_no_sync = false; static bool arg_no_wall = false; static bool arg_no_reload = false; static bool arg_dry = false; @@ -426,9 +425,11 @@ static void output_units_list(const struct unit_info *unit_infos, unsigned c) { "JOB = Pending job for the unit.\n"); if (arg_all) - printf("\n%u units listed.\n", n_shown); + printf("\n%u loaded units listed.\n" + "To show all installed unit files use 'systemctl list-unit-files'.\n", n_shown); else - printf("\n%u units listed. Pass --all to see inactive units, too.\n", n_shown); + printf("\n%u loaded units listed. Pass --all to see loaded but inactive units, too.\n" + "To show all installed unit files use 'systemctl list-unit-files'.\n", n_shown); } } @@ -586,7 +587,8 @@ static void output_unit_file_list(const UnitFileList *units, unsigned c) { if (u->state == UNIT_FILE_MASKED || u->state == UNIT_FILE_MASKED_RUNTIME || - u->state == UNIT_FILE_DISABLED) { + u->state == UNIT_FILE_DISABLED || + u->state == UNIT_FILE_INVALID) { on = ansi_highlight_red(true); off = ansi_highlight_red(false); } else if (u->state == UNIT_FILE_ENABLED) { @@ -1537,11 +1539,12 @@ static int start_unit_one( DBUS_TYPE_INVALID); free(n); if (r) { - if (r == -ENOENT && arg_action != ACTION_SYSTEMCTL ) { + if (r == -ENOENT && arg_action != ACTION_SYSTEMCTL ) /* There's always a fallback possible for * legacy actions. */ r = -EADDRNOTAVAIL; - } + else + log_error("Failed to issue method call: %s", bus_error_message(error)); goto finish; } @@ -2147,7 +2150,7 @@ static void print_status_info(UnitStatusInfo *i) { printf("\t Process: %u %s=%s ", p->pid, p->name, strna(t)); free(t); - good = is_clean_exit_lsb(p->code, p->status); + good = is_clean_exit_lsb(p->code, p->status, NULL); if (!good) { on = ansi_highlight_red(true); off = ansi_highlight_red(false); @@ -2259,7 +2262,7 @@ static void print_status_info(UnitStatusInfo *i) { if (i->id && arg_transport != TRANSPORT_SSH) { int flags = - arg_lines * OUTPUT_SHOW_ALL | + arg_all * OUTPUT_SHOW_ALL | arg_follow * OUTPUT_FOLLOW | !arg_quiet * OUTPUT_WARN_CUTOFF | on_tty() * OUTPUT_COLOR; @@ -3143,6 +3146,7 @@ finish: static int daemon_reload(DBusConnection *bus, char **args) { int r; const char *method; + DBusError error; if (arg_action == ACTION_RELOAD) method = "Reload"; @@ -3171,7 +3175,7 @@ static int daemon_reload(DBusConnection *bus, char **args) { "org.freedesktop.systemd1.Manager", method, NULL, - NULL, + &error, DBUS_TYPE_INVALID); if (r == -ENOENT && arg_action != ACTION_SYSTEMCTL) @@ -3182,6 +3186,9 @@ static int daemon_reload(DBusConnection *bus, char **args) { /* On reexecution, we expect a disconnect, not * a reply */ r = 0; + else if (r) + log_error("Failed to issue method call: %s", bus_error_message(&error)); + dbus_error_free(&error); return r; } @@ -3544,6 +3551,28 @@ finish: return r; } +static int mangle_names(char **original_names, char ***mangled_names) { + char **names_it = NULL; + char **name = NULL; + + (*mangled_names) = new(char*, strv_length(original_names)+1); + if(!(*mangled_names)) + return log_oom(); + + names_it = *mangled_names; + + STRV_FOREACH(name, original_names) { + char *n = unit_name_mangle(*name); + (*names_it) = n ? n : strdup(*name); + if(!(*names_it)) + return log_oom(); + names_it++; + } + *names_it = NULL; + + return 0; +} + static int enable_unit(DBusConnection *bus, char **args) { const char *verb = args[0]; UnitFileChange *changes = NULL; @@ -3552,6 +3581,7 @@ static int enable_unit(DBusConnection *bus, char **args) { DBusMessage *m = NULL, *reply = NULL; int r; DBusError error; + char **mangled_names = NULL; r = enable_sysv_units(args); if (r < 0) @@ -3637,7 +3667,11 @@ static int enable_unit(DBusConnection *bus, char **args) { dbus_message_iter_init_append(m, &iter); - r = bus_append_strv_iter(&iter, args+1); + r = mangle_names(args+1, &mangled_names); + if(r < 0) + goto finish; + + r = bus_append_strv_iter(&iter, mangled_names); if (r < 0) { log_error("Failed to append unit files."); goto finish; @@ -3737,6 +3771,9 @@ finish: unit_file_changes_free(changes, n_changes); dbus_error_free(&error); + + strv_free(mangled_names); + return r; } @@ -3866,7 +3903,7 @@ static int systemctl_help(void) { " -n --lines=INTEGER Journal entries to show\n" " --follow Follow journal\n" " -o --output=STRING Change journal output mode (short, short-monotonic,\n" - " verbose, export, json, cat)\n\n" + " verbose, export, json, json-pretty, cat)\n\n" "Unit Commands:\n" " list-units List loaded units\n" " start [NAME...] Start (activate) one or more units\n" @@ -3944,7 +3981,6 @@ static int halt_help(void) { " -f --force Force immediate halt/power-off/reboot\n" " -w --wtmp-only Don't halt/power-off/reboot, just write wtmp record\n" " -d --no-wtmp Don't write wtmp record\n" - " -n --no-sync Don't sync before halt/power-off/reboot\n" " --no-wall Don't send wall message before halt/power-off/reboot\n", program_invocation_short_name, arg_action == ACTION_REBOOT ? "Reboot" : @@ -4266,7 +4302,6 @@ static int halt_parse_argv(int argc, char *argv[]) { { "force", no_argument, NULL, 'f' }, { "wtmp-only", no_argument, NULL, 'w' }, { "no-wtmp", no_argument, NULL, 'd' }, - { "no-sync", no_argument, NULL, 'n' }, { "no-wall", no_argument, NULL, ARG_NO_WALL }, { NULL, 0, NULL, 0 } }; @@ -4312,16 +4347,13 @@ static int halt_parse_argv(int argc, char *argv[]) { arg_no_wtmp = true; break; - case 'n': - arg_no_sync = true; - break; - case ARG_NO_WALL: arg_no_wall = true; break; case 'i': case 'h': + case 'n': /* Compatibility nops */ break; @@ -5163,9 +5195,6 @@ static int halt_main(DBusConnection *bus) { } } - if (!arg_no_sync) - sync(); - if (arg_dry) return 0;