From b490fbe6a5b3d86c7f28a463a8576e7c80ee0cdd Mon Sep 17 00:00:00 2001 From: Frank Brehm Date: Tue, 23 May 2023 17:52:43 +0200 Subject: [PATCH] Checking virtual alias files. --- lib/pp_admintools/app/barracuda_sync.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/pp_admintools/app/barracuda_sync.py b/lib/pp_admintools/app/barracuda_sync.py index 7d02519..6cb6642 100644 --- a/lib/pp_admintools/app/barracuda_sync.py +++ b/lib/pp_admintools/app/barracuda_sync.py @@ -26,7 +26,7 @@ from fb_tools.xlate import format_list from .ldap import BaseLdapApplication from ..xlate import XLATOR -__version__ = '0.6.4' +__version__ = '0.6.5' LOG = logging.getLogger(__name__) _ = XLATOR.gettext @@ -292,6 +292,29 @@ class BarracudaSyncApp(BaseLdapApplication): """Check existence of given .""" LOG.debug(_('Checking all available virtual aliases table files ...')) + db_extension = self.postfix_filetype_extensions[self.postfix_db_hashtype] + if self.verbose > 1: + LOG.debug(_("Using file extension for db-files: {!r}.").format(db_extension)) + + for va_file in self.virtaliases_files: + db_file = va_file.parent / (va_file.name + db_extension) + if not db_file.exists() or not db_file.is_file(): + LOG.error(_( + "DB file for virtual aliases {!r} does not exists or is not a regular " + "file.").format(str(db_file))) + self.virtaliases_files.remove(va_file) + continue + mtime_db_file = db_file.stat().st_mtime + mtime_va_file = va_file.stat().st_mtime + if mtime_db_file < mtime_va_file: + LOG.warn(_( + "The last modification time of {db!r} is older than this " + "of {va!r}.").format(db=str(db_file), va=str(va_file))) + elif self.verbose > 1: + LOG.debug(_( + "The last modification time of {db!r} and {va!r} are " + "okay.").format(db=str(db_file), va=str(va_file))) + # ------------------------------------------------------------------------- def _run(self): -- 2.39.5