]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-test-unpriv: check user existence before removing it 1936/head
authorPo-Hsu Lin <po-hsu.lin@canonical.com>
Wed, 22 Nov 2017 08:11:34 +0000 (03:11 -0500)
committerPo-Hsu Lin <po-hsu.lin@canonical.com>
Wed, 22 Nov 2017 08:11:46 +0000 (03:11 -0500)
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 97b70e79647314d5b346dcd6424a5a0fea3d98be..16ff12dd7246bc5cc5082152f6d57e80915c9016 100755 (executable)
@@ -105,7 +105,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