commit: ae029bbb6836e5a68d87309f7e321dd1062f6c70 Author: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> AuthorDate: Thu Jan 23 17:55:55 2020 +0000 Commit: Thomas Deutschmann <whissi <AT> gentoo <DOT> org> CommitDate: Thu Jan 23 17:57:16 2020 +0000 URL: https://gitweb.gentoo.org/proj/genkernel.git/commit/?id=ae029bbb
sandbox: Set unique SANDBOX_LOG values to avoid collisions Bug: https://bugs.gentoo.org/704848 Signed-off-by: Thomas Deutschmann <whissi <AT> gentoo.org> gen_funcs.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/gen_funcs.sh b/gen_funcs.sh index 821f150..1297732 100755 --- a/gen_funcs.sh +++ b/gen_funcs.sh @@ -750,6 +750,7 @@ dropbear_create_key() { if isTrue "${SANDBOX}" then + envvars+=( "SANDBOX_LOG='$(get_temp_file "sandbox_XXXXXX.log")'" ) envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}:/proc/thread-self/attr/fscreate'" ) fi @@ -827,6 +828,7 @@ dropbear_generate_key_info_file() { if isTrue "${SANDBOX}" then + envvars+=( "SANDBOX_LOG='$(get_temp_file "sandbox_XXXXXX.log")'" ) envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}:/proc/thread-self/attr/fscreate'" ) fi @@ -1057,6 +1059,29 @@ get_tc_vars() { echo "${tc_vars[@]}" } +# @FUNCTION: get_temp_file +# @USAGE: [<TEMPLATE>] [<TMPDIR>] +# @DESCRIPTION: +# Create and return a temporary file (wrapper for mktemp with +# built-in error checking and handling). +# +# <TEMPLATE> TEMPLATE must contain at least 3 consecutive 'X's in +# last component. +# Defaults to tmp_XXXXXXXX +# +# <TMPDIR> Directory where the temporary file will be created in. +# Defaults to $TEMP +get_temp_file() { + local template=${1:-"tmp_XXXXXXXX"} + local tmpdir=${2:-"${TEMP}"} + local tempfile=$(mktemp -p "${tmpdir}" ${template} 2>/dev/null) + + [ -z "${tempfile}" ] \ + && gen_die "$(get_useful_function_stack "${FUNCNAME}")'mktemp -p \"${tmpdir}\" ${template}' failed!" + + echo "${tempfile}" +} + get_useful_function_stack() { local end_function=${1:-${FUNCNAME}} local n_functions=${#FUNCNAME[@]} @@ -1422,6 +1447,7 @@ gkbuild() { if isTrue "${SANDBOX}" then + envvars+=( "SANDBOX_LOG='$(get_temp_file "sandbox_XXXXXX.log")'" ) envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}:/proc/thread-self/attr/fscreate'" ) fi @@ -1477,6 +1503,7 @@ unpack() { if isTrue "${SANDBOX}" then + envvars+=( "SANDBOX_LOG='$(get_temp_file "sandbox_XXXXXX.log")'" ) envvars+=( "SANDBOX_WRITE='${LOGFILE}:${TEMP}:/proc/thread-self/attr/fscreate'" ) fi
