Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core user isn't added to groups when created via Ignition #41

Closed
bgilbert opened this issue Jan 15, 2019 · 8 comments · Fixed by #74
Closed

core user isn't added to groups when created via Ignition #41

bgilbert opened this issue Jan 15, 2019 · 8 comments · Fixed by #74
Labels
bug Something isn't working

Comments

@bgilbert
Copy link
Contributor

The core user is only added to groups if the user doesn't exist on first boot:

ExecStart=/usr/bin/sh -c 'if !getent passwd core &>/dev/null; then /usr/sbin/useradd -G wheel,sudo,adm,systemd-journal core; fi'

Thus, if Ignition is used to add an SSH key to the core user, but the Ignition config doesn't explicitly add the user to groups, it will not have sudo access:

passwd:
  users:
    - name: core
      ssh_authorized_keys:
        - "ssh-rsa ..."

The above config works on Container Linux.

cc @ajeddeloh

@bgilbert bgilbert added the bug Something isn't working label Jan 15, 2019
arithx added a commit to arithx/mantle that referenced this issue Jan 31, 2019
There is currently a bug where if the core user is created via Ignition
it is not added to the correct set of groups. This completely blocks
kola from running as the core user is not directly added to the sudoers
file with NOPASSWD but rather inherits it from the sudo group.
Temporarily work around it until a fix lands. Upstream tracking ticket:
coreos/fedora-coreos-config#41
@bgilbert
Copy link
Contributor Author

For context, that logic was originally added in 5a0d60e.

Assumptions:

Options:

  1. Ship the core user in the base image.
    1. The user can be removed via Ignition.
    2. Creation of the user's private group cannot be inhibited. Other user properties, including the home directory and the list of supplementary groups, can be modified by Ignition.
  2. Conditionally create the core user (the status quo).
    1. The user can be created via Ignition with any set of properties, including omission of a user group.
    2. If the config intends the user to have some non-default properties but otherwise replicate OS defaults (primarily the group list), it needs to explicitly encode those defaults.
    3. Creation of the user cannot be inhibited entirely.
  3. Create the core user in the Ignition base config.
    1. Via Ignition config merging, the user can be created with any set of properties, including omission of a user group, or inhibited entirely.
    2. Ignition would be involved in applying defaults to the base OS image, which is generally not the preferred approach.
  4. Create the core user via systemd-sysusers.
    1. systemd-sysusers is not designed for creating non-system users. It doesn't really want to create users outside the system ID range, and doesn't create home directories. The home directory would need to be created via systemd-tmpfiles.
    2. The user can be removed via Ignition, but the systemd-sysusers and systemd-tmpfiles fragments would also need to be masked to prevent the user from coming back.
    3. Creation of the user's private group could not be inhibited. The user's home directory could be changed, but the systemd-tmpfiles fragment would need to be masked to prevent the old one from coming back. Other user properties, including the list of supplementary groups, could be freely modified by Ignition.

On balance, option 3 seems like the one with the best UX and the fewest negative side effects.

cc @cgwalters

@lucab
Copy link
Contributor

lucab commented Feb 25, 2019

@bgilbert thanks for filing this, I hit it earlier but didn't realize what was going on under the hood. As a very-short-term workaround, I think the unit can be split in a conditional useradd and an unconditional usermod, with the ConditionFirstBoot=true at the top protecting further boots.

For the longer-term, I like that option 1 allows us to know and reference the uid/gid when assembling the base OS in a static way. But I don't know if that it a real use-case we will have to handle (that is, having core referenced by some RPMs content).

@bgilbert
Copy link
Contributor Author

I think either option 1 or option 3 could be implemented now without a lot of effort.

I'd hope that core isn't referenced by RPM content, especially if we want the core user to be optional. @cgwalters, any perspective on that?

@cgwalters
Copy link
Member

I can't think of a reason core would be referenced by RPMs.

@dustymabe
Copy link
Member

i'm good with whatever you prefer @bgilbert

@ashcrow
Copy link
Member

ashcrow commented Mar 15, 2019

We now see the same issue referenced in coreos/mantle#981 in RHCOS as well.

@jlebon
Copy link
Member

jlebon commented Mar 15, 2019

On balance, option 3 seems like the one with the best UX and the fewest negative side effects.

I agree. I think it's likely we'll have other such "conditionals" expressed through an overridable base Ignition config (e.g. for /var partition by default support, we may end up using the same strategy).

@bgilbert
Copy link
Contributor Author

I went with option 3 in #74.

c4rt0 pushed a commit to c4rt0/fedora-coreos-config that referenced this issue Mar 27, 2023
treecompose: Add missing --repo arg
dustymabe pushed a commit to jbtrystram/fedora-coreos-config that referenced this issue Apr 19, 2024
We link to it on the main docs page already, though it's useful here too
in this section.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants