mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 03:11:55 +02:00
Add a way to only save registration resources
This commit is contained in:
+18
-5
@@ -186,16 +186,29 @@ class AccountFileStorage(interfaces.AccountStorage):
|
||||
return acc
|
||||
|
||||
def save(self, account):
|
||||
self._save(account, regr_only=False)
|
||||
|
||||
def save_regr(self, account):
|
||||
"""Save the registration resource.
|
||||
|
||||
:param Account account: account whose regr should be saved
|
||||
|
||||
"""
|
||||
self._save(account, regr_only=True)
|
||||
|
||||
def _save(self, account, regr_only):
|
||||
account_dir_path = self._account_dir_path(account.id)
|
||||
le_util.make_or_verify_dir(account_dir_path, 0o700, os.geteuid(),
|
||||
self.config.strict_permissions)
|
||||
try:
|
||||
with open(self._regr_path(account_dir_path), "w") as regr_file:
|
||||
regr_file.write(account.regr.json_dumps())
|
||||
with le_util.safe_open(self._key_path(account_dir_path),
|
||||
"w", chmod=0o400) as key_file:
|
||||
key_file.write(account.key.json_dumps())
|
||||
with open(self._metadata_path(account_dir_path), "w") as metadata_file:
|
||||
metadata_file.write(account.meta.json_dumps())
|
||||
if not regr_only:
|
||||
with le_util.safe_open(self._key_path(account_dir_path),
|
||||
"w", chmod=0o400) as key_file:
|
||||
key_file.write(account.key.json_dumps())
|
||||
with open(self._metadata_path(
|
||||
account_dir_path), "w") as metadata_file:
|
||||
metadata_file.write(account.meta.json_dumps())
|
||||
except IOError as error:
|
||||
raise errors.AccountStorageError(error)
|
||||
|
||||
Reference in New Issue
Block a user