From: Lennart Poettering Date: Mon, 4 Dec 2017 16:06:56 +0000 (+0100) Subject: user-util: add UID_NOBODY defines that resolve to (uid_t) 65534 X-Git-Tag: v236~56^2~6 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3a664727fa95e9683da33770e88aaaa1a3183cc6;p=thirdparty%2Fsystemd.git user-util: add UID_NOBODY defines that resolve to (uid_t) 65534 We use it all over the place, let's add a #define for it. Makes things easier greppable, and more explanatory I think. --- diff --git a/src/basic/user-util.h b/src/basic/user-util.h index d148d5819ea..79adf91ee9b 100644 --- a/src/basic/user-util.h +++ b/src/basic/user-util.h @@ -60,6 +60,9 @@ int take_etc_passwd_lock(const char *root); #define UID_INVALID ((uid_t) -1) #define GID_INVALID ((gid_t) -1) +#define UID_NOBODY ((uid_t) 65534U) +#define GID_NOBODY ((gid_t) 65534U) + static inline bool uid_is_dynamic(uid_t uid) { return DYNAMIC_UID_MIN <= uid && uid <= DYNAMIC_UID_MAX; } diff --git a/src/machine/machine.c b/src/machine/machine.c index 10e379238c2..3d3c7cb6b8b 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -43,6 +43,7 @@ #include "string-table.h" #include "terminal-util.h" #include "unit-name.h" +#include "user-util.h" #include "util.h" Machine* machine_new(Manager *manager, MachineClass class, const char *name) { @@ -656,7 +657,7 @@ int machine_get_uid_shift(Machine *m, uid_t *ret) { if (uid_base != 0) return -ENXIO; /* Insist that at least the nobody user is mapped, everything else is weird, and hence complex, and we don't support it */ - if (uid_range < (uid_t) 65534U) + if (uid_range < UID_NOBODY) return -ENXIO; /* If there's more than one line, then we don't support this mapping. */ diff --git a/src/nss-mymachines/nss-mymachines.c b/src/nss-mymachines/nss-mymachines.c index ddad109eeeb..b2f46e3db2a 100644 --- a/src/nss-mymachines/nss-mymachines.c +++ b/src/nss-mymachines/nss-mymachines.c @@ -480,7 +480,7 @@ enum nss_status _nss_mymachines_getpwnam_r( pwd->pw_name = buffer; pwd->pw_uid = mapped; - pwd->pw_gid = 65534; /* nobody */ + pwd->pw_gid = GID_NOBODY; pwd->pw_gecos = buffer; pwd->pw_passwd = (char*) "*"; /* locked */ pwd->pw_dir = (char*) "/"; @@ -557,7 +557,7 @@ enum nss_status _nss_mymachines_getpwuid_r( pwd->pw_name = buffer; pwd->pw_uid = uid; - pwd->pw_gid = 65534; /* nobody */ + pwd->pw_gid = GID_NOBODY; pwd->pw_gecos = buffer; pwd->pw_passwd = (char*) "*"; /* locked */ pwd->pw_dir = (char*) "/"; diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c index 1852cf41cb7..cd6479573bf 100644 --- a/src/nss-systemd/nss-systemd.c +++ b/src/nss-systemd/nss-systemd.c @@ -47,8 +47,8 @@ static const struct passwd root_passwd = { static const struct passwd nobody_passwd = { .pw_name = (char*) NOBODY_USER_NAME, .pw_passwd = (char*) "*", /* locked */ - .pw_uid = 65534, - .pw_gid = 65534, + .pw_uid = UID_NOBODY, + .pw_gid = GID_NOBODY, .pw_gecos = (char*) "User Nobody", .pw_dir = (char*) "/", .pw_shell = (char*) "/sbin/nologin", @@ -63,7 +63,7 @@ static const struct group root_group = { static const struct group nobody_group = { .gr_name = (char*) NOBODY_GROUP_NAME, - .gr_gid = 65534, + .gr_gid = GID_NOBODY, .gr_passwd = (char*) "*", /* locked */ .gr_mem = (char*[]) { NULL }, };