mirror of
https://github.com/certbot/certbot.git
synced 2026-07-27 16:30:31 +02:00
NamespaceConfig
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
"""Let's Encrypt user-supplied configuration."""
|
||||
import zope.interface
|
||||
|
||||
from letsencrypt.client import interfaces
|
||||
|
||||
|
||||
class NamespaceConfig(object):
|
||||
"""Configuration wrapper around `argparse.Namespace`."""
|
||||
zope.interface.implements(interfaces.IConfig)
|
||||
|
||||
def __init__(self, namespace):
|
||||
self.namespace = namespace
|
||||
|
||||
def __getattr__(self, name):
|
||||
return getattr(self.namespace, name)
|
||||
|
||||
@property
|
||||
def temp_checkpoint_dir(self):
|
||||
return os.path.join(
|
||||
self.namespace.work_dir, constants.TEMP_CHECKPOINT_DIR_NAME)
|
||||
|
||||
@property
|
||||
def in_progress_dir(self):
|
||||
return os.path.join(
|
||||
self.namespace.work_dir, constants.IN_PROGRESS_DIR_NAME)
|
||||
|
||||
@property
|
||||
def cert_key_backup(self):
|
||||
return os.path.join(
|
||||
self.namespace.work_dir, constants.CERT_KEY_BACKUP_DIR_NAME)
|
||||
|
||||
@property
|
||||
def rev_tokens_dir(self):
|
||||
return os.path.join(
|
||||
self.namespace.work_dir, constants.REV_TOKENS_DIR_NAME)
|
||||
@@ -47,3 +47,19 @@ APACHE_REWRITE_HTTPS_ARGS = [
|
||||
|
||||
DVSNI_DOMAIN_SUFFIX = ".acme.invalid"
|
||||
"""Suffix appended to domains in DVSNI validation."""
|
||||
|
||||
|
||||
TEMP_CHECKPOINT_DIR_NAME = "temp_checkpoint"
|
||||
"""Temporary checkpoint directory (relative to IConfig.work_dir)."""
|
||||
|
||||
IN_PROGRESS_DIR_NAME = "IN_PROGRESS"
|
||||
"""Directory used before a permanent checkpoint is finalized (relative to
|
||||
IConfig.work_dir)."""
|
||||
|
||||
CERT_KEY_BACKUP_DIR_NAME = "keys-certs"
|
||||
"""Directory where all certificates and keys are stored (relative to
|
||||
IConfig.work_dir. Used for easy revocation."""
|
||||
|
||||
REV_TOKENS_DIR_NAME = "revocation_tokens"
|
||||
"""Directory where all revocation tokens are saved (relative to
|
||||
IConfig.work_dir)."""
|
||||
|
||||
@@ -60,7 +60,7 @@ class IChallenge(zope.interface.Interface):
|
||||
|
||||
|
||||
class IConfig(zope.interface.Interface):
|
||||
"""Marker interface for Let's Encrypt config."""
|
||||
"""Let's Encrypt uesr-supplied configuration."""
|
||||
|
||||
|
||||
class IInstaller(zope.interface.Interface):
|
||||
|
||||
@@ -11,10 +11,11 @@ import sys
|
||||
|
||||
import confargparse
|
||||
import zope.component
|
||||
import zope.interface
|
||||
|
||||
import letsencrypt
|
||||
|
||||
from letsencrypt.client import constants
|
||||
from letsencrypt.client import configuration
|
||||
from letsencrypt.client import client
|
||||
from letsencrypt.client import display
|
||||
from letsencrypt.client import errors
|
||||
@@ -60,17 +61,6 @@ def create_parser():
|
||||
help="Working directory.")
|
||||
add("--backup-dir", default="/var/lib/letsencrypt/backups",
|
||||
help="Configuration backups directory.")
|
||||
add("--temp-checkpoint-dir",
|
||||
default="/var/lib/letsencrypt/temp_checkpoint",
|
||||
help="Temporary checkpoint directory.")
|
||||
add("--in-progress-dir",
|
||||
default="/var/lib/letsencrypt/backups/IN_PROGRESS",
|
||||
help="Directory used before a permanent checkpoint is finalized")
|
||||
add("--cert-key-backup", default="/var/lib/letsencrypt/keys-certs",
|
||||
help="Directory where all certificates and keys are stored. "
|
||||
"Used for easy revocation.")
|
||||
add("--rev-tokens-dir", default="/var/lib/letsencrypt/revocation_tokens",
|
||||
help="Directory where all revocation tokens are saved.")
|
||||
add("--key-dir", default="/etc/letsencrypt/keys", help="Keys storage.")
|
||||
add("--cert-dir", default="/etc/letsencrypt/certs",
|
||||
help="Certificates storage.")
|
||||
@@ -96,12 +86,12 @@ def create_parser():
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def main(): # pylint: disable=too-many-branches
|
||||
"""Command line argument parsing and main script execution."""
|
||||
|
||||
# note: arg parser internally handles --help (and exits afterwards)
|
||||
config = create_parser().parse_args()
|
||||
zope.interface.directlyProvides(config, interfaces.IConfig)
|
||||
args = create_parser().parse_args()
|
||||
config = configuration.NamespaceConfig(args)
|
||||
|
||||
# note: check is done after arg parsing as --help should work w/o root also.
|
||||
if not os.geteuid() == 0:
|
||||
|
||||
Reference in New Issue
Block a user