Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752258AbdEDVO3 (ORCPT ); Thu, 4 May 2017 17:14:29 -0400 Received: from mail-io0-f193.google.com ([209.85.223.193]:34593 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdEDVO0 (ORCPT ); Thu, 4 May 2017 17:14:26 -0400 To: linux-kernel@vger.kernel.org, Andrew Morton , Michal Marek From: Rob Landley Subject: [PATCH] Teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user". Message-ID: <2df3a9fb-4378-fa16-679d-99e788926c05@landley.net> Date: Thu, 4 May 2017 16:14:24 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rob Landley Teach INITRAMFS_ROOT_UID and INITRAMFS_ROOT_GID that -1 means "current user". Signed-off-by: Rob Landley --- scripts/gen_initramfs_list.sh | 2 ++ usr/Kconfig | 12 ++++-------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 17fa901..7666fa1 100755 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh @@ -268,10 +268,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 diff --git a/usr/Kconfig b/usr/Kconfig index 572dcf7..3b6ff16 100644 --- a/usr/Kconfig +++ b/usr/Kconfig @@ -26,10 +26,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". @@ -38,10 +36,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".