From 8a3eb4f2ba3587c5924c337a3d1e8fbde50efdea Mon Sep 17 00:00:00 2001 From: James Kasten Date: Mon, 19 Jan 2015 16:01:44 -0800 Subject: [PATCH 1/6] Update interface.py documentation... Correctly list namedtuple challenge types in challenge_util.py --- letsencrypt/client/interfaces.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/letsencrypt/client/interfaces.py b/letsencrypt/client/interfaces.py index b052d6ac7..9e35a754a 100644 --- a/letsencrypt/client/interfaces.py +++ b/letsencrypt/client/interfaces.py @@ -17,13 +17,16 @@ class IAuthenticator(zope.interface.Interface): :param str domain: Domain for which challenge preferences are sought. :returns: list of strings with the most preferred challenges first. + If a type is not specified, it means the Authenticator cannot + perform the challenge. :rtype: list """ def perform(chall_list): """Perform the given challenge. - :param list chall_list: List of challenge types defined in client.py + :param list chall_list: List of namedtuple types defined in + challenge_util.py. DvsniChall...ect.. :returns: List of responses If the challenge cant be completed... From 269d49b7595d5572a9beafef8ae8065f0bb1428d Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 13:51:52 -0800 Subject: [PATCH 2/6] Remove load of unused modules from Augeas --- letsencrypt/client/apache/parser.py | 26 +++++------------------ letsencrypt/client/augeas_configurator.py | 6 ++++-- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index 792257b5a..e9dd7d8a3 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -240,11 +240,11 @@ class ApacheParser(object): regex = regex + letter return regex - def _parse_file(self, file_path): + def _parse_file(self, filepath): """Parse file with Augeas Checks to see if file_path is parsed by Augeas - If file_path isn't parsed, the file is added and Augeas is reloaded + If filepath isn't parsed, the file is added and Augeas is reloaded :param str file_path: Apache config file path @@ -252,13 +252,10 @@ class ApacheParser(object): # Test if augeas included file for Httpd.lens # Note: This works for augeas globs, ie. *.conf inc_test = self.aug.match( - "/augeas/load/Httpd/incl [. ='%s']" % file_path) + "/augeas/load/Httpd/incl [. ='%s']" % filepath) if not inc_test: # Load up files - # self.httpd_incl.append(file_path) - # self.aug.add_transform("Httpd.lns", - # self.httpd_incl, None, self.httpd_excl) - self._add_httpd_transform(file_path) + self.aug.add_transform("Httpd.lns", filepath) self.aug.load() def standardize_excl(self): @@ -292,20 +289,7 @@ class ApacheParser(object): self.aug.set("/augeas/load/Httpd/excl[%d]" % (i+1), excl[i]) self.aug.load() - - def _add_httpd_transform(self, incl): - """Add a transform to Augeas. - - This function will correctly add a transform to augeas - The existing augeas.add_transform in python is broken. - - :param str incl: TODO - - """ - last_include = self.aug.match("/augeas/load/Httpd/incl [last()]") - self.aug.insert(last_include[0], "incl", False) - self.aug.set("/augeas/load/Httpd/incl[last()]", incl) - + def _set_locations(self, ssl_options): """Set default location for directives. diff --git a/letsencrypt/client/augeas_configurator.py b/letsencrypt/client/augeas_configurator.py index 1c366c60e..881404db1 100644 --- a/letsencrypt/client/augeas_configurator.py +++ b/letsencrypt/client/augeas_configurator.py @@ -38,8 +38,10 @@ class AugeasConfigurator(object): self.direc = direc # TODO: this instantiation can be optimized to only load # relevant files - I believe -> NO_MODL_AUTOLOAD - # Set Augeas flags to save backup - self.aug = augeas.Augeas(flags=augeas.Augeas.NONE) + # Set Augeas flags to not save backup (we do it ourselves) + # Set Augeas to not load anything by default + my_flags = augeas.Augeas.NONE | augeas.Augeas.NO_MODL_AUTOLOAD + self.aug = augeas.Augeas(flags=my_flags) self.save_notes = "" def check_parsing_errors(self, lens): From a29984f0493354db24449891c484a625c6acea7f Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 14:03:05 -0800 Subject: [PATCH 3/6] Remove TODO item/fix formatting. --- letsencrypt/client/apache/parser.py | 2 +- letsencrypt/client/augeas_configurator.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index e9dd7d8a3..b6e6a8bc6 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -289,7 +289,7 @@ class ApacheParser(object): self.aug.set("/augeas/load/Httpd/excl[%d]" % (i+1), excl[i]) self.aug.load() - + def _set_locations(self, ssl_options): """Set default location for directives. diff --git a/letsencrypt/client/augeas_configurator.py b/letsencrypt/client/augeas_configurator.py index 881404db1..74c548def 100644 --- a/letsencrypt/client/augeas_configurator.py +++ b/letsencrypt/client/augeas_configurator.py @@ -36,8 +36,7 @@ class AugeasConfigurator(object): "progress": CONFIG.IN_PROGRESS_DIR} self.direc = direc - # TODO: this instantiation can be optimized to only load - # relevant files - I believe -> NO_MODL_AUTOLOAD + # Set Augeas flags to not save backup (we do it ourselves) # Set Augeas to not load anything by default my_flags = augeas.Augeas.NONE | augeas.Augeas.NO_MODL_AUTOLOAD From 55e13a906d2e0ae5cd690a161734bdfaca1f7ee2 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 19:29:00 -0800 Subject: [PATCH 4/6] Change incl to list to conform with augeas.add_transform func --- letsencrypt/client/apache/parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index b6e6a8bc6..efff7eba8 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -255,7 +255,7 @@ class ApacheParser(object): "/augeas/load/Httpd/incl [. ='%s']" % filepath) if not inc_test: # Load up files - self.aug.add_transform("Httpd.lns", filepath) + self.aug.add_transform("Httpd.lns", [filepath]) self.aug.load() def standardize_excl(self): From 6927c1b910a4ff76eab5fa1719341e621c271121 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 21:13:56 -0800 Subject: [PATCH 5/6] Add manual httpd_transform --- letsencrypt/client/apache/parser.py | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index efff7eba8..9f8dc06d9 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -255,9 +255,32 @@ class ApacheParser(object): "/augeas/load/Httpd/incl [. ='%s']" % filepath) if not inc_test: # Load up files - self.aug.add_transform("Httpd.lns", [filepath]) + # This doesn't seem to work on TravisCI + # self.aug.add_transform("Httpd.lns", [filepath]) + self._add_httpd_transform(filepath) self.aug.load() + def _add_httpd_transform(self, incl): + """Add a transform to Augeas. + + This function will correctly add a transform to augeas + The existing augeas.add_transform in python doesn't seem to work for + Travis CI as it loads in libaugeas.so.0.10.0 + + :param str incl: filepath to include for transform + + """ + last_include = self.aug.match("/augeas/load/Httpd/incl [last()]") + if last_include: + # Insert a new node immediately after the last incl + self.aug.insert(last_include[0], "incl", False) + self.aug.set("/augeas/load/Httpd/incl[last()]", incl) + # On first use... must load lens and add file to incl + else: + # Augeas uses base 1 indexing... insert at beginning... + self.aug.set("/augeas/load/Httpd/lens", "Httpd.lns") + self.aug.set("/augeas/load/Httpd/incl", incl) + def standardize_excl(self): """Standardize the excl arguments for the Httpd lens in Augeas. From 9729450d2caeef9a05246a7b69dae86522e27535 Mon Sep 17 00:00:00 2001 From: James Kasten Date: Tue, 20 Jan 2015 21:59:10 -0800 Subject: [PATCH 6/6] Change names to meet the API --- letsencrypt/client/apache/parser.py | 2 +- letsencrypt/client/augeas_configurator.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/letsencrypt/client/apache/parser.py b/letsencrypt/client/apache/parser.py index 9f8dc06d9..efc692d97 100644 --- a/letsencrypt/client/apache/parser.py +++ b/letsencrypt/client/apache/parser.py @@ -246,7 +246,7 @@ class ApacheParser(object): Checks to see if file_path is parsed by Augeas If filepath isn't parsed, the file is added and Augeas is reloaded - :param str file_path: Apache config file path + :param str filepath: Apache config file path """ # Test if augeas included file for Httpd.lens diff --git a/letsencrypt/client/augeas_configurator.py b/letsencrypt/client/augeas_configurator.py index 74c548def..793b141d6 100644 --- a/letsencrypt/client/augeas_configurator.py +++ b/letsencrypt/client/augeas_configurator.py @@ -188,7 +188,7 @@ class AugeasConfigurator(object): self.aug.load() - def show_config_changes(self): + def view_config_changes(self): """Displays all saved checkpoints. All checkpoints are printed to the console.