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/136dc8ee Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/136dc8ee Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/136dc8ee Branch: refs/heads/branch-2.1 Commit: 136dc8eedfdd2c33f3ce9a75436805af79a955a4 Parents: 4e1cce2 Author: Andrew Onishuk <aonis...@hortonworks.com> Authored: Fri Sep 18 13:24:13 2015 +0300 Committer: Andrew Onishuk <aonis...@hortonworks.com> Committed: Fri Sep 18 13:24:13 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/136dc8ee/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