Bug 2103933 - osbuild-composer cannot add a user with a given gid
Summary: osbuild-composer cannot add a user with a given gid
Keywords:
Status: MODIFIED
Alias: None
Product: Red Hat Enterprise Linux 8
Classification: Red Hat
Component: osbuild-composer
Version: 8.6
Hardware: All
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Image Builder team
QA Contact: Release Test Team
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-07-05 10:24 UTC by Christophe Besson
Modified: 2023-08-02 10:51 UTC (History)
7 users (show)

Fixed In Version: osbuild-composer-82-1.el8
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github osbuild osbuild-composer pull 3390 0 None Merged customizations: create all groups unconditionally 2023-07-24 11:29:22 UTC
Red Hat Issue Tracker RHELPLAN-126992 0 None None None 2022-07-05 10:32:06 UTC

Description Christophe Besson 2022-07-05 10:24:23 UTC
Description of problem:
The documentation mentions we can specify a GID but it does not work.
"""
The GID is optional and must already exist in the image, be created by a package, or be created by the blueprint [[customizations.group]] entry. 
"""

Version-Release number of selected component (if applicable):
osbuild-composer-46.3-1.el8_6.x86_64
osbuild-53-2.el8.noarch

How reproducible:
Always

Steps to Reproduce:
1. Push the below blueprint

name = "unexisting-group"
description = "reproducer unexisting group"
version = "0.0.1"
modules = []
groups = []
distro = ""

[[customizations.group]]
name = "foo"
gid = 9045

[[customizations.user]]
name = "foo"
description = "foo user"
password = "$6$R4EexOTlkvDDwsK8$WkL4pU.JGHSO9LmpI/SMKYbunZU.t7BYLsZs1B9m0SeOH4RBICGlbScNRl0jUri3CBwasAd/sdZMkDp4SGoBq."
home = "/home/foo"
shell = "/usr/bin/bash"
groups = ["foo", "wheel"]
uid = 9045
gid = 9045

2. Compose an image


Actual results:
# composer-cli compose log ca09da9b-2e1f-4d0d-84d6-42d2c767c052 | tail -n17
Stage org.osbuild.users
Output:
[/usr/lib/tmpfiles.d/journal-nocow.conf:26] Failed to resolve specifier: uninitialized /etc detected, skipping
All rules containing unresolvable specifiers will be skipped.
useradd: group '9045' does not exist
Traceback (most recent call last):
  File "/run/osbuild/bin/org.osbuild.users", line 171, in <module>
    r = main(args["tree"], args["options"])
  File "/run/osbuild/bin/org.osbuild.users", line 160, in main
    useradd(tree, name, uid, gid, groups, description, home, shell, password)
  File "/run/osbuild/bin/org.osbuild.users", line 103, in useradd
    subprocess.run(["chroot", root, "useradd", *arguments, name], check=True)
  File "/usr/lib64/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['chroot', '/run/osbuild/tree', 'useradd', '--uid', '9045', '-o', '--gid', '9045', '--groups', 'foo,wheel', '--comment', 'foo user', '--home-dir', '/home/foo', '--create-home', '--shell', '/usr/bin/bash', '--password', '$6$R4EexOTlkvDDwsK8$WkL4pU.JGHSO9LmpI/SMKYbunZU.t7BYLsZs1B9m0SeOH4RBICGlbScNRl0jUri3CBwasAd/sdZMkDp4SGoBq.', 'foo']' returned non-zero exit status 6.

Expected results:
org.osbuild.groups executed before org.osbuild.users ?

Comment 3 Ondřej Budai 2022-11-21 13:19:45 UTC
The group's name currently cannot be the same as the name of the user. Is there an option for you to omit the group customization entirely? The group "foo" should be created anyway, because it's the primary group for the user "foo".


Note You need to log in before you can comment on or make changes to this bug.