fix #52: when trying to get user home directory in exec_safe_bind_hooks, the grep and sed commands doesn't output the right result when multiple lines occours.

Now, we use awk to do so
This commit is contained in:
Anathema 2011-10-25 19:55:48 +02:00 committed by Jaromil
parent 350eeb7483
commit e7e71aa002

View File

@ -724,7 +724,7 @@ exec_safe_bind_hooks() {
fi
local MOUNTPOINT="${1}"
local ME=${SUDO_USER:-$(whoami)}
local HOME=$(grep $ME /etc/passwd | sed "s/^${ME}:.*:.*:.*:.*:\([\/a-z]*\):.*$/\1/" 2>/dev/null)
local HOME=$(awk -v a="$ME" -F ':' '{if ($1 == a) print $6}' /etc/passwd 2>/dev/null)
if [ $? -ne 0 ]; then
error "how pitiful! A tomb, and no HOME"
return 1