Module: check_mk
Branch: master
Commit: 89e209457d6dd364f80ddcd81e95d0aa87e20183
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=89e209457d6dd3…
Author: Jukka Aro <ja(a)mathias-kettner.de>
Date: Fri Oct 20 16:52:23 2017 +0200
Prevent useradd failure in chroot
Make sure user does not exist before calling useradd. Necessary as some
builds are executed as root.
Change-Id: I5b9de11068a5650c50ff3993a7f552f346cf9e7b
---
agents/windows/make-chroot | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/agents/windows/make-chroot b/agents/windows/make-chroot
index 32b067f..1236f0c 100755
--- a/agents/windows/make-chroot
+++ b/agents/windows/make-chroot
@@ -149,7 +149,9 @@ if [ ! -h $CHROOT_PATH/usr/bin/python ] ; then
fi
# Add user for building windows agent without root privileges
-./do-chroot "useradd -lmo -u $(id -u $SUDO_USER) -s /bin/bash $SUDO_USER"
+if ! grep -q $SUDO_USER "$CHROOT_PATH/etc/passwd" ; then
+ ./do-chroot "useradd -lmo -u $(id -u $SUDO_USER) -s /bin/bash $SUDO_USER"
+fi
# "Disable" apt privilege dropping in chroot
sed -ri 's/^_apt:x:[0-9]+:/_apt:x:0:/g' $CHROOT_PATH/etc/passwd