diff options
author | wpaul <wpaul@FreeBSD.org> | 1995-02-01 02:00:03 +0000 |
---|---|---|
committer | wpaul <wpaul@FreeBSD.org> | 1995-02-01 02:00:03 +0000 |
commit | a0d2144bc89a625f44cead983c107f5f7e99826e (patch) | |
tree | 7b18e49fd40547300eab42bf1b87e79e39615c06 /gnu/usr.sbin | |
parent | c66a9d7870c908a3f9a2d0da32276ccf7a48c234 (diff) | |
download | FreeBSD-src-a0d2144bc89a625f44cead983c107f5f7e99826e.zip FreeBSD-src-a0d2144bc89a625f44cead983c107f5f7e99826e.tar.gz |
Added Makefile.yp and mknetid, which are needed to rebuild NIS maps.
mknetid is a script. Both are installed by an afterinstall which as
been added to the main Makefile.
Diffstat (limited to 'gnu/usr.sbin')
-rw-r--r-- | gnu/usr.sbin/ypserv/Makefile | 11 | ||||
-rw-r--r-- | gnu/usr.sbin/ypserv/Makefile.yp | 312 | ||||
-rw-r--r-- | gnu/usr.sbin/ypserv/mknetid | 36 |
3 files changed, 358 insertions, 1 deletions
diff --git a/gnu/usr.sbin/ypserv/Makefile b/gnu/usr.sbin/ypserv/Makefile index 8310fee..00294c2 100644 --- a/gnu/usr.sbin/ypserv/Makefile +++ b/gnu/usr.sbin/ypserv/Makefile @@ -1,3 +1,4 @@ +# $Id$ # From: @(#)Makefile 8.3 (Berkeley) 4/2/94 PROG= ypserv @@ -8,7 +9,15 @@ CFLAGS+=-DINSTDIR='"/usr/libexec"' BINOWN= bin BINMODE=555 - +BINDIR= /usr/sbin MAN8= +afterinstall: /var/yp/Makefile /usr/libexec/mknetid + +/var/yp/Makefile: Makefile.yp + install -c -o bin -g bin -m 444 Makefile.yp /var/yp/Makefile + +/usr/libexec/mknetid: mknetid + install -c -o bin -g bin -m 555 mknetid /usr/libexec/mknetid + .include <bsd.prog.mk> diff --git a/gnu/usr.sbin/ypserv/Makefile.yp b/gnu/usr.sbin/ypserv/Makefile.yp new file mode 100644 index 0000000..564b01e --- /dev/null +++ b/gnu/usr.sbin/ypserv/Makefile.yp @@ -0,0 +1,312 @@ +# +# Makefile for the NIS database +# +# $Id$ +# +# This Makefile should only be run on the NIS master server of a domain. +# All updated maps will be pushed to all NIS slave servers listed in the +# /var/yp/ypservers file. Please make sure that the hostnames of all +# NIS servers in your domain are listed in /var/yp/ypservers. +# +# This Makefile can be modified to support more NIS maps if desired. +# + +# If this machine is an NIS master, comment out this next line so +# that changes to the NIS maps can be propagated to the slave servers. +# (By default we assume that we are only serving a small domain with +# only one server.) +# +NOPUSH = "True" + +# If you want to use a FreeBSD NIS server to serve non-FreeBSD clients +# (i.e. clients who expect the password field in the passwd maps to be +# valid) then uncomment this line. This will cause /var/yp/passwd to +# be generated with valid password fields. This is insecure: FreeBSD +# normally only serves the master.passwd maps (which have real encrypted +# passwords in them) to the superuser on other FreeBSD machines, but +# non-FreeBSD clients (e.g. SunOS, Solaris (without NIS+), IRIX, HP-UX, +# etc...) will only work properly in 'unsecure' mode. +# +# Note that you will also have to run yppasswdd in 'unsecure' mode +# (with the -u flag) if you use this option. +# +#UNSECURE = "True" + +# These are commands which this Makefile needs to properly rebuild the +# NIS databases. Don't change these unless you have a good reason. Also +# be sure not to place an @ in front of /usr/bin/awk: it isn't necessary +# and it'll break everything in sight. +# +AWK = /usr/bin/awk +RM = @/bin/rm -f +RCAT = /bin/cat +CAT = @$(RCAT) + +DBLOAD = /usr/sbin/yp_mkdb +MKNETID = /usr/libexec/mknetid +YPPUSH = /usr/bin/yppush +DOMAINNAME = `/bin/domainname` + +# These are the files from which the NIS databases are built. You may edit +# these to taste in the event that you wish to keep your NIS source files +# seperate from your NIS server's actual configuration files. Note that the +# NIS passwd and master.passwd files are stored in /var/yp: the server's +# real password database is not used by default. However, you may use +# the real /etc/passwd and /etc/master.passwd files by: +# +# - editing this Makefile +# - invoking yppasswdd without the -m and -o options (yppasswdd will +# automagically update the master.passwd, passwd, spwd.db and pwd.db +# files as needed) +# +# To add a user, edit /var/yp/master.passwd and type 'make'. The raw +# passwd file will be generated from the master.passwd file automagically. +# +ETHERS = /etc/ethers # ethernet addresses (for rarp) +HOSTS = /etc/hosts +NETWORKS = /etc/networks +PROTOCOLS = /etc/protocols +RPC = /etc/rpc +SERVICES = /etc/services +GROUP = /etc/group +PASSWD = /var/yp/passwd +MASTER = /var/yp/master.passwd +YPSERVERS = /var/yp/ypservers # Lists NIS master and slaves for a domain + +target: + @if [ ! -d `domainname` ]; then mkdir `domainname`; fi; \ + cd `domainname` ; make -f ../Makefile all + +# If you don't want some of these maps built, feel free to comment +# them out from this list. +# Note that we don't build an ethers map by default since FreeBSD +# doesn't have a rarpd (yet). +# +all: hosts networks protocols rpc services passwd group netid master.passwd \ + servers # ethers + +ethers: ethers.byname ethers.byaddr +hosts: hosts.byname hosts.byaddr +networks: networks.byaddr networks.byname +protocols: protocols.bynumber protocols.byname +rpc: rpc.byname rpc.bynumber +services: services.byname +passwd: passwd.byname passwd.byuid +group: group.byname group.bygid +netid: netid.byname +servers: ypservers +master.passwd: master.passwd.byname master.passwd.byuid + + +ypservers: $(YPSERVERS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(YPSERVERS) | \ + $(AWK) '{ if ($$1 != "" && $$1 != "#") print $$0"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + +ethers.byname: $(ETHERS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(ETHERS) | \ + $(AWK) '{ if ($$1 != "" && $$1 != "#") print $$2"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +ethers.byaddr: $(ETHERS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(ETHERS) | \ + $(AWK) '{ if ($$1 != "" && $$1 != "#") print $$1"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +hosts.byname: $(HOSTS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(HOSTS) | \ + $(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "#"; n++) \ + print $$n"\t"$$0 }' $^ | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +hosts.byaddr: $(HOSTS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(HOSTS) | \ + $(AWK) '$$1 !~ "#" { print $$1"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +networks.byname: $(NETWORKS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(NETWORKS) | \ + $(AWK) \ + '$$1 !~ "#" { print $$1"\t"$$0; \ + for (n=3; n<=NF && $$n !~ "#"; n++) \ + print $$n"\t"$$0 \ + }' $^ | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +networks.byaddr: $(NETWORKS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(NETWORKS) | \ + $(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +protocols.byname: $(PROTOCOLS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(PROTOCOLS) | \ + $(AWK) \ + '$$1 !~ "#" { print $$1"\t"$$0; \ + for (n=3; n<=NF && $$n !~ "#"; n++) \ + print $$n"\t"$$0 \ + }' $^ | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +protocols.bynumber: $(PROTOCOLS) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(PROTOCOLS) | \ + $(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +rpc.byname: $(RPC) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(RPC) | \ + $(AWK) \ + '$$1 !~ "#" { print $$1"\t"$$0; \ + for (n=3; n<=NF && $$n !~ "#"; n++) \ + print $$n"\t"$$0 \ + }' $^ | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +rpc.bynumber: $(RPC) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(RPC) | \ + $(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +services.byname: $(SERVICES) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(SERVICES) | \ + $(AWK) \ + '$$1 !~ "#" { print $$1"\t"$$0; \ + for (n=3; n<=NF && $$n !~ "#"; n++) \ + print $$n"\t"$$0 \ + }' $^ | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +$(PASSWD): $(MASTER) + @echo "Creating new $@ file from $(MASTER)..." + $(RM) $@ + @if [ ! $(UNSECURE) ]; then \ + $(RCAT) $(MASTER) | \ + $(AWK) -F: '{if ($$1 != "+") \ + print $$1":*:"$$3":"$$7":"$$8":"$$9":"$$10}' $^ \ + > $(PASSWD) ; \ + else $(RCAT) $(MASTER) | \ + $(AWK) -F: '{if ($$1 != "+") \ + print $$1":"$$2":"$$3":"$$7":"$$8":"$$9":"$$10}' $^ \ + > $(PASSWD) ; fi + + +passwd.byname: $(PASSWD) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(PASSWD) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +passwd.byuid: $(PASSWD) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(PASSWD) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +group.byname: $(GROUP) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(GROUP) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +group.bygid: $(GROUP) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(GROUP) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +netid.byname: $(GROUP) $(PASSWD) + @echo "Updating $@..." + $(RM) $@ + @$(MKNETID) $(PASSWD) $(GROUP) `basename \`pwd\`` \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +master.passwd.byname: $(MASTER) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(MASTER) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi + + +master.passwd.byuid: $(MASTER) + @echo "Updating $@..." + $(RM) $@ + $(CAT) $(MASTER) | \ + $(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \ + | $(DBLOAD) - $@ + @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi + @if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi diff --git a/gnu/usr.sbin/ypserv/mknetid b/gnu/usr.sbin/ypserv/mknetid new file mode 100644 index 0000000..6619b5d --- /dev/null +++ b/gnu/usr.sbin/ypserv/mknetid @@ -0,0 +1,36 @@ +#!/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 |