Try to use getent, so that it also works for NIS

setups.
This commit is contained in:
Werner Koch 2004-02-03 16:38:07 +00:00
parent 336e415f5b
commit 6788ede345
2 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,8 @@
2004-02-03 Werner Koch <wk@gnupg.org>
* addgnupghome: Try to use getent, so that it also works for NIS
setups.
2004-01-31 Marcus Brinkmann <marcus@g10code.de>
* gpgconf-comp.c: Some bug fixes, parse only defaults from the

View File

@ -14,6 +14,7 @@
PGM=addgnupghome
any_error=0
error () {
echo "$PGM: $*" >&2
any_error=1
@ -26,9 +27,9 @@ info () {
# Do it for one user
one_user () {
user="$1"
home=$(awk -F: -v n="$user" '$1 == n {print $6}' /etc/passwd )
home=$(${cat_passwd} | awk -F: -v n="$user" '$1 == n {print $6}')
if [ -z "$home" ]; then
if awk -F: -v n="$user" '$1 == n {exit 1}' /etc/passwd; then
if ${cat_passwd} | awk -F: -v n="$user" '$1 == n {exit 1}'; then
error "no such user \`$user'"
else
error "no home directory for user \`$user'"
@ -93,6 +94,14 @@ if [ -z "$1" ]; then
exit 1
fi
# Check whether we can use getent
if getent --help </dev/null >/dev/null 2>&1 ; then
cat_passwd='getent passwd'
else
cat_passwd='cat /etc/passwd'
info "please note that only users from /etc/passwd are checked"
fi
if [ ! -d /etc/skel/.gnupg ]; then
error "skeleton directory \`/etc/skel/.gnupg' does not exist"
exit 1
@ -101,7 +110,6 @@ cd "/etc/skel/.gnupg" || (error "error cd-ing to \`/etc/skel/.gnupg'"; exit 1)
filelist=$(find . \( -type f -or -type d \) -not -name '*~' -not -name . -print)
if ! umask 0077 ; then
error "error setting umask"
exit 1