mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 16:30:31 +02:00
Lock the Postfix config dir
This commit is contained in:
@@ -60,6 +60,7 @@ class Installer(plugins_common.Plugin):
|
||||
self._verify_postconf_available()
|
||||
self._set_config_dir()
|
||||
self._check_version()
|
||||
self._lock_config_dir()
|
||||
|
||||
self.fn = self.find_postfix_cf()
|
||||
with open(self.fn) as f:
|
||||
@@ -146,6 +147,19 @@ class Installer(plugins_common.Plugin):
|
||||
# - Built-in support for TLS management and DANE added, see:
|
||||
# http://www.postfix.org/postfix-tls.1.html
|
||||
|
||||
def _lock_config_dir(self):
|
||||
"""Stop two Postfix plugins from modifying the config at once.
|
||||
|
||||
:raises .PluginError: if unable to acquire the lock
|
||||
|
||||
"""
|
||||
try:
|
||||
certbot_util.lock_dir_until_exit(self.config_dir)
|
||||
except (OSError, errors.LockError):
|
||||
logger.debug("Encountered error:", exc_info=True)
|
||||
raise errors.PluginError(
|
||||
"Unable to lock %s", self.config_dir)
|
||||
|
||||
def find_postfix_cf(self):
|
||||
"Search far and wide for the correct postfix configuration file"
|
||||
return os.path.join(self.config_dir, "main.cf")
|
||||
|
||||
Reference in New Issue
Block a user