[PATCH] Fix unprivileged user builds of initramfs

From: Matthew Wilcox
Date: Sun Nov 19 2006 - 00:17:23 EST



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.

Signed-off-by: Matthew Wilcox <matthew@xxxxxx>

diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index 331c079..dcb5aff 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -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
diff --git a/usr/Makefile b/usr/Makefile
index e338e7b..3d59fb4 100644
--- a/usr/Makefile
+++ b/usr/Makefile
@@ -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))
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/