]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
unshare: use MAX_OF_UINT_TYPE instead of (type)-1
authorChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 2 Dec 2025 05:50:28 +0000 (00:50 -0500)
committerChristian Goeschel Ndjomouo <cgoesc2@wgu.edu>
Tue, 2 Dec 2025 05:50:28 +0000 (00:50 -0500)
Signed-off-by: Christian Goeschel Ndjomouo <cgoesc2@wgu.edu>
sys-utils/unshare.c

index 0671ed3e1a8a85a32ce805ac925b5fbde9a92356..3cec3be82ac2ba9a88b94f3599843b7b36dd1937 100644 (file)
@@ -1190,14 +1190,14 @@ int main(int argc, char *argv[])
 #endif
        }
 
-        if (mapuser != (uid_t) -1 && !usermap)
+        if (mapuser != MAX_OF_UINT_TYPE(uid_t) && !usermap)
                map_id(_PATH_PROC_UIDMAP, mapuser, real_euid);
 
         /* Since Linux 3.19 unprivileged writing of /proc/self/gid_map
          * has been disabled unless /proc/self/setgroups is written
          * first to permanently disable the ability to call setgroups
          * in that user namespace. */
-       if (mapgroup != (gid_t) -1 && !groupmap) {
+       if (mapgroup != MAX_OF_UINT_TYPE(gid_t) && !groupmap) {
                if (setgrpcmd == SETGROUPS_ALLOW)
                        errx(EXIT_FAILURE, _("options --setgroups=allow and "
                                        "--map-group are mutually exclusive"));