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/12/07 14:58:45 UTC

[2/2] ambari git commit: AMBARI-14247. Most tasks fail in non-root in case of advanced sudoers settings (aonishuk)

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/8527f761
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/8527f761
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/8527f761

Branch: refs/heads/branch-2.2
Commit: 8527f761993f2379036bd14a49f9247674961f8a
Parents: cd85ccd
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Mon Dec 7 15:58:40 2015 +0200
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Mon Dec 7 15:58:40 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/8527f761/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)