diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/basic/time-util.c | 7 | ||||
-rw-r--r-- | src/basic/time-util.h | 2 | ||||
-rw-r--r-- | src/core/main.c | 1 | ||||
-rw-r--r-- | src/login/logind-session.c | 6 | ||||
-rw-r--r-- | src/login/logind-user.c | 6 | ||||
-rw-r--r-- | src/machine/machine.c | 6 | ||||
-rw-r--r-- | src/shared/bus-util.c | 45 | ||||
-rw-r--r-- | src/shared/bus-util.h | 2 | ||||
-rw-r--r-- | src/systemctl/systemctl.c | 17 |
9 files changed, 57 insertions, 35 deletions
diff --git a/src/basic/time-util.c b/src/basic/time-util.c index ac5988fdf9..0b4f5ab5b9 100644 --- a/src/basic/time-util.c +++ b/src/basic/time-util.c @@ -449,7 +449,7 @@ int dual_timestamp_deserialize(const char *value, dual_timestamp *t) { assert(t); if (sscanf(value, "%llu %llu", &a, &b) != 2) { - log_debug("Failed to parse finish timestamp value %s.", value); + log_debug("Failed to parse dual timestamp value \"%s\": %m", value); return -EINVAL; } @@ -459,15 +459,14 @@ int dual_timestamp_deserialize(const char *value, dual_timestamp *t) { return 0; } -int deserialize_timestamp_value(const char *value, usec_t *timestamp) { +int timestamp_deserialize(const char *value, usec_t *timestamp) { int r; assert(value); r = safe_atou64(value, timestamp); - if (r < 0) - return log_debug_errno(r, "Failed to parse finish timestamp value \"%s\": %m", value); + return log_debug_errno(r, "Failed to parse timestamp value \"%s\": %m", value); return r; } diff --git a/src/basic/time-util.h b/src/basic/time-util.h index a826ad75ec..77e3cd08d4 100644 --- a/src/basic/time-util.h +++ b/src/basic/time-util.h @@ -99,7 +99,7 @@ char *format_timespan(char *buf, size_t l, usec_t t, usec_t accuracy); void dual_timestamp_serialize(FILE *f, const char *name, dual_timestamp *t); int dual_timestamp_deserialize(const char *value, dual_timestamp *t); -int deserialize_timestamp_value(const char *value, usec_t *timestamp); +int timestamp_deserialize(const char *value, usec_t *timestamp); int parse_timestamp(const char *t, usec_t *usec); diff --git a/src/core/main.c b/src/core/main.c index e2088574c0..c725a686f1 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1313,7 +1313,6 @@ int main(int argc, char *argv[]) { /* This is compatibility support for SysV, where * calling init as a user is identical to telinit. */ - errno = -ENOENT; execv(SYSTEMCTL_BINARY_PATH, argv); log_error_errno(errno, "Failed to exec " SYSTEMCTL_BINARY_PATH ": %m"); return 1; diff --git a/src/login/logind-session.c b/src/login/logind-session.c index 9874cdae5e..e088225beb 100644 --- a/src/login/logind-session.c +++ b/src/login/logind-session.c @@ -446,8 +446,10 @@ int session_load(Session *s) { safe_close(fd); } - deserialize_timestamp_value(realtime, &s->timestamp.realtime); - deserialize_timestamp_value(monotonic, &s->timestamp.monotonic); + if (realtime) + timestamp_deserialize(realtime, &s->timestamp.realtime); + if (monotonic) + timestamp_deserialize(monotonic, &s->timestamp.monotonic); if (controller) { if (bus_name_has_owner(s->manager->bus, controller, NULL) > 0) diff --git a/src/login/logind-user.c b/src/login/logind-user.c index aa27f73a87..a826321bf0 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -321,8 +321,10 @@ int user_load(User *u) { if (s && s->display && display_is_local(s->display)) u->display = s; - deserialize_timestamp_value(realtime, &u->timestamp.realtime); - deserialize_timestamp_value(monotonic, &u->timestamp.monotonic); + if (realtime) + timestamp_deserialize(realtime, &u->timestamp.realtime); + if (monotonic) + timestamp_deserialize(monotonic, &u->timestamp.monotonic); return r; } diff --git a/src/machine/machine.c b/src/machine/machine.c index 7e92ffc474..7a7a1bb42b 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -299,8 +299,10 @@ int machine_load(Machine *m) { m->class = c; } - deserialize_timestamp_value(realtime, &m->timestamp.realtime); - deserialize_timestamp_value(monotonic, &m->timestamp.monotonic); + if (realtime) + timestamp_deserialize(realtime, &m->timestamp.realtime); + if (monotonic) + timestamp_deserialize(monotonic, &m->timestamp.monotonic); if (netif) { size_t allocated = 0, nr = 0; diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c index 38557f0b8d..c87eaf63d8 100644 --- a/src/shared/bus-util.c +++ b/src/shared/bus-util.c @@ -2028,20 +2028,21 @@ static const struct { { "start-limit", "start of the service was attempted too often" } }; -static void log_job_error_with_service_result(const char* service, const char *result, const char *extra_args) { - _cleanup_free_ char *service_shell_quoted = NULL, *systemctl_extra_args = NULL; +static void log_job_error_with_service_result(const char* service, const char *result, const char* const* extra_args) { + _cleanup_free_ char *service_shell_quoted = NULL; + const char *systemctl = "systemctl", *journalctl = "journalct"; assert(service); service_shell_quoted = shell_maybe_quote(service); - systemctl_extra_args = strjoin("systemctl ", extra_args, " ", NULL); - if (!systemctl_extra_args) { - log_oom(); - return; - } + if (extra_args && extra_args[1]) { + _cleanup_free_ char *t; - systemctl_extra_args = strstrip(systemctl_extra_args); + t = strv_join((char**) extra_args, " "); + systemctl = strjoina("systemctl ", t ?: "<args>", NULL); + journalctl = strjoina("journalctl ", t ?: "<args>", NULL); + } if (!isempty(result)) { unsigned i; @@ -2051,30 +2052,34 @@ static void log_job_error_with_service_result(const char* service, const char *r break; if (i < ELEMENTSOF(explanations)) { - log_error("Job for %s failed because %s. See \"%s status %s\" and \"journalctl -xe\" for details.\n", + log_error("Job for %s failed because %s.\n" + "See \"%s status %s\" and \"%s -xe\" for details.\n", service, explanations[i].explanation, - systemctl_extra_args, - strna(service_shell_quoted)); - + systemctl, + service_shell_quoted ?: "<service>", + journalctl); goto finish; } } - log_error("Job for %s failed. See \"%s status %s\" and \"journalctl -xe\" for details.\n", + log_error("Job for %s failed.\n" + "See \"%s status %s\" and \"%s -xe\" for details.\n", service, - systemctl_extra_args, - strna(service_shell_quoted)); + systemctl, + service_shell_quoted ?: "<service>", + journalctl); finish: /* For some results maybe additional explanation is required */ if (streq_ptr(result, "start-limit")) - log_info("To force a start use \"%1$s reset-failed %2$s\" followed by \"%1$s start %2$s\" again.", - systemctl_extra_args, - strna(service_shell_quoted)); + log_info("To force a start use \"%1$s reset-failed %2$s\"\n" + "followed by \"%1$s start %2$s\" again.", + systemctl, + service_shell_quoted ?: "<service>"); } -static int check_wait_response(BusWaitForJobs *d, bool quiet, const char *extra_args) { +static int check_wait_response(BusWaitForJobs *d, bool quiet, const char* const* extra_args) { int r = 0; assert(d->result); @@ -2125,7 +2130,7 @@ static int check_wait_response(BusWaitForJobs *d, bool quiet, const char *extra_ return r; } -int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char *extra_args) { +int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args) { int r = 0; assert(d); diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h index 204da55682..fcda1b2c6c 100644 --- a/src/shared/bus-util.h +++ b/src/shared/bus-util.h @@ -180,7 +180,7 @@ typedef struct BusWaitForJobs BusWaitForJobs; int bus_wait_for_jobs_new(sd_bus *bus, BusWaitForJobs **ret); void bus_wait_for_jobs_free(BusWaitForJobs *d); int bus_wait_for_jobs_add(BusWaitForJobs *d, const char *path); -int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char *extra_args); +int bus_wait_for_jobs(BusWaitForJobs *d, bool quiet, const char* const* extra_args); int bus_wait_for_jobs_one(BusWaitForJobs *d, const char *path, bool quiet); DEFINE_TRIVIAL_CLEANUP_FUNC(BusWaitForJobs*, bus_wait_for_jobs_free); diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index 908ccabf8a..c75d12c136 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2778,9 +2778,22 @@ static int start_unit(int argc, char *argv[], void *userdata) { } if (!arg_no_block) { - int q; + int q, arg_count = 0; + const char* extra_args[4] = {}; + + if (arg_scope != UNIT_FILE_SYSTEM) + extra_args[arg_count++] = "--user"; + + assert(IN_SET(arg_transport, BUS_TRANSPORT_LOCAL, BUS_TRANSPORT_REMOTE, BUS_TRANSPORT_MACHINE)); + if (arg_transport == BUS_TRANSPORT_REMOTE) { + extra_args[arg_count++] = "-H"; + extra_args[arg_count++] = arg_host; + } else if (arg_transport == BUS_TRANSPORT_MACHINE) { + extra_args[arg_count++] = "-M"; + extra_args[arg_count++] = arg_host; + } - q = bus_wait_for_jobs(w, arg_quiet, arg_scope != UNIT_FILE_SYSTEM ? "--user" : NULL); + q = bus_wait_for_jobs(w, arg_quiet, extra_args); if (q < 0) return q; |