]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/standalone: discard pipe in sysctl kernel.core_pattern
authorJoao Eduardo Luis <joao@suse.de>
Wed, 14 Feb 2018 12:20:59 +0000 (12:20 +0000)
committerJoao Eduardo Luis <joao@suse.de>
Fri, 6 Apr 2018 03:18:22 +0000 (04:18 +0100)
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>
qa/run-standalone.sh

index 1dfe7dd6caf4bcdb36d42805191200f93c7c1214..c69b3bf9c8ff0a035d2f4af1f13d748ef523cc02 100755 (executable)
@@ -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