]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-test-unpriv: check user existence before removing it
authorPo-Hsu Lin <po-hsu.lin@canonical.com>
Wed, 22 Nov 2017 08:11:34 +0000 (03:11 -0500)
committerChristian Brauner <christian.brauner@ubuntu.com>
Wed, 7 Feb 2018 11:11:51 +0000 (12:11 +0100)
Check the test user (lxcunpriv) before calling deluser command,
otherwise it will print unnecessary error message:
/usr/sbin/deluser: The user 'lxcunpriv' does not exist.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
src/tests/lxc-test-unpriv

index bd6f294b34693464f097f54ae5b22d24968c8fa5..45d487d6de7178b29d5fc499183ff378ac384946 100755 (executable)
@@ -104,7 +104,7 @@ fi
 trap cleanup EXIT SIGHUP SIGINT SIGTERM
 set -eu
 
-deluser $TUSER && rm -Rf $HDIR || true
+id $TUSER &> /dev/null && deluser -q --remove-home $TUSER
 useradd $TUSER
 
 mkdir -p $HDIR