diff options
author | Thayne Harbaugh <tharbaugh@lnxi.com> | 2005-01-07 21:43:14 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@evo.osdl.org> | 2005-01-07 21:43:14 -0800 |
commit | a363b37930df6678d816b3711b07acbc0e566b04 (patch) | |
tree | f6f8d0f5b1308bd6f64841af0ea41bf79d5f563b /usr | |
parent | 2f0f10bb16dcc550feee88cab0fb5a2257688e59 (diff) | |
download | history-a363b37930df6678d816b3711b07acbc0e566b04.tar.gz |
[PATCH] initramfs: unprivileged image creation
This patch makes several tweaks so that an initramfs image can be
completely created by an unprivileged user. It should maintain
compatibility with previous initramfs early userspace cpio/image creation
and it updates documentation.
There are a few very important tweaks:
CONFIG_INITRAMFS_SOURCE is now either a single cpio archive that is
directly used or a list of directories and files for building a cpio
archive for the initramfs image. Making the cpio archive listable in
CONFIG_INITRAMFS_SOURCE makes the cpio step more official and automated so
that it doesn't have to be copied by hand to usr/initramfs_data.cpio (I
think this was broken anyway and would be overwritten). The alternative
list of directories *and* files means that files can be install in a "root"
directory and device-special files can be listed in a file list.
CONFIG_ROOT_UID and CONFIG_ROOT_GID are now available for doing simple
user/group ID translation. That means that user ID 500, group ID 500 can
create all the files in the "root" directory, but that they can all be
owned by user ID 0, group ID 0 in the cpio image.
Various documentation updates to pull it all together.
Removal of old cruft that was unused/misleading.
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'usr')
-rw-r--r-- | usr/Makefile | 48 |
1 files changed, 34 insertions, 14 deletions
diff --git a/usr/Makefile b/usr/Makefile index f269a5f7701f5a..248d5551029d5e 100644 --- a/usr/Makefile +++ b/usr/Makefile @@ -5,40 +5,60 @@ hostprogs-y := gen_init_cpio clean-files := initramfs_data.cpio.gz initramfs_list -# If you want a different list of files in the initramfs_data.cpio -# then you can either overwrite the cpio_list in this directory -# or set INITRAMFS_LIST to another filename. -INITRAMFS_LIST := $(obj)/initramfs_list - # initramfs_data.o contains the initramfs_data.cpio.gz image. # The image is included using .incbin, a dependency which is not # tracked automatically. $(obj)/initramfs_data.o: $(obj)/initramfs_data.cpio.gz FORCE -# initramfs-y are the programs which will be copied into the CPIO -# archive. Currently, the filenames are hardcoded in gen_init_cpio, -# but we need the information for the build as well, so it's duplicated -# here. +ifdef CONFIG_INITRAMFS_ROOT_UID +gen_initramfs_args += -u $(CONFIG_INITRAMFS_ROOT_UID) +endif + +ifdef CONFIG_INITRAMFS_ROOT_GID +gen_initramfs_args += -g $(CONFIG_INITRAMFS_ROOT_GID) +endif -# Commented out for now -# initramfs-y := $(obj)/root/hello +# The $(shell echo $(CONFIG_INITRAMFS_SOURCE)) is to remove the +# gratuitous begin and end quotes from the Kconfig string type. +# Internal, escaped quotes in the Kconfig string will loose the +# escape and become active quotes. +quotefixed_initramfs_source := $(shell echo $(CONFIG_INITRAMFS_SOURCE)) filechk_initramfs_list = $(CONFIG_SHELL) \ - $(srctree)/scripts/gen_initramfs_list.sh $(CONFIG_INITRAMFS_SOURCE) - + $(srctree)/scripts/gen_initramfs_list.sh $(gen_initramfs_args) $(quotefixed_initramfs_source) + $(obj)/initramfs_list: FORCE $(call filechk,initramfs_list) quiet_cmd_cpio = CPIO $@ cmd_cpio = ./$< $(obj)/initramfs_list > $@ + +# Check if the INITRAMFS_SOURCE is a cpio archive +ifneq (,$(findstring .cpio,$(quotefixed_initramfs_source))) + +# INITRAMFS_SOURCE has a cpio archive - verify that it's a single file +ifneq (1,$(words $(quotefixed_initramfs_source))) +$(error Only a single file may be specified in CONFIG_INITRAMFS_SOURCE (="$(quotefixed_initramfs_source)") when a cpio archive is directly specified.) +endif +# Now use the cpio archive directly +initramfs_data_cpio = $(quotefixed_initramfs_source) +targets += $(quotefixed_initramfs_source) + +else + +# INITRAMFS_SOURCE is not a cpio archive - create one $(obj)/initramfs_data.cpio: $(obj)/gen_init_cpio \ $(initramfs-y) $(obj)/initramfs_list FORCE $(call if_changed,cpio) targets += initramfs_data.cpio +initramfs_data_cpio = $(obj)/initramfs_data.cpio + +endif + -$(obj)/initramfs_data.cpio.gz: $(obj)/initramfs_data.cpio FORCE +$(obj)/initramfs_data.cpio.gz: $(initramfs_data_cpio) FORCE $(call if_changed,gzip) targets += initramfs_data.cpio.gz |