Index: univention-home-mounter/univention-mount-homedir =================================================================== --- univention-home-mounter/univention-mount-homedir (Revision 43351) +++ univention-home-mounter/univention-mount-homedir (Arbeitskopie) @@ -3,7 +3,7 @@ # Univention Home Mounter # mount the homedir # -# Copyright 2004-2012 Univention GmbH +# Copyright 2004-2013 Univention GmbH # # http://www.univention.de/ # @@ -43,37 +43,39 @@ # as the uid and deliver consequently a wrong or an empty result. numeric="" -numeric=`echo "$username" | egrep ^[0-9]+$` || true -first_numeric=`echo "$username" | egrep ^[0-9].*$` || true +numeric=`egrep ^[0-9]+$ <<<"$username" || true +first_numeric=`egrep ^[0-9].*$ <<<"$username" || true -eval "$(univention-config-registry shell ldap/hostdn)" +ldap_hostdn=$(univention-config-registry get ldap/hostdn) if [ -z "$numeric" ] && [ -z "$first_numeric" ]; then pw_entry=`getent passwd "$username"` - for i in 1 2 3 4 5 6; do - pw_fields[$i]=`echo $pw_entry | awk -F ':' '{ print $'$i' }'` - done + OIFS="$IFS" + IFS=':' + set -- $pw_entry + IFS="$OIFS" - HOME=${pw_fields[6]} - UID_NUMBER=${pw_fields[3]} - GID_NUMBER=${pw_fields[4]} + HOME="$6" + UID_NUMBER="$3" + GID_NUMBER="$4" else ldap_result=`ldapsearch -x -ZZ -D "$ldap_hostdn" -y /etc/machine.secret -LLL uid="$username" homeDirectory uidNumber gidNumber` if [ $? = 0 ]; then - HOME=`echo "$ldap_result" | grep ^homeDirectory | sed -e 's|homeDirectory: ||'` - UID_NUMBER=`echo "$ldap_result" | grep ^uidNumber | sed -e 's|uidNumber: ||'` - GID_NUMBER=`echo "$ldap_result" | grep ^gidNumber | sed -e 's|gidNumber: ||'` + HOME=$(sed -ne 's|^homeDirectory: ||p' <<<"$ldap_result") + UID_NUMBER=$(sed -ne 's|^uidNumber: ||p' <<<"$ldap_result") + GID_NUMBER=$(sed -ne 's|^gidNumber: ||p' <<<"$ldap_result") else pw_entry=`grep ^"$username" /etc/passwd` - for i in 1 2 3 4 5 6; do - pw_fields[$i]=`echo $pw_entry | awk -F ':' '{ print $'$i' }'` - done + OIFS="$IFS" + IFS=':' + set -- $pw_entry + IFS="$OIFS" - HOME=${pw_fields[6]} - UID_NUMBER=${pw_fields[3]} - GID_NUMBER=${pw_fields[4]} + HOME="$6" + UID_NUMBER="$3" + GID_NUMBER="$4" fi fi @@ -105,9 +107,9 @@ # doesn't exist yet, this will fail. We could probably login via krsh before # to make sure it exists and mount it then. Running krsh here isn't pretty # though. -homeattr=`ldapsearch -x -ZZ -D "$ldap_hostdn" -y /etc/machine.secret -z 1 "(&(objectClass=posixAccount)(objectClass=automount)(uid=$USER))" automountInformation -LLL | /usr/bin/ldapsearch-wrapper | sed -n 's/automountInformation: \(.*\)/\1/p'` +homeattr=`ldapsearch -x -ZZLLL -D "$ldap_hostdn" -y /etc/machine.secret -z 1 "(&(objectClass=posixAccount)(objectClass=automount)(uid=$USER))" automountInformation -LLL | /usr/bin/ldapsearch-wrapper | sed -n 's/automountInformation: \(.*\)/\1/p'` if [ -z "$homeattr" ]; then - eval "$(univention-config-registry shell server/role)" + server_role=$(univention-config-registry get server/role) if [ -z "$server_role" ]; then # Thin Client @@ -119,7 +121,7 @@ fi # Otherwise look for servers eval "$(univention-config-registry shell ldap/mydn)" - for server in `univention_policy_result -D "$ldap_hostdn" -y /etc/machine.secret -s "$ldap_mydn" | grep "univentionFileServer" | sed -e 's|.*univentionFileServer=||' | sed -e 's|"||g'`; do + for server in `univention_policy_result -D "$ldap_hostdn" -y /etc/machine.secret -s "$ldap_mydn" | sed -en 's|"||g;s|.*univentionFileServer=||p'`; do if [ -n "$server" ]; then # mount in heartbeat-situations needs to be done from /ha/home, but normally /home fits if mount -t nfs $server:/home /ramdisk/home || mount -t nfs $server:/ha/home /ramdisk/home @@ -162,8 +164,8 @@ REALHOME="$HOME" fi -host=`echo "$homeattr" | sed 's/.* \([^ ]*\):\([^ ]*\)/\1/'` -path=`echo "$homeattr" | sed 's/.* \([^ ]*\):\([^ ]*\)/\2/'` +host=`sed 's/.* \([^ ]*\):\([^ ]*\)/\1/' <<<"$homeattr"` +path=`sed 's/.* \([^ ]*\):\([^ ]*\)/\2/' <<<"$homeattr"` if [ -z "$host" ] || [ -z "$path" ]; then logger "Bad information in LDAP. Not mounting home directory." exit 1