You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2015/03/01 22:09:29 UTC

[2/2] ambari git commit: AMBARI-9867. Permission denied on ubuntu server with UMASK=027 (dlysnichenko)

AMBARI-9867. Permission denied on ubuntu server with UMASK=027 (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: dae0dadca97c5eb0ac47cec786f631a434ec0386
Parents: 0270df8
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Sun Mar 1 23:07:33 2015 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Sun Mar 1 23:08:25 2015 +0200

----------------------------------------------------------------------
 .../0.12.0.2.0/package/scripts/hive_service.py  | 16 +++++++--
 .../0.5.0.2.2/package/scripts/service_check.py  | 33 ++++++++++++------
 .../stacks/2.1/HIVE/test_hive_metastore.py      | 36 ++++++++++++++++++++
 3 files changed, 72 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/dae0dadc/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
index b729afd..a66b0c8 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
@@ -20,6 +20,7 @@ limitations under the License.
 
 from resource_management import *
 import sys
+import os
 import time
 from resource_management.core import shell
 
@@ -54,9 +55,18 @@ def hive_service(name, action='start', rolling_restart=False):
       hive_kinit_cmd = format("{kinit_path_local} -kt {hive_server2_keytab} {hive_principal}; ")
       Execute(hive_kinit_cmd, user=params.hive_user)
 
-    Execute(demon_cmd, user=params.hive_user,
-      environment={'HADOOP_HOME': params.hadoop_home}, path=params.execute_path,
-      not_if=process_id_exists_command )
+    # need tuple to run as sudo if (need if UMASK is not 022)
+    oldmask = os.umask (022)
+    os.umask (oldmask)
+    if oldmask == 027:
+      Execute(tuple(demon_cmd.split()), user=params.hive_user,
+        environment={'HADOOP_HOME': params.hadoop_home}, path=params.execute_path,
+        not_if=process_id_exists_command,
+        sudo=True )
+    else:
+      Execute(demon_cmd, user=params.hive_user,
+        environment={'HADOOP_HOME': params.hadoop_home}, path=params.execute_path,
+        not_if=process_id_exists_command )      
 
     if params.hive_jdbc_driver == "com.mysql.jdbc.Driver" or \
        params.hive_jdbc_driver == "org.postgresql.Driver" or \

http://git-wip-us.apache.org/repos/asf/ambari/blob/dae0dadc/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
index f30c19f..1d20290 100644
--- a/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/KNOX/0.5.0.2.2/package/scripts/service_check.py
@@ -20,6 +20,7 @@ limitations under the License.
 
 from resource_management import *
 import sys
+import os
 from ambari_commons import OSConst
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 
@@ -41,7 +42,7 @@ class KnoxServiceCheck(Script):
         validateKnoxFileName = "validateKnoxStatus.py"
         validateKnoxFilePath = format("{tmp_dir}/{validateKnoxFileName}")
         python_executable = sys.executable
-        validateStatusCmd = format("{python_executable} {validateKnoxFilePath} -p {knox_host_port} -n {knox_host_name}")
+        validateStatusCmd = (format("{python_executable}"), format("{validateKnoxFilePath}"), "-p", format("{knox_host_port}"), "-n", format("{knox_host_name}"))
         if params.security_enabled:
           kinit_cmd = format("{kinit_path_local} -kt {smoke_user_keytab} {smokeuser_principal};")
           smoke_cmd = format("{kinit_cmd} {validateStatusCmd}")
@@ -55,15 +56,27 @@ class KnoxServiceCheck(Script):
           content=StaticFile(validateKnoxFileName),
           mode=0755
           )
-
-        Execute(smoke_cmd,
-          tries=3,
-          try_sleep=5,
-          path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
-          user=params.smokeuser,
-          timeout=5,
-          logoutput=True
-        )
+        oldmask = os.umask (022)
+        os.umask (oldmask)
+        if oldmask == 027:
+          Execute(smoke_cmd,
+            tries=3,
+            try_sleep=5,
+            path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+            user=params.smokeuser,
+            timeout=5,
+            logoutput=True,
+            sudo=True
+          )
+        else:  
+          Execute(smoke_cmd,
+            tries=3,
+            try_sleep=5,
+            path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin',
+            user=params.smokeuser,
+            timeout=5,
+            logoutput=True
+          )
 
 if __name__ == "__main__":
     KnoxServiceCheck().execute()
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/dae0dadc/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
index 7f5b803..aa8bc7f 100644
--- a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
@@ -60,6 +60,42 @@ class TestHiveMetastore(RMFTestCase):
 
     self.assertNoMoreResources()
 
+  @patch("os.umask")
+  def test_start_default_umask_027(self, umask_mock):
+    umask_mock.return_value = 027
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py",
+                       classname = "HiveMetastore",
+                       command = "start",
+                       config_file="../../2.1/configs/default.json",
+                       hdp_stack_version = self.STACK_VERSION,
+                       target = RMFTestCase.TARGET_COMMON_SERVICES
+    )
+
+    self.assert_configure_default()
+    self.assertResourceCalled('Execute', (u'env',
+                                          u'HADOOP_HOME=/usr',
+                                          u'JAVA_HOME=/usr/jdk64/jdk1.7.0_45',
+                                          u'/tmp/start_metastore_script',
+                                          u'/var/log/hive/hive.out',
+                                          u'/var/log/hive/hive.log',
+                                          u'/var/run/hive/hive.pid',
+                                          u'/etc/hive/conf.server',
+                                          u'/var/log/hive'),
+                              environment = {'HADOOP_HOME': '/usr'},
+                              not_if = 'ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `cat /var/run/hive/hive.pid` >/dev/null 2>&1',
+                              sudo = True,
+                              user = 'hive',
+                              path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
+                              )
+
+    self.assertResourceCalled('Execute', '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/lib/hive/lib//mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification \'jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true\' hive aaa com.mysql.jdbc.Driver',
+                              path = ['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'],
+                              tries = 5,
+                              try_sleep = 10,
+                              )
+
+    self.assertNoMoreResources()
+
   def test_stop_default(self):
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_metastore.py",
                        classname = "HiveMetastore",