This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git


The following commit(s) were added to refs/heads/master by this push:
     new b17446818 IMPALA-11755: Fix impala-shell --ldap_password_cmd with 
python 3
b17446818 is described below

commit b17446818c548487fa5d71c678088ed35eed5bc8
Author: Michael Smith <[email protected]>
AuthorDate: Mon Nov 28 11:29:58 2022 -0800

    IMPALA-11755: Fix impala-shell --ldap_password_cmd with python 3
    
    subprocess.Popen returns a byte string in Python 3, which serializes
    incorrectly when sending it as the LDAP password and causes `endswith`
    to error with
    > first arg must be bytes or a tuple of bytes, not str
    
    Fixes `impala-shell --ldap_password_cmd` run with Python 3 by decoding
    bytes as unicode.
    
    Testing: confirmed that I can successfully authenticate via LDAP with
    impala-shell in Python 2.7 and Python 3.8.
    
    Change-Id: I3638d6f8d3ed7184495dbe3512d9e5ceb0ee8c45
    Reviewed-on: http://gerrit.cloudera.org:8080/19283
    Reviewed-by: Wenzhe Zhou <[email protected]>
    Tested-by: Impala Public Jenkins <[email protected]>
---
 shell/impala_shell.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/shell/impala_shell.py b/shell/impala_shell.py
index 542e5319f..0ba0e62da 100755
--- a/shell/impala_shell.py
+++ b/shell/impala_shell.py
@@ -2099,6 +2099,9 @@ def impala_shell_main():
         print("Error retrieving LDAP password (command was '%s', error was: "
               "'%s')" % (options.ldap_password_cmd, stderr.strip()), 
file=sys.stderr)
         raise FatalShellException()
+      if sys.version_info.major > 2:
+        # Ensure we can manipulate the password as a string later.
+        options.ldap_password = options.ldap_password.decode('utf-8')
     except Exception as e:
       print("Error retrieving LDAP password (command was: '%s', exception "
             "was: '%s')" % (options.ldap_password_cmd, e), file=sys.stderr)

Reply via email to