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

sysusers: remove bin entries and get systemd.post: /etc/gshadow: Group "bin" already exists. #1525

Closed
HuijingHei opened this issue Jul 12, 2023 · 5 comments · Fixed by coreos/rpm-ostree#4503
Labels
jira for syncing to jira

Comments

@HuijingHei
Copy link
Member

HuijingHei commented Jul 12, 2023

Refer to coreos/rpm-ostree#49 (comment), do testing with bin:

  1. Remove bin line in group and passwd (refer to https://github.com/coreos/fedora-coreos-config/tree/testing-devel/manifests)
  2. Build FCOS, see logs:
...
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
...

According to @cgwalters 's pointer, the above log will lead systemd-sysusers (during systemd.post) exit early before saving the updated /etc/{passwd,group} refer to code, and bin user/group will not be saved finally.

The root cause is the gshadow is not consistent with group, gshadow is from setup, and we override group according to fedora-coreos-config. And @cgwalters is correct, do testing with override/rootfs/etc/gshadow(from setup package) which removs the bin line, rebuild FCOS no such logs and verify bin user / group saved in /usr/lib/{passwd,group} after boot the disk.

To fix this, we should make sure gshadow is consistent with group before layering, like regenerating gshadow according to group.

@cgwalters
Copy link
Member

Right. I think we can do this automatically in rpm-ostree.

BTW though, this issue also relates a bit to coreos/rpm-ostree#4401 - I wonder if it would work for us to just empty out (or possibly even remove) the shadow files instead of regenerating them?

@cgwalters
Copy link
Member

So I'd probably say we should transfer this issue to rpm-ostree. This problem domain also applies to other systems using it (IoT, desktops, etc.)

@HuijingHei
Copy link
Member Author

HuijingHei commented Jul 13, 2023

I wonder if it would work for us to just empty out (or possibly even remove) the shadow files instead of regenerating them?

Tried to remove the shadow files:
with append src/config/manifests/fedora-coreos-base.yaml under remove-from-packages:, and build fcos, no error about /etc/gshadow: Group "bin" already exists.

  - [setup, /etc/shadow,
            /etc/gshadow]

Check shadow files have mode 0000, seems they do not include all the group/user, and also not include the package prein group for example utmp, not sure there is any concern.

[root@cosa-devsh ~]# ls -l /etc/*shadow*
----------. 1 root root 100 Jul 13 02:24 /etc/gshadow
----------. 1 root root  91 Jul 13 02:23 /etc/gshadow-
----------. 1 root root 107 Jul 13 02:24 /etc/shadow
----------. 1 root root  81 Jul 13 02:23 /etc/shadow-
[root@cosa-devsh ~]# cat /etc/gshadow
bin:!*::
kvm:!*::
render:!*::
sgx:!*::
zincati:!*::
systemd-coredump:!*::
systemd-oom:!*::
core:!::

@HuijingHei
Copy link
Member Author

I wonder if it would work for us to just empty out (or possibly even remove) the shadow files instead of regenerating them?

Test with empty shadow files:
Create empty file override/rootfs/etc/{,g}shadow and build fcos, no error logs.
Boot VM, check shadow files have same mode with override, and include the package prein groups.
Same with remove shadow files, they do not include all the group/user.

HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 17, 2023
Refer to coreos#49 (comment),
Remove bin line in group and passwd
Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```
According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 17, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 17, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
@HuijingHei HuijingHei changed the title sysuers: remove bin entries and get systemd.post: /etc/gshadow: Group "bin" already exists. sysusers: remove bin entries and get systemd.post: /etc/gshadow: Group "bin" already exists. Jul 17, 2023
HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 18, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 18, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
HuijingHei added a commit to HuijingHei/rpm-ostree that referenced this issue Jul 18, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
@HuijingHei HuijingHei added the jira for syncing to jira label Jul 18, 2023
@HuijingHei
Copy link
Member Author

HuijingHei commented Jul 18, 2023

IMU, we should also remove bin user and group in https://github.com/coreos/fedora-coreos-config/blob/testing-devel/overlay.d/15fcos/usr/lib/sysusers.d/10-setup-basic.conf, as they are duplicated in setup sysusers.d/20-setup-groups.conf and sysusers.d/20-setup-users.conf (refer to https://pagure.io/setup/blob/master/f/generate-sysusers-fragments.sh), is this right?

$ grep adm usr/lib/sysusers.d/*
usr/lib/sysusers.d/20-setup-groups.conf:g adm 4
usr/lib/sysusers.d/20-setup-users.conf:u adm 3:4 "adm" /var/adm -

cgwalters pushed a commit to coreos/rpm-ostree that referenced this issue Jul 19, 2023
Refer to #49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
lukewarmtemp pushed a commit to lukewarmtemp/rpm-ostree that referenced this issue Aug 8, 2023
Refer to coreos#49 (comment),
do testing:
1. Remove bin line in group and passwd
2. Build FCOS, see logs:
```
systemd.post: Creating group 'bin' with GID 1.
systemd.post: Creating user 'bin' (bin) with UID 1 and GID 1.
systemd.post: /etc/gshadow: Group "bin" already exists.
```

According to @cgwalters 's pointer:

The above log will lead systemd-sysusers (during systemd.post)
exit early before saving the updated `/etc/{passwd,group}` refer
to [code](https://github.com/systemd/systemd/blob/main/src/sysusers/sysusers.c#L820),
and bin user/group will not be saved finally.

The root cause is that `gshadow` is not consistent with group,
`gshadow` is from setup, and we override group according to https://github.com/coreos/fedora-coreos-config/blob/testing-devel/manifests/group.

The `shadow` is also from setup, and is not consistent with
passwd, we should also sync it.

Fix coreos/fedora-coreos-tracker#1525
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira for syncing to jira
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants