from .mailaddress import MailAddress
-__version__ = '0.4.3'
+__version__ = '0.4.4'
LOG = logging.getLogger(__name__)
cfg_stems='barracuda-sync'
)
+ self._check_virtaliases_files()
self._init_ignore_aliases_res()
self.initialized = True
if hasattr(self.args, 'postfix_dir') and self.args.postfix_dir:
self._init_postfix_dir(self.args.postfix_dir)
+ if not os.path.isdir(self.postfix_config_dir):
+ LOG.error("Postfix directory {!r} does not exists or is not a directory.".format(
+ self.postfix_config_dir))
+ self.exit(1)
+
+ if not os.path.isdir(self.postfix_maps_dir):
+ LOG.error("Postfix maps directory {!r} does not exists or is not a directory.".format(
+ self.postfix_maps_dir))
+ self.exit(1)
+
self._init_virtaliases_files(virtaliases_files)
# -------------------------------------------------------------------------
if afile not in self.virtaliases_files:
self.virtaliases_files.append(afile)
+ # -------------------------------------------------------------------------
+ def _check_virtaliases_files(self):
+
+ ok = True
+ for afile in self.virtaliases_files:
+
+ if not os.path.exists(afile):
+ LOG.error("Virtual aliases file {!r} does not exists.".format(afile))
+ ok = False
+ continue
+
+ if not os.path.isfile(afile):
+ LOG.error("Virtual aliases file {!r} is not a regular file.".format(afile))
+ ok = False
+ continue
+
+ if not os.access(afile, os.R_OK):
+ LOG.error("No read access to virtual aliases file {!r}.".format(afile))
+ ok = False
+ continue
+
+ if not ok:
+ self.exit(1)
+
# -------------------------------------------------------------------------
def _init_postfix_dir(self, value):
self.default_virtaliases_files = [
os.path.join(self.postfix_maps_dir, 'virtual-aliases'),
]
+ else:
+ LOG.warn("Postfix directory {!r} does not exists or is not a directory.".format(
+ value))
# -------------------------------------------------------------------------
def _init_ignore_aliases_res(self):
super(PpBarracudaSyncApp, self).pre_run()
+ self._check_ldap_barracuda_container()
+
+ # -------------------------------------------------------------------------
+ def _check_ldap_barracuda_container(self):
+
+ LOG.debug("Checking existence of Baracuda LDAP container {!r}.".format(
+ self.barracuda_base_dn))
+ query = '(objectclass=organizationalunit)'
+
+ self.ldap_connection.search(
+ search_base=self.barracuda_base_dn, search_filter=query,
+ search_scope=BASE, attributes='*')
+
+ LOG.debug("Found {} entries.".format(len(self.ldap_connection.response)))
+ if len(self.ldap_connection.response) < 1:
+ LOG.error((
+ "Did not found LDAP container {!r} for "
+ "Barracuda alias definitions.").format(
+ self.barracuda_base_dn))
+ self.exit(5)
+
+ entry = self.ldap_connection.response[0]
+ if self.verbose > 1:
+ LOG.debug("Container entry - class {cl!r}, content:\n{co}".format(
+ cl=entry.__class__.__name__, co=pp(entry)))
+
# -------------------------------------------------------------------------
def _run(self):