diff --git a/kdump.service b/kdump.service index 99feed8..15405dc 100644 --- a/kdump.service +++ b/kdump.service @@ -11,6 +11,7 @@ ExecStop=/usr/bin/kdumpctl stop ExecReload=/usr/bin/kdumpctl reload RemainAfterExit=yes StartLimitInterval=0 +PrivateTmp=yes [Install] WantedBy=multi-user.target diff --git a/kdumpctl b/kdumpctl index 942cb4c..4fd8bbe 100755 --- a/kdumpctl +++ b/kdumpctl @@ -42,6 +42,13 @@ if ! dlog_init; then exit 1 fi +KDUMP_TMPDIR=$(mktemp -d kdump.XXXX) +trap ' + ret=$?; + rm -rf "$KDUMP_TMPDIR" + exit $ret; + ' EXIT + single_instance_lock() { local rc timeout=5 lockfile @@ -1265,8 +1272,7 @@ get_kernel_size() # Prepare temp files: local tmp img=$1 - tmp=$(mktemp /tmp/vmlinux-XXX) - trap 'rm -f "$tmp"' 0 + tmp="$KDUMP_TMPDIR/vmlinux" # Try to check if it's a vmlinux already check_vmlinux "$img" && get_vmlinux_size "$img" && return 0