Add support for rootless podman with userns keep-id

Running `./kas-container` as rootless podman container fails with:

```
groupadd: Permission denied.
groupadd: cannot lock /etc/group; try again later.
useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.
```

This patch add a check whether the correct USER_ID is already in use.

Co-authored-by: Nicolas Riebesel <nicolas.riebesel@gmx.com>
Signed-off-by: Maximilian Schmidt <maximilian@schmidt.so>
[Jan: fixed indention]
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Maximilian Schmidt 2021-01-20 00:05:06 +01:00 committed by Jan Kiszka
parent c50b3d21d8
commit 15aaf4677b

View File

@ -18,6 +18,8 @@ if [ $USER_ID == 0 ]; then
# We shall run everything as root
mkdir -p /builder
GOSU=""
elif [ $USER_ID == $UID ]; then
GOSU=""
else
if ! grep -q "^builder:" /etc/group; then