user-record: add helper that checks if a user record is root or the nobody user

This commit is contained in:
Lennart Poettering
2024-08-28 18:56:45 +02:00
parent 4b54da2e37
commit 313c178b1b
3 changed files with 20 additions and 5 deletions
+2 -2
View File
@@ -245,9 +245,9 @@ int bind_user_prepare(
* and the user/group databases fully synthesized at runtime. Moreover, the name of the
* user/group name of the "nobody" account differs between distros, hence a check by numeric
* UID is safer. */
if (u->uid == 0 || streq(u->user_name, "root"))
if (user_record_is_root(u))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Mapping 'root' user not supported, sorry.");
if (u->uid == UID_NOBODY || STR_IN_SET(u->user_name, NOBODY_USER_NAME, "nobody"))
if (user_record_is_nobody(u))
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Mapping 'nobody' user not supported, sorry.");
if (u->uid >= uid_shift && u->uid < uid_shift + uid_range)