Skip to content
This repository has been archived by the owner on Oct 16, 2020. It is now read-only.

Specifying group "systemd-journal" in cloud-init doesn't work #312

Closed
pwaller opened this issue Mar 23, 2015 · 19 comments
Closed

Specifying group "systemd-journal" in cloud-init doesn't work #312

pwaller opened this issue Mar 23, 2015 · 19 comments

Comments

@pwaller
Copy link

pwaller commented Mar 23, 2015

I've got a system service and I want it to be able to read the systemd logs. To do that, it needs to be in the systemd-journal group. However, specifying it under "groups" has no effect. Groups works, but not for this system group.

Is it possible to make this work?

users:
  # system services
  - name: log
    groups: [systemd-journal]
@pwaller
Copy link
Author

pwaller commented Mar 23, 2015

I think I may be mistaken here, I'll reopen if I can reproduce. Apologies for the noise.

@pwaller pwaller closed this as completed Mar 23, 2015
@pwaller pwaller reopened this Mar 23, 2015
@pwaller
Copy link
Author

pwaller commented Mar 23, 2015

I can reproduce this, and @mischief was able to reproduce on the latest image.

@pwaller
Copy link
Author

pwaller commented Mar 23, 2015

Notes:

  • It appears to work if I just run useradd --groups systemd-journal log (which as far as I can tell is what cloudinit is running)
  • The group isn't listed in /etc/group but is in /usr/share/baselayout/group.

@mischief
Copy link

i can't successfully add systemd-journal to the user's groups with useradd. the command that is constructed based on your cloud-config is: useradd --password "*" --create-home --groups systemd-journal log. interestingly, if you give a group that exists in neither /etc/group or /usr/share/baselayout/group, useradd will abort. however, if it only exists in /usr/share/baselayout/group, useradd will print no error, but the user is not added to that group.

@pwaller
Copy link
Author

pwaller commented Mar 23, 2015

Works for me, starting with no log user existing (CoreOS stable (557.2.0)):

$ sudo useradd --groups systemd-journal log                                                                                                   
$ groups log
systemd-journal log

@pwaller pwaller closed this as completed Mar 23, 2015
@pwaller pwaller reopened this Mar 23, 2015
@pwaller
Copy link
Author

pwaller commented Mar 23, 2015

Oops, fat-fingered close, sorry.

@marineam
Copy link

This has been a known problem ever since we introduced images with the current disk layout. Each of the different shadow utils behaves a little differently here: some will silently ignore users/groups that exist on the systemd (provided by some nss module) but do not appear in the /etc files while others will fail. In no case do the tools copy the information into /etc in order to modify it. The assumption being that groups not in /etc are provided by something like LDAP so the local system shouldn't have control over them. The mixes of behavior, particularly the silent ignoring, turns that assumption into a whole series of surprises though.

CoreOS provides most system users and groups in /usr/share/baselayout/ to allow changes between versions to happen seamlessly without needing some special tool to merge/update the /etc files during upgrades. /etc is under the control of the user so system updates shouldn't muck with it whenever possible. To work around the awkwardness of the situation we do copy a couple things to /etc like the 'core' user and the 'docker' group but avoided doing everything.

Since that scheme was implemented a year ago systemd has actually written a tool specifically for safely updating the passwd/group databases in /etc during system upgrades. Switching to this scheme and removing the nss module that reads from /usr/share/baselayout will get systems working in the way users expect but we haven't gotten around to making the switch.

@JeanMertz
Copy link

Is there any way to (manually) add a user to the systemd-journal group after initial bootstrap?

$ usermod -aG systemd-journal me
$ groups me
# => sudo docker me

@zapient
Copy link

zapient commented Dec 16, 2015

Any workarounds for this?

@kayrus
Copy link

kayrus commented Dec 17, 2015

Switching to sysusers.d should partly solve the issue. But sysusers.d is developed (surprise) for system users and it doesn't allow to set additional options (shell, etc.)

@marineam
Copy link

For reference this script copies some users/groups from /usr to /etc so that they can be modified, in lieu of moving to sysusers.d systemd-journal will need to be added to this list. https://github.com/coreos/baselayout/blob/master/scripts/coreos-tmpfiles

@kayrus
Copy link

kayrus commented Dec 17, 2015

@marineam I already modified this script, but you didn't accept related changes. coreos/baselayout#37

@marineam
Copy link

@kayrus As mentioned in coreos/baselayout#37 that change doesn't look quite right to me, safely updating existing files needs to be a bit fancier. I may have misread it though. Adding things to /etc during updates is independent of what lands in /etc on first boot though, we can easily add more groups so new systems can easily modify systemd-journal and so on.

@agokjr
Copy link

agokjr commented Apr 23, 2016

any updates? Trying to Add systemd-journal to an account that exists.

mnaboka added a commit to mnaboka/dcos that referenced this issue Jul 7, 2016
3dt needs to read the journal. In order to do that it needs to be in
systemd-journal group. The issue is that coreos uses several backends for
users and groups. One is a regular /etc/passwd, /etc/groups and the other is
located under /usr/share/baselayout. If we try to append dcos_3dt user with
flag -G this will not work. (Tested on CoreOS beta (1068.3.0))
This seems to be a long running issue with CoreOS
coreos/bugs#312
However if we try to change a user's primary group with -g flag all works
as expected.

This is not meant to be merged, used for testing at this point.
mnaboka added a commit to mnaboka/dcos that referenced this issue Jul 18, 2016
3dt needs to read the journal. In order to do that it needs to be in
systemd-journal group. The issue is that coreos uses several backends for
users and groups. One is a regular /etc/passwd, /etc/groups and the other is
located under /usr/share/baselayout. If we try to append dcos_3dt user with
flag -G this will not work. (Tested on CoreOS beta (1068.3.0))
This seems to be a long running issue with CoreOS
coreos/bugs#312
However if we try to change a user's primary group with -g flag all works
as expected.

This is not meant to be merged, used for testing at this point.
mnaboka added a commit to mnaboka/dcos that referenced this issue Jul 19, 2016
3dt needs to read the journal. In order to do that it needs to be in
systemd-journal group. The issue is that coreos uses several backends for
users and groups. One is a regular /etc/passwd, /etc/groups and the other is
located under /usr/share/baselayout. If we try to append dcos_3dt user with
flag -G this will not work. (Tested on CoreOS beta (1068.3.0))
This seems to be a long running issue with CoreOS
coreos/bugs#312
However if we try to change a user's primary group with -g flag all works
as expected.
@hectorj2f
Copy link

Is there any update regarding this issue ?

@crawford
Copy link
Contributor

Unfortunately, no updates. I can tell you though that it is very unlikely that we will be fixing this for coreos-cloudinit. We've been investing in Ignition, the successor to coreos-cloudinit, which greatly simplifies configuration while drastically increasing the breadth of what can be configured.

I'm going to close this out in favor of #1267.

@hectorj2f
Copy link

Oh yeah! . We can also use ignition for this 👍. Thanks @crawford

@pwaller
Copy link
Author

pwaller commented Oct 29, 2016

@hectorj2f as far as I can tell, ignition doesn't yet solve this, or?

@hectorj2f
Copy link

@pwaller After looking at #1267, it might not be that easy although I need to add systemd-journal group to my users, not rkt.

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

No branches or pull requests

9 participants