]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
user-util: add UID_NOBODY defines that resolve to (uid_t) 65534
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Dec 2017 16:06:56 +0000 (17:06 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 6 Dec 2017 12:40:50 +0000 (13:40 +0100)
We use it all over the place, let's add a #define for it. Makes things
easier greppable, and more explanatory I think.

src/basic/user-util.h
src/machine/machine.c
src/nss-mymachines/nss-mymachines.c
src/nss-systemd/nss-systemd.c

index d148d5819eabee1bb7f2db84ee8fe44d202e3860..79adf91ee9b63a50de0cae39a43c1e1213488aff 100644 (file)
@@ -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;
 }
index 10e379238c2db6f22e0779592902c9eb20be10d2..3d3c7cb6b8bc6426c4a566f1793c45207851d13f 100644 (file)
@@ -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. */
index ddad109eeebd2245f6711a259f9854bb6c839d82..b2f46e3db2af01b74812f5d5c5c4298b9138da75 100644 (file)
@@ -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*) "/";
index 1852cf41cb73b8c023a1bb7a6ff0ff1a91ce3fe6..cd6479573bf1d132679dee72165aec014521d7d4 100644 (file)
@@ -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 },
 };