From 54955009eb8a54cd4607ea1e6a40d3ce8a534771 Mon Sep 17 00:00:00 2001 From: Jakub Warmuz Date: Fri, 1 May 2015 10:07:32 +0000 Subject: [PATCH] constants.CONFIG_DIRS_MODE, fix #362 config dir bug --- letsencrypt/client/constants.py | 3 +++ letsencrypt/client/plugins/apache/configurator.py | 9 ++++++--- letsencrypt/client/plugins/nginx/configurator.py | 9 ++++++--- letsencrypt/client/reverter.py | 8 ++++++-- letsencrypt/scripts/main.py | 6 ++++++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/letsencrypt/client/constants.py b/letsencrypt/client/constants.py index 20f735779..239db7373 100644 --- a/letsencrypt/client/constants.py +++ b/letsencrypt/client/constants.py @@ -50,6 +50,9 @@ DVSNI_CHALLENGE_PORT = 443 """Port to perform DVSNI challenge.""" +CONFIG_DIRS_MODE = 0o755 +"""Directory mode for ``.IConfig.config_dir`` et al.""" + TEMP_CHECKPOINT_DIR = "temp_checkpoint" """Temporary checkpoint directory (relative to IConfig.work_dir).""" diff --git a/letsencrypt/client/plugins/apache/configurator.py b/letsencrypt/client/plugins/apache/configurator.py index e826c011a..ff3842200 100644 --- a/letsencrypt/client/plugins/apache/configurator.py +++ b/letsencrypt/client/plugins/apache/configurator.py @@ -934,9 +934,12 @@ class ApacheConfigurator(augeas_configurator.AugeasConfigurator): """ uid = os.geteuid() - le_util.make_or_verify_dir(self.config.config_dir, 0o755, uid) - le_util.make_or_verify_dir(self.config.work_dir, 0o755, uid) - le_util.make_or_verify_dir(self.config.backup_dir, 0o755, uid) + le_util.make_or_verify_dir( + self.config.config_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + self.config.work_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + self.config.backup_dir, constants.CONFIG_DIRS_MODE, uid) def get_version(self): """Return version of Apache Server. diff --git a/letsencrypt/client/plugins/nginx/configurator.py b/letsencrypt/client/plugins/nginx/configurator.py index 95ebeab3a..5f49ca8ee 100644 --- a/letsencrypt/client/plugins/nginx/configurator.py +++ b/letsencrypt/client/plugins/nginx/configurator.py @@ -349,9 +349,12 @@ class NginxConfigurator(object): """ uid = os.geteuid() - le_util.make_or_verify_dir(self.config.work_dir, 0o755, uid) - le_util.make_or_verify_dir(self.config.backup_dir, 0o755, uid) - le_util.make_or_verify_dir(self.config.config_dir, 0o755, uid) + le_util.make_or_verify_dir( + self.config.work_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + self.config.backup_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + self.config.config_dir, constants.CONFIG_DIRS_MODE, uid) def get_version(self): """Return version of Nginx Server. diff --git a/letsencrypt/client/reverter.py b/letsencrypt/client/reverter.py index ebb85a954..9d739f37e 100644 --- a/letsencrypt/client/reverter.py +++ b/letsencrypt/client/reverter.py @@ -6,9 +6,11 @@ import time import zope.component +from letsencrypt.client import constants from letsencrypt.client import errors from letsencrypt.client import interfaces from letsencrypt.client import le_util + from letsencrypt.client.display import util as display_util @@ -164,7 +166,8 @@ class Reverter(object): unable to add checkpoint """ - le_util.make_or_verify_dir(cp_dir, 0o755, os.geteuid()) + le_util.make_or_verify_dir( + cp_dir, constants.CONFIG_DIRS_MODE, os.geteuid()) op_fd, existing_filepaths = self._read_and_append( os.path.join(cp_dir, "FILEPATHS")) @@ -305,7 +308,8 @@ class Reverter(object): else: cp_dir = self.config.in_progress_dir - le_util.make_or_verify_dir(cp_dir, 0o755, os.geteuid()) + le_util.make_or_verify_dir( + cp_dir, constants.CONFIG_DIRS_MODE, os.geteuid()) # Append all new files (that aren't already registered) new_fd = None diff --git a/letsencrypt/scripts/main.py b/letsencrypt/scripts/main.py index 315c93e5f..ae15f22dd 100644 --- a/letsencrypt/scripts/main.py +++ b/letsencrypt/scripts/main.py @@ -18,10 +18,13 @@ import letsencrypt from letsencrypt.client import account from letsencrypt.client import configuration +from letsencrypt.client import constants from letsencrypt.client import client from letsencrypt.client import errors from letsencrypt.client import interfaces +from letsencrypt.client import le_util from letsencrypt.client import log + from letsencrypt.client.display import util as display_util from letsencrypt.client.display import ops as display_ops @@ -177,6 +180,9 @@ def main(): # pylint: disable=too-many-branches, too-many-statements client.rollback(args.rollback, config) sys.exit() + le_util.make_or_verify_dir( + config.config_dir, constants.CONFIG_DIRS_MODE, os.geteuid()) + # Prepare for init of Client if args.email is None: acc = client.determine_account(config)