chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
systemctl: allow 'systemctl reboot -ff' to succeed even without D-Bus
[elogind.git]
/
src
/
systemctl
/
systemctl.c
diff --git
a/src/systemctl/systemctl.c
b/src/systemctl/systemctl.c
index d57e0931a5ff7bff92c641626f00061bb07c5808..681ad8c2116a0f6a8c12f22a88abbe47ad5b5544 100644
(file)
--- a/
src/systemctl/systemctl.c
+++ b/
src/systemctl/systemctl.c
@@
-67,7
+67,6
@@
static char **arg_property = NULL;
static bool arg_all = false;
static const char *arg_job_mode = "replace";
static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
static bool arg_all = false;
static const char *arg_job_mode = "replace";
static UnitFileScope arg_scope = UNIT_FILE_SYSTEM;
-static bool arg_immediate = false;
static bool arg_no_block = false;
static bool arg_no_legend = false;
static bool arg_no_pager = false;
static bool arg_no_block = false;
static bool arg_no_legend = false;
static bool arg_no_pager = false;
@@
-1784,11
+1783,15
@@
static int start_special(DBusConnection *bus, char **args) {
enum action a;
int r;
enum action a;
int r;
- assert(bus);
assert(args);
a = verb_to_action(args[0]);
assert(args);
a = verb_to_action(args[0]);
+ if (arg_force >= 2 && geteuid() != 0) {
+ log_error("Must be root.");
+ return -EPERM;
+ }
+
if (arg_force >= 2 &&
(a == ACTION_HALT ||
a == ACTION_POWEROFF ||
if (arg_force >= 2 &&
(a == ACTION_HALT ||
a == ACTION_POWEROFF ||
@@
-4525,7
+4528,7
@@
static int halt_parse_argv(int argc, char *argv[]) {
if (utmp_get_runlevel(&runlevel, NULL) >= 0)
if (runlevel == '0' || runlevel == '6')
if (utmp_get_runlevel(&runlevel, NULL) >= 0)
if (runlevel == '0' || runlevel == '6')
- arg_
immediate = true
;
+ arg_
force = 2
;
while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0) {
switch (c) {
while ((c = getopt_long(argc, argv, "pfwdnih", options, NULL)) >= 0) {
switch (c) {
@@
-4548,7
+4551,7
@@
static int halt_parse_argv(int argc, char *argv[]) {
break;
case 'f':
break;
case 'f':
- arg_
immediate = true
;
+ arg_
force = 2
;
break;
case 'w':
break;
case 'w':
@@
-5200,7
+5203,9
@@
static int systemctl_main(DBusConnection *bus, int argc, char *argv[], DBusError
return 0;
}
return 0;
}
- if (!bus) {
+ if (((!streq(verbs[i].verb, "reboot") &&
+ !streq(verbs[i].verb, "halt") &&
+ !streq(verbs[i].verb, "reboot")) || arg_force <= 0) && !bus) {
log_error("Failed to get D-Bus connection: %s",
dbus_error_is_set(error) ? error->message : "No connection to service manager.");
return -EIO;
log_error("Failed to get D-Bus connection: %s",
dbus_error_is_set(error) ? error->message : "No connection to service manager.");
return -EIO;
@@
-5350,7
+5355,7
@@
static int halt_main(DBusConnection *bus) {
if (arg_when <= 0 &&
!arg_dry &&
if (arg_when <= 0 &&
!arg_dry &&
- !arg_
immediat
e &&
+ !arg_
forc
e &&
(arg_action == ACTION_POWEROFF ||
arg_action == ACTION_REBOOT)) {
r = reboot_with_logind(bus, arg_action);
(arg_action == ACTION_POWEROFF ||
arg_action == ACTION_REBOOT)) {
r = reboot_with_logind(bus, arg_action);
@@
-5387,7
+5392,7
@@
static int halt_main(DBusConnection *bus) {
}
}
}
}
- if (!arg_dry && !arg_
immediat
e)
+ if (!arg_dry && !arg_
forc
e)
return start_with_fallback(bus);
if (!arg_no_wtmp) {
return start_with_fallback(bus);
if (!arg_no_wtmp) {