summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Shyba <victor1984@riseup.net>2017-09-30 02:35:06 -0300
committerVictor Shyba <victor1984@riseup.net>2017-10-05 05:43:20 -0300
commitd814ee4a06aee5b911e4a89d245738b4e5ef497e (patch)
treec818d628bc86b91149bafc85fede492a38426e94
parentca434f42dc91e2b9b15ef826e79a4c29ff314cb7 (diff)
[bug] refuse to start if blobs is misconfigured
As kali pointed out, one can disable blobs after enabling it, which would cause data loss as blobs documents would become unreacheable. This commit adds a warning and refuses to start the server. -- Resolves: #8866
-rw-r--r--src/leap/soledad/server/entrypoints.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/leap/soledad/server/entrypoints.py b/src/leap/soledad/server/entrypoints.py
index 7f521dba..7d18ca58 100644
--- a/src/leap/soledad/server/entrypoints.py
+++ b/src/leap/soledad/server/entrypoints.py
@@ -20,9 +20,11 @@ The entrypoint for Soledad server.
This is the entrypoint for the application that is loaded from the initscript
or the systemd script.
"""
+import os
from twisted.internet import reactor
from twisted.python import threadpool
+from twisted.logger import Logger
from .auth import localPortal, publicPortal
from .session import SoledadSession
@@ -32,6 +34,7 @@ from ._wsgi import init_couch_state
# load configuration from file
conf = get_config()
+log = Logger()
class SoledadEntrypoint(SoledadSession):
@@ -54,4 +57,20 @@ class LocalServicesEntrypoint(SoledadSession):
# initialized when the reactor is running
+def check_conf():
+ path = conf['blobs_path']
+ blobs_not_empty = bool(os.path.exists(path) and os.listdir(path))
+ if not conf['blobs'] and blobs_not_empty:
+ message = """
+** WARNING: Blobs is disabled, but blobs directory isn't empty. **
+** If it was previously enabled, disabling can cause data loss due blobs **
+** documents not being accessible to users. **
+** Blobs directory: %s
+** REFUSING TO START. Please double check your configuration. **
+ """
+ log.error(message % path)
+ reactor.stop()
+
+
+reactor.callWhenRunning(check_conf)
reactor.callWhenRunning(init_couch_state, conf)