Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 cd85ccd0a -> 8527f7619
  refs/heads/trunk aa1177cb9 -> 01820d6f0


AMBARI-14247. Most tasks fail in non-root in case of advanced sudoers settings 
(aonishuk)


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

Branch: refs/heads/trunk
Commit: 01820d6f0ba80a778f46a2edf3430e66ba3405ec
Parents: aa1177c
Author: Andrew Onishuk <[email protected]>
Authored: Mon Dec 7 15:58:37 2015 +0200
Committer: Andrew Onishuk <[email protected]>
Committed: Mon Dec 7 15:58:37 2015 +0200

----------------------------------------------------------------------
 .../src/main/python/resource_management/core/sudo.py        | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/01820d6f/ambari-common/src/main/python/resource_management/core/sudo.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/sudo.py 
b/ambari-common/src/main/python/resource_management/core/sudo.py
index 1a83ec5..46fa9d0 100644
--- a/ambari-common/src/main/python/resource_management/core/sudo.py
+++ b/ambari-common/src/main/python/resource_management/core/sudo.py
@@ -28,6 +28,7 @@ from resource_management.core import shell
 from resource_management.core.logger import Logger
 from resource_management.core.exceptions import Fail
 from ambari_commons.os_check import OSCheck
+import subprocess
 
 if os.geteuid() == 0:
   def chown(path, owner, group):
@@ -206,8 +207,12 @@ else:
   def stat(path):
     class Stat:
       def __init__(self, path):
-        out = shell.checked_call(["stat", "-c", "%u %g %a", path], 
sudo=True)[1]
-        uid_str, gid_str, mode_str = out.split(' ')
+        cmd = ["stat", "-c", "%u %g %a", path]
+        code, out, err = shell.checked_call(cmd, sudo=True, 
stderr=subprocess.PIPE)
+        values = out.split(' ')
+        if len(values) != 3:
+          raise Fail("Execution of '{0}' returned unexpected output. 
{2}\n{3}".format(cmd, code, err, out))
+        uid_str, gid_str, mode_str = values
         self.st_uid, self.st_gid, self.st_mode = int(uid_str), int(gid_str), 
int(mode_str, 8)
   
     return Stat(path)

Reply via email to