TT#173500 Create tmpfiles with template name

We want to be able to track down any left-behind tmp files,
so ensure we're creating them with according file names.

Change-Id: I1aa0ccdb8834e8aef919f1f028028c1bb14cbd01
mr10.5.1
Michael Prokop 3 years ago
parent e688e0f700
commit e51151ec35

@ -16,7 +16,7 @@ fi
filter_ignore() {
if [ -e ".gitignore" ]; then
listfile="$( mktemp -t ngcpcfg-git.XXXXXXXXXX )"
listfile="$(mktemp -t ngcpcfg-git.XXXXXXXXXX)"
(git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | sort | uniq > "$listfile" || true
sed 's/^\.\///' | grep -xFvf "$listfile"
rm -f "$listfile"
@ -94,7 +94,7 @@ generate_metadata() {
'
}
ngcpcfg_perms=$(mktemp)
ngcpcfg_perms=$(mktemp -t ngcpcfg-perms.XXXXXXXXXX)
chown root:root "${ngcpcfg_perms}"
# Make sure the file is not readable by others, since it can leak
# information about contents of non-readable directories

@ -63,7 +63,7 @@ build_config_files_instances() {
fi
log_debug "${RUNNER} ${HELPER}/instances-info $*"
inst_cfg=$(mktemp)
inst_cfg=$(mktemp -t ngcpcfg-build.XXXXXXXXXX )
while IFS=":" read -r -a info; do
source=${info[0]}
target=${info[1]}

@ -156,7 +156,7 @@ validate_config() {
case "${config_type}" in
config|constants)
c_cleanup=true
c="$(mktemp --tmpdir "ngcpcfg-${config_type}-XXXXXXXXXX.yml")"
c="$(mktemp -t "ngcpcfg-check-${config_type}.XXXXXXXXXX.yml")"
"${SCRIPTS}/cat" "${config_type}" >"$c"
;;
*)

@ -111,7 +111,7 @@ clean_untracked() {
log_info "Removing all untracked files (if any):"
local tmp
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-clean-untracked.XXXXXXXXXX)
log_debug "git clean -n -f -d -x"
if ! git clean -n -f -d -x > "${tmp}" ; then
@ -152,7 +152,7 @@ clean_stash() {
log_info "Removing all stashes (if any):"
local tmp
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-clean-stash.XXXXXXXXXX)
log_debug "git stash list"
if ! git stash list > "${tmp}" ; then
@ -193,7 +193,7 @@ clean_old_local_branches() {
log_info "Removing all old branches (if any):"
local tmp
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-clean-oldbranch.XXXXXXXXXX)
log_debug "git branch"
if ! git branch > "${tmp}" ; then
@ -244,7 +244,7 @@ clean_reset_master() {
fi
local tmp
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-clean-reset.XXXXXXXXXX)
log_debug "git diff origin/master..master"
if ! git diff origin/master..master > "${tmp}" ; then

@ -63,7 +63,7 @@ log_debug "Deleting option '${option}' from '${file}'"
perl_line="delete \$yaml->{${option//./\}->\{}};"
log_debug "perl line: ${perl_line}"
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-del.XXXXXXXXXX)
log_debug "Temporary perl file: ${tmp}"
cat > "${tmp}" << EOF

@ -11,9 +11,9 @@ get_value() {
# assume safe defaults
umask 0077
input_file="$(mktemp)"
input_file="$(mktemp -t ngcpcfg-get-in.XXXXXXXXXX)"
echo "[% $value %]" > "${input_file}"
output_file="$(mktemp)"
output_file="$(mktemp -t ngcpcfg-get-out.XXXXXXXXXX)"
if "${HELPER}/tt2-process" -p -q "${ARGS[@]}" "${input_file}" "${output_file}" >/dev/null 2>&1 ; then
cat "${output_file}"

@ -38,7 +38,7 @@ patch_search() {
shift # remove the first 'patchtt/customtt'
local files=("$@")
local fileslist
fileslist=$(mktemp)
fileslist=$(mktemp -t ngcpcfg-patch-search.XXXXXXXXXX)
local regexp=""
local hosts=()
@ -127,7 +127,7 @@ patch_apply() {
local template="${patch%%.patchtt*}.tt2"
local customtt="${patch//.patchtt/.customtt}"
local patch_output
patch_output=$(mktemp)
patch_output=$(mktemp -t ngcpcfg-patch-out.XXXXXXXXXX)
local patch_opts=()
patch_opts+=("--input=${patch}")
@ -199,9 +199,9 @@ patch_import_customtt() {
local patchtt="${customtt_file//.customtt/.patchtt}"
local tmp_patchtt
tmp_patchtt=$(mktemp)
tmp_patchtt=$(mktemp -t ngcpcfg-patch-import.XXXXXXXXXX)
local diff_output
diff_output=$(mktemp)
diff_output=$(mktemp -t ngcpcfg-patch-diff.XXXXXXXXXX)
# diff exit status is 0 if inputs are the same, 1 if different, 2 if trouble.

@ -73,7 +73,7 @@ exec_wrapper() {
# get rid of "./" and "//" in file names
normalize_files() {
NORMALIZED_FILES="$(mktemp)"
NORMALIZED_FILES="$(mktemp -t ngcpcfg-services-norm.XXXXXXXXXX)"
log_debug "NORMALIZED_FILES = ${NORMALIZED_FILES}"
CLEANUP_FILES+=("${NORMALIZED_FILES}")
@ -89,7 +89,7 @@ normalize_files() {
# restart HA just after monit (see MT#17163)
# restart other services in alphabetical order
sort_service_list() {
SORTED_LIST="$(mktemp)"
SORTED_LIST="$(mktemp -t ngcpcfg-services-sorted.XXXXXXXXXX)"
log_debug "SORTED_LIST = ${SORTED_LIST}"
CLEANUP_FILES+=("${SORTED_LIST}")
@ -305,7 +305,7 @@ fi
log_debug "systemd_daemon_reload_preset function"
systemd_daemon_reload_preset
TMPFILE="$(mktemp)"
TMPFILE="$(mktemp -t ngcpcfg-services-tmp.XXXXXXXXXX)"
log_debug "TMPFILE = ${TMPFILE}"
log_debug "OUTPUT_DIRECTORY=${OUTPUT_DIRECTORY}"

@ -97,7 +97,7 @@ else
value="\"${value}\""
fi
tmp=$(mktemp)
tmp=$(mktemp -t ngcpcfg-set.XXXXXXXXXX)
log_debug "Temporary perl file: ${tmp}"
cat > "${tmp}" << EOF

@ -12,7 +12,7 @@ PATH=$PATH:../t/fixtures/bin/
count=0
RC=0
OUTPUT=$(mktemp) || exit 1
OUTPUT=$(mktemp -t ngcpcfg-testsuite.XXXXXXXXXX) || exit 1
# generated files
rm -rf testfiles

Loading…
Cancel
Save