From f96c34546e91be25429a8a1c2f99710a9539f402 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sat, 10 Oct 2015 18:33:44 -0400 Subject: [PATCH 1/7] Fixes #902 Fix for #902 If the directory does't exist, it will create the directory before proceeding. --- letsencrypt/renewer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index 1c9cddc95..953b372f5 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -146,6 +146,10 @@ def main(config=None, args=sys.argv[1:]): # take precedence over this one. config.merge(configobj.ConfigObj(cli_config.renewer_config_file)) + # If the folder does not exist we need to create it. + if not os.path.isdir(cli_config.renewal_configs_dir): + os.makedirs(cli_config.renewal_configs_dir) + for i in os.listdir(cli_config.renewal_configs_dir): print "Processing", i if not i.endswith(".conf"): From f8daf5f09411ed9d317d310b8efc97d3f39b495e Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 11 Oct 2015 08:53:38 -0400 Subject: [PATCH 2/7] Fixed failing lint test and explicitly created all needed folders --- letsencrypt/renewer.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index 953b372f5..077af6a68 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -23,6 +23,8 @@ from letsencrypt import crypto_util from letsencrypt import errors from letsencrypt import notify from letsencrypt import storage +from letsencrypt import constants +from letsencrypt import le_util from letsencrypt.display import util as display_util from letsencrypt.plugins import disco as plugins_disco @@ -145,10 +147,16 @@ def main(config=None, args=sys.argv[1:]): # specify a config file on the command line, which, if provided, should # take precedence over this one. config.merge(configobj.ConfigObj(cli_config.renewer_config_file)) - - # If the folder does not exist we need to create it. - if not os.path.isdir(cli_config.renewal_configs_dir): - os.makedirs(cli_config.renewal_configs_dir) + # Ensure that all of the needed folders have been created before continuing + uid = os.geteuid() + le_util.make_or_verify_dir( + cli_config.renewal_configs_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.config_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) for i in os.listdir(cli_config.renewal_configs_dir): print "Processing", i @@ -189,4 +197,4 @@ def main(config=None, args=sys.argv[1:]): cert.update_all_links_to(cert.latest_common_version()) # TODO: restart web server (invoke IInstaller.restart() method) notify.notify("Autodeployed a cert!!!", "root", "It worked!") - # TODO: explain what happened + # TODO: explain what happened \ No newline at end of file From ef9312817e230f9d579c673685acae8547d7e5f4 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 11 Oct 2015 11:39:55 -0400 Subject: [PATCH 3/7] Alphabetized imports and added newline at end of file --- letsencrypt/renewer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index 077af6a68..81a557419 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -17,14 +17,14 @@ import zope.component from letsencrypt import account from letsencrypt import configuration +from letsencrypt import constants from letsencrypt import cli from letsencrypt import client from letsencrypt import crypto_util from letsencrypt import errors +from letsencrypt import le_util from letsencrypt import notify from letsencrypt import storage -from letsencrypt import constants -from letsencrypt import le_util from letsencrypt.display import util as display_util from letsencrypt.plugins import disco as plugins_disco @@ -197,4 +197,4 @@ def main(config=None, args=sys.argv[1:]): cert.update_all_links_to(cert.latest_common_version()) # TODO: restart web server (invoke IInstaller.restart() method) notify.notify("Autodeployed a cert!!!", "root", "It worked!") - # TODO: explain what happened \ No newline at end of file + # TODO: explain what happened From a809a059f0512159279b5dcbc100374393327e4b Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 11 Oct 2015 15:57:57 -0400 Subject: [PATCH 4/7] Don't create renewal_configs_dir and config_dir, instead just print a helpful error message and fail --- letsencrypt/renewer.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index ebd9a42d1..76922e6fd 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -169,14 +169,14 @@ def main(config=None, cli_args=sys.argv[1:]): config.merge(configobj.ConfigObj(cli_config.renewer_config_file)) # Ensure that all of the needed folders have been created before continuing uid = os.geteuid() - le_util.make_or_verify_dir( - cli_config.renewal_configs_dir, constants.CONFIG_DIRS_MODE, uid) - le_util.make_or_verify_dir( - cli_config.config_dir, constants.CONFIG_DIRS_MODE, uid) - le_util.make_or_verify_dir( - cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) - le_util.make_or_verify_dir( - cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) + if (not os.path.isdir(cli_config.renewal_configs_dir) or + not os.path.isdir(cli_config.config_dir)): + print "Could not find config directory. Exiting. " + else: + le_util.make_or_verify_dir( + cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) for i in os.listdir(cli_config.renewal_configs_dir): print "Processing", i From 8ec7fdd323b6e814ae54629e507ca23f0e736beb Mon Sep 17 00:00:00 2001 From: David Dworken Date: Sun, 11 Oct 2015 16:20:18 -0400 Subject: [PATCH 5/7] Always create the folders --- letsencrypt/renewer.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index 76922e6fd..bec868483 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -172,11 +172,10 @@ def main(config=None, cli_args=sys.argv[1:]): if (not os.path.isdir(cli_config.renewal_configs_dir) or not os.path.isdir(cli_config.config_dir)): print "Could not find config directory. Exiting. " - else: - le_util.make_or_verify_dir( - cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) - le_util.make_or_verify_dir( - cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) + le_util.make_or_verify_dir( + cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) for i in os.listdir(cli_config.renewal_configs_dir): print "Processing", i From 589145686fd4b3f92b90357f39f05fcfa1900b5b Mon Sep 17 00:00:00 2001 From: David Dworken Date: Mon, 12 Oct 2015 15:02:07 -0400 Subject: [PATCH 6/7] Don't print error message and only call os.geteuid() once --- letsencrypt/renewer.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index bec868483..ea1eb5ef7 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -153,7 +153,8 @@ def main(config=None, cli_args=sys.argv[1:]): args = _create_parser().parse_args(cli_args) - le_util.make_or_verify_dir(args.logs_dir, 0o700, os.geteuid()) + uid = os.geteuid() + le_util.make_or_verify_dir(args.logs_dir, 0o700, uid) cli.setup_logging(args, _cli_log_handler, logfile='renewer.log') cli_config = configuration.RenewerConfiguration(args) @@ -168,10 +169,6 @@ def main(config=None, cli_args=sys.argv[1:]): # take precedence over this one. config.merge(configobj.ConfigObj(cli_config.renewer_config_file)) # Ensure that all of the needed folders have been created before continuing - uid = os.geteuid() - if (not os.path.isdir(cli_config.renewal_configs_dir) or - not os.path.isdir(cli_config.config_dir)): - print "Could not find config directory. Exiting. " le_util.make_or_verify_dir( cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) le_util.make_or_verify_dir( From 20d7576f662999c2e53a6bd48d353fcd41a8b126 Mon Sep 17 00:00:00 2001 From: David Dworken Date: Mon, 12 Oct 2015 15:14:13 -0400 Subject: [PATCH 7/7] Deleted duplicate line caused by #912 --- letsencrypt/renewer.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/letsencrypt/renewer.py b/letsencrypt/renewer.py index ea1eb5ef7..b62e31bce 100644 --- a/letsencrypt/renewer.py +++ b/letsencrypt/renewer.py @@ -171,8 +171,6 @@ def main(config=None, cli_args=sys.argv[1:]): # Ensure that all of the needed folders have been created before continuing le_util.make_or_verify_dir( cli_config.work_dir, constants.CONFIG_DIRS_MODE, uid) - le_util.make_or_verify_dir( - cli_config.logs_dir, constants.CONFIG_DIRS_MODE, uid) for i in os.listdir(cli_config.renewal_configs_dir): print "Processing", i