You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ao...@apache.org on 2015/09/18 12:27:04 UTC

ambari git commit: AMBARI-13141. Properly handle not_if clause for command execution (aonishuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1.2 4e1cce23f -> b056638f8


AMBARI-13141. Properly handle not_if clause for command execution (aonishuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b056638f
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b056638f
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b056638f

Branch: refs/heads/branch-2.1.2
Commit: b056638f8579d11069d0d993849c1f693e07cee4
Parents: 4e1cce2
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Fri Sep 18 13:26:58 2015 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Fri Sep 18 13:26:58 2015 +0300

----------------------------------------------------------------------
 .../HIVE/0.12.0.2.0/package/scripts/hive.py             | 12 ++++++++++++
 1 file changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b056638f/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
index 7e35a57..39b3433 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive.py
@@ -35,6 +35,9 @@ from resource_management.libraries.resources.xml_config import XmlConfig
 from resource_management.libraries.functions.format import format
 from resource_management.core.exceptions import Fail
 from resource_management.core.shell import as_sudo
+from resource_management.core.shell import quote_bash_args
+from resource_management.core.logger import Logger
+from resource_management.core import utils
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
@@ -275,6 +278,15 @@ def hive(name=None):
                                         "-userName {hive_metastore_user_name} "
                                         "-passWord {hive_metastore_user_passwd!p}"), params.hive_user)
 
+      # HACK: in cases with quoted passwords and as_user (which does the quoting as well) !p won't work for hiding passwords.
+      # Fixing it with the hack below:
+      quoted_hive_metastore_user_passwd = quote_bash_args(quote_bash_args(params.hive_metastore_user_passwd))
+      if quoted_hive_metastore_user_passwd[0] == "'" and quoted_hive_metastore_user_passwd[-1] == "'" \
+          or quoted_hive_metastore_user_passwd[0] == '"' and quoted_hive_metastore_user_passwd[-1] == '"':
+        quoted_hive_metastore_user_passwd = quoted_hive_metastore_user_passwd[1:-1]
+      Logger.sensitive_strings[repr(check_schema_created_cmd)] = repr(check_schema_created_cmd.replace(
+          format("-passWord {quoted_hive_metastore_user_passwd}"), "-passWord " + utils.PASSWORDS_HIDE_STRING))
+
       Execute(create_schema_cmd,
               not_if = check_schema_created_cmd,
               user = params.hive_user