Relax the permission check on the directory containing the config database, as it may fail in some environments such as OpenShift. Fixes #4276

This commit is contained in:
Dave Page 2019-05-20 09:46:02 +01:00
parent 5786c17569
commit da8da7bb49
2 changed files with 12 additions and 2 deletions

View File

@ -24,4 +24,5 @@ Bug fixes
| `Bug #4246 <https://redmine.postgresql.org/issues/4246>`_ - Fixed console error when subnode control is used in panels.
| `Bug #4261 <https://redmine.postgresql.org/issues/4261>`_ - Stop using application/x-javascript as a mime type and use the RFC-compliant application/javascript instead.
| `Bug #4262 <https://redmine.postgresql.org/issues/4262>`_ - Fixed error on displaying table properties of a table partitioned by list having a default partition.
| `Bug #4269 <https://redmine.postgresql.org/issues/4269>`_ - Fix navigation of switch cells in grids.
| `Bug #4269 <https://redmine.postgresql.org/issues/4269>`_ - Fix navigation of switch cells in grids.
| `Bug #4276 <https://redmine.postgresql.org/issues/4276>`_ - Relax the permission check on the directory containing the config database, as it may fail in some environments such as OpenShift.

View File

@ -8,6 +8,7 @@
##########################################################################
import os
from flask import current_app
def _create_directory_if_not_exists(_path):
@ -21,7 +22,15 @@ def create_app_data_directory(config):
"""
# Create the directory containing the configuration file (if not present).
_create_directory_if_not_exists(os.path.dirname(config.SQLITE_PATH))
os.chmod(os.path.dirname(config.SQLITE_PATH), 0o700)
# Try to set the permissions on the direectory, but don't complain
# if we can't. This may be the case on a mounted directory, e.g. in
# OpenShift. We'll still secure the config database anyway.
try:
os.chmod(os.path.dirname(config.SQLITE_PATH), 0o700)
except Exception as e:
# The flask app isn't setup yet, so we can't use the logger
print('WARNING: Failed to set ACL on the directory containing the '
'configuration database: {}'.format(e))
# Create the directory containing the log file (if not present).
_create_directory_if_not_exists(os.path.dirname(config.LOG_FILE))