Browse Source

AMBARI-12406. Can't download client configs with ambari-server installed using non root user (aonishuk)

Andrew Onishuk 10 years ago
parent
commit
5d894952e0

+ 1 - 1
ambari-server/conf/unix/ambari-env.sh

@@ -16,6 +16,6 @@
 
 AMBARI_PASSHPHRASE="DEV"
 export AMBARI_JVM_ARGS=$AMBARI_JVM_ARGS' -Xms512m -Xmx2048m -Djava.security.auth.login.config=/etc/ambari-server/conf/krb5JAASLogin.conf -Djava.security.krb5.conf=/etc/krb5.conf -Djavax.security.auth.useSubjectCredsOnly=false'
-export PATH=$PATH:/var/lib/ambari-agent
+export PATH=$PATH:/var/lib/ambari-server
 # to add additional directory or jar to server classpath use SERVER_CLASSPATH variable
 # export SERVER_CLASSPATH=/etc/hadoop/conf/secure

+ 41 - 0
ambari-server/conf/unix/ambari-sudo.sh

@@ -0,0 +1,41 @@
+#!/bin/bash
+# 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
+
+# since ambari-server doesn't have sudo permissions this file is just a mock file
+# which always runs commands without sudo.
+ENV=()
+SUDO_ARGS=()
+
+for i ; do
+  if [[ "$i" == *"="* ]] ; then
+    ENV+=("$i")
+    shift
+  elif [[ "$i" == "-"* ]] ; then
+    SUDO_ARGS+=("$i")
+    shift
+  else
+    break
+  fi
+done
+  
+#echo "sudo arguments: ${SUDO_ARGS[@]}"
+#echo "env: ${ENV[@]}"
+#echo "args: $@"
+
+if [ "$ENV" ] ; then
+  export "${ENV[@]}"
+fi
+
+"$@"

+ 22 - 0
ambari-server/pom.xml

@@ -411,6 +411,17 @@
                 </source>
               </sources>
             </mapping>
+            <mapping>
+              <directory>/var/lib/ambari-server/</directory>
+              <filemode>700</filemode>
+              <username>root</username>
+              <groupname>root</groupname>
+              <sources>
+                <source>
+                  <location>conf/unix/ambari-sudo.sh</location>
+                </source>
+              </sources>
+            </mapping>
             <mapping>
               <directory>/var/lib/ambari-server/</directory>
               <filemode>700</filemode>
@@ -799,6 +810,17 @@
                 <filemode>700</filemode>
               </mapper>
             </data>
+            <data>
+              <src>conf/unix/ambari-sudo.sh</src>
+              <type>file</type>
+              <mapper>
+                <type>perm</type>
+                <prefix>/var/lib/ambari-server/</prefix>
+                <user>root</user>
+                <group>root</group>
+                <filemode>700</filemode>
+              </mapper>
+            </data>
             <data>
               <src>conf/unix/install-helper.sh</src>
               <type>file</type>

+ 1 - 0
ambari-server/src/main/python/ambari_server/serverConfiguration.py

@@ -293,6 +293,7 @@ class ServerConfigDefaultsLinux(ServerConfigDefaults):
       ("/var/run/ambari-server/", "755", "{0}", False),
       ("/var/run/ambari-server/bootstrap", "755", "{0}", False),
       ("/var/lib/ambari-server/ambari-env.sh", "700", "{0}", False),
+      ("/var/lib/ambari-server/ambari-sudo.sh", "700", "{0}", False),
       ("/var/lib/ambari-server/keys/", "600", "{0}", True),
       ("/var/lib/ambari-server/keys/", "700", "{0}", False),
       ("/var/lib/ambari-server/keys/db/", "700", "{0}", False),