Fix transport_maps function for non-existent domains
The postfix_transport_maps function had a bug causing
2012-04-15 17:40:22 CEST LOG: statement: SELECT transport FROM postfix_transport_map('logcheck', 'domine.madduck.net');
2012-04-15 17:40:22 CEST ERROR: query returned no rows
when the domain was not in the database. This would make did be NULL and make
the query fail.
This patch moves the tid query until after a check for did. If the latter is
NULL, the function RETURNs (rather than fails).
# -*- coding: UTF-8 -*-# Copyright (c) 2010 - 2011, Pascal Volk# See COPYING for distribution information.""" VirtualMailManager.pycompat.hashlib VirtualMailManager's minimal hashlib emulation for Python 2.4 hashlib.md5(...), hashlib.sha1(...), hashlib.new('md5', ...) and hashlib.new('sha1', ...) will work always. When the PyCrypto module <http://www.pycrypto.org/> could be found in sys.path hashlib.new('md4', ...) will also work. With PyCrypto >= 2.1.0alpha1 hashlib.new('sha256', ...) and hashlib.sha256(...) becomes functional."""importmd5as_md5importshaas_sha1try:importCryptoexceptImportError:_md4=NoneSHA256=Noneelse:fromCrypto.HashimportMD4as_md4ifhasattr(Crypto,'version_info'):# <- Available since v2.1.0alpha1fromCrypto.HashimportSHA256# SHA256 works since v2.1.0alpha1sha256=SHA256.newelse:SHA256=NonedelCryptocompat=0x01md5=_md5.newsha1=_sha1.newdefnew(name,string=''):"""Return a new hashing object using the named algorithm, optionally initialized with the provided string. """ifnamein('md5','MD5'):return_md5.new(string)ifnamein('sha1','SHA1'):return_sha1.new(string)ifnot_md4:raiseValueError('unsupported hash type')ifnamein('md4','MD4'):return_md4.new(string)ifnamein('sha256','SHA256')andSHA256:returnSHA256.new(string)raiseValueError('unsupported hash type')