mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Properly escape arguments when moving into jail or chroot
MFC after: 3 days X-MFC-to: stable/10
This commit is contained in:
parent
c1acb66e01
commit
e84a7d105d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287381
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue