From 5ba6286834386e5af7ac43440e8c3fb0f234646c Mon Sep 17 00:00:00 2001 From: Joao Eduardo Luis Date: Wed, 14 Feb 2018 12:20:59 +0000 Subject: [PATCH] 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 --- qa/run-standalone.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/qa/run-standalone.sh b/qa/run-standalone.sh index 1dfe7dd6caf4b..c69b3bf9c8ff0 100755 --- a/qa/run-standalone.sh +++ b/qa/run-standalone.sh @@ -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 -- 2.39.5