summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2005-08-23 23:44:49 +0000
committerMike Frysinger <vapier@gentoo.org>2005-08-23 23:44:49 +0000
commitb1ce9e53a3e6b06267fee6d7b86ab7f5f5ba0f80 (patch)
tree39314507cee53c249c362faf0c2a79c9ea9b3bc0
parent4b54d5bd133cd8c7a2e39aaa6bb7db0fccbd5003 (diff)
downloaduClibc-alpine-b1ce9e53a3e6b06267fee6d7b86ab7f5f5ba0f80.tar.bz2
uClibc-alpine-b1ce9e53a3e6b06267fee6d7b86ab7f5f5ba0f80.tar.xz
some updates from psm to better mirror glibc getent behavior
-rwxr-xr-xextra/scripts/getent19
1 files changed, 17 insertions, 2 deletions
diff --git a/extra/scripts/getent b/extra/scripts/getent
index c02149498..3a96d74f6 100755
--- a/extra/scripts/getent
+++ b/extra/scripts/getent
@@ -1,5 +1,5 @@
#!/bin/sh
-# $Header: /var/cvs/uClibc/extra/scripts/getent,v 1.2 2005/02/02 14:18:01 solar Exp $
+# Script to replicate the `getent` binary that comes with glibc
search_entry() {
if [ -e "$1" ] ; then
@@ -11,9 +11,19 @@ search_entry() {
fi
}
+if [ -z "$1" ] ; then
+ echo "getent: wrong number of arguments" 1>&2
+ exit 1
+fi
+
file="/etc/$1"
string="dummy"
+if [ ! -f "$file" ] ; then
+ echo "Unknown database: $1" 1>&2
+ exit 1
+fi
+
#aliases|ethers|group|hosts|netgroup|networks|passwd|protocols|rpc|services|shadow)
# dns based search is not supported for hosts|networks
# ethers|netgroup (not done, needed)?
@@ -48,6 +58,11 @@ case $1 in
;;
esac
-search_entry $file $2
+if [ -z "$2" ] ; then
+ cat $file
+ retval=$?
+else
+ search_entry "$file" "$2"
+fi
exit $retval