X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fsystemctl%2Fsystemctl.c;h=17dfff7887abca4f22b450447d00cb62d773bec9;hb=536bfdab4cca38916ec8b112a6f80b0c068cc806;hp=3f5bcdd1fb16c323c5d13452fd7fb36858d0a5d9;hpb=c09157eeeadf7b6810ca3b9ff7c180767e9a30b7;p=elogind.git diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 3f5bcdd1f..17dfff788 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -73,7 +73,6 @@ #include "bus-message.h" #include "bus-error.h" #include "bus-errors.h" -#include "copy.h" #include "mkdir.h" static char **arg_types = NULL; @@ -3221,6 +3220,7 @@ typedef struct UnitStatusInfo { const char *active_state; const char *sub_state; const char *unit_file_state; + const char *unit_file_preset; const char *description; const char *following; @@ -3344,7 +3344,10 @@ static void print_status_info( if (i->load_error) printf(" Loaded: %s%s%s (Reason: %s)\n", on, strna(i->load_state), off, i->load_error); - else if (path && i->unit_file_state) + else if (path && !isempty(i->unit_file_state) && !isempty(i->unit_file_preset)) + printf(" Loaded: %s%s%s (%s; %s; vendor preset: %s)\n", + on, strna(i->load_state), off, path, i->unit_file_state, i->unit_file_preset); + else if (path && !isempty(i->unit_file_state)) printf(" Loaded: %s%s%s (%s; %s)\n", on, strna(i->load_state), off, path, i->unit_file_state); else if (path) @@ -3669,6 +3672,8 @@ static int status_property(const char *name, sd_bus_message *m, UnitStatusInfo * i->following = s; else if (streq(name, "UnitFileState")) i->unit_file_state = s; + else if (streq(name, "UnitFilePreset")) + i->unit_file_preset = s; else if (streq(name, "Result")) i->result = s; } @@ -5138,7 +5143,7 @@ static int enable_sysv_units(const char *verb, char **args) { int r = 0; #if defined(HAVE_SYSV_COMPAT) && defined(HAVE_CHKCONFIG) - unsigned f = 1, t = 1; + unsigned f = 0; _cleanup_lookup_paths_free_ LookupPaths paths = {}; if (arg_scope != UNIT_FILE_SYSTEM) @@ -5157,7 +5162,7 @@ static int enable_sysv_units(const char *verb, char **args) { return r; r = 0; - for (f = 0; args[f]; f++) { + while (args[f]) { const char *name; _cleanup_free_ char *p = NULL, *q = NULL, *l = NULL; bool found_native = false, found_sysv; @@ -5168,7 +5173,7 @@ static int enable_sysv_units(const char *verb, char **args) { pid_t pid; siginfo_t status; - name = args[f]; + name = args[f++]; if (!endswith(name, ".service")) continue; @@ -5200,9 +5205,6 @@ static int enable_sysv_units(const char *verb, char **args) { if (!found_sysv) continue; - /* Mark this entry, so that we don't try enabling it as native unit */ - args[f] = (char*) ""; - log_info("%s is not a native service, redirecting to /sbin/chkconfig.", name); if (!isempty(arg_root)) @@ -5251,19 +5253,12 @@ static int enable_sysv_units(const char *verb, char **args) { return -EINVAL; } else return -EPROTO; - } - - /* Drop all SysV units */ - for (f = 0, t = 0; args[f]; f++) { - if (isempty(args[f])) - continue; - - args[t++] = args[f]; + /* Remove this entry, so that we don't try enabling it as native unit */ + assert(f > 0 && streq(args[f-1], name)); + assert_se(strv_remove(args + f - 1, name)); } - args[t] = NULL; - #endif return r; } @@ -5747,8 +5742,11 @@ static int create_edit_temp_file(const char *new_path, const char *original_path return log_oom(); r = mkdir_parents(new_path, 0755); - if (r < 0) - return log_error_errno(r, "Failed to create directories for %s: %m", new_path); + if (r < 0) { + log_error_errno(r, "Failed to create directories for %s: %m", new_path); + free(t); + return r; + } r = copy_file(original_path, t, 0, 0644); if (r == -ENOENT) { @@ -7238,12 +7236,9 @@ static int talk_initctl(void) { return -errno; } - errno = 0; - r = loop_write(fd, &request, sizeof(request), false) != sizeof(request); - if (r) { - log_error_errno(errno, "Failed to write to "INIT_FIFO": %m"); - return errno > 0 ? -errno : -EIO; - } + r = loop_write(fd, &request, sizeof(request), false); + if (r < 0) + return log_error_errno(r, "Failed to write to "INIT_FIFO": %m"); return 1; }