Skip to contentSkip to conversation

Fix unprivileged user builds of initramfs

PATCH In review Matthew Wilcox 2 participants 2 messages Nov 19, 2006 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix unprivileged user builds of initramfs

The Kconfig help for INITRAMFS_SOURCE claims that you can specify multiple space-separated sources in order to allow unprivileged users to build an image. There are two bugs in the current implementation that prevent this from working.

First, we pass "file1 dir2" to the gen_initramfs_list.sh script, which it obviously can't open. I opted to fix this in the Makefile by doing a $(shell echo ...).

Second, gen_initramfs_list.sh -l outputs multiple definitions for deps_initramfs -- one for each argument. This annoys make the second time you run it. I chose to fix this problem by introducing list_header_once() and making list_header() be a nop.

Someone with more time might find a more elegant fix for either or both of these problems. But now my qlogic adapter can find its firmware without being turned into a module.

scripts/gen_initramfs_list.sh +6 -1
index 331c079..dcb5aff 100644
@@ -157,10 +157,14 @@ unknown_option() {
 	exit 1
 }
 
-list_header() {
+list_header_once() {
 	echo "deps_initramfs := \\"
 }
 
+list_header() {
+	:
+}
+
 header() {
 	printf "\n#####################\n# $1\n" >> ${output}
 }
@@ -227,6 +231,7 @@ arg="$1"
 case "$arg" in
 	"-l")	# files included in initramfs - used by kbuild
 		dep_list="list_"
+		list_header_once
 		shift
 		;;
 	"-o")	# generate gzipped cpio image named $1
usr/Makefile +1 -1
index e338e7b..3d59fb4 100644
@@ -20,7 +20,7 @@ $(obj)/initramfs_data.o: $(obj)/initramf
 hostprogs-y := gen_init_cpio
 initramfs   := $(CONFIG_SHELL) $(srctree)/scripts/gen_initramfs_list.sh
 ramfs-input := $(if $(filter-out "",$(CONFIG_INITRAMFS_SOURCE)), \
-                    $(CONFIG_INITRAMFS_SOURCE),-d)
+                    $(shell echo $(CONFIG_INITRAMFS_SOURCE)),-d)
 ramfs-args  := \
         $(if $(CONFIG_INITRAMFS_ROOT_UID), -u $(CONFIG_INITRAMFS_ROOT_UID)) \
         $(if $(CONFIG_INITRAMFS_ROOT_GID), -g $(CONFIG_INITRAMFS_ROOT_GID))
#1 lore raw

On 2006-11-19, Matthew Wilcox wrote:
[]

Quoted 3 lines

Someone with more time might find a more elegant fix for either or both of these problems. But now my qlogic adapter can find its firmware without being turned into a module.

Please check "initramfs-handle-more-than-one-source-dir-or-file-list.patch" in mm.

____