udev: define a generic helper to print messages about unknown users and groups
We cannot just use %m, because strerror returns a confusing error message for ESRCH or ENOEXEC. udev code was doing a good job, but the error handling was very verbose. Let's encapsulate the customized error messages in a helper. No functional change, except that the error messages have a slightly different form now. The old messages were a bit better, but we don't have as much flexibility in the new scheme. "Failed to resolve user 'foo': Unknown user" should be good enough.
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
|
||||
#include "basic-forward.h"
|
||||
|
||||
/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details how this range fits into the rest of the world */
|
||||
/* Users managed by systemd-homed. See https://systemd.io/UIDS-GIDS for details
|
||||
* how this range fits into the rest of the world. */
|
||||
#define HOME_UID_MIN ((uid_t) 60001)
|
||||
#define HOME_UID_MAX ((uid_t) 60513)
|
||||
|
||||
@@ -18,6 +19,12 @@
|
||||
#define MAP_UID_MIN ((uid_t) 60514)
|
||||
#define MAP_UID_MAX ((uid_t) 60577)
|
||||
|
||||
/* A helper to print an error message when user or group resolution fails.
|
||||
* Note that we can't use ({ … }) to define a temporary variable, so errnum is
|
||||
* evaluated multiple times. */
|
||||
#define STRERROR_USER(errnum) ((errnum) == -ESRCH ? "Unknown user" : (errnum) == -ENOEXEC ? "Not a system user" : STRERROR(errnum))
|
||||
#define STRERROR_GROUP(errnum) ((errnum) == -ESRCH ? "Unknown group" : (errnum) == -ENOEXEC ? "Not a system group" : STRERROR(errnum))
|
||||
|
||||
bool uid_is_valid(uid_t uid) _const_;
|
||||
|
||||
static inline bool gid_is_valid(gid_t gid) {
|
||||
|
||||
Reference in New Issue
Block a user