public inbox for [email protected]
help / color / mirror / Atom feedFrom: Dave Page <[email protected]>
To: pgadmin-hackers <[email protected]>
Subject: RM4999 - Rename variables that could conflict with Kubernetes
Date: Thu, 12 Dec 2019 10:18:18 +0000
Message-ID: <CA+OCxozwC__=w4P1+41YDDC7hRWLfvyqsQvUKqZRKthyQ2rkNg@mail.gmail.com> (raw)
The attached patch renames the PGADMIN_PORT and PGADMIN_KEY environment
variables used by the desktop runtime so they're less likely to conflict
with variable names used by Kubernetes.
--
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake
EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company
Attachments:
[application/octet-stream] RM_4999.diff (5.5K, 3-RM_4999.diff)
download | inline diff:
diff --git a/docs/en_US/release_notes_4_17.rst b/docs/en_US/release_notes_4_17.rst
index aff6af1b..38d18156 100644
--- a/docs/en_US/release_notes_4_17.rst
+++ b/docs/en_US/release_notes_4_17.rst
@@ -19,4 +19,5 @@ Bug fixes
| `Issue #4506 <https://redmine.postgresql.org/issues/4506>`_ - Fix an issue where clicking on an empty textbox like fill factor or comments, considers it as change and enabled the save button.
| `Issue #4943 <https://redmine.postgresql.org/issues/4943>`_ - Added more information to the 'Database connected/disconnected' message.
+| `Issue #4999 <https://redmine.postgresql.org/issues/4999>`_ - Rename some internal environment variables that could conflict with Kubernetes.
| `Issue #5004 <https://redmine.postgresql.org/issues/5004>`_ - Fix vulnerability issues reported by 'yarn audit'. Replace the deprecated uglifyjs-webpack-plugin with a terser-webpack-plugin.
\ No newline at end of file
diff --git a/runtime/Server.cpp b/runtime/Server.cpp
index 60ddc7e5..76ee95d6 100644
--- a/runtime/Server.cpp
+++ b/runtime/Server.cpp
@@ -341,8 +341,8 @@ void Server::run()
// Set the port number and key, and force SERVER_MODE off.
Logger::GetLogger()->Log("Set the port number, key and force SERVER_MODE off");
- PyRun_SimpleString(QString("PGADMIN_PORT = %1").arg(m_port).toLatin1());
- PyRun_SimpleString(QString("PGADMIN_KEY = '%1'").arg(m_key).toLatin1());
+ PyRun_SimpleString(QString("PGADMIN_INT_PORT = %1").arg(m_port).toLatin1());
+ PyRun_SimpleString(QString("PGADMIN_INT_KEY = '%1'").arg(m_key).toLatin1());
PyRun_SimpleString(QString("SERVER_MODE = False").toLatin1());
// Run the app!
diff --git a/web/pgAdmin4.py b/web/pgAdmin4.py
index 4668458f..71eaed5e 100644
--- a/web/pgAdmin4.py
+++ b/web/pgAdmin4.py
@@ -129,15 +129,15 @@ if config.DEBUG:
# runtime if we're running in desktop mode, otherwise we'll just use the
# Flask default.
PGADMIN_RUNTIME = False
-if 'PGADMIN_PORT' in globals():
+if 'PGADMIN_INT_PORT' in globals():
app.logger.debug(
'Running under the desktop runtime, port: %s',
- globals()['PGADMIN_PORT']
+ globals()['PGADMIN_INT_PORT']
)
- server_port = int(globals()['PGADMIN_PORT'])
+ server_port = int(globals()['PGADMIN_INT_PORT'])
PGADMIN_RUNTIME = True
-elif 'PGADMIN_PORT' in os.environ:
- port = os.environ['PGADMIN_PORT']
+elif 'PGADMIN_INT_PORT' in os.environ:
+ port = os.environ['PGADMIN_INT_PORT']
app.logger.debug(
'Not running under the desktop runtime, port: %s',
port
@@ -154,11 +154,11 @@ else:
app.PGADMIN_RUNTIME = PGADMIN_RUNTIME
# Set the key if appropriate
-if 'PGADMIN_KEY' in globals():
- app.PGADMIN_KEY = globals()['PGADMIN_KEY']
- app.logger.debug("Desktop security key: %s" % app.PGADMIN_KEY)
+if 'PGADMIN_INT_KEY' in globals():
+ app.PGADMIN_INT_KEY = globals()['PGADMIN_INT_KEY']
+ app.logger.debug("Desktop security key: %s" % app.PGADMIN_INT_KEY)
else:
- app.PGADMIN_KEY = ''
+ app.PGADMIN_INT_KEY = ''
# Output a startup message if we're not under the runtime and startup.
# If we're under WSGI, we don't need to worry about this
diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py
index 293054f2..7fd960b4 100644
--- a/web/pgadmin/__init__.py
+++ b/web/pgadmin/__init__.py
@@ -620,11 +620,11 @@ def create_app(app_name=None):
# Check the auth key is valid, if it's set, and we're not in server
# mode, and it's not a help file request.
- if not config.SERVER_MODE and app.PGADMIN_KEY != '':
+ if not config.SERVER_MODE and app.PGADMIN_INT_KEY != '':
if (
('key' not in request.args or
- request.args['key'] != app.PGADMIN_KEY) and
- request.cookies.get('PGADMIN_KEY') != app.PGADMIN_KEY and
+ request.args['key'] != app.PGADMIN_INT_KEY) and
+ request.cookies.get('PGADMIN_INT_KEY') != app.PGADMIN_INT_KEY and
request.endpoint != 'help.static'
):
abort(401)
@@ -659,7 +659,7 @@ def create_app(app_name=None):
if config.COOKIE_DEFAULT_DOMAIN and \
config.COOKIE_DEFAULT_DOMAIN != 'localhost':
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
- response.set_cookie('PGADMIN_KEY', value=request.args['key'],
+ response.set_cookie('PGADMIN_INT_KEY', value=request.args['key'],
path=config.COOKIE_DEFAULT_PATH,
**domain)
diff --git a/web/regression/feature_utils/app_starter.py b/web/regression/feature_utils/app_starter.py
index 7597cde9..6d1340fa 100644
--- a/web/regression/feature_utils/app_starter.py
+++ b/web/regression/feature_utils/app_starter.py
@@ -28,7 +28,7 @@ class AppStarter:
""" This function start the subprocess to start pgAdmin app """
random_server_port = str(random.randint(10000, 65535))
env = {
- "PGADMIN_PORT": random_server_port,
+ "PGADMIN_INT_PORT": random_server_port,
"SQLITE_PATH": str(self.app_config.TEST_SQLITE_PATH)
}
env.update(os.environ)
diff --git a/web/regression/runtests.py b/web/regression/runtests.py
index 8c52753f..f80eb5c7 100644
--- a/web/regression/runtests.py
+++ b/web/regression/runtests.py
@@ -106,7 +106,7 @@ config.CONSOLE_LOG_LEVEL = WARNING
# Create the app
app = create_app()
-app.PGADMIN_KEY = ''
+app.PGADMIN_INT_KEY = ''
app.config.update({'SESSION_COOKIE_DOMAIN': None})
driver = None
app_starter = None
view thread (2+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: RM4999 - Rename variables that could conflict with Kubernetes
In-Reply-To: <CA+OCxozwC__=w4P1+41YDDC7hRWLfvyqsQvUKqZRKthyQ2rkNg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox