opened 05:04PM - 17 Mar 24 UTC
RFE 🎁
pid1
### 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:
* https://github.com/Kicksecure/security-misc/issues/213
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`
```
[Service]
ConditionDropIn=Exists:/path/to/status/file
# Additional configuration specific to the condition, which is disregarded if the status file does not exist.
```
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_