From owner-svn-src-all@freebsd.org Tue Sep 1 21:40:05 2015 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id DA4719C8A8F; Tue, 1 Sep 2015 21:40:05 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB5761119; Tue, 1 Sep 2015 21:40:05 +0000 (UTC) (envelope-from dteske@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t81Le50P019738; Tue, 1 Sep 2015 21:40:05 GMT (envelope-from dteske@FreeBSD.org) Received: (from dteske@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t81Le5In019737; Tue, 1 Sep 2015 21:40:05 GMT (envelope-from dteske@FreeBSD.org) Message-Id: <201509012140.t81Le5In019737@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dteske set sender to dteske@FreeBSD.org using -f From: Devin Teske Date: Tue, 1 Sep 2015 21:40:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287381 - head/usr.sbin/sysrc X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Sep 2015 21:40:06 -0000 Author: dteske Date: Tue Sep 1 21:40:04 2015 New Revision: 287381 URL: https://svnweb.freebsd.org/changeset/base/287381 Log: Properly escape arguments when moving into jail or chroot MFC after: 3 days X-MFC-to: stable/10 Modified: head/usr.sbin/sysrc/sysrc Modified: head/usr.sbin/sysrc/sysrc ============================================================================== --- head/usr.sbin/sysrc/sysrc Tue Sep 1 21:20:43 2015 (r287380) +++ head/usr.sbin/sysrc/sysrc Tue Sep 1 21:40:04 2015 (r287381) @@ -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