1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/pgadmin_ynh.git synced 2024-09-03 19:56:38 +02:00
pgadmin_ynh/sources/fix_add_local_db.patch
Josué Tille 72c3a867da
Full rework of package following PR #35
- Fix regression #35 - python dependancy
- Fix regression #35 - armv7 support
- Fix regression #35 - bad install dir
- Fix DB setup and don't request password to user
- Fix data storage path
- Add SSO support
- Update app to 8.3 (will be updated to 8.4 by auto update)
- Add mail support
- Remove legacy uwsig and use gunicorn instead
- Remove expect dependancy
- Set permission explicitly
- Add multi instance support
- Simplify again restore script
2024-03-11 12:18:35 +01:00

64 lines
2.7 KiB
Diff

diff --git a/pgadmin/__init__.py b/pgadmin/__init__.py
index c20016bbc..42ccfd874 100644
--- a/pgadmin/__init__.py
+++ b/pgadmin/__init__.py
@@ -586,10 +586,22 @@ def create_app(app_name=None):
servergroup = servergroups.first()
servergroup_id = servergroup.id
+ # BEGIN Yunohost Patch
+ from pgadmin.utils.master_password import get_crypt_key
+ from pgadmin.utils.exception import CryptKeyMissing
+ from pgadmin.utils.crypto import encrypt
+
+ crypt_key_present, crypt_key = get_crypt_key()
+ if not crypt_key_present:
+ raise CryptKeyMissing
+ # END Yunohost Patch
+
'''Add a server to the config database'''
+ # BEGIN Yunohost Patch
def add_server(user_id, servergroup_id, name, superuser, port,
- discovery_id, comment):
+ discovery_id, comment, password):
+ # END Yunohost Patch
# Create a server object if needed, and store it.
servers = Server.query.filter_by(
user_id=user_id,
@@ -609,7 +621,11 @@ def create_app(app_name=None):
connection_params={'sslmode': 'prefer',
'connect_timeout': 10},
comment=comment,
- discovery_id=discovery_id)
+ # BEGIN Yunohost Patch
+ discovery_id=discovery_id,
+ password=encrypt(password, crypt_key),
+ save_password=1)
+ # END Yunohost Patch
db.session.add(svr)
db.session.commit()
@@ -676,7 +692,7 @@ def create_app(app_name=None):
registry = ConfigParser()
try:
- registry.read('/etc/postgres-reg.ini')
+ registry.read(config.REGISTRY_CONFIG_FILE)
sections = registry.sections()
# Loop the sections, and get the data from any that are PG or PPAS
@@ -703,9 +719,12 @@ def create_app(app_name=None):
svr_comment = gettext("Auto-detected {0} installation "
"with the data directory at {1}"
).format(description, data_directory)
+ # BEGIN Yunohost Patch
+ password = registry.get(section, 'Password')
add_server(user_id, servergroup_id, svr_name,
svr_superuser, svr_port, svr_discovery_id,
- svr_comment)
+ svr_comment, password)
+ # END Yunohost Patch
except Exception as e:
print(str(e))