X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?p=elogind.git;a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=dd835aa37a3b0286d4996370ecc4d2a408710443;hp=14f8a129d58a321ddee28f5970d9906beaf6df45;hb=37370d0cbe7c79d3f5b44a9ddbfac87c59dc09dd;hpb=57371e5829a61e5ee6c9f98404dfc729d6c62608 diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 14f8a129d..dd835aa37 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -425,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); } } @@ -585,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) { @@ -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; @@ -3548,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; @@ -3556,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) @@ -3641,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; @@ -3741,6 +3771,9 @@ finish: unit_file_changes_free(changes, n_changes); dbus_error_free(&error); + + strv_free(mangled_names); + return r; }