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

Support drop-in configuration files for systemd #933

Open
twiggler opened this issue Nov 5, 2024 · 0 comments
Open

Support drop-in configuration files for systemd #933

twiggler opened this issue Nov 5, 2024 · 0 comments

Comments

@twiggler
Copy link
Contributor

twiggler commented Nov 5, 2024

Introduction

systemd supports "drop-in" configuration directories (see https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html)

Suppose we have the following network configuration file in /etc/systemd/network/wlan0.network

[Match]
Name=wlan0

[Network]
Address=REDACTED IP/24
DHCPServer=true
IPMasquerade=ipv4

Without modifying the original configuration file, we can drop in a directory /etc/systemd/network/wlan0.network.d/ with additional configuration files, such as new-address.network:

[Network]
Address=REDACTED IP/24

These drop in configuration files are merged with the original configuration. Note that a drop-in directory can contain multiple configuration files, which are processed in alphabetical order. The drop-in directory can also reside in a different place: see the documentation for details.

Proposal

Add support for drop-in configuration as an extension to the systemd configuration parser, or as a new parser.

Open problems:

  • It is a bit unclear how values are merged exactly. Some sections and keys are allowed to occur multiple times, in which case the additional configuration extends the original, whereas other sections / keys only occur once. When keys occur only once, does the drop-in file overwrite the original value?

Answer, from the doc: Yes. When multiple files specify the same option, for options which accept just a single value, the entry in the file sorted last takes precedence, and for options which accept a list of values, entries are collected as they occur in the sorted files.

This would imply that the parser needs to know which keys / sections are singletons, and which ones can occur multiple times.

Additionally, some keys can be cleared by assigning it an empty string:

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

No branches or pull requests

2 participants