From: Tobias Brunner Date: Thu, 28 Jun 2018 14:29:22 +0000 (+0200) Subject: testing: Add wrapper for systemctl to collect leaks from charon-systemd X-Git-Tag: 5.7.0dr5~26 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80c9ae4521eebf0b792461f4f504518b790456bb;p=thirdparty%2Fstrongswan.git testing: Add wrapper for systemctl to collect leaks from charon-systemd Similar to the wrapper around `service` added with 71d59af58aea, this sets the variable only when running the automated tests. --- diff --git a/testing/hosts/default/usr/local/bin/systemctl b/testing/hosts/default/usr/local/bin/systemctl new file mode 100755 index 0000000000..bbe2bc9b3f --- /dev/null +++ b/testing/hosts/default/usr/local/bin/systemctl @@ -0,0 +1,22 @@ +#!/bin/bash +# +# LEAK_DETECTIVE_LOG is set for automated runs, however, this is not passed +# to a process started via systemctl. This wrapper is used to set the variable +# for the strongswan-swanctl.service unit. + +ORIG=/bin/systemctl +CONF=/lib/systemd/system/strongswan-swanctl.service + +if [[ "$2" != "strongswan-swanctl" ]]; then + $ORIG "$@" +fi + +if [[ "$1" == "start" && -n $LEAK_DETECTIVE_LOG ]]; then + sed -i "s:Type=:Environment=LEAK_DETECTIVE_LOG=$LEAK_DETECTIVE_LOG\nType=:" $CONF 2>/dev/null +fi + +$ORIG "$@" + +if [[ "$1" == "stop" ]]; then + sed -i '/LEAK_DETECTIVE_LOG/d' $CONF 2>/dev/null +fi