You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ma...@apache.org on 2013/06/13 20:52:45 UTC

svn commit: r1492819 [1/3] - in /incubator/ambari/trunk/ambari-server: ./ etc/init.d/ sbin/ src/main/package/rpm/ src/main/python/ src/test/python/

Author: mahadev
Date: Thu Jun 13 18:52:44 2013
New Revision: 1492819

URL: http://svn.apache.org/r1492819
Log:
AMBARI-2370. Run Ambari Server as non-root. (Dmitry Lysnichenko via mahadev)

Removed:
    incubator/ambari/trunk/ambari-server/etc/init.d/ambari-server
Modified:
    incubator/ambari/trunk/ambari-server/pom.xml
    incubator/ambari/trunk/ambari-server/sbin/ambari-server
    incubator/ambari/trunk/ambari-server/src/main/package/rpm/postinstall.sh
    incubator/ambari/trunk/ambari-server/src/main/package/rpm/preremove.sh
    incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
    incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py

Modified: incubator/ambari/trunk/ambari-server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/pom.xml?rev=1492819&r1=1492818&r2=1492819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/pom.xml (original)
+++ incubator/ambari/trunk/ambari-server/pom.xml Thu Jun 13 18:52:44 2013
@@ -183,21 +183,18 @@
             <scriptFile>src/main/package/rpm/preremove.sh</scriptFile>
             <fileEncoding>utf-8</fileEncoding>
           </preremoveScriptlet>
-
+          <defaultFilemode>644</defaultFilemode>
+          <defaultDirmode>755</defaultDirmode>
+          <defaultUsername>root</defaultUsername>
+          <defaultGroupname>root</defaultGroupname>
           <mappings>
             <mapping>
               <directory>/usr/lib/ambari-server</directory>
               <dependency>
               </dependency>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
             </mapping>
             <mapping>
               <directory>/usr/lib/ambari-server/web</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>${basedir}/../ambari-web/public</location>
@@ -209,9 +206,6 @@
             </mapping>
             <mapping>
               <directory>/usr/lib/ambari-server</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>${project.build.directory}/${project.artifactId}-${project.version}.jar</location>
@@ -227,14 +221,6 @@
                 <source>
                   <location>src/main/python/ambari-server.py</location>
                 </source>
-              </sources>
-            </mapping>
-            <mapping>
-              <directory>/usr/sbin</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
-              <sources>
                 <source>
                   <location>sbin/ambari-server</location>
                 </source>
@@ -242,9 +228,6 @@
             </mapping>
             <mapping>
               <directory>/etc/ambari-server/conf</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <configuration>true</configuration>
               <sources>
                 <source>
@@ -268,9 +251,6 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/keys</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>conf/unix/ca.config</location>
@@ -279,7 +259,7 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/keys/db</directory>
-              <filemode>755</filemode>
+              <filemode>700</filemode>
               <username>root</username>
               <groupname>root</groupname>
               <sources>
@@ -290,21 +270,12 @@
             </mapping>
             <mapping>
               <directory>/var/run/ambari-server/bootstrap</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
             </mapping>
             <mapping>
               <directory>/var/log/ambari-server</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>src/main/resources/Ambari-DDL-Postgres-CREATE.sql</location>
@@ -341,15 +312,9 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources/upgrade</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources/upgrade/ddl</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>src/main/resources/upgrade/ddl/Ambari-DDL-Postgres-UPGRADE-1.3.0.sql</location>
@@ -365,9 +330,6 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources/upgrade/dml</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>src/main/resources/upgrade/dml/Ambari-DML-Postgres-UPGRADE_STACK.sql</location>
@@ -376,9 +338,6 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources/stacks/HDP</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>src/main/resources/stacks/HDP</location>
@@ -387,9 +346,6 @@
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources/stacks/HDPLocal</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <configuration>noreplace</configuration>
               <sources>
                 <source>
@@ -416,26 +372,9 @@
             </mapping>
             <mapping>
               <directory>/var/run/ambari-server</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
-            </mapping>
-            <mapping>
-              <directory>/etc/rc.d/init.d</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
-              <sources>
-                <source>
-                  <location>etc/init.d/ambari-server</location>
-                </source>
-              </sources>
             </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/resources</directory>
-              <filemode>755</filemode>
-              <username>root</username>
-              <groupname>root</groupname>
               <sources>
                 <source>
                   <location>../version</location>

Modified: incubator/ambari/trunk/ambari-server/sbin/ambari-server
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/sbin/ambari-server?rev=1492819&r1=1492818&r2=1492819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/sbin/ambari-server (original)
+++ incubator/ambari/trunk/ambari-server/sbin/ambari-server Thu Jun 13 18:52:44 2013
@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
+# chkconfig: 345 20 80
 # description: ambari-server daemon
 # processname: ambari-server
 
@@ -31,15 +32,15 @@ if [ -a /var/lib/ambari-server/ambari-en
   . /var/lib/ambari-server/ambari-env.sh
 fi
 
-if [ "x$PYTHON" == "x" ]; then
+if [ -z "$PYTHON" ]; then
   PYTHON=/usr/bin/python
 fi
 
-if [ "x$AMBARI_PASSPHRASE" == "x" ]; then
+if [ -z "$AMBARI_PASSPHRASE" ]; then
   AMBARI_PASSPHRASE="DEV"
 fi
 
-if [ "x$JAVA_HOME" != "x" ]; then
+if [ -n "$JAVA_HOME" ]; then
   export JAVA_HOME=$JAVA_HOME
 fi
 

Modified: incubator/ambari/trunk/ambari-server/src/main/package/rpm/postinstall.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/package/rpm/postinstall.sh?rev=1492819&r1=1492818&r2=1492819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/package/rpm/postinstall.sh (original)
+++ incubator/ambari/trunk/ambari-server/src/main/package/rpm/postinstall.sh Thu Jun 13 18:52:44 2013
@@ -13,4 +13,12 @@
 # See the License for the specific language governing permissions and
 # limitations under the License
 
+if [ -e "/etc/init.d/ambari-server" ];
+then # Check is needed for upgrade
+    # Remove link created by previous package version
+    rm /etc/init.d/ambari-server
+fi
+
+ln -s /usr/sbin/ambari-server /etc/init.d/ambari-server
+
 exit 0
\ No newline at end of file

Modified: incubator/ambari/trunk/ambari-server/src/main/package/rpm/preremove.sh
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/package/rpm/preremove.sh?rev=1492819&r1=1492818&r2=1492819&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/package/rpm/preremove.sh (original)
+++ incubator/ambari/trunk/ambari-server/src/main/package/rpm/preremove.sh Thu Jun 13 18:52:44 2013
@@ -23,6 +23,13 @@ then
     then
         mv /etc/ambari-server/conf.save /etc/ambari-server/conf_$(date '+%d_%m_%y_%H_%M').save
     fi
+
+    if [ -e "/etc/init.d/ambari-server" ];
+    then
+        # Remove link created during install
+        rm /etc/init.d/ambari-server
+    fi
+
     mv /etc/ambari-server/conf /etc/ambari-server/conf.save
 fi