tree-wide: unify logging of "Must be root" message

Let's unify this in one call, generalizing must_be_root() from
bootctl.c.
This commit is contained in:
Lennart Poettering
2017-12-11 23:19:45 +01:00
parent 4fe2ba0e25
commit fba868fa71
7 changed files with 25 additions and 27 deletions
+8 -8
View File
@@ -2074,10 +2074,9 @@ static int list_machines(int argc, char *argv[], void *userdata) {
sd_bus *bus;
int r;
if (geteuid() != 0) {
log_error("Must be root.");
return -EPERM;
}
r = must_be_root();
if (r < 0)
return r;
r = acquire_bus(BUS_MANAGER, &bus);
if (r < 0)
@@ -3603,9 +3602,10 @@ static int start_special(int argc, char *argv[], void *userdata) {
if (r < 0)
return r;
if (arg_force >= 2 && geteuid() != 0) {
log_error("Must be root.");
return -EPERM;
if (arg_force >= 2) {
r = must_be_root();
if (r < 0)
return r;
}
r = prepare_firmware_setup();
@@ -8638,7 +8638,7 @@ static int halt_main(void) {
if (geteuid() != 0) {
if (arg_dry_run || arg_force > 0) {
log_error("Must be root.");
(void) must_be_root();
return -EPERM;
}