mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Hmpf boring resolvconf shit
This commit is contained in:
parent
3869c2f68e
commit
2f0a95645a
2 changed files with 22 additions and 8 deletions
|
@ -50,6 +50,21 @@ do_pre_regen() {
|
||||||
do_post_regen() {
|
do_post_regen() {
|
||||||
regen_conf_files=$1
|
regen_conf_files=$1
|
||||||
|
|
||||||
|
# Fuck it, those domain/search entries from dhclient are usually annoying
|
||||||
|
# lying shit from the ISP trying to MiTM
|
||||||
|
if grep -q -E "^ *(domain|search)" /run/resolvconf/resolv.conf
|
||||||
|
then
|
||||||
|
if grep -q -E "^ *(domain|search)" /run/resolvconf/interface/*.dhclient 2>/dev/null
|
||||||
|
then
|
||||||
|
sed -E "s/^(domain|search)/#\1/g" -i /run/resolvconf/interface/*.dhclient
|
||||||
|
fi
|
||||||
|
|
||||||
|
grep -q '^supersede domain-name "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo '^supersede domain-name "";' >> /etc/dhcp/dhclient.conf
|
||||||
|
grep -q '^supersede domain-search "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo '^supersede domain-search "";' >> /etc/dhcp/dhclient.conf
|
||||||
|
grep -q '^supersede name "";' /etc/dhcp/dhclient.conf 2>/dev/null || echo '^supersede name "";' >> /etc/dhcp/dhclient.conf
|
||||||
|
systemctl restart resolvconf
|
||||||
|
fi
|
||||||
|
|
||||||
[[ -z "$regen_conf_files" ]] \
|
[[ -z "$regen_conf_files" ]] \
|
||||||
|| service dnsmasq restart
|
|| service dnsmasq restart
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ class IPDiagnoser(Diagnoser):
|
||||||
|
|
||||||
# In every case, we can check that resolvconf seems to be okay
|
# In every case, we can check that resolvconf seems to be okay
|
||||||
# (symlink managed by resolvconf service + pointing to dnsmasq)
|
# (symlink managed by resolvconf service + pointing to dnsmasq)
|
||||||
good_resolvconf = self.resolvconf_is_symlink() and self.resolvconf_points_to_localhost()
|
good_resolvconf = self.good_resolvconf()
|
||||||
|
|
||||||
# If we can't resolve domain names at all, that's a pretty big issue ...
|
# If we can't resolve domain names at all, that's a pretty big issue ...
|
||||||
# If it turns out that at the same time, resolvconf is bad, that's probably
|
# If it turns out that at the same time, resolvconf is bad, that's probably
|
||||||
|
@ -131,13 +131,12 @@ class IPDiagnoser(Diagnoser):
|
||||||
def can_resolve_dns(self):
|
def can_resolve_dns(self):
|
||||||
return os.system("dig +short ip.yunohost.org >/dev/null 2>/dev/null") == 0
|
return os.system("dig +short ip.yunohost.org >/dev/null 2>/dev/null") == 0
|
||||||
|
|
||||||
def resolvconf_is_symlink(self):
|
def good_resolvconf(self):
|
||||||
return os.path.realpath("/etc/resolv.conf") == "/run/resolvconf/resolv.conf"
|
content = read_file(file_).strip().split("\n")
|
||||||
|
# Ignore comments and empty lines
|
||||||
def resolvconf_points_to_localhost(self):
|
content = [l.strip() for l in content if l.strip() and not l.strip().startswith("#")]
|
||||||
file_ = "/etc/resolv.conf"
|
# We should only find a "nameserver 127.0.0.1"
|
||||||
resolvers = [r.split(" ")[1] for r in read_file(file_).split("\n") if r.startswith("nameserver")]
|
return len(content) == 1 and content.split() == ["nameserver", "127.0.0.1"]
|
||||||
return resolvers == ["127.0.0.1"]
|
|
||||||
|
|
||||||
def get_public_ip(self, protocol=4):
|
def get_public_ip(self, protocol=4):
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue