mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Only allow specification of a pgpass file if libpq >= 10. Fixes #2768
This commit is contained in:
parent
63103c7a48
commit
2f5a2b2392
@ -88,9 +88,11 @@ Use the fields in the *Advanced* tab to configure a connection:
|
|||||||
* The DB restriction field allows you to enter an SQL restriction that will be used against the pg_database table to
|
* The DB restriction field allows you to enter an SQL restriction that will be used against the pg_database table to
|
||||||
limit the databases that you see. For example, you might enter: *live_db test_db* so that only live_db and test_db are
|
limit the databases that you see. For example, you might enter: *live_db test_db* so that only live_db and test_db are
|
||||||
shown in the pgAdmin browser. Separate entries with a comma or tab as you type.
|
shown in the pgAdmin browser. Separate entries with a comma or tab as you type.
|
||||||
* Specify the password file which allow user to login without providing password, see Section 31 of the Postgres documentation:
|
* Specify the password file which allow user to login without providing password, see Section 33.15 of the Postgres documentation:
|
||||||
|
|
||||||
https://www.postgresql.org/docs/9.6/static/libpq-pgpass.html
|
https://www.postgresql.org/docs/current/static/libpq-pgpass.html
|
||||||
|
|
||||||
|
*NOTE:* The password file option is only supported when pgAdmin is using libpq v10.0 or later to connect to the server.
|
||||||
|
|
||||||
* Click the *Save* button to save work.
|
* Click the *Save* button to save work.
|
||||||
* Click the *Cancel* button to exit without saving work.
|
* Click the *Cancel* button to exit without saving work.
|
||||||
|
@ -555,6 +555,15 @@ def utils():
|
|||||||
insert_pair_brackets_perf = prefs.preference('insert_pair_brackets')
|
insert_pair_brackets_perf = prefs.preference('insert_pair_brackets')
|
||||||
insert_pair_brackets = insert_pair_brackets_perf.get()
|
insert_pair_brackets = insert_pair_brackets_perf.get()
|
||||||
|
|
||||||
|
# Try to fetch current libpq version from the driver
|
||||||
|
try:
|
||||||
|
from config import PG_DEFAULT_DRIVER
|
||||||
|
from pgadmin.utils.driver import get_driver
|
||||||
|
driver = get_driver(PG_DEFAULT_DRIVER)
|
||||||
|
pg_libpq_version = driver.libpq_version()
|
||||||
|
except:
|
||||||
|
pg_libpq_version = 0
|
||||||
|
|
||||||
for submodule in current_blueprint.submodules:
|
for submodule in current_blueprint.submodules:
|
||||||
snippets.extend(submodule.jssnippets)
|
snippets.extend(submodule.jssnippets)
|
||||||
return make_response(
|
return make_response(
|
||||||
@ -569,7 +578,8 @@ def utils():
|
|||||||
editor_wrap_code=editor_wrap_code,
|
editor_wrap_code=editor_wrap_code,
|
||||||
editor_brace_matching=brace_matching,
|
editor_brace_matching=brace_matching,
|
||||||
editor_insert_pair_brackets=insert_pair_brackets,
|
editor_insert_pair_brackets=insert_pair_brackets,
|
||||||
app_name=config.APP_NAME
|
app_name=config.APP_NAME,
|
||||||
|
pg_libpq_version=pg_libpq_version
|
||||||
),
|
),
|
||||||
200, {'Content-Type': 'application/x-javascript'})
|
200, {'Content-Type': 'application/x-javascript'})
|
||||||
|
|
||||||
|
@ -779,7 +779,7 @@ define('pgadmin.node.server', [
|
|||||||
},{
|
},{
|
||||||
id: 'passfile', label: gettext('Password File'), type: 'text',
|
id: 'passfile', label: gettext('Password File'), type: 'text',
|
||||||
group: gettext('Advanced'), mode: ['edit', 'create'],
|
group: gettext('Advanced'), mode: ['edit', 'create'],
|
||||||
disabled: 'isConnected', control: Backform.FileControl,
|
disabled: 'isConnectedWithValidLib', control: Backform.FileControl,
|
||||||
dialog_type: 'select_file', supp_types: ['*']
|
dialog_type: 'select_file', supp_types: ['*']
|
||||||
},{
|
},{
|
||||||
id: 'passfile', label: gettext('Password File'), type: 'text',
|
id: 'passfile', label: gettext('Password File'), type: 'text',
|
||||||
@ -888,6 +888,14 @@ define('pgadmin.node.server', [
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return _.indexOf(SSL_MODES, ssl_mode) == -1;
|
return _.indexOf(SSL_MODES, ssl_mode) == -1;
|
||||||
|
},
|
||||||
|
isConnectedWithValidLib: function(model) {
|
||||||
|
if(model.get('connected')) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// older version of libpq do not support 'passfile' parameter in
|
||||||
|
// connect method, valid libpq must have version >= 100000
|
||||||
|
return pgBrowser.utils.pg_libpq_version < 100000;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
connection_lost: function(i, resp) {
|
connection_lost: function(i, resp) {
|
||||||
|
@ -24,6 +24,7 @@ define('pgadmin.browser.utils',
|
|||||||
insertPairBrackets: '{{ editor_insert_pair_brackets }}' == 'True',
|
insertPairBrackets: '{{ editor_insert_pair_brackets }}' == 'True',
|
||||||
braceMatching: '{{ editor_brace_matching }}' == 'True',
|
braceMatching: '{{ editor_brace_matching }}' == 'True',
|
||||||
app_name: '{{ app_name }}',
|
app_name: '{{ app_name }}',
|
||||||
|
pg_libpq_version: {{pg_libpq_version|e}},
|
||||||
|
|
||||||
counter: {total: 0, loaded: 0},
|
counter: {total: 0, loaded: 0},
|
||||||
registerScripts: function (ctx) {
|
registerScripts: function (ctx) {
|
||||||
|
@ -32,6 +32,9 @@ class BaseDriver(object):
|
|||||||
* Version (string):
|
* Version (string):
|
||||||
Current version string for the database server
|
Current version string for the database server
|
||||||
|
|
||||||
|
* libpq_version (string):
|
||||||
|
Current version string for the used libpq library
|
||||||
|
|
||||||
Abstract Methods:
|
Abstract Methods:
|
||||||
-------- -------
|
-------- -------
|
||||||
* get_connection(*args, **kwargs)
|
* get_connection(*args, **kwargs)
|
||||||
@ -51,6 +54,10 @@ class BaseDriver(object):
|
|||||||
def Version(cls):
|
def Version(cls):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@abstractproperty
|
||||||
|
def libpq_version(cls):
|
||||||
|
pass
|
||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_connection(self, *args, **kwargs):
|
def get_connection(self, *args, **kwargs):
|
||||||
pass
|
pass
|
||||||
|
@ -2043,6 +2043,18 @@ class Driver(BaseDriver):
|
|||||||
"Driver Version information for psycopg2 is not available!"
|
"Driver Version information for psycopg2 is not available!"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def libpq_version(cls):
|
||||||
|
"""
|
||||||
|
Returns the loaded libpq version
|
||||||
|
"""
|
||||||
|
version = getattr(psycopg2, '__libpq_version__', None)
|
||||||
|
if version:
|
||||||
|
return version
|
||||||
|
|
||||||
|
raise Exception(
|
||||||
|
"libpq version information is not available!"
|
||||||
|
)
|
||||||
|
|
||||||
def get_connection(
|
def get_connection(
|
||||||
self, sid, database=None, conn_id=None, auto_reconnect=True
|
self, sid, database=None, conn_id=None, auto_reconnect=True
|
||||||
):
|
):
|
||||||
|
Loading…
Reference in New Issue
Block a user