mirror of
https://github.com/certbot/certbot.git
synced 2026-08-02 19:22:16 +02:00
Merge pull request #3164 from jsha/eacces-guidance
Provide nonroot guidance when logging gets EACCES.
This commit is contained in:
+11
-2
@@ -1,6 +1,7 @@
|
|||||||
"""Certbot main entry point."""
|
"""Certbot main entry point."""
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import atexit
|
import atexit
|
||||||
|
import errno
|
||||||
import functools
|
import functools
|
||||||
import logging.handlers
|
import logging.handlers
|
||||||
import os
|
import os
|
||||||
@@ -588,8 +589,16 @@ def renew(config, unused_plugins):
|
|||||||
def setup_log_file_handler(config, logfile, fmt):
|
def setup_log_file_handler(config, logfile, fmt):
|
||||||
"""Setup file debug logging."""
|
"""Setup file debug logging."""
|
||||||
log_file_path = os.path.join(config.logs_dir, logfile)
|
log_file_path = os.path.join(config.logs_dir, logfile)
|
||||||
handler = logging.handlers.RotatingFileHandler(
|
try:
|
||||||
log_file_path, maxBytes=2 ** 20, backupCount=10)
|
handler = logging.handlers.RotatingFileHandler(
|
||||||
|
log_file_path, maxBytes=2 ** 20, backupCount=10)
|
||||||
|
except IOError as e:
|
||||||
|
if e.errno == errno.EACCES:
|
||||||
|
msg = ("Access denied writing to {0}. To run as non-root, set " +
|
||||||
|
"--logs-dir, --config-dir, --work-dir to writable paths.")
|
||||||
|
raise errors.Error(msg.format(log_file_path))
|
||||||
|
else:
|
||||||
|
raise
|
||||||
# rotate on each invocation, rollover only possible when maxBytes
|
# rotate on each invocation, rollover only possible when maxBytes
|
||||||
# is nonzero and backupCount is nonzero, so we set maxBytes as big
|
# is nonzero and backupCount is nonzero, so we set maxBytes as big
|
||||||
# as possible not to overrun in single CLI invocation (1MB).
|
# as possible not to overrun in single CLI invocation (1MB).
|
||||||
|
|||||||
Reference in New Issue
Block a user