Author: swagle
Date: Mon May  6 22:18:29 2013
New Revision: 1479702

URL: http://svn.apache.org/r1479702
Log:
AMBARI-2081. changeUid.sh failing during installation. (swagle)

Added:
    
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeToSecureUid.sh
Removed:
    
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeUid.sh
Modified:
    incubator/ambari/trunk/CHANGES.txt
    
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp

Modified: incubator/ambari/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1479702&r1=1479701&r2=1479702&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Mon May  6 22:18:29 2013
@@ -828,6 +828,8 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-2081. changeUid.sh failing during installation. (swagle)
+
  AMBARI-2079. Can't change service configuration if heartbeat lost from
  service component host. (yusaku)
 

Added: 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeToSecureUid.sh
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeToSecureUid.sh?rev=1479702&view=auto
==============================================================================
--- 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeToSecureUid.sh
 (added)
+++ 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/files/changeToSecureUid.sh
 Mon May  6 22:18:29 2013
@@ -0,0 +1,58 @@
+#!/bin/sh
+#
+#
+# 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.
+#
+
+username=$1
+newUid=$2
+dirs=$3
+
+function find_available_uid() {
+ for ((i=1001; i<=2000; i++))
+ do
+   grep -q $i /etc/passwd
+   if [ "$?" != 0 ]
+   then
+    newUid=$i
+    break
+   fi
+ done
+}
+
+grep -q $i /etc/passwd
+if [ "$?" != 0 ]
+then
+  echo "Uid $newUid is available for $username"
+else
+  newUid=0
+  find_available_uid
+fi
+
+if [ $newUid == 0 ]
+then
+  echo "Failed to find Uid between 1000 and 2000"
+  exit 1
+fi
+
+dir_array=($(echo $dirs | sed 's/,/\n/g'))
+old_uid=$(id -u $username)
+echo "Changing uid of $username from $old_uid to $newUid"
+echo "Changing directory permisions for ${dir_array[@]}"
+usermod -u $newUid $username && for dir in ${dir_array[@]} ; do chown -Rh 
$newUid $dir ; done
+exit 0

Modified: 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp
URL: 
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp?rev=1479702&r1=1479701&r2=1479702&view=diff
==============================================================================
--- 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp
 (original)
+++ 
incubator/ambari/trunk/ambari-agent/src/main/puppet/modules/hdp/manifests/init.pp
 Mon May  6 22:18:29 2013
@@ -160,11 +160,11 @@ class hdp::create_smoke_user()
   $changeUid_path = "/tmp/changeUid.sh"
   $smoke_user_dirs = 
"/tmp/${smoke_user},/home/${smoke_user},/var/spool/mail/${smoke_user}"
   $cmd_set_uid = "$changeUid_path ${smoke_user} ${secure_uid} 
${smoke_user_dirs}"
-  $cmd_set_uid_check = "id -u ${smoke_user} | grep ${secure_uid}"
+  $cmd_set_uid_check = "test $(id -u ${smoke_user}) -gt 1000"
 
   file { $changeUid_path :
     ensure => present,
-    source => "puppet:///modules/hdp/changeUid.sh",
+    source => "puppet:///modules/hdp/changeToSecureUid.sh",
     mode => '0755'
   }
 


Reply via email to