init: make mount options safe from word splitting

This commit is contained in:
illiliti 2021-05-11 13:04:02 +03:00
parent f9f2dbfd40
commit 19d06826f3

4
init
View File

@ -89,7 +89,7 @@ parse_cmdline()
rootfstype=*) root_type="${line#*=}" ;; rootfstype=*) root_type="${line#*=}" ;;
rootflags=*) root_opts="${line#*=}" ;; rootflags=*) root_opts="${line#*=}" ;;
debug=1) set -x ;; debug=1) set -x ;;
ro | rw) rorw="-o $line" ;; ro | rw) rorw="$line" ;;
--*) init_args="${cmdline#*-- }"; break ;; --*) init_args="${cmdline#*-- }"; break ;;
*=*) command export "$line" ;; *=*) command export "$line" ;;
*) command export "${line}=1" ;; *) command export "${line}=1" ;;
@ -105,7 +105,7 @@ mount_root()
# https://www.shellcheck.net/wiki/SC2086 # https://www.shellcheck.net/wiki/SC2086
# shellcheck disable=2086 # shellcheck disable=2086
mount \ mount \
${rorw:--o ro}${root_opts:+,$root_opts} ${root_type:+-t $root_type} \ -o "${rorw:-ro}${root_opts:+,$root_opts}" ${root_type:+-t $root_type} \
-- "$device" /mnt/root || panic "failed to mount root" -- "$device" /mnt/root || panic "failed to mount root"
} }