]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
CI: Make user creation idempotent
authorSimon McVittie <smcv@collabora.com>
Tue, 1 Aug 2023 17:30:14 +0000 (18:30 +0100)
committerSimon McVittie <smcv@collabora.com>
Tue, 1 Aug 2023 17:30:14 +0000 (18:30 +0100)
adduser --system exits successfully if the user already exists, but
ordinary adduser doesn't.

Resolves: https://gitlab.freedesktop.org/dbus/dbus/-/issues/468
Signed-off-by: Simon McVittie <smcv@collabora.com>
tools/ci-install.sh

index 2afcd789bbf73a2334685425444a03108e49087b..8abbc6d00739de90c8c403bb39489b9ebd80f47f 100755 (executable)
@@ -173,7 +173,9 @@ case "$ci_distro" in
         if [ "$ci_in_docker" = yes ]; then
             # Add the user that we will use to do the build inside the
             # Docker container, and let them use sudo
-            adduser --disabled-password --gecos "" user
+            if ! getent passwd user > /dev/null; then
+                adduser --disabled-password --gecos "" user
+            fi
             echo "user ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/nopasswd
             chmod 0440 /etc/sudoers.d/nopasswd
         fi