From ac908aa749f9854a257f6d4957e1342a4db0e1f9 Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Fri, 1 Jul 2022 13:37:03 +0200 Subject: tests: add fake adduser So we can simulate what happens when adduser fails ref https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10519 --- tests/bin/adduser | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 tests/bin/adduser (limited to 'tests/bin/adduser') diff --git a/tests/bin/adduser b/tests/bin/adduser new file mode 100755 index 0000000..72defc4 --- /dev/null +++ b/tests/bin/adduser @@ -0,0 +1,92 @@ +#!/bin/sh + +prog=${0##*/} +usage() { + cat <&2 + exit 1 +} + +eval set -- "$OPTS" +while true; do + opt="$1" + case "$opt" in + --help) + usage >&2 + exit 0 + ;; + -h) + shift + homedir="$1" + ;; + -g) + shift + gecos="$1" + ;; + -s) + shift + shell="$1" + ;; + -G) + shift + shell="$1" + ;; + -S) + systemuser=1 + ;; + -D) + omitpassword=1 + ;; + -H) + omithomedir=1 + ;; + -u) + shift + uid="$1" + ;; + -k) + shift + skel="$1" + ;; + --) + shift + break + ;; + *) usage "1" >&2 + ;; + esac + shift +done + +if [ $# -eq 0 ]; then + usage >&2 + exit 1 +fi + +if [ "$ADDUSER_EXIST" = "$1" ]; then + echo "adduser: user '$1' in use" >&2 + exit 1 +fi + +eval set -- "$OPTS" +echo "adduser $@" + -- cgit v1.2.3