This is an automated email from the ASF dual-hosted git repository.
hapylestat pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git
The following commit(s) were added to refs/heads/branch-2.7 by this push:
new f7b740c AMBARI-25296 alert_ldap_password for Hive service check does
not allow single-quotes (ihorlukianov) (#3002)
f7b740c is described below
commit f7b740c43e46eb0354418f721661d8436d490db1
Author: Ihor Lukianov <[email protected]>
AuthorDate: Fri Jun 14 12:20:00 2019 +0300
AMBARI-25296 alert_ldap_password for Hive service check does not allow
single-quotes (ihorlukianov) (#3002)
AMBARI-25296 alert_ldap_password for Hive service check does not allow
single-quotes (ihorlukianov)
---
.../resource_management/libraries/functions/hive_check.py | 12 ++++++++----
.../test/python/stacks/2.0.6/HIVE/test_hive_service_check.py | 10 +++++-----
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git
a/ambari-common/src/main/python/resource_management/libraries/functions/hive_check.py
b/ambari-common/src/main/python/resource_management/libraries/functions/hive_check.py
index da9b417..fa3eb7e 100644
---
a/ambari-common/src/main/python/resource_management/libraries/functions/hive_check.py
+++
b/ambari-common/src/main/python/resource_management/libraries/functions/hive_check.py
@@ -22,6 +22,7 @@ from resource_management.core import global_lock
from resource_management.core.resources import Execute
from resource_management.libraries.functions import format
from resource_management.core.signal_utils import TerminateStrategy
+from resource_management.core.shell import quote_bash_args
def check_thrift_port_sasl(address, port, hive_auth="NOSASL", key=None,
kinitcmd=None, smokeuser='ambari-qa',
@@ -51,10 +52,13 @@ def check_thrift_port_sasl(address, port,
hive_auth="NOSASL", key=None, kinitcmd
if hive_auth == "NOSASL":
beeline_url.append('auth=noSasl')
- credential_str = ""
+ credential_str = "-n {hive_user}"
+
# append username and password for LDAP
if hive_auth == "LDAP":
- credential_str = "-n '{ldap_username}' -p '{ldap_password!p}'"
+ # password might contain special characters that need to be escaped
+ quoted_ldap_password = quote_bash_args(ldap_password)
+ credential_str = "-n {ldap_username} -p {quoted_ldap_password!p}"
# append url according to ssl configuration
if ssl and ssl_keystore is not None and ssl_password is not None:
@@ -74,9 +78,9 @@ def check_thrift_port_sasl(address, port, hive_auth="NOSASL",
key=None, kinitcmd
# -n the user to connect as (ignored when using the hive principal in the
URL, can be different from the user running the beeline command)
# -e ';' executes a SQL commmand of NOOP
- cmd = ("beeline -n %s -u '%s' %s -e ';' 2>&1 | awk '{print}' | grep -i " + \
+ cmd = ("beeline -u '%s' %s -e ';' 2>&1 | awk '{print}' | grep -i " + \
"-e 'Connected to:' -e 'Transaction isolation:' -e 'inactive HS2
instance; use service discovery'") % \
- (format(hive_user), format(";".join(beeline_url)),
format(credential_str))
+ (format(";".join(beeline_url)), format(credential_str))
Execute(cmd,
user=smokeuser,
diff --git
a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
index 39a58ed..4dc57c2 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
@@ -46,7 +46,7 @@ class TestServiceCheck(RMFTestCase):
stack_version = self.STACK_VERSION,
target = RMFTestCase.TARGET_COMMON_SERVICES
)
- self.assertResourceCalled('Execute', "beeline -n hive -u
'jdbc:hive2://c6402.ambari.apache.org:10000/;transportMode=binary;auth=noSasl'
-e ';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction
isolation:' -e 'inactive HS2 instance; use service discovery'",
+ self.assertResourceCalled('Execute', "beeline -u
'jdbc:hive2://c6402.ambari.apache.org:10000/;transportMode=binary;auth=noSasl'
-n hive -e ';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e
'Transaction isolation:' -e 'inactive HS2 instance; use service discovery'",
path = ['/bin/', '/usr/bin/',
'/usr/lib/hive/bin/', '/usr/sbin/'],
user = 'ambari-qa',
timeout = 30,
@@ -165,7 +165,7 @@ class TestServiceCheck(RMFTestCase):
self.assertResourceCalled('Execute', '/usr/bin/kinit -kt
/etc/security/keytabs/smokeuser.headless.keytab [email protected]; ',
user = 'ambari-qa',
)
- self.assertResourceCalled('Execute', "beeline -n hive -u
'jdbc:hive2://c6402.ambari.apache.org:10000/;transportMode=binary;principal=hive/[email protected]'
-e ';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction
isolation:' -e 'inactive HS2 instance; use service discovery'",
+ self.assertResourceCalled('Execute', "beeline -u
'jdbc:hive2://c6402.ambari.apache.org:10000/;transportMode=binary;principal=hive/[email protected]'
-n hive -e ';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e
'Transaction isolation:' -e 'inactive HS2 instance; use service discovery'",
path = ['/bin/', '/usr/bin/',
'/usr/lib/hive/bin/', '/usr/sbin/'],
user = 'ambari-qa',
timeout = 30,
@@ -283,7 +283,7 @@ class TestServiceCheck(RMFTestCase):
stack_version = self.STACK_VERSION,
target = RMFTestCase.TARGET_COMMON_SERVICES)
- self.assertResourceCalled('Execute', "beeline -n hive -u
'jdbc:hive2://c6402.ambari.apache.org:10010/;transportMode=binary' -e ';' 2>&1
| awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction isolation:' -e
'inactive HS2 instance; use service discovery'",
+ self.assertResourceCalled('Execute', "beeline -u
'jdbc:hive2://c6402.ambari.apache.org:10010/;transportMode=binary' -n hive -e
';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction
isolation:' -e 'inactive HS2 instance; use service discovery'",
path = ['/bin/', '/usr/bin/', '/usr/lib/hive/bin/', '/usr/sbin/'],
timeout = 30,
user = 'ambari-qa',
@@ -322,7 +322,7 @@ class TestServiceCheck(RMFTestCase):
target = RMFTestCase.TARGET_COMMON_SERVICES)
self.assertResourceCalled('Execute',
- "beeline -n hive -u
'jdbc:hive2://c6402.ambari.apache.org:10010/;transportMode=binary' -e ';' 2>&1
| awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction isolation:' -e
'inactive HS2 instance; use service discovery'",
+ "beeline -u
'jdbc:hive2://c6402.ambari.apache.org:10010/;transportMode=binary' -n hive -e
';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction
isolation:' -e 'inactive HS2 instance; use service discovery'",
path = ['/bin/', '/usr/bin/', '/usr/lib/hive/bin/', '/usr/sbin/'],
timeout = 30,
user = 'ambari-qa',
@@ -330,7 +330,7 @@ class TestServiceCheck(RMFTestCase):
)
self.assertResourceCalled('Execute',
- "beeline -n hive -u
'jdbc:hive2://c6402.ambari.apache.org:10500/;transportMode=binary' -e ';' 2>&1
| awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction isolation:' -e
'inactive HS2 instance; use service discovery'",
+ "beeline -u
'jdbc:hive2://c6402.ambari.apache.org:10500/;transportMode=binary' -n hive -e
';' 2>&1 | awk '{print}' | grep -i -e 'Connected to:' -e 'Transaction
isolation:' -e 'inactive HS2 instance; use service discovery'",
path = ['/bin/', '/usr/bin/', '/usr/lib/hive/bin/', '/usr/sbin/'],
timeout = 30,
user = 'ambari-qa',