]> git.decadent.org.uk Git - dak.git/commitdiff
Merge
authorJoerg Jaspert <joerg@debian.org>
Thu, 24 Apr 2008 21:34:53 +0000 (23:34 +0200)
committerJoerg Jaspert <joerg@debian.org>
Thu, 24 Apr 2008 21:34:53 +0000 (23:34 +0200)
ChangeLog
dak/process_unchecked.py
daklib/queue.py
daklib/utils.py

index 4f72b591b03c7149670fdaf491d3b3fc78a90a48..ce36677eccae40482678770469460fb1d5faa620 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2008-04-23  Thomas Viehmann  <tviehmann@debian.org>
+
+       * dak/process_unchecked.py: add changes["sponsoremail"]
+         for sponsored uploads if desired
+       * daklib/queue.py: add changes["sponsoremail"] to
+         Subst["__MAINTAINER_TO__"] if present
+       * daklib/utils.py: add functions
+         is_email_alias to check which accounts allow email forwarding,
+         which_alias_file to find the alias file, and
+         gpg_get_key_addresses to find uid addresses for a given
+           fingerprint
+
 2008-04-22  Joerg Jaspert  <joerg@debian.org>
 
        * setup/init_pool.sql: added a function/aggregate for the release
@@ -12,7 +24,7 @@
        dumps, using a scheme to keep more of the recent dumps.
 
        * config/debian/cron.daily: Use the new script. Also - compress
-       all files older than 7 days, instead of 30. 
+       all files older than 7 days, instead of 30.
 
        * dak/process_accepted.py (install): Do not break if a
        source/maintainer combination is already in src_uploaders, "just"
index 30737ed1252fb7d7996d1612541798ad76d87db4..82133068be56c33fb4d4b96b6908467eaafb14b5 100755 (executable)
@@ -1072,6 +1072,11 @@ def check_signed_by_key():
         if uid_name == "": sponsored = 1
     else:
         sponsored = 1
+        if daklib.utils.is_email_alias(uid_email):
+            sponsor_addresses = daklib.utils.gpg_get_key_addresses(changes["fingerprint"])
+            if (changes["maintaineremail"] not in sponsor_addresses and
+                changes["changedbyemail"] not in sponsor_addresses):
+                changes["sponsoremail"] = uid_email
 
     if sponsored and not may_sponsor: 
         reject("%s is not authorised to sponsor uploads" % (uid))
index 9fac0cc00b2053e3deb63b7778adff9da48242b3..a5a8eab4a2518e703d3a8c4f9884b588c60b9201 100755 (executable)
@@ -279,6 +279,8 @@ class Upload:
             Subst["__MAINTAINER_FROM__"] = changes["changedby2047"]
             Subst["__MAINTAINER_TO__"] = "%s, %s" % (changes["changedby2047"],
                                                      changes["maintainer2047"])
+            if "sponsoremail" in changes:
+                Subst["__MAINTAINER_TO__"] += ", %s"%changes["sponsoremail"]
             Subst["__MAINTAINER__"] = changes.get("changed-by", "Unknown")
         else:
             Subst["__MAINTAINER_FROM__"] = changes["maintainer2047"]
index 16cc1ff16ed54df640d0ccbfb1da8e5879e4eef2..0d22bd1d236ec11b6ccf88c9632f5dd72d95bd68 100755 (executable)
@@ -41,6 +41,7 @@ re_multi_line_field = re.compile(r"^\s(.*)")
 re_taint_free = re.compile(r"^[-+~/\.\w]+$")
 
 re_parse_maintainer = re.compile(r"^\s*(\S.*\S)\s*\<([^\>]+)\>")
+re_gpg_uid = re.compile('^uid.*<([^>]*)>')
 
 re_srchasver = re.compile(r"^(\S+)\s+\((\S+)\)$")
 re_verwithext = re.compile(r"^(\d+)(?:\.(\d+))(?:\s+\((\S+)\))?$")
@@ -59,6 +60,9 @@ tried_too_hard_exc = "Tried too hard to find a free filename."
 default_config = "/etc/dak/dak.conf"
 default_apt_config = "/etc/dak/apt.conf"
 
+alias_cache = None
+key_uid_email_cache = {}
+
 ################################################################################
 
 class Error(Exception):
@@ -468,6 +472,14 @@ def which_apt_conf_file ():
     else:
        return default_apt_config
 
+def which_alias_file():
+    hostname = socket.gethostbyaddr(socket.gethostname())[0]
+    aliasfn = '/var/lib/misc/'+hostname+'/forward-alias'
+    if os.path.exists(aliasfn):
+        return aliasfn
+    else:
+        return None
+
 ################################################################################
 
 # Escape characters which have meaning to SQL's regex comparison operator ('~')
@@ -1081,6 +1093,25 @@ used."""
 
 ################################################################################
 
+def gpg_get_key_addresses(fingerprint):
+  """retreive email addresses from gpg key uids for a given fingerprint"""
+  addresses = key_uid_email_cache.get(fingerprint)
+  if addresses != None:
+      return addresses
+  addresses = set()
+  cmd = "gpg --no-default-keyring %s --fingerprint %s" \
+              % (gpg_keyring_args(), fingerprint)
+  (result, output) = commands.getstatusoutput(cmd)
+  if result == 0:
+    for l in output.split('\n'):
+      m = re_gpg_uid.match(l)
+      if m:
+        addresses.add(m.group(1))
+  key_uid_email_cache[fingerprint] = addresses
+  return addresses
+
+################################################################################
+
 # Inspired(tm) by http://www.zopelabs.com/cookbook/1022242603
 
 def wrap(paragraph, max_length, prefix=""):
@@ -1148,6 +1179,21 @@ If 'dotprefix' is non-null, the filename will be prefixed with a '.'."""
 
 ################################################################################
 
+# checks if the user part of the email is listed in the alias file
+
+def is_email_alias(email):
+    global alias_cache
+    if alias_cache == None:
+        aliasfn = which_alias_file()
+        alias_cache = set()
+        if aliasfn:
+            for l in open(aliasfn):
+                alias_cache.add(l.split(':')[0])
+    uid = email.split('@')[0]
+    return uid in alias_cache
+
+################################################################################
+
 apt_pkg.init()
 
 Cnf = apt_pkg.newConfiguration()