Skip to content

Commit 5a9fbf4

Browse files
committed
fix: debian image creation with host UID/GID
Creation of fatbuildr user and group with host UID/GID in deb format container image at build time may fail due to possible conflict with other Debian sid packages (typically systemd). To avoid this error, possibly existing user and group with the conflicting UID/GID are removed before running systemd-sysusers. Fix #83
1 parent a67f66b commit 5a9fbf4

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6969
- Avoid removal of tilde from version extracted in source tarball filename
7070
when submitted during build through HTTP REST API (#81).
7171
- Remove useless imports
72+
- images: fix fatbuildr user and group with host UID/GID in deb format container
73+
image due to possible conflicts with other installed Debian sid packages (#83)
7274

7375
### Changed
7476
- cli: transform `images` command options `--create`, `--update`,
+21-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
#!/bin/sh
22

3-
# Debian packages installed in OSI image do not call systemd-sysusers in their
4-
# postinst scripts. Then it is called explicitely here to create missing
5-
# sysusers, and especially fatbuildr system user.
3+
# The systemd package installed in Debian sid OSI image runs systemd-sysusers in
4+
# its deb postinst scripts with its own sysusers.d/*.conf files in arguments.
5+
# This makes systemd-sysusers ignoring the sysusers.d/fatbuildr.conf file
6+
# installed by mkosi skeleton with its explicit UID/GID (to match the host) and
7+
# it could potentially create systemd users and groups with conflicting UID/GID.
8+
# The solution in this postinstall script is to remove possible conflicting user
9+
# and group with the required UID/GID and rerun systemd-sysusers without
10+
# arguments to create all the missing stuff.
11+
12+
EXISTING_USER=$(getent passwd ${FATBUILDR_UID}|cut -d: -f1)
13+
if [ -n "${EXISTING_USER}" ]; then
14+
echo "Deleting conflicting system user ${EXISTING_USER}"
15+
userdel $EXISTING_USER
16+
fi
17+
18+
EXISTING_GROUP=$(getent group ${FATBUILDR_GID}|cut -d: -f1)
19+
if [ -n "${EXISTING_GROUP}" ]; then
20+
echo "Deleting conflicting system group ${EXISTING_GROUP}"
21+
groupdel $EXISTING_GROUP
22+
fi
23+
624
systemd-sysusers

conf/vendor/fatbuildr.ini

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

fatbuildr/images.py

+3
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def create(self, task, force):
113113
path=str(self.path),
114114
skeleton=str(self.skel_path),
115115
user=user,
116+
group=group,
117+
uid=uid,
118+
gid=gid,
116119
)
117120
.split(' ')
118121
)

0 commit comments

Comments
 (0)