base-files: fix uid/gid auto-enumeration to avoid 16-bit limit
authorThomas Winkler <tewinkler86@gmail.com>
Fri, 10 Nov 2023 21:48:59 +0000 (22:48 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Fri, 10 May 2024 20:39:57 +0000 (22:39 +0200)
uid/gid range should be limited to 16bit unsigned integer range to
avoid "wraparound" issues with permissions where jffs2
is employed for storage and chown 65536 (first auto-created user)
becomes equivalent to chown 0

Fixes: #13927
Signed-off-by: Thomas Winkler <tewinkler86@gmail.com>
package/base-files/files/lib/functions.sh

index 7b3203f55abf527d49e1644de124a1d9a546ab71..82ee58f6425ed23ff195e69a034c47b8b17cbb5f 100644 (file)
@@ -408,7 +408,7 @@ group_add_next() {
                return
        fi
        gids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/group)
-       gid=65536
+       gid=32768
        while echo "$gids" | grep -q "^$gid$"; do
                gid=$((gid + 1))
        done
@@ -439,7 +439,7 @@ user_add() {
        local rc
        [ -z "$uid" ] && {
                uids=$(cut -d: -f3 ${IPKG_INSTROOT}/etc/passwd)
-               uid=65536
+               uid=32768
                while echo "$uids" | grep -q "^$uid$"; do
                        uid=$((uid + 1))
                done