Browse code

Keep only directories when looking up certificates.

It appears /etc/letsencrypt/live is liable to contain a README file.
Although it can be filtered out using the certificate filter feature, it is
simpler to focus on directories and thus ignore files.

Xavier G authored on 11/04/2020 18:36:22
Showing 1 changed files

... ...
@@ -161,6 +161,13 @@ class CombinedFS(Operations):
161 161
 		return dict((key, getattr(st, key)) for key in ('st_atime', 'st_ctime',
162 162
 		      'st_gid', 'st_mode', 'st_mtime', 'st_nlink', 'st_size', 'st_uid'))
163 163
 
164
+	def certificates(self, conf):
165
+		for dentry in os.listdir(conf.root):
166
+			if conf.filter_cert(dentry):
167
+				fullpath = os.path.join(conf.root, dentry)
168
+				if os.path.isdir(fullpath):
169
+					yield dentry
170
+
164 171
 	def get_conf(self):
165 172
 		return self.configuration
166 173
 
... ...
@@ -311,7 +318,7 @@ class CombinedFS(Operations):
311 318
 		if not cert:
312 319
 			# Top-level directory
313 320
 			flat_mode = conf.separator != '/'
314
-			for cert in (d for d in os.listdir(conf.root) if conf.filter_cert(d)):
321
+			for cert in self.certificates(conf):
315 322
 				if flat_mode:
316 323
 					for filename in conf.files:
317 324
 						yield cert + conf.separator + filename, reg_attrs, 0