freebsd-src/usr.sbin/ypserv/mknetid
Bill Paul 778c7b1c1c Import the new, non-GPL ypserv, written by yours truly. Functionally
equivalent to the old ypserv, except that it doesn't support the
-p [port] option to force the server to use a particular port.

The server stubs and yp.h header file are auto-generated from the yp.x
protocol definition file. The auto-generated XDR routines in libc/yp
are also used. The database access code has been broken out into a
seperate module so that other NIS utilities (ypxfr in particular)
can use it.

Note that the old mknetid script is being temporarily moved here; it
will be replaced by an mknetid program which will eventually have
a home under /usr/src/libexec. (The existing script is actually
somewhat broken -- it doesn't handle hosts -- but this isn't a big
deal at this point since the netid.byname map is really only useful
fopr Secure RPC, which we don't have yet.)
1995-12-16 20:54:17 +00:00

36 lines
875 B
Bash
Executable file

#!/bin/sh
#
# Produce netid.byname map file
#
# Written by O.Kirch, 1994.
#
PASSWD=$1
GROUP=$2
DOMAIN=$3
tempsed=/tmp/pass.$$
# First, get all login/uid info from passwd file
grep -v '^+:' $PASSWD |
awk -F: '{ printf "s/^%s:/%s/\n", $1, $3; }' >$tempsed
# next one is a giant pipe:
grep -v '^+:' $GROUP |
grep -v ':[ ]*$' |
sed 's/^[^:]*:[^:]*:\([0-9]*\):\(.*\)/\1,\2/' |
awk -F, '{ for (n=2; n<=NF; n++)
if ($n != "") print $n":\t"$1;
}' |
sed -f $tempsed | sort | grep -v ':' |
awk 'BEGIN { uid=-1; }
{ if (uid == $1) {
groups=groups","$2;
} else {
if (uid != -1)
print uid":"groups;
uid=$1; groups=$2;
}
}
END { if (uid != -1) printf("%s:%s\n", uid, groups); }' |
sed "s/\(.*\):/unix.\1@$DOMAIN &/"
rm -f $tempsed
exit 0