kdumpctl: Move temp file in get_kernel_size to global temp dir

Resolves: bz2169720
Upstream: src.fedoraproject.org/rpms/kexec-tools.git
Conflicts: None

commit ea00b7db43d12a48676f40614c2c5601a6cd34cc
Author: Philipp Rudo <prudo@redhat.com>
Date:   Fri May 5 17:14:41 2023 +0200

    kdumpctl: Move temp file in get_kernel_size to global temp dir

    Others will need to use a temporary files, too. In order to avoid
    potential clashes of multiple trap handlers move the local temp file
    into a global temp dir.

    While at it make sure that the trap handler returns the correct exit
    code.

    Signed-off-by: Philipp Rudo <prudo@redhat.com>
    Reviewed-by: Pingfan Liu <piliu@redhat.com>
    Reviewed-by: Coiby Xu <coxu@redhat.com>

Signed-off-by: Philipp Rudo <prudo@redhat.com>
Signed-off-by: Tao Liu <ltao@redhat.com>
This commit is contained in:
Tao Liu 2023-05-31 15:10:30 +08:00
parent 27f67f14ee
commit bcd5eb5a45
2 changed files with 9 additions and 2 deletions

View File

@ -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

View File

@ -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