From 0fb8b6a8abf3fef5f04214951e4f209244e373ef Mon Sep 17 00:00:00 2001 From: Pranav Jerry Date: Sat, 12 Jun 2021 19:28:59 +0530 Subject: [PATCH] stopped messing with resolv.conf Completely removed the part that symlinks resolv.conf to systemd-resolved's conf. Instead, added an optional dependency of resolved in README.md --- README.md | 3 ++- naxalnet | 35 +---------------------------------- naxalnet.service | 1 - 3 files changed, 3 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index 2b2dbe6..15b904b 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ advocating the constitutional rights). ## Requirements -- systemd v248 or more (for batman support) +- systemd{,-networkd} v248 or more (for batman support) - Linux kernel with batman-adv module (if `modinfo batman-adv` shows no error then you already have it) - iwd (for starting ad-hoc network) @@ -36,6 +36,7 @@ advocating the constitutional rights). - [python-dasbus][] - wifi adapter with ad-hoc support - two or more computers with wifi adapter +- systemd-resolved (optional, for DNS) ## Installing diff --git a/naxalnet b/naxalnet index 124a1bc..042c327 100755 --- a/naxalnet +++ b/naxalnet @@ -22,7 +22,6 @@ with systemd-networkd and iwd import sys -import time from pathlib import Path from shutil import copy from dasbus.connection import SystemMessageBus @@ -30,8 +29,6 @@ from dasbus.error import DBusError NETWORKD_CONFIGS = "/usr/share/naxalnet/networkd" NETWORKD_VOLATILE_DIR = "/run/systemd/network" -RESOLVED_STUB_RESOLVE = "/run/systemd/resolve/stub-resolv.conf" -RESOLV_CONF = "/etc/resolv.conf" ADHOC_SSID = "HelloWorld" # Copy networkd configs to volatile dir. @@ -51,36 +48,6 @@ except PermissionError as error: print(error) sys.exit("Make sure you are root") - -# Symlink resolvd.conf to systemd's stub-resolvd.conf -# This is needed for DNS resolution to work. -# see https://wiki.archlinux.org/title/Systemd-resolved#DNS -try: - print("Checking resolv.conf") - r = Path(RESOLV_CONF) - if r.is_symlink(): - # Naxalnet will be started before resolved, so the destination - # is unlikely to exist at the time - # If r is linked to resolved's resolv.conf, dont change it - if r.samefile(RESOLVED_STUB_RESOLVE): - print(r, "is already linked to stub-resolv.conf. Not changing") - # Else if the destination exists - elif r.exists(): - print(r, "is a symlink that exists. Not removing") - else: - print(r, "is a symlink to a destination that doesn't exist. Removing") - r.unlink() - elif r.exists(): - print(r, "is not a symlink") - x = r.rename(RESOLV_CONF + ".naxalnet-bkp") - print(r, "was moved to", x) - print("Linking resolv.conf") - r.symlink_to(RESOLVED_STUB_RESOLVE) -except PermissionError as error: - print(error) - sys.exit("An error occured while linking resolv.conf") - - # Now, the iwd part try: # connect to the System bus @@ -108,7 +75,7 @@ try: print("Device is in", dev1.Mode) print("Switching to ad-hoc") dev1.Mode = "ad-hoc" - # Changing Mode requires connecting to the proxy again + # Changing Mode needs connecting to the proxy again dev1 = bus.get_proxy("net.connman.iwd", devpath) print("Starting ad-hoc network") dev1.StartOpen(ADHOC_SSID) diff --git a/naxalnet.service b/naxalnet.service index 19a6182..98082bf 100644 --- a/naxalnet.service +++ b/naxalnet.service @@ -15,7 +15,6 @@ After=wpa_supplicant.service [Service] Type=oneshot RemainAfterExit=yes -# Temporary (maybe permanent) fix to aborting after changing to ad-hoc Restart=on-failure RestartSec=5sec ExecStart=/usr/bin/naxalnet