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

Run systemd-sysusers when generating initrd #1830

Open
lnykryn opened this issue May 30, 2022 · 6 comments
Open

Run systemd-sysusers when generating initrd #1830

lnykryn opened this issue May 30, 2022 · 6 comments
Labels
enhancement Issue adding new functionality

Comments

@lnykryn
Copy link
Member

lnykryn commented May 30, 2022

I was looking at #1658 where we removed the Condition, so the sysusers are run every time in the initrd. I don't think this is necessary since we always take the same sysusers drop-ins and create the same users every time.
I think it should be safe to call systemd-sysusers while generating the initrd. We will move the module to the end of the queue and use systemd-sysusers --root.
This should result in smaller initrd (no need for sysusers binary in the initrd) and faster boot (no need to create the users every time).

I am willing to write a patch for this, but first, I want to check what others think.

@lnykryn lnykryn added the enhancement Issue adding new functionality label May 30, 2022
@aafeijoo-suse
Copy link
Member

I think it's a good proposal.

@johannbg
Copy link
Collaborator

johannbg commented May 30, 2022

Such a patch would then have to use the systemd sysusers files that we are shipping with our modules ( and being shipped with modules that reside outside our own repository ) not anything that resides on the host system itself since there is no guarantee that those files exist there in the first place.

@johannbg
Copy link
Collaborator

johannbg commented May 30, 2022

Quite frankly I'm not seeing how such a patch will not end up being more of a mess then just keeping things as they are ( with the cons it has ) since in the end of the day we serve plethora of systemd based distribution which are in various stages of implementation of systemd in them ( Debian vs Arch for example ) as well as we also need to make sure that dracut ( and it's modules ) for none systemd based distro's behave the same ( void, gentoo, debian as well etc. ) which requires the none systemd based modules to generate the users/groups in the same manner ( equivalent to how systemd does it ).

@lnykryn
Copy link
Member Author

lnykryn commented May 30, 2022

Such a patch would then have to use the systemd sysusers files that we are shipping with our modules ( and being shipped with modules that reside outside our own repository ) not anything that resides on the host system itself since there is no guarantee that those files exist there in the first place.

I think you misunderstood my proposal. I want all dracut modules to copy their dropins to initrd (as they do now) and then just call systemd-sysusers at the end on them (not the host's ones).

Quite frankly I'm not seeing how such a patch will not end up being more of a mess then just keeping things as they are ( with the cons it has ) since in the end of the day we serve plethora of systemd based distribution which are in various stages of implementation of systemd in them ( Debian vs Arch for example ) as well as we also need to make sure that dracut ( and it's modules ) for none systemd based distro's behave the same ( void, gentoo, debian as well etc. ) which requires the none systemd based modules to generate the users/groups in the same manner ( equivalent to how systemd does it ).

There is literally no difference between the current state and my proposal. Right now we gather the dropins into the initrd and generate the users on every boot. I am just saying, that this is redundant since you can do it just once when initrd is created.

@lnykryn
Copy link
Member Author

lnykryn commented May 30, 2022

And also to back up my proposal. In a normal system we have ConditionNeedsUpdate just because we need to run the service when etc or usr change. Those are static in initrd.

@johannbg
Copy link
Collaborator

johannbg commented May 30, 2022

Yup completely misunderstood you proposal and your proposal has now a solid go from me.
One thing I would like to add I'm not so sure we can do it just once as in when the initrd is created however we can easily introduce a new kernel commandline switch (rd.create.sysusers= or whatever ) and add that as a condition in the type unit file ( ConditionKernelCommandLine=rd.create.sysusers=0 ) to trigger the unit and provide backwards compatibility to existing behaviour since when "ConditionNeedsUpdate" got added to the unit in upstream systemd, it broke existing system for users, using the dracut sysuser module in the wild so someone is doing something with it and might be relying on that behaviour. ( my best guess would be something stateless releated but I dont care, unlike upstream systemd I dont make assumption how people are using dracut modules or in/for what purpose )

aafeijoo-suse added a commit to aafeijoo-suse/dracut that referenced this issue Nov 17, 2022
When generating the initrd, dracut copies all the sysusers dropins provided by
its modules to it, and systemd-sysusers runs at every boot to always create the
same users.

This patch is intended to create the system users only when the initrd is
generated, without including the systemd-sysusers stuff in the initrd, as it is
not necessary.

To control this functionality and allow to use the old method, added the
`create_sysusers` configuration option (default to yes) and the
`--no-create-sysusers` parameter.

Fixes dracutdevs#1830
aafeijoo-suse added a commit to aafeijoo-suse/dracut that referenced this issue Nov 21, 2022
When generating the initrd, dracut copies all the sysusers dropins provided by
its modules to it, and systemd-sysusers runs at every boot to always create the
same users (`ConditionNeedsUpdate` removed in dracutdevs#1658).

This patch is intended to create the system users only when the initrd is
generated, without including the systemd-sysusers stuff in the initrd, as it is
not necessary.

To control this functionality and allow to use the old method, added the
`create_sysusers` configuration option (default to yes) and the
`--no-create-sysusers` parameter.

Fixes dracutdevs#1830
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issue adding new functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants