Skip to content

Commit f1d1360

Browse files
author
olevole
committed
jail: improved environment variables control
1 parent 609df61 commit f1d1360

File tree

1 file changed

+34
-26
lines changed

1 file changed

+34
-26
lines changed

sudoexec/jcreate

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,32 @@ else
343343
trap "${RM_CMD} -f ${temprcconf}" HUP INT ABRT BUS TERM EXIT
344344
fi
345345

346+
## environment manage
347+
xenvironment=
348+
for i in ${*}; do
349+
strpos --str="${i}" --search="="
350+
_pos=$?
351+
352+
if [ ${_pos} -ne 0 ]; then
353+
_arg_len=$( strlen ${i} )
354+
_pref=$(( _arg_len - _pos ))
355+
ARG=$( substr --pos=0 --len=${_pos} --str="${i}" )
356+
357+
case "${ARG}" in
358+
environment)
359+
VAL=$( substr --pos=$(( _pos + 2 )) --len=${_pref} --str="${i}" | ${TR_CMD} -d '"' )
360+
if [ -z "${xenvironment}" ]; then
361+
xenvironment="${VAL}"
362+
else
363+
xenvironment="${xenvironment} ${VAL}"
364+
fi
365+
;;
366+
esac
367+
shift
368+
continue
369+
fi
370+
done
371+
346372
# todo: when 'from' exist: use temprcconf settings to jset fromfile to re-configure default image options
347373
[ -n "${ofrom}" ] && from="${ofrom}"
348374

@@ -449,6 +475,14 @@ if [ -n "${from}" ]; then
449475
done
450476
fi
451477

478+
echo "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin" > ${jailsysdir}/${jname}/environment
479+
if [ -n "${xenvironment}" ]; then
480+
# save env
481+
for i in ${xenvironment}; do
482+
echo "${i}" >> ${jailsysdir}/${jname}/environment
483+
done
484+
fi
485+
452486
for i in ${MYOPTARG}; do
453487
case "${i}" in
454488
jname|from|removejconf)
@@ -738,32 +772,6 @@ if [ -n "${fstablocal}" ]; then
738772
fi
739773
fi
740774

741-
## environment manage
742-
xenvironment=
743-
for i in ${*}; do
744-
strpos --str="${i}" --search="="
745-
_pos=$?
746-
747-
if [ ${_pos} -ne 0 ]; then
748-
_arg_len=$( strlen ${i} )
749-
_pref=$(( _arg_len - _pos ))
750-
ARG=$( substr --pos=0 --len=${_pos} --str="${i}" )
751-
752-
case "${ARG}" in
753-
environment)
754-
VAL=$( substr --pos=$(( _pos + 2 )) --len=${_pref} --str="${i}" | ${TR_CMD} -d '"' )
755-
if [ -z "${xenvironment}" ]; then
756-
xenvironment="${VAL}"
757-
else
758-
xenvironment="${xenvironment} ${VAL}"
759-
fi
760-
;;
761-
esac
762-
shift
763-
continue
764-
fi
765-
done
766-
767775
echo "PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/root/bin" > ${jailsysdir}/${jname}/environment
768776
if [ -n "${xenvironment}" ]; then
769777
# save env

0 commit comments

Comments
 (0)