public inbox for [email protected]
help / color / mirror / Atom feedFrom: Nikhil Mohite <[email protected]>
To: Akshay Joshi <[email protected]>
Cc: pgadmin-hackers <[email protected]>
Cc: Fahar Abbas <[email protected]>
Cc: Dave Page <[email protected]>
Subject: Re: [pgAdmin][RM-2341]: Add menu option for starting PSQL
Date: Mon, 14 Jun 2021 18:43:26 +0530
Message-ID: <CAOBg0AN8FjiTHS2tiLQYRYUAUBcMcohENmDjwOc6Oqb+2t4e6w@mail.gmail.com> (raw)
In-Reply-To: <CANxoLDf+KsDfGM4X7ba3WX9hr-RALwpfRYWEKLeRsMy_hD0J7A@mail.gmail.com>
References: <CAOBg0AO6Tjksb+EOA_-O13yRzdL_2d3y6G74m=GGQS+Ymjv=0g@mail.gmail.com>
<CA+OCxow9+UDMrsBBvJKW2AeAYaN4cO3w7kBGNKtsWhSM6_D7gQ@mail.gmail.com>
<CAOBg0AMVyLBma8wsbZ-VQWF4q3OAhqWeRLpmrxVcM_YOKH+MDQ@mail.gmail.com>
<CANxoLDd2xMu7ym9PFdhYUSy4ucNuPoZ2fvaRkuwyB+EqowLXwA@mail.gmail.com>
<CA+OCxowoz1oFE=eMKEnfFtf=oDrkPKHGfZpUGRW-sG_tpfMBTw@mail.gmail.com>
<CAOBg0ANFNvtD-LoFxXcLY5JJ4BVH5zNyrmdBED6B++-nKf012g@mail.gmail.com>
<CA+OCxowW7BEZzULbEpn73ygqWtWkUwdCAB3PMcHocUeQXcM3ow@mail.gmail.com>
<CAOBg0APGPTA4qNNryAXMwKP63uFLxQdQwnFdDXMjSr4OeH-HAg@mail.gmail.com>
<CA+OCxozYus58i3BhP37E-2Xc6Nq5zrJegcq+eANWpvN++_LtXw@mail.gmail.com>
<CAOBg0AO7NfJjLLFD8g5NkkbbnKiCSR5g9yshxc-65sWk2sFyBA@mail.gmail.com>
<CA+OCxoxdaBmh6e4Fo1F_+vZExq8SPUyGAByRzOPy2kz_vgRiSA@mail.gmail.com>
<CAOBg0AO6A10OHiQAOOguagW1mNzfK1oVPHG9W+JSCkYjR+xQkA@mail.gmail.com>
<CA+OCxoxpyfJabnycSGmtUK1-QEndNfZV3q2d1xP-oftDn-pGDw@mail.gmail.com>
<CANxoLDexHsJQcrd6ZrkjCub+xj_Ke+dDp_Av5no84MOJH1uC_g@mail.gmail.com>
<CAOBg0AN6Gb9gp1F=jKeefAz6d0U2GSjC40qAJ8i7psor2KmQLA@mail.gmail.com>
<CANxoLDd3QdOPY7Y6kDCSy99s3DFrbdhP9LNxphsEg9B5G14Dbg@mail.gmail.com>
<CAOBg0AN3eSLvS_cG7R3WiTpfBxiJfi2YB6sV8NBWiakioXRAsQ@mail.gmail.com>
<CANxoLDdGeNOBZJu-v9YaefKeTSGcCcU2DQic1MQU9jYYLJ6K_Q@mail.gmail.com>
<CAOBg0AO-gsDJSrLoGPJGKsq772Okgg3BWDuERaaGSDvoGbhQAA@mail.gmail.com>
<CA+OCxozEBo7-8hSeWo8K9mAL5E5MkeW3JG+JnjJXMEkT6q8SNg@mail.gmail.com>
<CANxoLDcfbqO5qYOV=LE8x1ocVEUoLD7bCm_UXYHmXL2=n9kX7A@mail.gmail.com>
<CAOBg0ANMJTzaEQdcEwUnLLGJXSbsT6=0L8Jvs_MTuBTfj0YtrQ@mail.gmail.com>
<CANxoLDcjno=sUmj11QSEv8OYCSoiOtMVvHjo=jrWjumBPtk6RA@mail.gmail.com>
<CAOBg0AMqZwQZoaxNHFn2cL0yHtfW04=RDYw-UqvjG-vA4KHmBA@mail.gmail.com>
<CA+OCxoypWKk=5uST1gQEyYpYfgiX4=_EVSpy6o+AF8LErMd3pA@mail.gmail.com>
<CAOBg0ANY6j0MHeSx0tOyrBz_+ZGH_zVYaB8+O0O6=qQ5f_BcVw@mail.gmail.com>
<CA+OCxoyqJeMUFU4bujdUM9kcjSGngENeD4DuvLHu7ks_EQGhHw@mail.gmail.com>
<CAOBg0ANz0XJ1j-YArXN6xUkbm2WhV0p-yX3Pw5emxk7EUpN4WA@mail.gmail.com>
<CA+OCxoyAd7TUNjs6xyUrDR32YKNhfJTzzzH4JP=StKw0PoVXVQ@mail.gmail.com>
<CAJFwRrOwY3wskN_A_VvU+gGzDYXrGkw8wFbD3xrd===WxFX_gg@mail.gmail.com>
<CA+OCxoytJ_XXYPwq-=OmRiimbSrXz1Jjb+4z-pHgLBpcK=3bbQ@mail.gmail.com>
<CAJFwRrMcivZdFBnsPWs7WZuFziCBBq-bWNQKbDDXfvV7d41svQ@mail.gmail.com>
<CA+OCxoxUnPV61uxNVWniQLtfXZxkf-oz2Tzw6-PgZazP8g4Phw@mail.gmail.com>
<CAJFwRrPJvbBQ9PjjtavQvv7OW_FQak7LG4E1HR3seH5+Nzck=g@mail.gmail.com>
<CA+OCxoxqpCXKfDO5DKNUWWCeK+v8zosW8HZif=ReGQmBWynjFg@mail.gmail.com>
<CAJFwRrNw8jTx0eNP+1GX6C_4nzpchM0_zqE5oHY8c3ipCwDejw@mail.gmail.com>
<CA+OCxoxMYB2uVg8AfUm9mYtKpps1f+8YxZZaQwT2cK0njrjbGQ@mail.gmail.com>
<CAOBg0APg0nvq0XfihscQLdJ+Vz5S2gDa2qfwROCLC=kYNXDQEg@mail.gmail.com>
<CAOBg0AP1NLfkiF30R6zddrficHRkOsfa3127sGTChJrigWgYEA@mail.gmail.com>
<CANxoLDf+KsDfGM4X7ba3WX9hr-RALwpfRYWEKLeRsMy_hD0J7A@mail.gmail.com>
Hi Akshay,
Please find the updated patch for psql, Updated invalid command logic added
3 more commands in it.
1. \copy or \COPY
2. \e or \E
3. \ef or \EF
Now user can't execute these commands if allow shell commands is set to
False.
If required any changes please let me know.
Regards,
Nikhil Mohite
On Mon, Jun 14, 2021 at 11:48 AM Akshay Joshi <[email protected]>
wrote:
> Thanks, the patch applied.
>
> On Mon, Jun 14, 2021 at 10:55 AM Nikhil Mohite <
> [email protected]> wrote:
>
>> Hi Team,
>>
>> PFA patch v8
>>
>> On Mon, Jun 14, 2021 at 10:25 AM Nikhil Mohite <
>> [email protected]> wrote:
>>
>>> Hi Team,
>>>
>>> Please find the updated patch for the PSQL tool, Added check if the
>>> Windows version is not supporting the ConPty or WinPty disable the PSQL for
>>> that version. (PSQL option will not visible to the user).
>>>
>>> I have raised the issue with "pywinpty"
>>> https://github.com/spyder-ide/pywinpty/issues/161
>>>
>>> Regards,
>>> Nikhil Mohite
>>>
>>> On Fri, Jun 11, 2021 at 6:25 PM Dave Page <[email protected]> wrote:
>>>
>>>> Hi
>>>>
>>>> On Fri, Jun 11, 2021 at 1:45 PM Fahar Abbas <
>>>> [email protected]> wrote:
>>>>
>>>>> Hi Dave,
>>>>>
>>>>> On Fri, Jun 11, 2021 at 1:39 PM Dave Page <[email protected]> wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Jun 11, 2021 at 9:35 AM Fahar Abbas <
>>>>>> [email protected]> wrote:
>>>>>>
>>>>>>> Sure Dave, I will create a new VM with the latest iso.
>>>>>>>
>>>>>>
>>>>>> Not the latest. 1809 please. And if that doesn't work, 1909. We need
>>>>>> to understand exactly what versions work and which don't.
>>>>>>
>>>>>> pgadmin4 is working fine on Windows 10 x64(1809).
>>>>>
>>>>
>>>> Great, thanks!
>>>>
>>>>
>>>>>
>>>>> Do I also need to test pgadmin4 on 1909 iso?
>>>>>
>>>>
>>>> I don't think so. I'm 99% certain that what we're seeing is that it
>>>> works on the versions of Windows that support conpty, but not the older
>>>> ones where the pywinpty library is *supposed* to fall back to using winpty.
>>>>
>>>> Hopefully Nikhil can get to the bottom of the problem with the
>>>> pywinpty folks.
>>>>
>>>>
>>>>
>>>>>
>>>>>>
>>>>>>> Nikhil is not able to reproduce the issue on Windows 10 with the
>>>>>>> latest version. So the issue is reproducible with older versions.
>>>>>>>
>>>>>>> Kind Regards,
>>>>>>> On Fri, Jun 11, 2021 at 1:28 PM Dave Page <[email protected]> wrote:
>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> On Fri, Jun 11, 2021 at 9:25 AM Fahar Abbas <
>>>>>>>> [email protected]> wrote:
>>>>>>>>
>>>>>>>>> Windows 10 Enterprise 2016 LTSB.
>>>>>>>>>
>>>>>>>>
>>>>>>>> Hmm, I assume that is version 1607. Can you test with 1809 please?
>>>>>>>> And if that doesn't work, try 1909.
>>>>>>>>
>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Fri, Jun 11, 2021 at 1:12 PM Dave Page <[email protected]>
>>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>>> Hi
>>>>>>>>>>
>>>>>>>>>> On Fri, Jun 11, 2021 at 7:44 AM Fahar Abbas <
>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>
>>>>>>>>>>> Hi,
>>>>>>>>>>>
>>>>>>>>>>> pgadmin4 is failing on following operating systems :
>>>>>>>>>>> Windows 2016
>>>>>>>>>>> Windows 2012
>>>>>>>>>>> Windows 07
>>>>>>>>>>> Windows 2008R2
>>>>>>>>>>> Windows 10 64
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> What version of Windows 10? I *think* conpty was introduced in
>>>>>>>>>> 1809.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> pgadmin4 is working fine in following operating system:
>>>>>>>>>>> Windows 2019
>>>>>>>>>>>
>>>>>>>>>>> On Thu, Jun 10, 2021 at 7:51 PM Dave Page <[email protected]>
>>>>>>>>>>> wrote:
>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> On Thu, Jun 10, 2021 at 2:22 PM Nikhil Mohite <
>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Hi Dave,
>>>>>>>>>>>>>
>>>>>>>>>>>>> On Thu, Jun 10, 2021 at 6:37 PM Dave Page <[email protected]>
>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> On Thu, Jun 10, 2021 at 2:00 PM Nikhil Mohite <
>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Hi Dave,
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> On Thu, Jun 10, 2021 at 5:22 PM Dave Page <[email protected]>
>>>>>>>>>>>>>>> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Hi
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> On Thu, Jun 10, 2021 at 11:08 AM Nikhil Mohite <
>>>>>>>>>>>>>>>> [email protected]> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> Hi Dave/ Team,
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>> We are facing an issue with winpty.dll on Windows server
>>>>>>>>>>>>>>>>> 2016 and Windows 7(these are platforms on which we have tested).
>>>>>>>>>>>>>>>>> Files required for winpty are present in the site-packages
>>>>>>>>>>>>>>>>> but still, it is unable to load the winpty.dll file on these specific
>>>>>>>>>>>>>>>>> platforms. We have tested it on Windows 10 pro and Windows server 2019 and
>>>>>>>>>>>>>>>>> it is working fine. (Also tried building the local pywinpty but unable to
>>>>>>>>>>>>>>>>> build it.) ref link for winPty
>>>>>>>>>>>>>>>>> https://github.com/rprichard/winpty#:~:text=winpty%20is%20a%20Windows%20software,in%20a%20Cygwin%2FM....
>>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> Does winpty.exe run, if executed from the command line
>>>>>>>>>>>>>>>> instead of pgAdmin? If not, does dependency walker show any missing
>>>>>>>>>>>>>>>> libraries that are required?
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> Not found the winpty.exe in site packages, but as per the
>>>>>>>>>>>>>>> winpty documents "winpty-agent.exe" will start the process with a new,
>>>>>>>>>>>>>>> hidden console window. It is not showing any error while installing the
>>>>>>>>>>>>>>> package. I tried to use it outside the pgAdmin but still facing the same
>>>>>>>>>>>>>>> error "Exception in import winpty DLL load failed while importing winpty:
>>>>>>>>>>>>>>> The specified procedure could not be found."(created a separate python
>>>>>>>>>>>>>>> environment for this)
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 1. if try to run winpty-agent.exe from the command line, it
>>>>>>>>>>>>>>> shows the user entered inputs on the same terminal, not showing any errors.
>>>>>>>>>>>>>>> [image: image.png]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> 2. I found winpty.exe in the other installed app (Git
>>>>>>>>>>>>>>> command line: C:\Program Files (x86)\Git\usr\bin) if try to run it through
>>>>>>>>>>>>>>> the command line not getting any error, it is showing user entered inputs
>>>>>>>>>>>>>>> on the same terminal. (It is not related to pgAdmin but just tried to check
>>>>>>>>>>>>>>> winpty.exe throwing any error or not)
>>>>>>>>>>>>>>> [image: image.png]
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Hmmm, that sounds oddly similar to an issue I had with
>>>>>>>>>>>>>> Kerberos on Windows when I was mucking around with that. I can't remember
>>>>>>>>>>>>>> the exact details, but as a test, does the problem go away if winpty.dll is
>>>>>>>>>>>>>> copied into the Windows system32 directory?
>>>>>>>>>>>>>>
>>>>>>>>>>>>> Tried it but still facing the same issue.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> OK, I had a fiddle around, and see the same thing. I can't do a
>>>>>>>>>>>> simple import of winpty. On 2019 it's fine. I tried various tricks that
>>>>>>>>>>>> I've used in the past to make sure libraries are found etc.
>>>>>>>>>>>>
>>>>>>>>>>>> Could this be because it's trying to use the conpty interface
>>>>>>>>>>>> in Windows 10 and above?
>>>>>>>>>>>>
>>>>>>>>>>>> If we can't get this to work tomorrow, I think it's fine to
>>>>>>>>>>>> simply hide the menu options and button if the server detects it's running
>>>>>>>>>>>> on an unsupported version of Windows. Of course, this should be documented.
>>>>>>>>>>>> We also need to make sure we know *exactly* what versions it does and does
>>>>>>>>>>>> not work on.
>>>>>>>>>>>>
>>>>>>>>>>>> --
>>>>>>>>>>>> Dave Page
>>>>>>>>>>>> Blog: https://pgsnake.blogspot.com
>>>>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>>>>
>>>>>>>>>>>> EDB: https://www.enterprisedb.com
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> --
>>>>>>>>>>> Fahar Abbas
>>>>>>>>>>> EnterpriseDB Corporation
>>>>>>>>>>> Phone Office: +92-51-835-8874
>>>>>>>>>>> Phone Direct: +92-51-8466803
>>>>>>>>>>> Mobile: +92-333-5409707
>>>>>>>>>>> Skype ID: *live:fahar.abbas*
>>>>>>>>>>> Website: www.enterprisedb.com
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> --
>>>>>>>>>> Dave Page
>>>>>>>>>> Blog: https://pgsnake.blogspot.com
>>>>>>>>>> Twitter: @pgsnake
>>>>>>>>>>
>>>>>>>>>> EDB: https://www.enterprisedb.com
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Fahar Abbas
>>>>>>>>> EnterpriseDB Corporation
>>>>>>>>> Phone Office: +92-51-835-8874
>>>>>>>>> Phone Direct: +92-51-8466803
>>>>>>>>> Mobile: +92-333-5409707
>>>>>>>>> Skype ID: *live:fahar.abbas*
>>>>>>>>> Website: www.enterprisedb.com
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> --
>>>>>>>> Dave Page
>>>>>>>> Blog: https://pgsnake.blogspot.com
>>>>>>>> Twitter: @pgsnake
>>>>>>>>
>>>>>>>> EDB: https://www.enterprisedb.com
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Fahar Abbas
>>>>>>> EnterpriseDB Corporation
>>>>>>> Phone Office: +92-51-835-8874
>>>>>>> Phone Direct: +92-51-8466803
>>>>>>> Mobile: +92-333-5409707
>>>>>>> Skype ID: *live:fahar.abbas*
>>>>>>> Website: www.enterprisedb.com
>>>>>>>
>>>>>>
>>>>>>
>>>>>> --
>>>>>> Dave Page
>>>>>> Blog: https://pgsnake.blogspot.com
>>>>>> Twitter: @pgsnake
>>>>>>
>>>>>> EDB: https://www.enterprisedb.com
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> Fahar Abbas
>>>>> EnterpriseDB Corporation
>>>>> Phone Office: +92-51-835-8874
>>>>> Phone Direct: +92-51-8466803
>>>>> Mobile: +92-333-5409707
>>>>> Skype ID: *live:fahar.abbas*
>>>>> Website: www.enterprisedb.com
>>>>>
>>>>
>>>>
>>>> --
>>>> Dave Page
>>>> Blog: https://pgsnake.blogspot.com
>>>> Twitter: @pgsnake
>>>>
>>>> EDB: https://www.enterprisedb.com
>>>>
>>>>
>
> --
> *Thanks & Regards*
> *Akshay Joshi*
> *pgAdmin Hacker | Principal Software Architect*
> *EDB Postgres <http://edbpostgres.com>*
>
> *Mobile: +91 976-788-8246*
>
Attachments:
[image/png] image.png (42.2K, 3-image.png)
download | view image
[image/png] image.png (26.6K, 4-image.png)
download | view image
[application/octet-stream] RM_2341_v9.patch (2.8K, 5-RM_2341_v9.patch)
download | inline diff:
diff --git a/web/pgadmin/tools/psql/__init__.py b/web/pgadmin/tools/psql/__init__.py
index cb10d5db..befd2e0e 100644
--- a/web/pgadmin/tools/psql/__init__.py
+++ b/web/pgadmin/tools/psql/__init__.py
@@ -495,8 +495,9 @@ def invalid_cmd():
def check_valid_cmd(user_input):
"""
- Check if user entered a valid cmd and \\! command is preset as a string
- only in current executing command. if \\! is present as command don't
+ Check if user entered a valid cmd and \\!, \\copy, \\e and \\ef command is
+ preset as a string only in current executing command.
+ if \\!, \\copy, \\e and \\ef is present as command don't
allow the execution of command.
:param user_input:
:return:
@@ -512,6 +513,12 @@ def check_valid_cmd(user_input):
if re.search("\\\!", sub_str):
stop_execution = False
# break
+ if re.search("\\\copy", sub_str.lower()):
+ stop_execution = False
+ if re.search("\\\e", sub_str.lower()):
+ stop_execution = False
+ if re.search("\\\ef", sub_str.lower()):
+ stop_execution = False
if stop_execution:
session_last_cmd[request.sid]['invalid_cmd'] = True
@@ -570,6 +577,30 @@ def enter_key_press(data):
not config.ALLOW_PSQL_SHELL_COMMANDS and\
not session_last_cmd[request.sid]['is_new_connection']:
check_valid_cmd(user_input)
+ elif (user_input.lower().startswith('\copy') and
+ re.match("^\\\copy$", user_input.lower()))\
+ and not config.ALLOW_PSQL_SHELL_COMMANDS:
+ invalid_cmd()
+ elif re.search("\\\copy", user_input.lower()) \
+ and not config.ALLOW_PSQL_SHELL_COMMANDS \
+ and not session_last_cmd[request.sid]['is_new_connection']:
+ check_valid_cmd(user_input)
+ elif (user_input.lower().startswith('\e') and
+ re.match("^\\\e$", user_input.lower())) and\
+ not config.ALLOW_PSQL_SHELL_COMMANDS:
+ invalid_cmd()
+ elif re.search("\\\e", user_input.lower()) \
+ and not config.ALLOW_PSQL_SHELL_COMMANDS \
+ and not session_last_cmd[request.sid]['is_new_connection']:
+ check_valid_cmd(user_input)
+ elif (user_input.lower().startswith('\ef') and
+ re.match("^\\\ef$", user_input.lower())) and\
+ not config.ALLOW_PSQL_SHELL_COMMANDS:
+ invalid_cmd()
+ elif re.search("\\\ef", user_input.lower()) \
+ and not config.ALLOW_PSQL_SHELL_COMMANDS \
+ and not session_last_cmd[request.sid]['is_new_connection']:
+ check_valid_cmd(user_input)
elif user_input == '\q' or user_input == 'q\\q' or user_input in ['exit',
'exit;']:
# If user enter \q to terminate the PSQL, emit the msg to
view thread (54+ 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], [email protected], [email protected]
Subject: Re: [pgAdmin][RM-2341]: Add menu option for starting PSQL
In-Reply-To: <CAOBg0AN8FjiTHS2tiLQYRYUAUBcMcohENmDjwOc6Oqb+2t4e6w@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