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

Reuse existing user id if it exists #145

Merged
merged 2 commits into from
Apr 22, 2024
Merged

Reuse existing user id if it exists #145

merged 2 commits into from
Apr 22, 2024

Conversation

Itxaka
Copy link
Collaborator

@Itxaka Itxaka commented Apr 22, 2024

We dont want to fully skip the user update if it exists as it may be for a specific reason like updating groups and such, but if the entry does not have a specific user id set by the user object and the user already exists in the passwd file, we should reuse the userid as to not break existing files that may have permissions linked to that user

This should fix:

  • users in config files appearing more than once, so their uid wont change
  • ssh keys added to users than are updated after the key creation
  • anything else adding a user to the passwd file and bumping the next uid free, as our calculation picks the latest free uid

We dont want to fully skip the user update if it exists as it may be for
a specific reason like updating groups and such, but if the entry does
not have a specific user id set by the user object and the user already
exists in the passwd file, we should reuse the userid as to not break
existing files that may have permissions linked to that user

This should fix:
 - users in config files appearing more than once, so their uid wont
   change
 - ssh keys added to users than are updated after the key creation
 - anything else adding a user to the passwd file and bumping the next
   uid free, as our calculation picks the latest free uid

Signed-off-by: Itxaka <itxaka@kairos.io>
 - Provide a proper /etc/passwd with normal lines instead of empty
 - Check that the user management does not remove existing users
 - Rework the test to deal with the extended passwd file
 - Add tests for maintaining the UID of an user

Signed-off-by: Itxaka <itxaka@kairos.io>
@Itxaka Itxaka merged commit 9484451 into master Apr 22, 2024
5 checks passed
@Itxaka Itxaka deleted the reuse-exiting-uid branch April 22, 2024 12:48
davidcassany pushed a commit to davidcassany/yip that referenced this pull request Jul 3, 2024
kkaempf pushed a commit to rancher/yip that referenced this pull request Jul 3, 2024
* Set the vfat label using the correct flag (mudler#141)

-i expects a hexadecimal value
-n should be used for the filesystem label

https://man7.org/linux/man-pages/man8/mkfs.vfat.8.html

Needed as part of kairos-io/kairos#2281

so that this config:

```
      add_partitions:
        - fsLabel: COS_GRUB
          size: 64
          pLabel: efi
          filesystem: "fat"
```

won't result in this error:

```
Volume ID must be a hexadecimal number
```

Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
(cherry picked from commit 4ebbc75)

* Reuse existing user id if it exists (mudler#145)

(cherry picked from commit 9484451)

* Handle duplicated names in a stage (mudler#147)

(cherry picked from commit 9394813)

---------

Co-authored-by: Dimitris Karakasilis <jimmykarily@gmail.com>
Co-authored-by: Itxaka <itxaka.garcia@spectrocloud.com>
Co-authored-by: Mauro Morales <contact@mauromorales.com>
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

Successfully merging this pull request may close these issues.

2 participants