user-util: add new uid_is_system() helper

This adds uid_is_system() and gid_is_system(), similar in style to
uid_is_dynamic(). That a helper like this is useful is illustrated by
the fact that test-condition.c didn't get the check right so far, which
this patch fixes.
This commit is contained in:
Lennart Poettering
2017-12-06 13:40:50 +01:00
parent 399725532d
commit ece877d434
7 changed files with 16 additions and 8 deletions
+1 -1
View File
@@ -391,7 +391,7 @@ static void test_condition_test_user(void) {
assert_se(condition);
r = condition_test(condition);
log_info("ConditionUser=@system → %i", r);
if (getuid() < SYSTEM_UID_MAX || geteuid() < SYSTEM_UID_MAX)
if (uid_is_system(getuid()) || uid_is_system(geteuid()))
assert_se(r > 0);
else
assert_se(r == 0);