Skip to contentSkip to conversation

scripts/gen_initramfs_list.sh: teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user".

PATCH New [email protected] 1 participant 1 message Jul 6, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 7/108 scripts/gen_initramfs_list.sh: teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user".

From: Rob Landley <[email protected]>
Subject: scripts/gen_initramfs_list.sh: teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user".

Teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user".

---

 scripts/gen_initramfs_list.sh |    2 ++
 usr/Kconfig                   |   12 ++++--------
 2 files changed, 6 insertions(+), 8 deletions(-)
scripts/gen_initramfs_list.sh renamed from scripts/gen_initramfs_list.sh~teach-initramfs_root_uid-and-initramfs_root_gid-that-1-means-current-user +2 -0
diff -puN scripts/gen_initramfs_list.sh~teach-initramfs_root_uid-and-initramfs_root_gid-that-1-means-current-user scripts/gen_initramfs_list.sh
@@ -271,10 +271,12 @@ while [ $# -gt 0 ]; do
 	case "$arg" in
 		"-u")	# map $1 to uid=0 (root)
 			root_uid="$1"
+			[ "$root_uid" = "-1" ] && root_uid=$(id -u || echo 0)
 			shift
 			;;
 		"-g")	# map $1 to gid=0 (root)
 			root_gid="$1"
+			[ "$root_gid" = "-1" ] && root_gid=$(id -g || echo 0)
 			shift
 			;;
 		"-d")	# display default initramfs list
usr/Kconfig renamed from usr/Kconfig~teach-initramfs_root_uid-and-initramfs_root_gid-that-1-means-current-user +4 -8
diff -puN usr/Kconfig~teach-initramfs_root_uid-and-initramfs_root_gid-that-1-means-current-user usr/Kconfig
@@ -36,10 +36,8 @@ config INITRAMFS_ROOT_UID
 	depends on INITRAMFS_SOURCE!=""
 	default "0"
 	help
-	  This setting is only meaningful if the INITRAMFS_SOURCE is
-	  contains a directory.  Setting this user ID (UID) to something
-	  other than "0" will cause all files owned by that UID to be
-	  owned by user root in the initial ramdisk image.
+	  If INITRAMFS_SOURCE points to a directory, files owned by this UID
+	  (-1 = current user) will be owned by root in the resulting image.
 
 	  If you are not sure, leave it set to "0".
 
@@ -48,10 +46,8 @@ config INITRAMFS_ROOT_GID
 	depends on INITRAMFS_SOURCE!=""
 	default "0"
 	help
-	  This setting is only meaningful if the INITRAMFS_SOURCE is
-	  contains a directory.  Setting this group ID (GID) to something
-	  other than "0" will cause all files owned by that GID to be
-	  owned by group root in the initial ramdisk image.
+	  If INITRAMFS_SOURCE points to a directory, files owned by this GID
+	  (-1 = current group) will be owned by root in the resulting image.
 
 	  If you are not sure, leave it set to "0".
 

_