Skip to content

Commit b5aabdb

Browse files
committed
Avoid copying files to temporary root
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
1 parent a8b613f commit b5aabdb

File tree

22 files changed

+172
-220
lines changed

22 files changed

+172
-220
lines changed

features/fsck/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22

3-
$(call assgin-shell-once,FSCK_RUNTIME_FILES,$(FEATURESDIR)/fsck/bin/find-files)
3+
$(call assign-shell-once,FSCK_RUNTIME_FILES,$(FEATURESDIR)/fsck/bin/find-files)
44

55
PUT_FEATURE_DIRS += $(FSCK_DATADIR)
66
PUT_FEATURE_FILES += $(FSCK_FILES) $(FSCK_RUNTIME_FILES)

features/gpu-drm/rules.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22

3-
$(call assgin-shell-once,GPUDRM_MODULES,$(FEATURESDIR)/gpu-drm/bin/get-modules)
3+
$(call assign-shell-once,GPUDRM_MODULES,$(FEATURESDIR)/gpu-drm/bin/get-modules)
44

55
MODULES_ADD += $(GPUDRM_MODULES)

features/kickstart/bin/get-ks-configs

Lines changed: 0 additions & 12 deletions
This file was deleted.

features/kickstart/rules.mk

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22

3-
$(call assgin-shell-once,KICKSTART_DIRS,$(FEATURESDIR)/kickstart/bin/get-ks-configs)
4-
53
FAT_MODULES = fs-vfat /fs/nls/
64
ZFS_MODULES = zfs
75

@@ -10,6 +8,13 @@ MODULES_TRY_ADD += $(FAT_MODULES)
108
MODULES_TRY_ADD += $(ZFS_MODULES)
119

1210
PUT_FEATURE_FILES += $(KICKSTART_FILES)
13-
PUT_FEATURE_DIRS += $(KICKSTART_DATADIR) $(KICKSTART_DIRS)
11+
PUT_FEATURE_DIRS += $(KICKSTART_DATADIR)
1412
PUT_FEATURE_PROGS += $(KICKSTART_PROGS)
1513
PUT_FEATURE_PROGS_WILDCARD += $(KICKSTART_PROGS_PATTERNS)
14+
15+
kickstart: create
16+
@$(VMSG) "Adding kickstart configs..."
17+
@mkdir -p -- "$(ROOTDIR)/etc/ks.conf.d"
18+
@[ -z "$(KICKSTART_CONFIGS)" ] || cp -f -- $(KICKSTART_CONFIGS) "$(ROOTDIR)"/etc/ks.conf.d
19+
20+
pack: kickstart

features/luks/bin/get-data

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
. shell-error
88
. "$FEATURESDIR"/luks/data/bin/crypttab-sh-functions
99

10-
DIR="$WORKDIR/root"
10+
DIR="$ROOTDIR"
1111
unsupported=()
1212

1313
join_by()
@@ -110,5 +110,3 @@ shell_foreach_crypttab "$LUKS_CRYPTTAB" crypttab_entry ||:
110110
if [ "${#unsupported[@]}" -gt 0 ]; then
111111
message "luks: $(join_by , "${unsupported[@]}") from crypttab is not supported."
112112
fi
113-
114-
printf '%s\n' "$DIR"

features/luks/rules.mk

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
2-
LUKS_CRYPTTAB_DATA =
3-
4-
ifneq ($(LUKS_CRYPTTAB),)
5-
$(call assgin-shell-once,LUKS_CRYPTTAB_DATA,$(FEATURESDIR)/luks/bin/get-data)
6-
endif
72

83
MODULES_LOAD += $(LUKS_MODULES)
94

10-
PUT_FEATURE_DIRS += $(LUKS_DATADIR) $(LUKS_CRYPTTAB_DATA)
5+
PUT_FEATURE_DIRS += $(LUKS_DATADIR)
116
PUT_FEATURE_PROGS += $(CRYPTSETUP_BIN)
7+
8+
ifneq ($(LUKS_CRYPTTAB),)
9+
luks-crypttab: create
10+
@$(VMSG) "Adding LUKS crypttab..."
11+
@$(FEATURESDIR)/luks/bin/get-data
12+
13+
pack: luks-crypttab
14+
endif

features/mdadm/bin/generate-udev-rules

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33

44
. sh-functions
55

6-
DIR="$WORKDIR/root"
6+
DIR="$ROOTDIR"
77

88
if [ "${1-}" = dirs ]; then
9-
mkdir -p -- "$DIR/etc/initrd/md"
10-
printf '%s\n' "$DIR"
9+
mkdir ${verbose2-} -p -- "$DIR/etc/initrd/md"
1110
fi
1211

1312
for majmin in ${GENERATE_UDEV_RULES_FOR_MD_DEVICE-}; do
13+
verbose2 "Processing MD device $majmin..."
14+
1415
DEVNAME=
1516

1617
. "$SYSFS_PATH/dev/block/$majmin/uevent"
@@ -32,6 +33,7 @@ for majmin in ${GENERATE_UDEV_RULES_FOR_MD_DEVICE-}; do
3233
uuid="${MD_UUID//:}"
3334

3435
if [ "${1-}" = dirs ]; then
36+
verbose2 "Creating: /etc/initrd/md/$uuid"
3537
:> "$DIR/etc/initrd/md/$uuid"
3638
continue
3739
fi
@@ -66,5 +68,6 @@ ACTION=="remove", ENV{ID_PATH}!="?*", RUN+="/sbin/mdadm -If \$name"
6668
6769
LABEL="md_inc_end"
6870
EOF
71+
verbose2 "Adding udev rules: $rules"
6972
printf '%s\n' "$rules"
7073
done

features/mdadm/rules.mk

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22

3-
$(call assgin-shell-once,MDADM_UDEV_RULES,$(FEATURESDIR)/mdadm/bin/generate-udev-rules)
4-
$(call assgin-shell-once,MDADM_DIRS, $(FEATURESDIR)/mdadm/bin/generate-udev-rules dirs)
3+
$(call assign-shell-once,MDADM_UDEV_RULES,$(FEATURESDIR)/mdadm/bin/generate-udev-rules)
54

65
PUT_UDEV_RULES += $(MDAMD_RULES_OLD) $(MDAMD_RULES) $(MDADM_UDEV_RULES)
7-
PUT_FEATURE_DIRS += $(MDADM_DATADIR) $(MDADM_DIRS)
6+
PUT_FEATURE_DIRS += $(MDADM_DATADIR)
87
PUT_FEATURE_FILES += $(MDADM_FILES)
98
PUT_FEATURE_PROGS += $(MDADM_PROGS) $(MDADM_EXTRA_PROGS)
9+
10+
mdadm: create
11+
@$(VMSG) "Adding mdadm uuids..."
12+
@$(FEATURESDIR)/mdadm/bin/generate-udev-rules dirs
13+
14+
pack: mdadm

features/plymouth/rules.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# SPDX-License-Identifier: GPL-3.0-or-later
22
PLYMOUTH_DIRS := $(foreach d,$(LIB_DIRS),$(wildcard $(d)/plymouth))
33

4-
$(call assgin-shell-once,PLYMOUTH_PACK_MODULES, $(FEATURESDIR)/plymouth/bin/get-modules)
5-
$(call assgin-shell-once,PLYMOUTH_PACK_THEME, $(FEATURESDIR)/plymouth/bin/get-theme-files "$(PLYMOUTH_THEME)
6-
$(call assgin-shell-once,PLYMOUTH_PACK_DEFFONT, fc-match -f '%{file}\n' 'DejaVuSans' ||:)
4+
$(call assign-shell-once,PLYMOUTH_PACK_MODULES, $(FEATURESDIR)/plymouth/bin/get-modules)
5+
$(call assign-shell-once,PLYMOUTH_PACK_THEME, $(FEATURESDIR)/plymouth/bin/get-theme-files "$(PLYMOUTH_THEME)
6+
$(call assign-shell-once,PLYMOUTH_PACK_DEFFONT, fc-match -f '%{file}\n' 'DejaVuSans' ||:)
77

88
PLYMOUTH_PACK_FONT := $(or $(PLYMOUTH_FONT),$(PLYMOUTH_PACK_DEFFONT))
99

features/rdshell/bin/add-login

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,18 @@ if [ -n "${RDSHELL_PASSWORD-}" ] && [ -n "${RDSHELL_COPY_PASSWORD_FROM_USER-}" ]
77
fatal 'Options "RDSHELL_PASSWORD" and "RDSHELL_COPY_PASSWORD_FROM_USER" are mutually exclusive'
88
fi
99

10+
DIR="$ROOTDIR"
1011

11-
case "${1-}" in
12-
files)
13-
;;
14-
dirs)
15-
DIR="$WORKDIR/root"
12+
mkdir -p -- "$DIR/etc/sysconfig"
1613

17-
mkdir -p -- "$DIR/etc/sysconfig"
14+
hash="${RDSHELL_PASSWORD-}"
15+
[ -z "${RDSHELL_COPY_PASSWORD_FROM_USER-}" ] ||
16+
hash="$(getent shadow "${RDSHELL_COPY_PASSWORD_FROM_USER-}" |cut -d: -f2)"
1817

19-
hash="${RDSHELL_PASSWORD-}"
20-
[ -z "${RDSHELL_COPY_PASSWORD_FROM_USER-}" ] ||
21-
hash="$(getent shadow "${RDSHELL_COPY_PASSWORD_FROM_USER-}" |cut -d: -f2)"
18+
for n in passwd shadow; do
19+
touch "$DIR/etc/$n"
20+
sed -i -e '/^root:/d' "$DIR/etc/$n"
21+
done
2222

23-
for n in passwd shadow; do
24-
touch "$DIR/etc/$n"
25-
sed -i -e '/^root:/d' "$DIR/etc/$n"
26-
done
27-
28-
printf 'root:x:0:0::/home/root:/bin/sh\n' >> "$DIR/etc/passwd"
29-
printf 'root:%s:13957::::::\n' "$hash" >> "$DIR/etc/shadow"
30-
31-
printf '%s\n' "$DIR"
32-
;;
33-
esac
23+
printf 'root:x:0:0::/home/root:/bin/sh\n' >> "$DIR/etc/passwd"
24+
printf 'root:%s:13957::::::\n' "$hash" >> "$DIR/etc/shadow"

0 commit comments

Comments
 (0)