Jelajahi Sumber

AMBARI-9829. Ranger usersync process needs to be run as root (aonishuk)

Andrew Onishuk 10 tahun lalu
induk
melakukan
6ed6784c36

+ 1 - 1
ambari-common/src/main/python/resource_management/core/shell.py

@@ -138,7 +138,7 @@ def _call(command, logoutput=None, throw_on_failure=True,
     command = command.replace(placeholder, replacement.format(env_str=env_str))
 
   master_fd, slave_fd = pty.openpty()
-  Logger.info(command) # TODO: remove this before commit
+
   # --noprofile is used to preserve PATH set for ambari-agent
   subprocess_command = ["/bin/bash","--login","--noprofile","-c", command]
   proc = subprocess.Popen(subprocess_command, bufsize=1, stdout=slave_fd, stderr=subprocess.STDOUT,

+ 3 - 2
ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_service.py

@@ -27,7 +27,8 @@ def ranger_service(name):
     Execute(format('{params.ranger_start}'), user=params.unix_user, not_if=no_op_test)
   elif name == 'ranger_usersync':
     no_op_test = format('ps -ef | grep proc_rangerusersync | grep -v grep')
-    Execute(params.usersync_start, 
+    # Usersync requires to be run as root.
+    Execute((params.usersync_start,), 
             not_if=no_op_test,
-            user=params.unix_user,
+            sudo=True,
     )

+ 1 - 1
ambari-server/src/main/resources/common-services/RANGER/0.4.0/package/scripts/ranger_usersync.py

@@ -40,7 +40,7 @@ class RangerUsersync(Script):
     import params
 
     env.set_params(params)
-    Execute(format('{params.usersync_stop}'))
+    Execute((params.usersync_stop,), sudo=True)
 
   def pre_rolling_restart(self, env):
     import params

+ 1 - 1
ambari-server/src/test/python/stacks/2.2/RANGER/test_ranger_usersync.py

@@ -43,5 +43,5 @@ class TestRangerUserSync(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES)
 
     self.assertTrue(setup_usersync_mock.called)
-    self.assertResourceCalled("Execute", "/usr/bin/ranger-usersync-stop")
+    self.assertResourceCalled("Execute", ("/usr/bin/ranger-usersync-stop",), sudo=True)
     self.assertResourceCalled("Execute", "hdp-select set ranger-usersync 2.2.2.0-2399")