Change backslash-dquote to single quote

Slightly breaking change, but improves security and readability.
This commit is contained in:
Jonas Weber 2018-10-03 19:38:47 +02:00
parent ae7ccc5995
commit 53728a7ff0
18 changed files with 64 additions and 64 deletions

View File

@ -29,9 +29,9 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo "add-apt-repository \"$name\"" echo "add-apt-repository '$name'"
;; ;;
absent) absent)
echo "remove-apt-repository \"$name\"" echo "remove-apt-repository '$name'"
;; ;;
esac esac

View File

@ -42,18 +42,18 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp \""$1"\" \""$destination"\" echo "chgrp '$1' '$destination'"
echo chgrp "$1" >> "$__messages_out" echo "chgrp '$1'" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown \""$1"\" \""$destination"\" echo "chown '$1' '$destination'"
echo chown "$1" >> "$__messages_out" echo "chown '$1'" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod \""$1"\" \""$destination"\" echo "chmod '$1' '$destination'"
echo chmod "$1" >> "$__messages_out" echo "chmod '$1'" >> "$__messages_out"
} }
set_attributes= set_attributes=
@ -81,7 +81,7 @@ case "$state_should" in
absent) absent)
if [ "$type" = "file" ]; then if [ "$type" = "file" ]; then
echo rm -f \""$destination"\" echo "rm -f '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View File

@ -57,18 +57,18 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp "$recursive" \""$1"\" \""$destination"\" echo "chgrp '$recursive' '$1' '$destination'"
echo chgrp "$recursive" "$1" >> "$__messages_out" echo "chgrp '$recursive' '$1'" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown "$recursive" \""$1"\" \""$destination"\" echo "chown '$recursive' '$1' '$destination'"
echo chown "$recursive" "$1" >> "$__messages_out" echo "chown '$recursive' '$1'" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod "$recursive" \""$1"\" \""$destination"\" echo "chmod '$recursive' '$1' '$destination'"
echo chmod "$recursive" "$1" >> "$__messages_out" echo "chmod '$recursive' '$1'" >> "$__messages_out"
} }
case "$state_should" in case "$state_should" in
@ -78,10 +78,10 @@ case "$state_should" in
if [ "$type" != "none" ]; then if [ "$type" != "none" ]; then
# our destination is not a directory, remove whatever is there # our destination is not a directory, remove whatever is there
# and then create our directory and set all attributes # and then create our directory and set all attributes
echo rm -f "\"$destination\"" echo "rm -f '$destination'"
echo "remove non directory" >> "$__messages_out" echo "remove non directory" >> "$__messages_out"
fi fi
echo "mkdir $mkdiropt \"$destination\"" echo "mkdir $mkdiropt '$destination'"
echo "create" >> "$__messages_out" echo "create" >> "$__messages_out"
fi fi
@ -105,7 +105,7 @@ case "$state_should" in
;; ;;
absent) absent)
if [ "$type" = "directory" ]; then if [ "$type" = "directory" ]; then
echo rm -rf \""$destination"\" echo "rm -rf '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View File

@ -43,18 +43,18 @@ get_current_value() {
} }
set_group() { set_group() {
echo chgrp \""$1"\" \""$destination"\" echo "chgrp '$1' '$destination'"
echo chgrp "$1" >> "$__messages_out" echo "chgrp '$1'" >> "$__messages_out"
} }
set_owner() { set_owner() {
echo chown \""$1"\" \""$destination"\" echo "chown '$1' '$destination'"
echo chown "$1" >> "$__messages_out" echo "chown '$1'" >> "$__messages_out"
} }
set_mode() { set_mode() {
echo chmod \""$1"\" \""$destination"\" echo "chmod '$1' '$destination'"
echo chmod "$1" >> "$__messages_out" echo "chmod '$1'" >> "$__messages_out"
} }
set_attributes= set_attributes=
@ -82,7 +82,7 @@ case "$state_should" in
absent) absent)
if [ "$type" = "file" ]; then if [ "$type" = "file" ]; then
echo rm -f \""$destination"\" echo "rm -f '$destination'"
echo remove >> "$__messages_out" echo remove >> "$__messages_out"
fi fi
;; ;;

View File

@ -33,13 +33,13 @@ rule="$(cat "$__object/parameter/rule")"
case "$state_should" in case "$state_should" in
present) present)
echo "firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" echo "firewall-cmd --quiet --permanent --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo "firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" echo "firewall-cmd --quiet --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule"
;; ;;
absent) absent)
echo "firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" echo "firewall-cmd --quiet --permanent --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
echo "firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" echo "firewall-cmd --quiet --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule"
;; ;;
*) *)
echo "Unknown state $state_should" >&2 echo "Unknown state $state_should" >&2

View File

@ -85,7 +85,7 @@ primary_count=0
for object in $objects; do for object in $objects; do
device="$(cat "$object/parameter/device")" device="$(cat "$object/parameter/device")"
if [ "$current_device" != "$device" ]; then if [ "$current_device" != "$device" ]; then
echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'" echo "create_disklabel '$device' || die 'Failed to create disklabel for $device'"
current_device="$device" current_device="$device"
device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g') device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g')
available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))

View File

@ -77,11 +77,11 @@ case "$state_should" in
if [ -n "$version" ]; then if [ -n "$version" ]; then
name="${name}=${version}" name="${name}=${version}"
fi fi
echo "$aptget install $target_release \"$name\"" echo "$aptget install $target_release '$name'"
echo "installed" >> "$__messages_out" echo "installed" >> "$__messages_out"
;; ;;
absent) absent)
echo "$aptget remove $purgeparam \"$name\"" echo "$aptget remove $purgeparam '$name'"
echo "removed" >> "$__messages_out" echo "removed" >> "$__messages_out"
;; ;;
*) *)

View File

@ -63,10 +63,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo "emerge \"$name\" &>/dev/null || exit 1" echo "emerge '$name' &>/dev/null || exit 1"
;; ;;
absent) absent)
echo "emerge -C \"$name\" &>/dev/null || exit 1" echo "emerge -C '$name' &>/dev/null || exit 1"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -42,10 +42,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo luarocks install \""$name"\" echo "luarocks install '$name'"
;; ;;
absent) absent)
echo luarocks remove \""$name"\" echo "luarocks remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -45,10 +45,10 @@ case "$state_should" in
if [ "$present" = "notpresent" ]; then if [ "$present" = "notpresent" ]; then
echo opkg --verbosity=0 update echo opkg --verbosity=0 update
fi fi
echo opkg --verbosity=0 install \""$name"\" echo "opkg --verbosity=0 install '$name'"
;; ;;
absent) absent)
echo opkg --verbosity=0 remove \""$name"\" echo "opkg --verbosity=0 remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state" >&2 echo "Unknown state: $state" >&2

View File

@ -45,10 +45,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo pacman --needed --noconfirm --noprogressbar -S \""$name"\" echo "pacman --needed --noconfirm --noprogressbar -S '$name'"
;; ;;
absent) absent)
echo pacman --noconfirm --noprogressbar -R \""$name"\" echo "pacman --noconfirm --noprogressbar -R '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -53,7 +53,7 @@ case "$state_should" in
present) present)
if [ "$runas" ] if [ "$runas" ]
then then
echo "su -c \"$pip install -q $name\" $runas" echo "su -c '$pip install -q $name' $runas"
else else
echo $pip install -q "$name" echo $pip install -q "$name"
fi fi
@ -61,7 +61,7 @@ case "$state_should" in
absent) absent)
if [ "$runas" ] if [ "$runas" ]
then then
echo "su -c \"$pip uninstall -q -y $name\" $runas" echo "su -c '$pip uninstall -q -y $name' $runas"
else else
echo $pip uninstall -q -y "$name" echo $pip uninstall -q -y "$name"
fi fi

View File

@ -39,10 +39,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo gem install \""$name"\" --no-ri --no-rdoc echo "gem install '$name' --no-ri --no-rdoc"
;; ;;
absent) absent)
echo gem uninstall \""$name"\" echo "gem uninstall '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -60,10 +60,10 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo "yum $opts install \"$install_name\"" echo "yum $opts install '$install_name'"
;; ;;
absent) absent)
echo "yum $opts remove \"$name\"" echo "yum $opts remove '$name'"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -61,15 +61,15 @@ case "$state_should" in
present) present)
if [ -z "$version_should" ]; then if [ -z "$version_should" ]; then
[ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything
echo "zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" >/dev/null" echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null"
else else
[ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything
echo "zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" >/dev/null" echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null"
fi fi
;; ;;
absent) absent)
[ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything
echo "zypper $globalopts remove --type \"$ptype\" \"$name\" >/dev/null" echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null"
;; ;;
*) *)
echo "Unknown state: $state_should" >&2 echo "Unknown state: $state_should" >&2

View File

@ -18,4 +18,4 @@ format="$(cat "$__object/parameter/format")"
size="$(cat "$__object/parameter/size")" size="$(cat "$__object/parameter/size")"
diskimage="/$__object_id" diskimage="/$__object_id"
echo "qemu-img create -f \"$format\" \"$diskimage\" \"$size\"" echo "qemu-img create -f '$format' '$diskimage' '$size'"

View File

@ -37,16 +37,16 @@ case "$state_should" in
if [ "$init" = 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q enable \"$name\"" echo "systemctl -q enable '$name'"
else else
case "$os" in case "$os" in
debian) debian)
case "$os_version" in case "$os_version" in
[1-7]*) [1-7]*)
echo "update-rc.d \"$name\" defaults >/dev/null" echo "update-rc.d '$name' defaults >/dev/null"
;; ;;
8*) 8*)
echo "systemctl enable \"$name\"" echo "systemctl enable '$name'"
;; ;;
*) *)
echo "Unsupported version $os_version of $os" >&2 echo "Unsupported version $os_version of $os" >&2
@ -55,26 +55,26 @@ case "$state_should" in
esac esac
;; ;;
devuan) devuan)
echo "update-rc.d \"$name\" defaults >/dev/null" echo "update-rc.d '$name' defaults >/dev/null"
;; ;;
gentoo) gentoo)
echo "rc-update add \"$name\" \"$target_runlevel\"" echo "rc-update add '$name' '$target_runlevel'"
;; ;;
amazon|scientific|centos|fedora|owl|redhat|suse) amazon|scientific|centos|fedora|owl|redhat|suse)
echo "chkconfig \"$name\" on" echo "chkconfig '$name' on"
;; ;;
openwrt) openwrt)
# 'enable' can be successful and still return a non-zero exit # 'enable' can be successful and still return a non-zero exit
# code, deal with it by checking for success ourselves in that # code, deal with it by checking for success ourselves in that
# case (the || ... part). # case (the || ... part).
echo "/etc/init.d/\"$name\" enable || [ -f /etc/rc.d/S??\"$name\" ]" echo "'/etc/init.d/$name' enable || [ -f /etc/rc.d/S??'$name' ]"
;; ;;
ubuntu) ubuntu)
echo "update-rc.d \"$name\" defaults >/dev/null" echo "update-rc.d '$name' defaults >/dev/null"
;; ;;
freebsd) freebsd)
@ -93,24 +93,24 @@ case "$state_should" in
if [ "$init" = 'systemd' ]; then if [ "$init" = 'systemd' ]; then
# this handles ALL linux distros with systemd # this handles ALL linux distros with systemd
# e.g. archlinux, gentoo in some cases, new RHEL and SLES versions # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions
echo "systemctl -q disable \"$name\"" echo "systemctl -q disable '$name'"
else else
case "$os" in case "$os" in
debian|ubuntu|devuan) debian|ubuntu|devuan)
echo "update-rc.d -f \"$name\" remove" echo "update-rc.d -f '$name' remove"
;; ;;
gentoo) gentoo)
echo "rc-update del \"$name\" \"$target_runlevel\"" echo "rc-update del '$name' '$target_runlevel'"
;; ;;
centos|fedora|owl|redhat|suse) centos|fedora|owl|redhat|suse)
echo "chkconfig \"$name\" off" echo "chkconfig '$name' off"
;; ;;
openwrt) openwrt)
echo "\"/etc/init.d/$name\" disable" echo "'/etc/init.d/$name' disable"
;; ;;
*) *)

View File

@ -71,7 +71,7 @@ fi
case "$state_should" in case "$state_should" in
present) present)
echo "zypper $zypper_def_opts addservice -t $stype $uri \"$desc\"" echo "zypper $zypper_def_opts addservice -t $stype $uri '$desc'"
echo "zypper $zypper_def_opts refs" echo "zypper $zypper_def_opts refs"
echo "zypper $zypper_def_opts ref" echo "zypper $zypper_def_opts ref"
;; ;;