From 19d06826f3ec2891375ade408828532d79c3031f Mon Sep 17 00:00:00 2001 From: illiliti Date: Tue, 11 May 2021 13:04:02 +0300 Subject: [PATCH] init: make mount options safe from word splitting --- init | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init b/init index 02b9111..7cea3bf 100755 --- a/init +++ b/init @@ -89,7 +89,7 @@ parse_cmdline() rootfstype=*) root_type="${line#*=}" ;; rootflags=*) root_opts="${line#*=}" ;; debug=1) set -x ;; - ro | rw) rorw="-o $line" ;; + ro | rw) rorw="$line" ;; --*) init_args="${cmdline#*-- }"; break ;; *=*) command export "$line" ;; *) command export "${line}=1" ;; @@ -105,7 +105,7 @@ mount_root() # https://www.shellcheck.net/wiki/SC2086 # shellcheck disable=2086 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" }