浏览代码

AMBARI-11664. Unable to Install Hive Due To Invalid sudo Module Function (aonishuk)

Andrew Onishuk 10 年之前
父节点
当前提交
7a75fb0a3e
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      ambari-common/src/main/python/resource_management/core/sudo.py

+ 7 - 0
ambari-common/src/main/python/resource_management/core/sudo.py

@@ -88,6 +88,9 @@ if os.geteuid() == 0:
   def path_lexists(path):
     return os.path.lexists(path)
   
+  def readlink(path):
+    return os.readlink(path)
+  
   def path_isfile(path):
     return os.path.isfile(path)
 
@@ -187,6 +190,10 @@ else:
   def path_lexists(path):
     return (shell.call(["test", "-L", path], sudo=True)[0] == 0)
   
+  # os.readlink
+  def readlink(path):
+    return shell.checked_call(["readlink", path], sudo=True)[1].strip()
+  
   # os.path.isfile
   def path_isfile(path):
     return (shell.call(["test", "-f", path], sudo=True)[0] == 0)