summaryrefslogtreecommitdiffstats
path: root/src/systemctl
diff options
context:
space:
mode:
Diffstat (limited to 'src/systemctl')
-rw-r--r--src/systemctl/systemctl-compat-shutdown.c3
-rw-r--r--src/systemctl/systemctl-logind.c2
-rw-r--r--src/systemctl/systemctl-show.c33
-rw-r--r--src/systemctl/systemctl-start-special.c4
-rw-r--r--src/systemctl/systemctl-util.c4
-rw-r--r--src/systemctl/systemctl.c15
-rw-r--r--src/systemctl/systemctl.h1
7 files changed, 43 insertions, 19 deletions
diff --git a/src/systemctl/systemctl-compat-shutdown.c b/src/systemctl/systemctl-compat-shutdown.c
index c5b4cb4e8c..96597b1d9d 100644
--- a/src/systemctl/systemctl-compat-shutdown.c
+++ b/src/systemctl/systemctl-compat-shutdown.c
@@ -6,6 +6,7 @@
#include "pretty-print.h"
#include "reboot-util.h"
#include "systemctl-compat-shutdown.h"
+#include "systemctl-logind.h"
#include "systemctl-sysv-compat.h"
#include "systemctl.h"
#include "terminal-util.h"
@@ -137,7 +138,7 @@ int shutdown_parse_argv(int argc, char *argv[]) {
return r;
}
} else
- arg_when = now(CLOCK_REALTIME) + USEC_PER_MINUTE;
+ arg_when = USEC_INFINITY; /* logind chooses on server side */
if (argc > optind && arg_action == ACTION_CANCEL_SHUTDOWN)
/* No time argument for shutdown cancel */
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c
index d6cdd9748f..87e96a3a17 100644
--- a/src/systemctl/systemctl-logind.c
+++ b/src/systemctl/systemctl-logind.c
@@ -408,7 +408,7 @@ int logind_show_shutdown(void) {
else /* If we don't recognize the action string, we'll show it as-is */
pretty_action = action;
- if (arg_action == ACTION_SYSTEMCTL)
+ if (IN_SET(arg_action, ACTION_SYSTEMCTL, ACTION_SYSTEMCTL_SHOW_SHUTDOWN))
log_info("%s scheduled for %s, use 'systemctl %s --when=cancel' to cancel.",
pretty_action,
FORMAT_TIMESTAMP_STYLE(elapse, arg_timestamp_style),
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 2fdf321886..50f30d8565 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -202,11 +202,13 @@ typedef struct UnitStatusInfo {
bool transient;
/* Service */
+ bool running;
pid_t main_pid;
pid_t control_pid;
- const char *status_text;
const char *pid_file;
- bool running;
+ const char *status_text;
+ const char *status_bus_error;
+ const char *status_varlink_error;
int status_errno;
uint32_t fd_store_max;
@@ -681,9 +683,26 @@ static void print_status_info(
if (i->status_text)
printf(" Status: \"%s%s%s\"\n", ansi_highlight_cyan(), i->status_text, ansi_normal());
- if (i->status_errno > 0) {
- errno = i->status_errno;
- printf(" Error: %i (%m)\n", i->status_errno);
+
+ if (i->status_errno > 0 || i->status_bus_error || i->status_varlink_error) {
+ const char *prefix = " ";
+
+ printf(" Error:");
+
+ if (i->status_errno > 0) {
+ printf("%scode: %i (%s)", prefix, i->status_errno, STRERROR(i->status_errno));
+ prefix = "; ";
+ }
+ if (i->status_bus_error) {
+ printf("%sD-Bus: %s", prefix, i->status_bus_error);
+ prefix = "; ";
+ }
+ if (i->status_varlink_error) {
+ printf("%sVarlink: %s", prefix, i->status_varlink_error);
+ prefix = "; ";
+ }
+
+ putchar('\n');
}
if (i->ip_ingress_bytes != UINT64_MAX && i->ip_egress_bytes != UINT64_MAX)
@@ -2041,9 +2060,11 @@ static int show_one(
{ "ExecMainPID", "u", NULL, offsetof(UnitStatusInfo, main_pid) },
{ "MainPID", "u", map_main_pid, 0 },
{ "ControlPID", "u", NULL, offsetof(UnitStatusInfo, control_pid) },
- { "StatusText", "s", NULL, offsetof(UnitStatusInfo, status_text) },
{ "PIDFile", "s", NULL, offsetof(UnitStatusInfo, pid_file) },
+ { "StatusText", "s", NULL, offsetof(UnitStatusInfo, status_text) },
{ "StatusErrno", "i", NULL, offsetof(UnitStatusInfo, status_errno) },
+ { "StatusBusError", "s", NULL, offsetof(UnitStatusInfo, status_bus_error) },
+ { "StatusVarlinkError", "s", NULL, offsetof(UnitStatusInfo, status_varlink_error) },
{ "FileDescriptorStoreMax", "u", NULL, offsetof(UnitStatusInfo, fd_store_max) },
{ "NFileDescriptorStore", "u", NULL, offsetof(UnitStatusInfo, n_fd_store) },
{ "ExecMainStartTimestamp", "t", NULL, offsetof(UnitStatusInfo, start_timestamp) },
diff --git a/src/systemctl/systemctl-start-special.c b/src/systemctl/systemctl-start-special.c
index 95cf00fc81..00dd05bff7 100644
--- a/src/systemctl/systemctl-start-special.c
+++ b/src/systemctl/systemctl-start-special.c
@@ -203,10 +203,8 @@ int verb_start_special(int argc, char *argv[], void *userdata) {
case ACTION_SOFT_REBOOT:
if (arg_when == 0)
r = logind_reboot(a);
- else if (arg_when != USEC_INFINITY)
+ else
r = logind_schedule_shutdown(a);
- else /* arg_when == USEC_INFINITY */
- r = logind_cancel_shutdown();
if (r >= 0 || IN_SET(r, -EACCES, -EOPNOTSUPP, -EINPROGRESS))
/* The latter indicates that the requested operation requires auth,
* is not supported or already in progress, in which cases we ignore the error. */
diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c
index be3b35e6f9..a73fc3afd0 100644
--- a/src/systemctl/systemctl-util.c
+++ b/src/systemctl/systemctl-util.c
@@ -6,6 +6,7 @@
#include "sd-bus.h"
#include "sd-daemon.h"
+#include "ask-password-agent.h"
#include "bus-common-errors.h"
#include "bus-locator.h"
#include "bus-map-properties.h"
@@ -19,11 +20,10 @@
#include "macro.h"
#include "path-util.h"
#include "pidref.h"
+#include "polkit-agent.h"
#include "process-util.h"
#include "reboot-util.h"
#include "set.h"
-#include "spawn-ask-password-agent.h"
-#include "spawn-polkit-agent.h"
#include "stat-util.h"
#include "systemctl-util.h"
#include "systemctl.h"
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 0ca76ac23d..5bb6ccacf7 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -1023,15 +1023,17 @@ static int systemctl_parse_argv(int argc, char *argv[]) {
case ARG_WHEN:
if (streq(optarg, "show")) {
- r = logind_show_shutdown();
- if (r < 0 && r != -ENODATA)
- return r;
-
- return 0;
+ arg_action = ACTION_SYSTEMCTL_SHOW_SHUTDOWN;
+ return 1;
}
if (STR_IN_SET(optarg, "", "cancel")) {
- arg_when = USEC_INFINITY;
+ arg_action = ACTION_CANCEL_SHUTDOWN;
+ return 1;
+ }
+
+ if (streq(optarg, "auto")) {
+ arg_when = USEC_INFINITY; /* logind chooses on server side */
break;
}
@@ -1339,6 +1341,7 @@ static int run(int argc, char *argv[]) {
break;
case ACTION_SHOW_SHUTDOWN:
+ case ACTION_SYSTEMCTL_SHOW_SHUTDOWN:
r = logind_show_shutdown();
break;
diff --git a/src/systemctl/systemctl.h b/src/systemctl/systemctl.h
index cc2b8c2cc4..00405f4705 100644
--- a/src/systemctl/systemctl.h
+++ b/src/systemctl/systemctl.h
@@ -35,6 +35,7 @@ enum action {
ACTION_RUNLEVEL,
ACTION_CANCEL_SHUTDOWN,
ACTION_SHOW_SHUTDOWN,
+ ACTION_SYSTEMCTL_SHOW_SHUTDOWN,
_ACTION_MAX,
_ACTION_INVALID = -EINVAL,
};