}
}
+int must_be_root(void) {
+
+ if (geteuid() == 0)
+ return 0;
+
+ log_error("Need to be root.");
+ return -EPERM;
+}
+
static const char *const ioprio_class_table[] = {
[IOPRIO_CLASS_NONE] = "none",
[IOPRIO_CLASS_RT] = "realtime",
int ioprio_parse_priority(const char *s, int *ret);
pid_t getpid_cached(void);
+
+int must_be_root(void);
log_warning_errno(r, "Failed to read EFI variable %s: %m", name);
}
-static int must_be_root(void) {
-
- if (geteuid() == 0)
- return 0;
-
- log_error("Need to be root.");
- return -EPERM;
-}
-
static int verb_status(int argc, char *argv[], void *userdata) {
sd_id128_t uuid = SD_ID128_NULL;
if (r <= 0)
goto finish;
- if (geteuid() != 0) {
- log_error("Need to be root.");
- r = -EPERM;
+ r = must_be_root();
+ if (r < 0)
goto finish;
- }
+
r = determine_names();
if (r < 0)
goto finish;
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)
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();
if (geteuid() != 0) {
if (arg_dry_run || arg_force > 0) {
- log_error("Must be root.");
+ (void) must_be_root();
return -EPERM;
}
{}
};
- if (getuid() != 0) {
- log_error("root privileges required");
+ if (must_be_root() < 0)
return 1;
- }
uctrl = udev_ctrl_new(udev);
if (uctrl == NULL)
log_set_max_level(LOG_DEBUG);
}
- if (getuid() != 0) {
- r = log_error_errno(EPERM, "root privileges required");
+ r = must_be_root();
+ if (r < 0)
goto exit;
- }
if (arg_children_max == 0) {
cpu_set_t cpu_set;