Date: Mon, 2 Nov 2015 22:32:59 +0000 (UTC) From: Devin Teske <dteske@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r290304 - stable/10/usr.sbin/sysrc Message-ID: <201511022232.tA2MWxSV085999@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: dteske Date: Mon Nov 2 22:32:59 2015 New Revision: 290304 URL: https://svnweb.freebsd.org/changeset/base/290304 Log: MFC r287381: Properly escape arguments when moving into jail or chroot Modified: stable/10/usr.sbin/sysrc/sysrc Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/sysrc/sysrc ============================================================================== --- stable/10/usr.sbin/sysrc/sysrc Mon Nov 2 22:32:13 2015 (r290303) +++ stable/10/usr.sbin/sysrc/sysrc Mon Nov 2 22:32:59 2015 (r290304) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201511022232.tA2MWxSV085999>