File tree Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Expand file tree Collapse file tree 2 files changed +32
-0
lines changed Original file line number Diff line number Diff line change 44
55import os
66
7+ from aikido_zen .background_process .test_uds_file_access import test_uds_file_access
8+
79# Re-export functions :
810from aikido_zen .context .users import set_user
911from aikido_zen .middleware import should_block_request
@@ -30,6 +32,9 @@ def protect(mode="daemon", token=""):
3032 if aikido_disabled_flag_active ():
3133 # Do not run any aikido code when the disabled flag is on
3234 return
35+ if not test_uds_file_access ():
36+ return # Unable to start background process
37+
3338 if token :
3439 os .environ ["AIKIDO_TOKEN" ] = token
3540
Original file line number Diff line number Diff line change 1+ import os
2+ import platform
3+ import sys
4+
5+ from aikido_zen .background_process import get_uds_filename
6+ from aikido_zen .helpers .logging import logger
7+
8+
9+ def test_uds_file_access ():
10+ """Returns true if access is possible, false if it's not."""
11+ filename = get_uds_filename ()
12+ directory = "/" .join (filename .split ("/" )[:- 1 ])
13+
14+ if platform .system () == "Windows" :
15+ # Python does not support Windows UDS just yet, so we have to rely on INET
16+ return True
17+
18+ if not os .access (directory , os .R_OK ) or not os .access (directory , os .W_OK ):
19+ # We need both read and write permissions in order to start the socket
20+ logger .critical (
21+ "Cannot start Zen: no read/write permissions for directory %s. "
22+ + "You can change the path by setting "
23+ + "the AIKIDO_TMP_DIR environment variable." ,
24+ directory ,
25+ )
26+ return False
27+ return True
You can’t perform that action at this time.
0 commit comments