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 2017/06/30 11:55:21 UTC

[2/2] ambari git commit: AMBARI-21379. Ambari Agent doesn't start as non-root user with "ambari-agent start" logged in as root (aonishuk)

AMBARI-21379. Ambari Agent doesn't start as non-root user with "ambari-agent start" logged in as root (aonishuk)


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

Branch: refs/heads/branch-2.5
Commit: f8d01eba988bfb364130505dd18ae09af0f78643
Parents: 2f162ca
Author: Andrew Onishuk <ao...@hortonworks.com>
Authored: Fri Jun 30 14:51:46 2017 +0300
Committer: Andrew Onishuk <ao...@hortonworks.com>
Committed: Fri Jun 30 14:51:46 2017 +0300

----------------------------------------------------------------------
 ambari-agent/conf/unix/install-helper.sh  |  8 ++++++++
 ambari-agent/etc/init.d/ambari-agent      | 22 +---------------------
 ambari-agent/pom.xml                      | 11 -----------
 ambari-agent/src/packages/tarball/all.xml |  2 +-
 4 files changed, 10 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f8d01eba/ambari-agent/conf/unix/install-helper.sh
----------------------------------------------------------------------
diff --git a/ambari-agent/conf/unix/install-helper.sh b/ambari-agent/conf/unix/install-helper.sh
index ee5b62b..58daf81 100644
--- a/ambari-agent/conf/unix/install-helper.sh
+++ b/ambari-agent/conf/unix/install-helper.sh
@@ -31,6 +31,8 @@ SIMPLEJSON_AGENT_DIR="/usr/lib/ambari-agent/lib/ambari_simplejson"
 AMBARI_AGENT="/usr/lib/python2.6/site-packages/ambari_agent"
 PYTHON_WRAPER_TARGET="/usr/bin/ambari-python-wrap"
 AMBARI_AGENT_VAR="/var/lib/ambari-agent"
+AMBARI_AGENT_BINARY="/etc/init.d/ambari-agent"
+AMBARI_AGENT_BINARY_SYMLINK="/usr/sbin/ambari-agent"
 
 clean_pyc_files(){
   # cleaning old *.pyc files
@@ -46,6 +48,10 @@ do_install(){
     cp -f /etc/ambari-agent/conf.save/* /etc/ambari-agent/conf
     mv /etc/ambari-agent/conf.save /etc/ambari-agent/conf_$(date '+%d_%m_%y_%H_%M').save
   fi
+
+  # setting up /usr/sbin/ambari-agent symlink
+  rm -f "$AMBARI_AGENT_BINARY_SYMLINK"
+  ln -s "$AMBARI_AGENT_BINARY" "$AMBARI_AGENT_BINARY_SYMLINK"
     
   # setting ambari_commons shared resource
   rm -rf "$OLD_COMMON_DIR"
@@ -124,6 +130,8 @@ do_remove(){
 
   clean_pyc_files
 
+  rm -f "$AMBARI_AGENT_BINARY_SYMLINK"
+
   if [ -d "/etc/ambari-agent/conf.save" ]; then
     mv /etc/ambari-agent/conf.save /etc/ambari-agent/conf_$(date '+%d_%m_%y_%H_%M').save
   fi

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8d01eba/ambari-agent/etc/init.d/ambari-agent
----------------------------------------------------------------------
diff --git a/ambari-agent/etc/init.d/ambari-agent b/ambari-agent/etc/init.d/ambari-agent
index 044f86d..b70de85 100644
--- a/ambari-agent/etc/init.d/ambari-agent
+++ b/ambari-agent/etc/init.d/ambari-agent
@@ -36,26 +36,6 @@ else
   command_prefx="bash -c"
 fi
 
-case "$1" in
-  start)
-        $command_prefx "/usr/sbin/ambari-agent $@"
-        ;;
-  stop)
-        $command_prefx "/usr/sbin/ambari-agent $@"
-        ;;
-  status)
-        $command_prefx "/usr/sbin/ambari-agent $@"
-        ;;
-  restart)
-        $command_prefx "$0 stop"
-        $command_prefx "$0 start"
-        ;;
-  reset)
-        /usr/sbin/ambari-agent $@
-        ;;
-  *)
-        echo "Usage: $0 {start|stop|status|restart|reset <server_hostname>}"
-        exit 1
-esac
+$command_prefx "/var/lib/ambari-agent/bin/ambari-agent $@"
 
 exit $?

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8d01eba/ambari-agent/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/pom.xml b/ambari-agent/pom.xml
index 8de433c..475adf2 100644
--- a/ambari-agent/pom.xml
+++ b/ambari-agent/pom.xml
@@ -272,17 +272,6 @@
               </sources>
             </mapping>
            <mapping>
-              <directory>/usr/sbin</directory>
-              <username>root</username>
-              <groupname>root</groupname>
-              <directoryIncluded>false</directoryIncluded> <!-- avoid managing /usr/sbin -->
-              <sources>
-                <source>
-                  <location>${project.build.directory}${dirsep}${project.artifactId}-${project.version}/usr/sbin</location>
-                </source>
-              </sources>
-            </mapping>
-           <mapping>
               <directory>/usr/lib/ambari-agent</directory>
               <filemode>755</filemode>
               <username>root</username>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f8d01eba/ambari-agent/src/packages/tarball/all.xml
----------------------------------------------------------------------
diff --git a/ambari-agent/src/packages/tarball/all.xml b/ambari-agent/src/packages/tarball/all.xml
index 363941a..10fe0ce 100644
--- a/ambari-agent/src/packages/tarball/all.xml
+++ b/ambari-agent/src/packages/tarball/all.xml
@@ -167,7 +167,7 @@
     <file>
       <fileMode>755</fileMode>
       <source>${basedir}/target/src/ambari-agent</source>
-      <outputDirectory>/usr/sbin</outputDirectory>
+      <outputDirectory>/var/lib/ambari-agent/bin</outputDirectory>
     </file>
     <file>
       <fileMode>700</fileMode>