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

allow systemd-networkd to set hostname without polkit #22792

Closed
wants to merge 7 commits into from

Conversation

gyakovlev
Copy link
Member

@floppym as discussed on irc.

still WIP, not tested, just opening for visibility and initial feedback.
ofc it'll require a bit of keywording on dbus-broker, new GID assignement and flag masking and better comments, but later with that.
just drafting systemd change here.

not sure if it's ok to use systemd_get_systemunitdir here.

@gyakovlev gyakovlev closed this Nov 1, 2021
@gyakovlev gyakovlev reopened this Nov 1, 2021
@gyakovlev gyakovlev added do not merge Please DO NOT MERGE this PR. It will not be assigned but it will be scanned by CI. work in progress The PR is not yet ready to be merged. labels Nov 1, 2021
@gyakovlev gyakovlev marked this pull request as draft November 1, 2021 23:42
Copy link
Contributor

@floppym floppym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable.

You'll need to add a USE flag description to metadata.xml.

sys-apps/systemd/systemd-9999.ebuild Outdated Show resolved Hide resolved
gentoo-bot pushed a commit to gentoo/api-gentoo-org that referenced this pull request Nov 2, 2021
Recommended GID only: 66
For gentoo/gentoo#22792
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
@gyakovlev gyakovlev changed the title WIP: allow systemd-networkd to set hostname without polkit allow systemd-networkd to set hostname without polkit Nov 2, 2021
@gyakovlev gyakovlev marked this pull request as ready for review November 2, 2021 23:26
@gyakovlev
Copy link
Member Author

Ok I seems to have covered all formalities around, including GID so I remove WIP status.
Testing, still not ready to merge until I test more.

@gentoo-repo-qa-bot
Copy link
Collaborator

Pull request CI report

Report generated at: 2021-11-02 23:40 UTC
Newest commit scanned: e261c03
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/a7c293dff7/output.html

Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
this will allow networkd/hostnamed to properly set hostname
on systems without polkit.

while it's possible to set hostname/fqdn manually already, with fallback workaround
it will be possible to get hostnames from DHCP via networkd too without
using polkit->spidermonkey->rust->llvm chain of deps.

ideas and configs taken from yocto/oe
https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=3dc37c12c17d5bb6d4701a425a4f79f6e31784ee

systemd/systemd#13501
Signed-off-by: Georgy Yakovlev <gyakovlev@gentoo.org>
@gyakovlev
Copy link
Member Author

tested

as expected networkd can now set hostname.

from system without workaround:

 systemctl status systemd-networkd
● systemd-networkd.service - Network Configuration
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2021-07-23 07:58:46 PDT; 3 months 15 days ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 1638 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 37644)
     Memory: 1.7M
        CPU: 38.382s
     CGroup: /system.slice/systemd-networkd.service
             └─1638 /lib/systemd/systemd-networkd

Jul 23 07:58:45 honeycomb systemd[1]: Starting Network Configuration...
Jul 23 07:58:46 honeycomb systemd-networkd[1638]: Enumeration completed
Jul 23 07:58:46 honeycomb systemd[1]: Started Network Configuration.
Jul 23 07:58:46 honeycomb systemd-networkd[1638]: eth0: Link UP
Sep 30 17:51:30 honeycomb systemd-networkd[1638]: eth0: Gained carrier
Sep 30 17:51:31 honeycomb systemd-networkd[1638]: eth0: DHCPv4 address 192.168.1.231/24 via 192.168.1.1
Sep 30 17:51:32 honeycomb systemd-networkd[1638]: Could not set hostname: Access denied
Oct 14 10:07:02 honeycomb systemd-networkd[1638]: docker0: Link UP

from system with workaround:

● systemd-networkd.service - Network Configuration
     Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-11-06 16:53:50 PDT; 4min 31s ago
TriggeredBy: ● systemd-networkd.socket
       Docs: man:systemd-networkd.service(8)
   Main PID: 16249 (systemd-network)
     Status: "Processing requests..."
      Tasks: 1 (limit: 154477)
     Memory: 1.1M
     CGroup: /system.slice/systemd-networkd.service
             └─16249 /lib/systemd/systemd-networkd

Nov 06 16:53:53 node systemd-networkd[16249]: eno1: Lost carrier
Nov 06 16:53:53 node systemd-networkd[16249]: bond0: Lost carrier
Nov 06 16:53:54 node systemd-networkd[16249]: eno2: Link UP
Nov 06 16:53:54 node systemd-networkd[16249]: eno1: Link UP
Nov 06 16:53:54 node systemd-networkd[16249]: bridge0: Lost carrier
Nov 06 16:53:59 node systemd-networkd[16249]: eno2: Gained carrier
Nov 06 16:53:59 node systemd-networkd[16249]: bond0: Gained carrier
Nov 06 16:53:59 node systemd-networkd[16249]: eno1: Gained carrier
Nov 06 16:54:20 node systemd-networkd[16249]: bridge0: Gained carrier
Nov 06 16:54:20 node systemd-networkd[16249]: bridge0: DHCPv4 address 192.168.1.206/24 via 192.168.1.1

rebased just now.
anything else @floppym ?

@gentoo-repo-qa-bot
Copy link
Collaborator

Pull request CI report

Report generated at: 2021-11-07 00:25 UTC
Newest commit scanned: aa6fef2
Status: ✅ good

There are existing issues already. Please look into the report to make sure none of them affect the packages in question:
https://qa-reports.gentoo.org/output/gentoo-ci/486accca0b/output.html

Copy link
Contributor

@floppym floppym left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@gentoo-bot gentoo-bot closed this in c897165 Nov 7, 2021
@gyakovlev gyakovlev deleted the systemd-nopolkit-hostnamed branch November 7, 2021 05:28
@gyakovlev
Copy link
Member Author

thanks for checking, merged.

@ulm
Copy link
Member

ulm commented Nov 13, 2021

Is there any special reason for using a GID below 100 (other than none other being available)?

@floppym
Copy link
Contributor

floppym commented Nov 13, 2021

No special reason.

@Karlson2k
Copy link
Contributor

Karlson2k commented Mar 12, 2022

It doesn't work unless dbus-broker.service is enabled. By default it is disabled, which results in cryptic errors like:

Mar 12 14:00:28 dbus-daemon[257]: [system] Failed to activate service 'org.freedesktop.hostname1': timed out (service_start_timeout=25000ms)
Mar 12 14:00:28 systemd-networkd[212]: Could not set hostname: Method call timed out
Mar 12 14:00:33 systemd-hostnamed[273]: Failed to run event loop: Transport endpoint is not connected
Mar 12 14:00:33 systemd[1]: systemd-hostnamed.service: Main process exited, code=exited, status=1/FAILURE
Mar 12 14:00:33 systemd[1]: systemd-hostnamed.service: Failed with result 'exit-code'.
Mar 12 14:00:33 systemd[1]: Failed to start Hostname Service.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do not merge Please DO NOT MERGE this PR. It will not be assigned but it will be scanned by CI. work in progress The PR is not yet ready to be merged.
Projects
None yet
5 participants