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
systemd: Allow setting the transient hostname via DHCP #91232
systemd: Allow setting the transient hostname via DHCP #91232
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't test this yet, but this needs to:
- direct staging
- be added to the release notes
- be added to the tests (running
hostnamectl set-hostname --transient foobar
on a host with a config allowing it, and one ensuring it fails on another)
a6b762f
to
1f0ef84
Compare
I messed up the switch to staging, sorry for the automated review requrests, etc. @flokli I don't need this change and only created the PR because no one else volunteered in #74847 and since I already proposed a few possible solutions. As I'm already busy enough with other stuff, I unfortunately won't have time (i.e. enough priority) for the second two items:
But tbh: IMO these are indeed nice to have but also optional as I'd consider this a bug fix and not a new feature etc. If someone has time for the necessary changes: Feel free to re-use my commit. |
No worries, thanks. Better to say you don't have the time than not replying :-) I'll try to get to this over the weekend, and address the changes I requested by myself - it's probably not urgent to merge it before that. |
I don't think this needs a release notes entry, or is there a workflow this would break? All for a test though :) |
I didn't forget this, just haven't gotten to it yet. Will soon, promise! |
This permits using method_set_hostname but still denies method_set_static_hostname. As a result DHCP clients can now always set the transient hostname via the SetHostname method of the D-Bus interface of systemd-hostnamed (org.freedesktop.hostname1.set-hostname). If the NixOS option networking.hostName is set to an empty string (or "localhost") the static hostname (kernel.hostname but NOT /etc/hostname) will additionally be updated (this is intended). From "man hostnamectl": The transient hostname is a fallback value received from network configuration. If a static hostname is set, and is valid (something other than localhost), then the transient hostname is not used. Fix NixOS#74847. Note: It's possible to restrict access to the org.freedesktop.hostname1 interface using Polkit rules.
1f0ef84
to
483dbe9
Compare
I added a regression test to Couldn't yet test with a |
Thanks! |
This permits using method_set_hostname but still denies
method_set_static_hostname. As a result DHCP clients can now always set
the transient hostname via the SetHostname method of the D-Bus interface
of systemd-hostnamed (org.freedesktop.hostname1.set-hostname).
If the NixOS option networking.hostName is set to an empty string (or
"localhost") the static hostname (kernel.hostname but NOT /etc/hostname)
will additionally be updated (this is intended).
From "man hostnamectl": The transient hostname is a fallback value
received from network configuration. If a static hostname is set, and is
valid (something other than localhost), then the transient hostname is
not used.
Fix #74847.
Note: It's possible to restrict access to the org.freedesktop.hostname1
interface using Polkit rules.
Motivation for this change
Examples
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)