Permalink
Browse files

Improve home directory detection

Reading the home directory from /etc/passwd will fail if the user data is for example taken from ldap. The proper way to obtain this information is to query the nss via getent.
  • Loading branch information...
kasimon committed Mar 16, 2017
1 parent d315776 commit 4cb67c099a0229a398ddcc7296c6df448a707742
Showing with 1 addition and 1 deletion.
  1. +1 −1 pre-receive
View
@@ -3,7 +3,7 @@
# Puppet attempts to source ~/.puppet and will error if $HOME is not set
if [[ -z $HOME ]]
then
HOME="$(grep "${USER}:" /etc/passwd | awk -F ':' '{print $6}')"
HOME="$(getent passwd "${USER}" | awk -F ':' '{print $6}')"
export HOME
fi

0 comments on commit 4cb67c0

Please sign in to comment.