FS#61228 - [pgadmin4] 3.6-1 python3-pycryptodome patch encoding failure
Attached to Project:
Community Packages
Opened by mal (mal) - Tuesday, 01 January 2019, 09:02 GMT
Last edited by Balló György (City-busz) - Friday, 29 March 2019, 11:54 GMT
Opened by mal (mal) - Tuesday, 01 January 2019, 09:02 GMT
Last edited by Balló György (City-busz) - Friday, 29 March 2019, 11:54 GMT
Details
Description:
The change to using native python libraries re-found the same error as https://bugs.archlinux.org/task/60332 with a different cause. pgadmin4 3.6-1 python-pycryptodome 3.7.2-1 Log: 2019-01-01 03:39:56,598: ERROR flask.app: Object type <class 'str'> cannot be passed to C code Traceback (most recent call last): File "/usr/lib/pgadmin4/web/pgadmin/utils/driver/psycopg2/server_manager.py", line 409, in create_ssh_tunnel tunnel_password = decrypt(tunnel_password, user.password) File "/usr/lib/pgadmin4/web/pgadmin/utils/crypto.py", line 54, in decrypt cipher = AES.new(pad(key), AES.MODE_CFB, iv) File "/usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 232, in new return _create_cipher(sys.modules[__name__], key, mode, *args, **kwargs) File "/usr/lib/python3.7/site-packages/Crypto/Cipher/__init__.py", line 79, in _create_cipher return modes[mode](factory, **kwargs) File "/usr/lib/python3.7/site-packages/Crypto/Cipher/_mode_cfb.py", line 270, in _create_cfb_cipher cipher_state = factory._create_base_cipher(kwargs) File "/usr/lib/python3.7/site-packages/Crypto/Cipher/AES.py", line 103, in _create_base_cipher result = start_operation(c_uint8_ptr(key), File "/usr/lib/python3.7/site-packages/Crypto/Util/_raw_api.py", line 144, in c_uint8_ptr raise TypeError("Object type %s cannot be passed to C code" % type(data)) TypeError: Object type <class 'str'> cannot be passed to C code 2019-01-01 03:39:56,602: ERROR flask.app: Could not connected to server(#6) - 'REDACTED'. Error: Failed to decrypt the SSH tunnel password. Error: Object type <class 'str'> cannot be passed to C code Steps to reproduce: - Have a server accessed via an SSH tunnel using a key with a password that's not saved by pgadmin - Attempt to connect to the server Fix: pgadmin4-compatibility-with-python3-pycryptodome.patch, instead of patching psycopg2, should be adding encoding for the key on line 54 of crypto.py: - cipher = AES.new(pad(key), AES.MODE_CFB, iv) + cipher = AES.new(pad(key.encode('utf-8')), AES.MODE_CFB, iv) Thanks! |
This task depends upon
Closed by Balló György (City-busz)
Friday, 29 March 2019, 11:54 GMT
Reason for closing: Fixed
Additional comments about closing: pgadmin4 4.2-1
Friday, 29 March 2019, 11:54 GMT
Reason for closing: Fixed
Additional comments about closing: pgadmin4 4.2-1
Attachment adds mal's suggested change to the patch file.
I strongly recommend against managing system-wide things with pip regardless, since if you do that they'll never get updated, and can interfere with the package manager.
This problem still exists with pgadmin4 4.1-1, and the following does work, but is probably not the best solution:
pacman -Rdd python-pycryptodome
pikaur -S python-pycrypto