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
+9
View File
@@ -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",
+2
View File
@@ -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);