diff options
author | dteske <dteske@FreeBSD.org> | 2015-09-01 21:40:04 +0000 |
---|---|---|
committer | dteske <dteske@FreeBSD.org> | 2015-09-01 21:40:04 +0000 |
commit | 4518a723b5579345a59e2f140b9c7155e3810308 (patch) | |
tree | 7a3d84749bb842758b0045aea82da52edfe8eea0 /usr.sbin/sysrc | |
parent | ce88023a5f159453984a59eef9cb154ca04e9e05 (diff) | |
download | FreeBSD-src-4518a723b5579345a59e2f140b9c7155e3810308.zip FreeBSD-src-4518a723b5579345a59e2f140b9c7155e3810308.tar.gz |
Properly escape arguments when moving into jail or chroot
MFC after: 3 days
X-MFC-to: stable/10
Diffstat (limited to 'usr.sbin/sysrc')
-rw-r--r-- | usr.sbin/sysrc/sysrc | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/usr.sbin/sysrc/sysrc b/usr.sbin/sysrc/sysrc index d8e3a54..2e810dc 100644 --- a/usr.sbin/sysrc/sysrc +++ b/usr.sbin/sysrc/sysrc @@ -195,6 +195,24 @@ jail_depend() cat $BSDCFG_SHARE/sysrc.subr } +escape() +{ + local __start="$1" __var_to_set="$2" __string= + while [ "$__start" ]; do + case "$__start" in *\'*) + __string="$__string${__start%%\'*}'\\''" + __start="${__start#*\'}" continue + esac + break + done + __string="$__string$__start" + if [ "$__var_to_set" ]; then + setvar "$__var_to_set" "$__string" + else + echo "$__string" + fi +} + ############################################################ MAIN SOURCE # @@ -330,9 +348,12 @@ if [ "$JAIL" -o "$ROOTDIR" ]; then $( [ "$SHOW_FILE" ] && echo \ -F ) " if [ "${RC_CONFS+set}" ]; then - args="$args -f '$RC_CONFS'" + escape "$RC_CONFS" _RC_CONFS + args="$args -f '$_RC_CONFS'" + unset _RC_CONFS fi for arg in "$@"; do + escape "$arg" arg args="$args '$arg'" done |