mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Only set permissions on the storage directory upon creation. Fixes #6958
This commit is contained in:
parent
9dfa5ea77d
commit
bf974e73ce
@ -24,6 +24,7 @@ Bug fixes
|
||||
*********
|
||||
|
||||
| `Issue #6725 <https://redmine.postgresql.org/issues/6725>`_ - Fixed an issue where the Query tool opens on minimum size if the user opens multiple query tool Window quickly.
|
||||
| `Issue #6958 <https://redmine.postgresql.org/issues/6958>`_ - Only set permissions on the storage directory upon creation.
|
||||
| `Issue #7168 <https://redmine.postgresql.org/issues/7168>`_ - Improvement to the Geometry Viewer popup to change the size of the result tables when column names are quite long.
|
||||
| `Issue #7187 <https://redmine.postgresql.org/issues/7187>`_ - Fixed an issue where the downloaded ERD diagram was 0 bytes.
|
||||
| `Issue #7188 <https://redmine.postgresql.org/issues/7188>`_ - Fixed an issue where the connection bar is not visible.
|
||||
|
@ -9,7 +9,6 @@
|
||||
|
||||
import os
|
||||
import getpass
|
||||
from flask import current_app
|
||||
from pgadmin.utils.constants import KERBEROS
|
||||
|
||||
FAILED_CREATE_DIR = \
|
||||
@ -19,6 +18,9 @@ FAILED_CREATE_DIR = \
|
||||
def _create_directory_if_not_exists(_path):
|
||||
if _path and not os.path.exists(_path):
|
||||
os.mkdir(_path)
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def create_app_data_directory(config):
|
||||
@ -26,8 +28,10 @@ def create_app_data_directory(config):
|
||||
Create the required directories (if not present).
|
||||
"""
|
||||
# Create the directory containing the configuration file (if not present).
|
||||
is_directory_created = False
|
||||
try:
|
||||
_create_directory_if_not_exists(os.path.dirname(config.SQLITE_PATH))
|
||||
is_directory_created = _create_directory_if_not_exists(
|
||||
os.path.dirname(config.SQLITE_PATH))
|
||||
except PermissionError as e:
|
||||
print(FAILED_CREATE_DIR.format(os.path.dirname(config.SQLITE_PATH), e))
|
||||
print(
|
||||
@ -44,7 +48,7 @@ def create_app_data_directory(config):
|
||||
# Try to set the permissions on the directory, 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.
|
||||
if os.name != 'nt':
|
||||
if os.name != 'nt' and is_directory_created:
|
||||
try:
|
||||
os.chmod(os.path.dirname(config.SQLITE_PATH), 0o700)
|
||||
except Exception as e:
|
||||
@ -74,7 +78,8 @@ def create_app_data_directory(config):
|
||||
|
||||
# Create the session directory (if not present).
|
||||
try:
|
||||
_create_directory_if_not_exists(config.SESSION_DB_PATH)
|
||||
is_directory_created = \
|
||||
_create_directory_if_not_exists(config.SESSION_DB_PATH)
|
||||
except PermissionError as e:
|
||||
print(FAILED_CREATE_DIR.format(config.SESSION_DB_PATH, e))
|
||||
print(
|
||||
@ -88,7 +93,7 @@ def create_app_data_directory(config):
|
||||
config.APP_VERSION))
|
||||
exit(1)
|
||||
|
||||
if os.name != 'nt':
|
||||
if os.name != 'nt' and is_directory_created:
|
||||
os.chmod(config.SESSION_DB_PATH, 0o700)
|
||||
|
||||
# Create the storage directory (if not present).
|
||||
|
Loading…
Reference in New Issue
Block a user