Selaa lähdekoodia

AMBARI-2370. Run Ambari Server as non-root. (Dmitry Lysnichenko via mahadev)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1492819 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 12 vuotta sitten
vanhempi
commit
b90a20866e

+ 0 - 41
ambari-server/etc/init.d/ambari-server

@@ -1,41 +0,0 @@
-#!/usr/bin/env bash
-# chkconfig: 345 20 80
-# description: ambari-server daemon
-# processname: ambari-server
-
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#     http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-case "$1" in
-  start)
-        /usr/sbin/ambari-server $@
-        ;;
-  stop)
-        /usr/sbin/ambari-server $@
-        ;;
-  status)
-        /usr/sbin/ambari-server $@
-        ;;
-  restart)
-        $0 stop
-        $0 start
-        ;;
-  *)
-        echo "Usage: $0 {start|stop|status|restart}"
-        exit 1
-esac
-
-exit 0

+ 5 - 66
ambari-server/pom.xml

@@ -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>

+ 4 - 3
ambari-server/sbin/ambari-server

@@ -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-env.sh ]; then
   . /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
 

+ 8 - 0
ambari-server/src/main/package/rpm/postinstall.sh

@@ -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

+ 7 - 0
ambari-server/src/main/package/rpm/preremove.sh

@@ -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
 

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1381 - 1100
ambari-server/src/main/python/ambari-server.py


Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 511 - 147
ambari-server/src/test/python/TestAmbaryServer.py


Kaikkia tiedostoja ei voida näyttää, sillä liian monta tiedostoa muuttui tässä diffissä