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:
@@ -1053,6 +1053,15 @@ pid_t getpid_cached(void) {
|
||||
}
|
||||
}
|
||||
|
||||
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",
|
||||
|
||||
@@ -138,3 +138,5 @@ static inline bool pid_is_valid(pid_t p) {
|
||||
int ioprio_parse_priority(const char *s, int *ret);
|
||||
|
||||
pid_t getpid_cached(void);
|
||||
|
||||
int must_be_root(void);
|
||||
|
||||
Reference in New Issue
Block a user