-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Feature Request: Conditional Application of systemd Drop-In Files #31833
Comments
This can't really be implemented, it would be a by-the-book TOCTOU as the files are read on reload only, not when a service is started, so the condition would be evaluated at the wrong time |
Can't it be evaluated by the same time |
No, because again that would make the configuration change randomly outside of reload time, and we do not want that to happen |
Make it same as |
That would mean having some 'special' directive that doesn't mean anything in a file but means something in a different file, and also it means that the provenance of an option becomes important, and also make the actual configuration dependent on random other factors. I don't think that makes much sense. If you want complex configuration management, either use one of the existing config management tools or build a new one. |
I too would really like this feature and would have no problem with the directive being applied at reload time instead of unit startup time. One advantage would be that unit files provided upstream could be even more precise/better. E.g. different properties based on distribution or filesystem layout. Another area where this would make sense even for unit files provided by the distro would be scenarios where different properties should be selected based on the presence of security mechanism like selinux or based on Kernel versions. Sure, some of this would be possible by changes in the application itself but not everything (anything apart from changes to the execstart cmdline or maybe environment would be considerably harder if not impossible). |
Component
systemd
Is your feature request related to a problem? Please describe
Currently, systemd supports the use of drop-in files to extend or override configuration settings for unit files. While systemd provides the
ConditionPathExists
directive to conditionally start a service based on the existence of a file or directory, there is no built-in mechanism to conditionally apply drop-in files based on custom conditions within those files.It would be highly beneficial to have a feature in systemd that allows for the conditional application of drop-in files based on custom conditions. This would provide users with greater flexibility and control over the configuration of systemd units.
A specific example would be the following one:
Complex hardening would be enabled by default. But to easily opt-in/out the additional hardening, to simplify testing, a status file would be helpful.
Describe the solution you'd like
Introduce a new directive, such as
ConditionDropIn
, that allows users to specify custom conditions within drop-in files themselves. This directive could accept a condition expression similar to other systemd directives, enabling users to define conditions based on various factors such as the existence of specific files, system properties, environment variables, or other runtime conditions.Example:
/lib/systemd/system/myservice.service.d/50_drop-in.conf
In this example, the drop-in file
50_user.conf
would only be applied if the file/path/to/status/file
exists.Describe alternatives you've considered
Packaging, scripting.
The systemd version you checked that didn't have the feature you are asking for
No response
The text was updated successfully, but these errors were encountered: