freebsd-skq/usr.sbin/ypserv/Makefile.yp
Bill Paul b3e932340d Makefile.yp:
- Add a 'pushpw' target that only yppushes the various passwd maps
  and sends a YPPROC_CLEAR to the local ypserv. This will be used by
  rpc.yppasswdd once I merge in the in-place update changes.

yp_access.c:

- Make the yp_access() function print RPC program and procedure numbers
  that it doesn't know about in literal form. This will allow it to work
  with other prgrams that it doesn't know about, like rpc.ypxfrd I'm going
  to import shortly.

yp_dblookup.c:

- Take out the __inline keywords. They weren't really helping me anyway.

- Somehow I broke yp_next() when DB_CACHE wasn't #defined. Fix it.

- Also fix potential case where yp_next() might loop forever; make sure
  it checks the return values of all the (dbp->seq)()/R_NEXT calls that
  it does as well as comparing keys.
1996-06-05 02:01:31 +00:00

490 lines
15 KiB
Makefile

#
# Makefile for the NIS databases
#
# $Id: Makefile.yp,v 1.5 1996/06/03 16:24:32 wpaul Exp $
#
# 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 $YPDIR/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.
#
#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
MV = @/bin/mv -f
RCAT = /bin/cat
CAT = @$(RCAT)
SED = /usr/bin/sed
DBLOAD = /usr/sbin/yp_mkdb -m `hostname`
MKNETID = /usr/libexec/mknetid
MKALIASES = /usr/libexec/mkaliases
NEWALIASES = /usr/bin/newaliases
YPPUSH = /usr/sbin/yppush
.if !defined(UPDATE_DOMAIN)
DOMAIN = `/bin/domainname`
.else
DOMAIN = $(UPDATE_DOMAIN)
.endif
REVNETGROUP = /usr/libexec/revnetgroup
NFILE = /tmp/ypmake
TMP = `$(RCAT) $(NFILE)`
# It is advisable to create a seperate directory to contain the
# source files used to generate your NIS maps. If you intent to
# support multiple domains, something like /src/dir/$DOMAIN
# would work well.
YPSRCDIR = /etc
YPDIR = /var/yp
YPMAPDIR = $(YPDIR)/$(DOMAIN)
# 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:
#
#
# - invoking yppasswdd without the -m option (yppasswdd will use
# /etc/master.passwd if no alternate master.passwd file is specified
# and do a 'pwd_mkdb' as needed).
# - Specifying the location of the master.passwd file using the
# MASTER_PASSWD variable, i.e.:
#
# # make MASTER_PASSWD=/path/to/some/other/master.passwd
#
# - (optionally): editing this Makefile to change the default location.
#
# To add a user, edit $(YPDIR)/master.passwd and type 'make'. The raw
# passwd file will be generated from the master.passwd file automagically.
#
ETHERS = $(YPSRCDIR)/ethers # ethernet addresses (for rarpd)
BOOTPARAMS= $(YPSRCDIR)/bootparams # for booting Sun boxes (bootparamd)
HOSTS = $(YPSRCDIR)/hosts
NETWORKS = $(YPSRCDIR)/networks
PROTOCOLS = $(YPSRCDIR)/protocols
RPC = $(YPSRCDIR)/rpc
SERVICES = $(YPSRCDIR)/services
GROUP = $(YPSRCDIR)/group
ALIASES = $(YPSRCDIR)/aliases
NETGROUP = $(YPDIR)/netgroup
PASSWD = $(YPDIR)/passwd
.if !defined(MASTER_PASSWD)
MASTER = $(YPDIR)/master.passwd
.else
MASTER = $(MASTER_PASSWD)
.endif
YPSERVERS = $(YPDIR)/ypservers # List of all NIS servers for a domain
PUBLICKEY = $(YPSRCDIR)/publickey
target:
@$(RM) $(NFILE)
@if [ ! -d $(DOMAIN) ]; then mkdir $(DOMAIN); fi; \
cd $(DOMAIN) ; echo "NIS Map update started on `date` for domain $(DOMAIN)" ; \
make -f ../Makefile all; echo "NIS Map update completed."
# 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 the ethers or boorparams maps by default
# since /etc/ethers and /etc/bootparams are not likely to be present
# on all systems.
#
all: master.passwd passwd hosts group networks protocols rpc \
services servers netid # aliases publickey netgroup ethers bootparam
ethers: ethers.byname ethers.byaddr
bootparam: bootparams
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
netgrp: netgroup
netid: netid.byname
servers: ypservers
publickey: publickey.byname
aliases: mail.aliases
master.passwd: master.passwd.byname master.passwd.byuid
#
# This is a special target used only when doing in-place updates with
# rpc.yppasswdd. In this case, the maps will be updated by the rpc.yppasswdd
# server and won't need to be remade. They will have to be pushed to the
# slaves however. Calling this target implicitly insures that this will
# happen.
#
pushpw:
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byname ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) master.passwd.byuid ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byname ; fi
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) passwd.byuid ; fi
mail.aliases: $(ALIASES)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(ALIASES) | \
$(SED) -e "/^#/d" -e s/#.*$$// -e "/^ *$$/d" |\
$(MKALIASES) \
| $(DBLOAD) -i $(ALIASES) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@$(NEWALIASES)
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
ypservers: $(YPSERVERS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(YPSERVERS) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#") print $$0"\t"$$0 }' $^ \
| $(DBLOAD) -i $(YPSERVERS) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
ethers.byname: $(ETHERS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(ETHERS) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$2"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) -i $(ETHERS) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
ethers.byaddr: $(ETHERS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(ETHERS) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$1"\t"$$0 }' $^ | $(DBLOAD) -i $(ETHERS) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
bootparams: $(BOOTPARAMS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(BOOTPARAMS) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$0 }' $^ | $(DBLOAD) -i $(BOOTPARAMS) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
netgroup: $(NETGROUP) netgroup.byhost netgroup.byuser
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(NETGROUP) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
@$(MAKE) -f ../Makefile netid
netgroup.byhost: $(NETGROUP)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(NETGROUP) | $(REVNETGROUP) -h -f $(NETGROUP) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
netgroup.byuser: $(NETGROUP)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(NETGROUP) | $(REVNETGROUP) -u -f $(NETGROUP) | \
$(AWK) '{ if ($$1 != "" && $$1 != "#" && $$1 != "+") \
print $$0 }' $^ | $(DBLOAD) -i $(NETGROUP) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
hosts.byname: $(HOSTS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(HOSTS) | \
$(AWK) '/^[0-9]/ { for (n=2; n<=NF && $$n !~ "#"; n++) \
print $$n"\t"$$0 }' $^ | $(DBLOAD) -i $(HOSTS) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
@$(MAKE) -f ../Makefile netid
hosts.byaddr: $(HOSTS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(HOSTS) | \
$(AWK) '$$1 !~ "#" { print $$1"\t"$$0 }' $^ \
| $(DBLOAD) -i $(HOSTS) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
@$(MAKE) -f ../Makefile netid
networks.byname: $(NETWORKS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(NETWORKS) | \
$(AWK) \
'$$1 !~ "#" { print $$1"\t"$$0; \
for (n=3; n<=NF && $$n !~ "#"; n++) \
print $$n"\t"$$0 \
}' $^ | $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
networks.byaddr: $(NETWORKS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(NETWORKS) | \
$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
| $(DBLOAD) -i $(NETWORKS) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
protocols.byname: $(PROTOCOLS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(PROTOCOLS) | \
$(AWK) \
'$$1 !~ "#" { print $$1"\t"$$0; \
for (n=3; n<=NF && $$n !~ "#"; n++) \
print $$n"\t"$$0 \
}' $^ | $(DBLOAD) -i $(PROTOCOLS) \
-o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
protocols.bynumber: $(PROTOCOLS)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(PROTOCOLS) | \
$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
| $(DBLOAD) -i $(PROTOCOLS) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
rpc.byname: $(RPC)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(RPC) | \
$(AWK) \
'$$1 !~ "#" { print $$1"\t"$$0; \
for (n=3; n<=NF && $$n !~ "#"; n++) \
print $$n"\t"$$0 \
}' $^ | $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
rpc.bynumber: $(RPC)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(RPC) | \
$(AWK) '$$1 !~ "#" { print $$2"\t"$$0 }' $^ \
| $(DBLOAD) -i $(RPC) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
services.byname: $(SERVICES)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(SERVICES) | \
$(AWK) \
'$$1 !~ "#" { if (index($$2,"udp")) { printf("%s/udp",$$1) } \
else { printf("%s/tcp",$$1) }; print "\t"$$0 ; \
print $$2"\t"$$0 ; \
}' $^ | $(DBLOAD) -i $(SERVICES) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
publickey.byname: $(PUBLICKEY)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(TMP) = `$(RCAT) $(NFILE)`
$(AWK) '$$1 !~ "#" { print $$1"\t"$$2 }' $^ \
| $(DBLOAD) -i $(PUBLICKEY) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
$(PASSWD): $(MASTER)
@echo "Creating new $@ file from $(MASTER)..."
@if [ ! $(UNSECURE) ]; then \
$(RCAT) $(MASTER) | \
$(AWK) -F: '{if ($$1 != "+") \
print $$1":*:"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
> $(PASSWD) ; \
else $(RCAT) $(MASTER) | \
$(AWK) -F: '{if ($$1 != "+") \
print $$1":"$$2":"$$3":"$$4":"$$8":"$$9":"$$10}' $^ \
> $(PASSWD) ; fi
passwd.byname: $(PASSWD)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(PASSWD) | \
$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
passwd.byuid: $(PASSWD)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(PASSWD) | \
$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
| $(DBLOAD) -i $(PASSWD) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
@$(MAKE) -f ../Makefile netid
group.byname: $(GROUP)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(GROUP) | \
$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
group.bygid: $(GROUP)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(GROUP) | \
$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
| $(DBLOAD) -i $(GROUP) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
@$(MAKE) -f ../Makefile netid
netid.byname: $(GROUP) $(PASSWD)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
@$(MKNETID) $(PASSWD) $(GROUP) `basename \`pwd\`` \
| $(DBLOAD) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
master.passwd.byname: $(MASTER)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(MASTER) | \
$(AWK) -F: '{ if ($$1 != "+") print $$1"\t"$$0 }' $^ \
| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi
master.passwd.byuid: $(MASTER)
@echo "Updating $@..."
@echo $@.$$$$ > $(NFILE)
$(CAT) $(MASTER) | \
$(AWK) -F: '{ if ($$1 != "+") print $$3"\t"$$0 }' $^ \
| $(DBLOAD) -i $(MASTER) -o $(YPMAPDIR)/$@ - $(TMP)
@$(MV) $(TMP) $@
@$(DBLOAD) -c
@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOMAIN) $@; fi
@if [ ! $(NOPUSH) ]; then echo "Pushed $@ map." ; fi