Prefer explicit escaping

https://github.com/koalaman/shellcheck/wiki/SC1117
modified:   scripts/web-add.sh
This commit is contained in:
Patrick Marchand 2018-10-16 14:39:23 -04:00
parent 2861d90119
commit 5d2d8be5ad

View file

@ -287,7 +287,7 @@ create_www_account() {
done done
if grep -qE '^AllowGroups' /etc/ssh/sshd_config; then if grep -qE '^AllowGroups' /etc/ssh/sshd_config; then
if ! grep -qE "^AllowGroups(\s+\S+)*(\s+$SSH_GROUP)" /etc/ssh/sshd_config; then if ! grep -qE "^AllowGroups(\\s+\\S+)*(\\s+$SSH_GROUP)" /etc/ssh/sshd_config; then
sed -i "s/^AllowGroups .*/& $SSH_GROUP/" /etc/ssh/sshd_config sed -i "s/^AllowGroups .*/& $SSH_GROUP/" /etc/ssh/sshd_config
groupadd --force $SSH_GROUP groupadd --force $SSH_GROUP
fi fi
@ -384,7 +384,7 @@ EOT
cat <<EOT >>"$vhostfile" cat <<EOT >>"$vhostfile"
<Proxy "unix:${phpfpm_socket_path}|fcgi://localhost/" timeout=300> <Proxy "unix:${phpfpm_socket_path}|fcgi://localhost/" timeout=300>
</Proxy> </Proxy>
<FilesMatch "\.php$"> <FilesMatch "\\.php$">
SetHandler proxy:unix:${phpfpm_socket_path}|fcgi://localhost/ SetHandler proxy:unix:${phpfpm_socket_path}|fcgi://localhost/
</FilesMatch> </FilesMatch>
</VirtualHost> </VirtualHost>
@ -396,9 +396,9 @@ EOT
fi fi
# On active aussi example.com si domaine commence par "www." comme www.example # On active aussi example.com si domaine commence par "www." comme www.example
if echo $in_wwwdomain | grep '^www.' > /dev/null; then if echo "$in_wwwdomain" | grep '^www.' > /dev/null; then
subweb=`echo $in_wwwdomain | sed -e "s/www.//"` subweb="${in_wwwdomain#www.}"
sed -i -e "s/^\(.*\)#\(ServerAlias\).*$/\1\2 $subweb/" $vhostfile sed -i -e "s/^\\(.*\\)#\\(ServerAlias\\).*$/\\1\\2 $subweb/" "$vhostfile"
fi fi
a2ensite "$in_login" >/dev/null a2ensite "$in_login" >/dev/null
@ -636,8 +636,8 @@ op_setphpversion() {
validate_phpversion "$phpversion" validate_phpversion "$phpversion"
sed -i "s#^\( \+SetHandler proxy:unix:/home/.*/php-fpm\)..\(\.sock\)#\1${phpversion}\2#" /etc/apache2/sites-available/${login}.conf sed -i "s#^\\( \\+SetHandler proxy:unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
sed -i "s#^\( \+<Proxy .*unix:/home/.*/php-fpm\)..\(\.sock\)#\1${phpversion}\2#" /etc/apache2/sites-available/${login}.conf sed -i "s#^\\( \\+<Proxy .*unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
/etc/init.d/apache2 force-reload >/dev/null /etc/init.d/apache2 force-reload >/dev/null
DATE=$(date +"%Y-%m-%d") DATE=$(date +"%Y-%m-%d")
@ -739,7 +739,7 @@ op_aliasadd() {
vhost="${1}.conf" vhost="${1}.conf"
alias=$2 alias=$2
[ -f $VHOST_PATH/$vhost ] && sed -i -e "s/\(ServerName .*\)/\1\n\tServerAlias $alias/" $VHOST_PATH/$vhost --follow-symlinks [ -f $VHOST_PATH/"$vhost" ] && sed -i -e "s/\\(ServerName .*\\)/\\1\\n\\tServerAlias $alias/" "$VHOST_PATH"/"$vhost" --follow-symlinks
apache2ctl configtest 2>/dev/null apache2ctl configtest 2>/dev/null
/etc/init.d/apache2 force-reload >/dev/null /etc/init.d/apache2 force-reload >/dev/null