diff --git a/docs/en_US/psql_tool.rst b/docs/en_US/psql_tool.rst index 946925866..c87cf0b63 100644 --- a/docs/en_US/psql_tool.rst +++ b/docs/en_US/psql_tool.rst @@ -10,6 +10,10 @@ PSQL tool allows user to connect to PostgreSQL/EDB Advanced server using psql te * PSQL will connect to the current connected database from browser tree. +* PSQL utility does support execution of OS meta-commands by using "\\!". Due + to security concerns, we have disabled the execution of such commands in + pgAdmin. To enable OS meta-commands set ALLOW_PSQL_SHELL_COMMANDS = True in configuration. + .. image:: images/psql_tool.png :alt: PSQL tool window :align: center @@ -17,3 +21,5 @@ PSQL tool allows user to connect to PostgreSQL/EDB Advanced server using psql te You can open multiple instance of the PSQL tool in individual tabs simultaneously. To close the PSQL tool, click the *X* in the upper-right hand corner of the tab bar. +**Note:** For the Windows platform, this feature is available on Windows 10 (1809 version) and onwards. + diff --git a/web/pgadmin/__init__.py b/web/pgadmin/__init__.py index 2042ada8d..41a7e328a 100644 --- a/web/pgadmin/__init__.py +++ b/web/pgadmin/__init__.py @@ -60,7 +60,7 @@ winreg = None if os.name == 'nt': import winreg -socketio = SocketIO(manage_session=False, async_mode='eventlet', +socketio = SocketIO(manage_session=False, async_mode='threading', logger=False, engineio_logger=False, debug=False, ping_interval=25, ping_timeout=120) diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py index 6e9fb6298..fa7aa9e54 100644 --- a/web/pgadmin/browser/__init__.py +++ b/web/pgadmin/browser/__init__.py @@ -855,7 +855,8 @@ def utils(): support_ssh_tunnel=config.SUPPORT_SSH_TUNNEL, logout_url=_get_logout_url(), platform=sys.platform, - qt_default_placeholder=QT_DEFAULT_PLACEHOLDER + qt_default_placeholder=QT_DEFAULT_PLACEHOLDER, + enable_psql=config.ENABLE_PSQL ), 200, {'Content-Type': MIMETYPE_APP_JS}) diff --git a/web/pgadmin/browser/register_browser_preferences.py b/web/pgadmin/browser/register_browser_preferences.py index cfe279b40..c2c16ad89 100644 --- a/web/pgadmin/browser/register_browser_preferences.py +++ b/web/pgadmin/browser/register_browser_preferences.py @@ -505,39 +505,39 @@ def register_browser_preferences(self): ' revert back to the default title with placeholders.' ) ) - - self.open_in_new_tab = self.preference.register( - 'tab_settings', 'new_browser_tab_open', - gettext("Open in new browser tab"), 'select2', None, - category_label=PREF_LABEL_OPTIONS, - options=[{'label': gettext('Query Tool'), 'value': 'qt'}, - {'label': gettext('Debugger'), 'value': 'debugger'}, - {'label': gettext('Schema Diff'), 'value': 'schema_diff'}, - {'label': gettext('ERD Tool'), 'value': 'erd_tool'}, - {'label': gettext('PSQL Tool'), 'value': 'psql_tool'}], - help_str=gettext( - 'Select Query Tool, Debugger, Schema Diff, ERD Tool ' - 'or PSQL Tool from the drop-down to set ' - 'open in new browser tab for that particular module.' - ), - select2={ - 'multiple': True, 'allowClear': False, - 'tags': True, 'first_empty': False, - 'selectOnClose': False, 'emptyOptions': True, - 'tokenSeparators': [','], - 'placeholder': gettext('Select open new tab...') - } - ) - - self.psql_tab_title = self.preference.register( - 'tab_settings', 'psql_tab_title_placeholder', - gettext("PSQL tool tab title"), - 'text', '%DATABASE%/%USERNAME%@%SERVER%', - category_label=PREF_LABEL_DISPLAY, - help_str=gettext( - 'Supported placeholders are %DATABASE%, %USERNAME%, ' - 'and %SERVER%. Users can provide any string with or without' - ' placeholders of their choice. The blank title will be revert' - ' back to the default title with placeholders.' + if config.ENABLE_PSQL: + self.open_in_new_tab = self.preference.register( + 'tab_settings', 'new_browser_tab_open', + gettext("Open in new browser tab"), 'select2', None, + category_label=PREF_LABEL_OPTIONS, + options=[{'label': gettext('Query Tool'), 'value': 'qt'}, + {'label': gettext('Debugger'), 'value': 'debugger'}, + {'label': gettext('Schema Diff'), 'value': 'schema_diff'}, + {'label': gettext('ERD Tool'), 'value': 'erd_tool'}, + {'label': gettext('PSQL Tool'), 'value': 'psql_tool'}], + help_str=gettext( + 'Select Query Tool, Debugger, Schema Diff, ERD Tool ' + 'or PSQL Tool from the drop-down to set ' + 'open in new browser tab for that particular module.' + ), + select2={ + 'multiple': True, 'allowClear': False, + 'tags': True, 'first_empty': False, + 'selectOnClose': False, 'emptyOptions': True, + 'tokenSeparators': [','], + 'placeholder': gettext('Select open new tab...') + } + ) + + self.psql_tab_title = self.preference.register( + 'tab_settings', 'psql_tab_title_placeholder', + gettext("PSQL tool tab title"), + 'text', '%DATABASE%/%USERNAME%@%SERVER%', + category_label=PREF_LABEL_DISPLAY, + help_str=gettext( + 'Supported placeholders are %DATABASE%, %USERNAME%, ' + 'and %SERVER%. Users can provide any string with or without' + ' placeholders of their choice. The blank title will be revert' + ' back to the default title with placeholders.' + ) ) - ) diff --git a/web/pgadmin/browser/templates/browser/js/utils.js b/web/pgadmin/browser/templates/browser/js/utils.js index 17268a4e7..e38bf1b41 100644 --- a/web/pgadmin/browser/templates/browser/js/utils.js +++ b/web/pgadmin/browser/templates/browser/js/utils.js @@ -53,7 +53,7 @@ define('pgadmin.browser.utils', pgAdmin['override_user_inactivity_timeout'] = '{{ current_app.config.get('OVERRIDE_USER_INACTIVITY_TIMEOUT') }}' == 'True'; /* GET PSQL Tool related config */ - pgAdmin['enable_psql'] = '{{ current_app.config.get('ENABLE_PSQL') }}' == 'True'; + pgAdmin['enable_psql'] = '{{enable_psql}}' == 'True'; pgAdmin['allow_psql_shell_commands'] = '{{ current_app.config.get('ALLOW_PSQL_SHELL_COMMANDS') }}' == 'True'; pgAdmin['platform'] = '{{platform}}'; pgAdmin['qt_default_placeholder'] = '{{qt_default_placeholder}}' diff --git a/web/pgadmin/tools/psql/__init__.py b/web/pgadmin/tools/psql/__init__.py index f62e0743c..cb10d5db1 100644 --- a/web/pgadmin/tools/psql/__init__.py +++ b/web/pgadmin/tools/psql/__init__.py @@ -20,7 +20,12 @@ from ... import socketio as sio from pgadmin.utils import get_complete_file_path if _platform == 'win32': - from winpty import PtyProcess + # Check Windows platform support for WinPty api, Disable psql + # if not supporting + try: + from winpty import PtyProcess + except ImportError as error: + config.ENABLE_PSQL = False else: import fcntl import termios