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>
This commit is contained in:
parent
81d89c885f
commit
ea00b7db43
@ -11,6 +11,7 @@ ExecStop=/usr/bin/kdumpctl stop
|
|||||||
ExecReload=/usr/bin/kdumpctl reload
|
ExecReload=/usr/bin/kdumpctl reload
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
StartLimitInterval=0
|
StartLimitInterval=0
|
||||||
|
PrivateTmp=yes
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
10
kdumpctl
10
kdumpctl
@ -45,6 +45,13 @@ if ! dlog_init; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
KDUMP_TMPDIR=$(mktemp -d kdump.XXXX)
|
||||||
|
trap '
|
||||||
|
ret=$?;
|
||||||
|
rm -rf "$KDUMP_TMPDIR"
|
||||||
|
exit $ret;
|
||||||
|
' EXIT
|
||||||
|
|
||||||
_get_dracut_arg()
|
_get_dracut_arg()
|
||||||
{
|
{
|
||||||
local shortopt longopt n tmp
|
local shortopt longopt n tmp
|
||||||
@ -1193,8 +1200,7 @@ get_kernel_size()
|
|||||||
# Prepare temp files:
|
# Prepare temp files:
|
||||||
local tmp img=$1
|
local tmp img=$1
|
||||||
|
|
||||||
tmp=$(mktemp /tmp/vmlinux-XXX)
|
tmp="$KDUMP_TMPDIR/vmlinux"
|
||||||
trap 'rm -f "$tmp"' 0
|
|
||||||
|
|
||||||
# Try to check if it's a vmlinux already
|
# Try to check if it's a vmlinux already
|
||||||
check_vmlinux "$img" && get_vmlinux_size "$img" && return 0
|
check_vmlinux "$img" && get_vmlinux_size "$img" && return 0
|
||||||
|
Loading…
Reference in New Issue
Block a user