gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [ascension] branch master updated (437a1cd -> 523342b)


From: gnunet
Subject: [GNUnet-SVN] [ascension] branch master updated (437a1cd -> 523342b)
Date: Thu, 09 May 2019 00:37:04 +0200

This is an automated email from the git hooks/post-receive script.

rexxnor pushed a change to branch master
in repository ascension.

    from 437a1cd  destroying Ascension
     new 85a1365  updated files
     new 428ca05  Merge remote-tracking branch 'gnunet/master'
     new 523342b  fixed bugs, updated create and get pkey

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ascension/ascension.py                             | 93 +++++++++++++---------
 ascension/test/basic_named.conf                    |  1 +
 .../debian/ascension-bind/DEBIAN/config            | 67 +++++++++-------
 .../debian/ascension-bind/DEBIAN/control           |  2 +-
 .../debian/ascension-bind/DEBIAN/postrm            |  2 +-
 5 files changed, 97 insertions(+), 68 deletions(-)

diff --git a/ascension/ascension.py b/ascension/ascension.py
index e6b6d93..63b2680 100644
--- a/ascension/ascension.py
+++ b/ascension/ascension.py
@@ -267,10 +267,10 @@ class Ascender():
 
                 taskqueue.task_done()
         # End of worker
-        
+
 
         # Check if a delegated zone is available in GNS as per NS record
-        nsrecords = self.zone.iterate_rdatas(dns.rdatatype.NS)
+        nsrecords = self.zone.iterate_rdatasets(dns.rdatatype.NS)
 
         # This is broken if your NS is for ns.foo.YOURZONE as you add
         # the PKEY to YOURZONE instead of to the foo.YOURZONE subzone.
@@ -283,26 +283,35 @@ class Ascender():
         # foo.bar A IN 1.2.3.4
         # => bar PKEY GNS $NEWKEY     + mapping: bar => $NEWKEY
         # => foo[.bar] A GNS 1.2.3.4
-        gnspkey = list(filter(lambda record: for rec in record[2]: if 
str(rec).startswith('gns--pkey--'): return true; return false, nsrecords))
+        #gnspkey = list(filter(lambda record: for rec in record[2]: if 
str(rec).startswith('gns--pkey--'): return true; return false, nsrecords))
         for nsrecord in nsrecords:
             name = str(nsrecord[0])
-            ttl = nsrecord[1]
-            values = nsrecord[2]
+            values = nsrecord[1]
+            ttl = values.ttl
+            #if values.startswith('gns--pkey--'):
+            #    gnspkeys.add()
             gnspkeys = list(filter(lambda record: 
str(record).startswith('gns--pkey--'), values))
-            if len(gnspkeys) > 1:
-                logging.critical("Detected ambiguous PKEY records for label %s 
(not generating PKEY record)", name)
+
+            num_gnspkeys = len(gnspkeys)
+            if not num_gnspkeys:
+                # skip empty values
+                continue
+            if num_gnspkeys > 1:
+                logging.critical("Detected ambiguous PKEY records for label \
+                                  %s (not generating PKEY record)", name)
                 continue
-            gnspkey = gnspkeys[0]
+
+            gnspkey = str(gnspkeys[0])
             # FIXME: check that this is actucally a well-formed PKEY string! 
(Crockford base32, sufficient length)
-            self.add_pkey_record_to_zone(pkey[11:], self.domain, name, ttl)
+            self.add_pkey_record_to_zone(gnspkey[11:], self.domain, name, ttl)
             # FIXME: drop all NS records under this name later! => new map, if 
entry present during NS processing, skip!
-            
+
         # Unify all records under same label into a record set
         customrdataset = dict()
         for name, rdset in self.zone.iterate_rdatasets():
             # build lookup table for later GNS2DNS records
             name = str(name) # Name could be str or DNS.name.Name
-            if customrdataset.get(name)) is None:
+            if customrdataset.get(name) is None:
                 work = list()
                 work.append(rdset)
                 customrdataset[name] = work
@@ -386,13 +395,23 @@ class Ascender():
 
     def resolve_glue(self,
                      authorityname: str) -> list:
-        rdsets = self.zone[dnsresolver].rdatasets
+        """
+        Resolves IP Adresses within zone
+        :param authorityname:
+        """
+        try:
+            rdsets = self.zone[authorityname].rdatasets
+        except KeyError:
+            return []
         value = []
         for rdataset in rdsets:
             if rdataset.rdtype in [dns.rdatatype.A, dns.rdatatype.AAAA]:
-                value.append("address@hidden" % (zonename, str(rdataset)))
+                for rdata in rdataset:
+                    value.append("address@hidden" % (authorityname,
+                                               self.domain,
+                                               str(rdata)))
         return value
-            
+
     def transform_to_gns_format(self,
                                 record: dns.rdata.Rdata,
                                 rdtype: dns.rdata.Rdata,
@@ -430,18 +449,28 @@ class Ascender():
             else:
                 value = "%s.%s" % (value, zonename)
         elif rdtype == 'NS':
-            nameserver = str(record)                   
+            nameserver = str(record.target)
+            if nameserver[-1] == ".":
+                nameserver = nameserver[:-1]
             if value[-1] == ".":
                 # FQDN provided
-                if value.endswith("." + zonename):
-                     # in bailiwick
-                     value = resolve_glue (self, nameserver)
+                if value.endswith(".%s." % zonename):
+                    # in bailiwick
+                    value = self.resolve_glue(record.target)
                 else:
                      # out of bailiwick
-                    value = 'address@hidden' % (str(label), zonename, 
dnsresolver)
+                    if label.startswith("@"):
+                        value = 'address@hidden' % (zonename, nameserver)
+                    else:
+                        value = 'address@hidden' % (str(label), zonename, 
nameserver)
             else:
                 # Name is relative to zone, must be in bailiwick
-                value = resolve_glue (self, nameserver)
+                value = self.resolve_glue(record.target)
+                if not value:
+                    if label.startswith("@"):
+                        value = 'address@hidden' % (self.domain, 
record.target, self.domain)
+                    else:
+                        value = 'address@hidden' % (str(label), self.domain, 
record.target, self.domain)
 
             logging.info("transformed %s record to GNS2DNS format", rdtype)
             rdtype = 'GNS2DNS'
@@ -559,26 +588,14 @@ class Ascender():
         """
         try:
             ret = sp.run([GNUNET_ZONE_CREATION_COMMAND,
-                          '-C', zonestring],
-                         stdout=sp.DEVNULL,
+                          '-C', zonestring,
+                          '-V'],
+                         stdout=sp.PIPE,
                          stderr=sp.DEVNULL)
             logging.info("executed command: %s", " ".join(ret.args))
+            pkey_zone = ret.stdout.decode().strip()
         except sp.CalledProcessError:
             logging.info("Zone %s already exists!", zonestring)
-
-        # This is the most inefficient part of the zone hierarchy building
-        pkey_lookup = sp.Popen([GNUNET_ZONE_CREATION_COMMAND,
-                                '-d'],
-                               stdout=sp.PIPE)
-        pkey_line = sp.Popen(['grep', '^' + zonestring],
-                             stdin=pkey_lookup.stdout,
-                             stdout=sp.PIPE)
-        pkey_zone = sp.check_output(['cut', '-d',
-                                     ' ', '-f3'],
-                                    stdin=pkey_line.stdout)
-        pkey_zone = pkey_zone.decode().strip()
-        pkey_lookup.stdout.close()
-        pkey_line.stdout.close()
         return pkey_zone
 
     @staticmethod
@@ -675,6 +692,7 @@ def main():
     # Set to defaults to use before we get a SOA for the first time
     retry = 300
     refresh = 300
+
     # Main loop for actual daemon
     while True:
         gns_zone_serial = ascender.get_gns_zone_serial()
@@ -698,9 +716,11 @@ def main():
             continue
         if not gns_zone_serial:
             logging.info("GNS zone does not exist yet, performing full 
transfer.")
+            print("GNS zone does not exist yet, performing full transfer.")
             ascender.bootstrap_zone()
         elif gns_zone_serial == dns_zone_serial:
             logging.info("GNS zone is up to date.")
+            print("GNS zone is up to date.")
             if standalone:
                 return 0
             time.sleep(refresh)
@@ -714,6 +734,7 @@ def main():
             continue
         else:
             logging.info("GNS zone is out of date, performing incremental 
transfer.")
+            print("GNS zone is out of date, performing incremental transfer.")
 
         try:
             ascender.zone = dns.zone.from_xfr(ascender.zonegenerator,
diff --git a/ascension/test/basic_named.conf b/ascension/test/basic_named.conf
index 932ca4d..eb66bba 100644
--- a/ascension/test/basic_named.conf
+++ b/ascension/test/basic_named.conf
@@ -1,4 +1,5 @@
 options {
+    port 5000;
     directory ".";
     pid-file "/run/named/named.pid";
 
diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config 
b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config
index 5d7d46b..f96bba0 100755
--- a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config
+++ b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/config
@@ -14,8 +14,8 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*" 1>&2 }
 #grep "Zone dump" /var/cache/bind/named_dump.db | grep -v "arpa" | grep "IN" | 
grep -v localhost > installedzones
 #read -r zones < installedzones
 
-zonelist=$(cat /etc/bind/named.conf.local | grep "^zone" | grep -vE 
"(arpa|localhost|\"\.\")" | cut -d '"' -f2)
-zonelist=$(echo $zonelist | sed "s/ /, /g")
+zonelist=$(grep "^zone" < /etc/bind/named.conf.local | grep -vE 
"(arpa|localhost|\"\.\")" | grep -v "allow-transfer" | cut -d '"' -f2)
+zonelist=$(echo $zonelist | sed 's/ /, /g')
 #altzonelist=$(named-checkconf -z | grep -P "\d{4,}$")
 #altzones=("$altzonelist")
 
@@ -29,11 +29,9 @@ zonelist=$(echo $zonelist | sed "s/ /, /g")
 #db_set ascension-bind/zones 'foo.bar, this.does.not.work'
 #db_subst ascension-bind/zones choices "mine, this.does.work"
 #db_set ascension-bind/zones "foo.bar, this.does.not.work"
-if cat /etc/bind/named.conf.local | grep allow-transfer &> /dev/null; then
-       db_fset ascension-bind/transfer-allowed seen false
-       db_input high ascension-bind/transfer-allowed
-       db_go || true
-       exit 1
+
+if [ -n "$(ls -A /etc/ascension.d/)" ]; then
+    echo "there seem to be config files already"
 fi
 
 db_set ascension-bind/zones "$zonelist"
@@ -42,9 +40,16 @@ db_fset ascension-bind/zones seen false
 db_input high ascension-bind/zones || true
 db_go || true
 # fix the zone selection
-db_get ascension-bind/zones 
-echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' > selectedzones
+db_get ascension-bind/zones
+
+echo "$RET" | sed 's/ //g' | sed 's/,/\n/g' | sed '/^ *$/d' > selectedzones
 readarray zones < selectedzones
+rm selectedzones
+
+if [ address@hidden -eq 0 ]; then
+    echo "No zones to enable zonetransfer on"
+    exit 0
+fi
 
 db_fset ascension-bind/publishing seen false
 db_input medium ascension-bind/publishing || true
@@ -54,20 +59,20 @@ PUBLIC=$RET
 mkdir -p /etc/ascension.d/
 for ZONE in "address@hidden"
 do
-       echo "creating ascension import config files"
-       cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF
+    ZONE=$(echo "$ZONE" | tr -d '\n' | tr '.' '_')
+    echo "creating ascension import config files"
+    cat > "/etc/ascension.d/bind-import-$ZONE.conf" << EOF
 [ascension]
 ZONE = $ZONE
 TRANSFERNS = localhost
 PORT = 53
 PUBLIC = $PUBLIC
 EOF
-       printf $ZONE
-       touch "/etc/ascension.d/bind-import-$ZONE.conf"
-       echo "editing config to allow local zone transfer"
-       sed -i.backup -r 's|(^[^\n\S]*zone\s\"[a-zA-Z.]*\".*\{)|\1 
allow\-transfer { localhost; }; |g' /etc/bind/named.conf.local
-       echo "creating systemd unit file"
-       cat > "/etc/ascension.d/ascension-bind-$ZONE.service" << EOF
+touch "/etc/ascension.d/bind-import-$ZONE.conf"
+echo "editing config to allow local zone transfer"
+sed -i.backup -r 's|(^[^\n\S]*zone\s\"[a-zA-Z.]*\".*\{)|\1 allow\-transfer { 
localhost; }; |g' /etc/bind/named.conf.local
+echo "creating systemd unit file"
+cat > "/etc/ascension.d/ascension-bind-$ZONE.service" << EOF
 [Unit]
 Description=Ascension-bind for $ZONE
 After=gnunet-ascension.service
@@ -80,21 +85,23 @@ ExecStart=/usr/bin/ascension $ZONE -n localhost
 [Install]
 WantedBy=multi-user.target
 EOF
-       ln -s "/etc/ascension.d/ascension-bind-$ZONE.service" 
"/lib/systemd/system/ascension-bind-$ZONE.service" 
+ln -sf "/etc/ascension.d/ascension-bind-$ZONE.service" 
"/lib/systemd/system/ascension-bind-$ZONE.service"
 done
 
-#if deb-systemd-invoke reload bind9; then
-#      echo "reconfiguring failed, restoring original state"
-#      mv /etc/bind/named.conf.local.backup /etc/bind/named.conf.local
-#      exit 1
-#fi
-#
-#for ZONE in "address@hidden"
-#do
-#      echo "starting and enabling ascension-bind-$ZONE"
-#      deb-systemd-invoke start "ascension-bind-$ZONE"
-#      deb-systemd-invoke enable "ascension-bind-$ZONE"
-#done
+if systemctl reload bind9; then
+    echo "reconfiguring failed, restoring original state"
+    mv /etc/bind/named.conf.local.backup /etc/bind/named.conf.local
+    systemctl reload bind9
+    exit 1
+fi
+
+for ZONE in "address@hidden"
+do
+    ZONE=$(echo "$ZONE" | tr -d '\n' | tr '.' '_')
+    echo "starting and enabling ascension-bind-$ZONE"
+    systemctl start "ascension-bind-$ZONE"
+    systemctl enable "ascension-bind-$ZONE"
+done
 
 exit 0
 
diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control 
b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control
index 018c7d3..ddd8c9e 100644
--- a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control
+++ b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/control
@@ -2,7 +2,7 @@ Package: ascension-bind
 Version: 0.0.1-1
 Architecture: amd64
 Maintainer: rexxnor <address@hidden>
-Installed-Size: 15
+Installed-Size: 16
 Depends: debconf (>= 0.5) | debconf-2.0
 Section: net
 Priority: optional
diff --git a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm 
b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm
index 2193e07..0450ba0 100755
--- a/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm
+++ b/debian/ascension-bind-0.0.1/debian/ascension-bind/DEBIAN/postrm
@@ -1,6 +1,6 @@
 #!/bin/sh
 set -e
-# Automatically added by dh_installdebconf
+# Automatically added by dh_installdebconf/12.1.1~bpo9+1
 if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
        . /usr/share/debconf/confmodule
        db_purge

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]