ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject git commit: AMBARI-4111. RMF Fix Execute user attribute to work like su does (aonishuk)
Date Wed, 18 Dec 2013 17:37:08 GMT
Updated Branches:
  refs/heads/trunk 3c1c0a02e -> 7feffb0ce


AMBARI-4111. RMF Fix Execute user attribute to work like su does
(aonishuk)


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

Branch: refs/heads/trunk
Commit: 7feffb0ce84f4e098be1fdf953ce96c5e3891fb9
Parents: 3c1c0a0
Author: Andrew Onischuk <aonishuk@hortonworks.com>
Authored: Wed Dec 18 09:36:16 2013 -0800
Committer: Andrew Onischuk <aonishuk@hortonworks.com>
Committed: Wed Dec 18 09:36:55 2013 -0800

----------------------------------------------------------------------
 .../resource_management/core/providers/system.py     |  6 +-----
 .../main/python/resource_management/core/shell.py    | 15 +++++++++------
 .../services/OOZIE/package/scripts/oozie_service.py  |  5 +++--
 .../2.0._/services/YARN/package/scripts/service.py   |  4 ++--
 4 files changed, 15 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7feffb0c/ambari-agent/src/main/python/resource_management/core/providers/system.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/core/providers/system.py b/ambari-agent/src/main/python/resource_management/core/providers/system.py
index 81ae391..f5a04d3 100644
--- a/ambari-agent/src/main/python/resource_management/core/providers/system.py
+++ b/ambari-agent/src/main/python/resource_management/core/providers/system.py
@@ -208,10 +208,6 @@ def _preexec_fn(resource):
       gid = _coerce_gid(resource.group)
       os.setgid(gid)
       os.setegid(gid)
-    if resource.user:
-      uid = _coerce_uid(resource.user)
-      os.setuid(uid)
-      os.seteuid(uid)
 
   return preexec
 
@@ -234,7 +230,7 @@ class ExecuteProvider(Provider):
       try:
         shell.checked_call(self.resource.command, logoutput=self.resource.logoutput,
                             cwd=self.resource.cwd, env=self.resource.environment,
-                            preexec_fn=_preexec_fn(self.resource))
+                            preexec_fn=_preexec_fn(self.resource), user=self.resource.user)
         break
       except Fail as ex:
         if i == self.resource.tries-1: # last try

http://git-wip-us.apache.org/repos/asf/ambari/blob/7feffb0c/ambari-agent/src/main/python/resource_management/core/shell.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/resource_management/core/shell.py b/ambari-agent/src/main/python/resource_management/core/shell.py
index 3981bf3..6739974 100644
--- a/ambari-agent/src/main/python/resource_management/core/shell.py
+++ b/ambari-agent/src/main/python/resource_management/core/shell.py
@@ -30,16 +30,16 @@ from exceptions import Fail
 log = logging.getLogger("resource_management.provider")
 
 def checked_call(command, logoutput=False, 
-         cwd=None, env=None, preexec_fn=None):
-  return _call(command, logoutput, True, cwd, env, preexec_fn)
+         cwd=None, env=None, preexec_fn=None, user=None):
+  return _call(command, logoutput, True, cwd, env, preexec_fn, user)
 
 def call(command, logoutput=False, 
-         cwd=None, env=None, preexec_fn=None):
-  return _call(command, logoutput, False, cwd, env, preexec_fn)
+         cwd=None, env=None, preexec_fn=None, user=None):
+  return _call(command, logoutput, False, cwd, env, preexec_fn, user)
   
 
 def _call(command, logoutput=False, throw_on_failure=True, 
-         cwd=None, env=None, preexec_fn=None):
+         cwd=None, env=None, preexec_fn=None, user=None):
   """
   Execute shell command
   
@@ -54,7 +54,10 @@ def _call(command, logoutput=False, throw_on_failure=True,
   if isinstance(command, (list, tuple)):
     command = ' '.join(pipes.quote(x) for x in command)
 
-  command = ["/bin/bash","--login","-c", command]
+  if user:
+    command = ["su", "-", user, "-c", command]
+  else:
+    command = ["/bin/bash","--login","-c", command]
 
   proc = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT,
                           cwd=cwd, env=env, shell=False,

http://git-wip-us.apache.org/repos/asf/ambari/blob/7feffb0c/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
index 1f6096b..1d8767c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/OOZIE/package/scripts/oozie_service.py
@@ -7,7 +7,7 @@ def oozie_service(action = 'start'): # 'start' or 'stop'
   no_op_test = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}`
>/dev/null 2>&1")
   
   if action == 'start':
-    start_cmd = format("su - {oozie_user} -c  'cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-start.sh'")
+    start_cmd = format("cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-start.sh")
     
     if params.jdbc_driver_name == "com.mysql.jdbc.Driver" or params.jdbc_driver_name == "oracle.jdbc.driver.OracleDriver":
       db_connection_check_command = format("{java_home}/bin/java -cp {check_db_connection_jar}:{jdbc_driver_jar}
org.apache.ambari.server.DBConnectionVerification {oozie_jdbc_connection_url} {oozie_metastore_user_name}
{oozie_metastore_user_passwd} {jdbc_driver_name}")
@@ -32,7 +32,8 @@ def oozie_service(action = 'start'): # 'start' or 'stop'
     )
     
     Execute( start_cmd,
-      not_if  = no_op_test
+      user = params.oozie_user,
+      not_if  = no_op_test,
     )
   elif action == 'stop':
     stop_cmd  = format("su - {oozie_user} -c  'cd {oozie_tmp_dir} && /usr/lib/oozie/bin/oozie-stop.sh'
&& rm -f {pid_file}")

http://git-wip-us.apache.org/repos/asf/ambari/blob/7feffb0c/ambari-server/src/main/resources/stacks/HDP/2.0._/services/YARN/package/scripts/service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/YARN/package/scripts/service.py
b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/YARN/package/scripts/service.py
index 714f971..441ef6c 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0._/services/YARN/package/scripts/service.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0._/services/YARN/package/scripts/service.py
@@ -41,10 +41,10 @@ def service(
   cmd = format("export HADOOP_LIBEXEC_DIR={hadoop_libexec_dir} && {daemon} --config
{config_dir}")
 
   if action == 'start':
-    daemon_cmd = format("su - {usr} -c '{cmd} start {name}'")
+    daemon_cmd = format("{cmd} start {name}")
     no_op = format("ls {pid_file} >/dev/null 2>&1 && ps `cat {pid_file}`
>/dev/null 2>&1")
     Execute(daemon_cmd,
-            #user=usr,      #Fix execution from user
+            user=usr,
             not_if=no_op
     )
 


Mime
View raw message