qa/standalone: discard pipe in sysctl kernel.core_pattern

At least verified in openSUSE tumbleweed and ubuntu 16.04,
`sysctl -n kernel.core_pattern` returns a pipe at the start of the
value. We reset core_pattern to its original form once the script is
about to end, but if we do not discard the pipe the new value will
contain an extra pipe (apparently, the pipe is added automatically at
some point, possibly simply on read). We are simply stripping it on
read, as to prevent this behavior.

Additionally, we are also enclosing the reset of kernel.core_pattern in
quotes, so as to make sure patterns that include spaces (e.g., ubuntu's
apport, or tumbleweed's systemd-coredump) are properly reset.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
This commit is contained in:
Joao Eduardo Luis 2018-02-14 12:20:59 +00:00
parent 5cd2b057f3
commit 5ba6286834

View File

@ -75,6 +75,11 @@ count=0
errors=0
userargs=""
precore="$(sysctl -n $KERNCORE)"
if [[ "${precore:0:1}" = "|" ]]; then
precore="${precore:1}"
fi
# If corepattern already set, avoid having to use sudo
if [ "$precore" = "$COREPATTERN" ]; then
precore=""
@ -131,7 +136,7 @@ do
fi
done
if [ -n "$precore" ]; then
sudo sysctl -w ${KERNCORE}=${precore}
sudo sysctl -w ${KERNCORE}="${precore}"
fi
if [ "$errors" != "0" ]; then