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

passwd: implement systemd-userdb mechanism to fallback on if useradd does not work #1593

Open
tormath1 opened this issue Mar 29, 2023 · 1 comment

Comments

@tormath1
Copy link
Contributor

tormath1 commented Mar 29, 2023

Feature Request

Hi, with Flatcar we noticed back in the days that an update changed the behavior to add user into a group:

passwd:
  users:
    - name: tormath1
      groups:
        - docker
        - kvm
        - sudo

This configuration fails the following message:

[failed]   creating or modifying user "build": exit status 6: Cmd: "useradd" "--root" "/sysroot" "--create-home" "--password" "*" "--groups" "docker,sudo,kvm" "tormath1" Stdout: "" Stderr: "useradd: group 'kvm' does not exist\n"

The group kvm does exist but it's present under an alternative location (/usr/share/baselayout/group), it's just that there is no active NSS switch configuration, useradd only tries to find the group in /etc/group.

Note: with an older useradd binary it was failing too but it was not throwing an error.

This led us to try an alternative way to add user into a group: systemd-userdb1 - with this configuration:

variant: flatcar
version: 1.0.0
storage:
  files:
    - path: /etc/userdb/tormath1:docker.membership
      contents:
        inline: |
          some content
    - path: /etc/userdb/tormath1:kvm.membership
      contents:
        inline: |
          some content
    - path: /etc/userdb/tormath1:sudo.membership
      contents:
        inline: |
          some content

We can create the user with the correct group membership.

Desired Feature

The idea would be to use systemd-userdb as a last resort if useradd fails because of non-existing group.

Footnotes

  1. https://www.freedesktop.org/software/systemd/man/nss-systemd.html

@bgilbert
Copy link
Contributor

xref #1596, which proposes a different workaround.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants