[openwrt/openwrt] base-files: fix uid/gid auto-enumeration to avoid 16-bit limit

LEDE Commits lede-commits at lists.infradead.org
Mon Jul 8 12:17:35 PDT 2024


hauke pushed a commit to openwrt/openwrt.git, branch openwrt-23.05:
https://git.openwrt.org/ccac75a37f13e77071d4b481aad1aa7fbb8a4c29

commit ccac75a37f13e77071d4b481aad1aa7fbb8a4c29
Author: Thomas Winkler <tewinkler86 at gmail.com>
AuthorDate: Fri Nov 10 22:48:59 2023 +0100

    base-files: fix uid/gid auto-enumeration to avoid 16-bit limit
    
    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 at gmail.com>
    (cherry picked from commit 140b48a9e93909873bee777ca5bdf49fe4f01271)
    Link: https://github.com/openwrt/openwrt/pull/15898
    Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
 package/base-files/files/lib/functions.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/base-files/files/lib/functions.sh b/package/base-files/files/lib/functions.sh
index 50aed53b06..c688ac77ee 100644
--- a/package/base-files/files/lib/functions.sh
+++ b/package/base-files/files/lib/functions.sh
@@ -371,7 +371,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
@@ -402,7 +402,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




More information about the lede-commits mailing list