Skip to content

Commit 7372d76

Browse files
iavclaude
andcommitted
extensions: lvm: quote variables in destructive commands (#9400 P0)
Quote ${SDCARD}.raw, ${rootdevice}, ${LVM_VG_NAME}, ${volsize} in parted, pvcreate, vgcreate, lvcreate, e2label, blkid, and vgchange commands to prevent word splitting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 7c2e5fd commit 7372d76

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

extensions/lvm.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ function extension_prepare_config__prepare_lvm() {
3333

3434
function post_create_partitions__setup_lvm() {
3535
# Setup LVM on the partition, ROOTFS
36-
parted -s ${SDCARD}.raw -- set ${rootpart} lvm on
36+
parted -s "${SDCARD}.raw" -- set "${rootpart}" lvm on
3737
display_alert "LVM Partition table created" "${EXTENSION}" "info"
38-
parted -s ${SDCARD}.raw -- print >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
38+
parted -s "${SDCARD}.raw" -- print >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1
3939
}
4040

4141
function prepare_root_device__create_volume_group() {
@@ -52,25 +52,25 @@ function prepare_root_device__create_volume_group() {
5252

5353
# Create the PV VG and VOL
5454
display_alert "LVM Creating VG" "${rootdevice}" "info"
55-
check_loop_device ${rootdevice}
56-
pvcreate ${rootdevice}
55+
check_loop_device "${rootdevice}"
56+
pvcreate "${rootdevice}"
5757
wait_for_disk_sync "wait for pvcreate to sync"
58-
vgcreate ${LVM_VG_NAME} ${rootdevice}
58+
vgcreate "${LVM_VG_NAME}" "${rootdevice}"
5959
add_cleanup_handler cleanup_lvm
6060
wait_for_disk_sync "wait for vgcreate to sync"
6161
# Note that devices wont come up automatically inside docker
62-
lvcreate -Zn --name root --size ${volsize}M ${LVM_VG_NAME}
62+
lvcreate -Zn --name root --size "${volsize}M" "${LVM_VG_NAME}"
6363
vgmknodes
64-
lvs >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
65-
66-
rootdevice=/dev/mapper/${LVM_VG_NAME}-root
64+
lvs >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1
65+
66+
rootdevice="/dev/mapper/${LVM_VG_NAME}-root"
6767
display_alert "LVM created volume group - root device ${rootdevice}" "${EXTENSION}" "info"
6868
}
6969

7070
function format_partitions__format_lvm() {
7171
# Label the root volume
72-
e2label /dev/mapper/${LVM_VG_NAME}-root armbi_root
73-
blkid | grep ${LVM_VG_NAME} >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1
72+
e2label "/dev/mapper/${LVM_VG_NAME}-root" armbi_root
73+
blkid | grep "${LVM_VG_NAME}" >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1
7474
display_alert "LVM labeled partitions" "${EXTENSION}" "info"
7575
}
7676

@@ -79,6 +79,6 @@ function post_umount_final_image__cleanup_lvm(){
7979
}
8080

8181
function cleanup_lvm() {
82-
vgchange -a n ${LVM_VG_NAME} >> "${DEST}"/${LOG_SUBPATH}/lvm.log 2>&1 || true
82+
vgchange -a n "${LVM_VG_NAME}" >> "${DEST}/${LOG_SUBPATH}/lvm.log" 2>&1 || true
8383
display_alert "LVM deactivated volume group" "${EXTENSION}" "info"
8484
}

0 commit comments

Comments
 (0)