X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=daklib%2Futils.py;h=c4c55723ddee9f87fc64e3fab805ed4e56688c95;hb=ebc80c6941140d9d81a18069d45097478c8d1c60;hp=16cc1ff16ed54df640d0ccbfb1da8e5879e4eef2;hpb=1271680e053c92528ade608def345cb5a88d4cae;p=dak.git diff --git a/daklib/utils.py b/daklib/utils.py index 16cc1ff1..c4c55723 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -59,6 +59,8 @@ 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 + ################################################################################ class Error(Exception): @@ -468,6 +470,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 ('~') @@ -1148,6 +1158,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()