summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
Diffstat (limited to 'extra')
-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