# $NetBSD: Makefile.yp,v 1.10 2000/07/30 02:33:13 itojun Exp $ # # This is the YP Makefile, used to create and push YP maps. # # Invoke with NOPUSH != "" to prevent the maps from being yppushed upon rebuild # NOPUSH?= "" # Password maps in standard YP are insecure, because the pw_passwd # field is accessable by any user. FreeBSD, NetBSD and OpenBSD have # a common solution: a secure map (generated with makedbm -s) can # only be accessed by a client bound to a privileged port. # # Uncomment out the following if you need compatibility with # sites that don't support this feature. # #INSECURE?= yes YPDBDIR= /var/yp DIR= /etc AMDDIR= /etc/amd DOMAIN= "`/usr/bin/basename ${.CURDIR}`" AWK= /usr/bin/awk CAT= /bin/cat CP= /bin/cp CUT= /usr/bin/cut ECHO= /bin/echo MAKEDBM= /usr/sbin/makedbm MAKEDBM_S= ${MAKEDBM} -s MKALIAS= /usr/sbin/mkalias MKNETID= /usr/sbin/mknetid REVNETGROUP= /usr/sbin/revnetgroup RM= /bin/rm SED= /usr/bin/sed SENDMAIL= /usr/sbin/sendmail SORT= /usr/bin/sort STDETHERS= /usr/sbin/stdethers STDHOSTS= /usr/sbin/stdhosts TOUCH= /usr/bin/touch YPPUSH= /usr/sbin/yppush # We have a rule for ypservers, but we don't build it by default, since # it seldom changes (only when slaves are added/deleted). all: passwd aliases amd.home ethers group hosts ipnodes netgroup networks rpc services protocols netid passwd.time: ${DIR}/master.passwd -@if [ -f ${.ALLSRC} ]; then \ umask 077 ; \ if [ "${INSECURE}" != "yes" ]; then \ ${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 | \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$1, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\ ${SORT} | ${MAKEDBM} - passwd.byname; \ ${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 |\ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$3, $$1":*:"$$3":"$$4":"$$5":"$$6":"$$7 }' -|\ ${SORT} | ${MAKEDBM} - passwd.byuid; \ else \ ${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 | \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$1, $$0 }' - | ${SORT} | \ ${MAKEDBM} - passwd.byname; \ ${CAT} ${.ALLSRC} | ${CUT} -d: -f1-4,8-10 |\ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$3, $$0 }' - | ${SORT} | \ ${MAKEDBM} - passwd.byuid; \ fi; \ ${CAT} ${.ALLSRC} | \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$1, $$0 }' - | ${SORT} | \ ${MAKEDBM_S} - master.passwd.byname; \ ${CAT} ${.ALLSRC} | \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$3, $$0 }' - | ${SORT} | \ ${MAKEDBM_S} - master.passwd.byuid; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated passwd"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} passwd.byname; \ ${YPPUSH} -d ${DOMAIN} passwd.byuid; \ ${YPPUSH} -d ${DOMAIN} master.passwd.byname; \ ${YPPUSH} -d ${DOMAIN} master.passwd.byuid; \ ${ECHO} "pushed passwd"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi aliases.time: ${DIR}/aliases -@if [ -f ${.ALLSRC} ]; then \ ${CP} -p ${.ALLSRC} ${DOMAIN}-aliases; \ ${SENDMAIL} -bi -oA${PWD}/${DOMAIN}-aliases; \ ${MAKEDBM} -u ${DOMAIN}-aliases | ${SORT} | \ ${MAKEDBM} - mail.aliases; \ ${MKALIAS} mail.aliases mail.byaddr; \ ${TOUCH} ${.TARGET}; \ ${RM} ${DOMAIN}-aliases.db ${DOMAIN}-aliases; \ ${ECHO} "updated aliases"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} mail.aliases; \ ${YPPUSH} -d ${DOMAIN} mail.byaddr; \ ${ECHO} "pushed aliases"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi amd.home.time: ${AMDDIR}/amd.home -@if [ -f ${.ALLSRC} ]; then \ ${SED} -e "s/#.*$$//" -e "/^$$/d" ${.ALLSRC} | \ ${AWK} '{ \ for (i = 1; i <= NF; i++) \ if (i == NF) { \ if (substr($$i, length($$i), 1) == "\\") { \ printf("%s", \ substr($$i, 1, length($$i) - 1)); \ } \ else \ printf("%s\n", $$i); \ } \ else \ printf("%s ", $$i); \ }' | \ ${SORT} | ${MAKEDBM} - amd.home; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated amd.home"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} amd.home; \ ${ECHO} "pushed amd.home"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi ethers.time: ${DIR}/ethers -@if [ -f ${.ALLSRC} ]; then \ ${STDETHERS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \ ${AWK} 'BEGIN { FS="\t"; OFS="\t"; } { print $$1, $$0 }' | \ ${SORT} | ${MAKEDBM} - ethers.byaddr; \ ${STDETHERS} ${.ALLSRC} | \ ${AWK} 'BEGIN { FS="\t"; OFS="\t"; } { print $$2, $$0 }' | \ ${SORT} | ${MAKEDBM} - ethers.byname; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated ethers"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} ethers.byaddr; \ ${YPPUSH} -d ${DOMAIN} ethers.byname; \ ${ECHO} "pushed ethers"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi group.time: ${DIR}/group -@if [ -f ${.ALLSRC} ]; then \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$1, $$0 }' ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - group.byname; \ ${AWK} 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \ { print $$3, $$0 }' ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - group.bygid; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated group"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} group.byname; \ ${YPPUSH} -d ${DOMAIN} group.bygid; \ ${ECHO} "pushed group"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi # Solaris 8 does the following: # - /etc/hosts and hosts.{byname,byaddr} are IPv4 only. # - /etc/inet/ipnodes and ipnodes.{byname,byaddr} are used for protocol # independent name-to-address mapping. # # For local name resolution, we made /etc/hosts protocol independent. # For NIS name resolution, we obey Solaris 8 practice. # - We keep hosts.{byname,byaddr} IPv4 only, to be friendly with Solaris 8 # clients. # - ipnodes.{byname,byaddr} is used for protocol independent mapping. # We generate all the mappings from /etc/hosts, for compatibility with NetBSD # local name resolution. # hosts.time: ${DIR}/hosts -@if [ -f ${.ALLSRC} ]; then \ ${STDHOSTS} ${.ALLSRC} | ${SED} -e s/#.*$$// | \ ${AWK} '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \ ${SORT} | ${MAKEDBM} - hosts.byname; \ ${STDHOSTS} ${.ALLSRC} | \ ${AWK} 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \ ${SORT} | ${MAKEDBM} - hosts.byaddr; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated hosts"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} hosts.byname; \ ${YPPUSH} -d ${DOMAIN} hosts.byaddr; \ ${ECHO} "pushed hosts"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi ipnodes.time: ${DIR}/hosts -@if [ -f ${.ALLSRC} ]; then \ ${STDHOSTS} -n ${.ALLSRC} | ${SED} -e s/#.*$$// | \ ${AWK} '{for (i = 2; i <= NF; i++) print $$i, $$0 }' | \ ${SORT} | ${MAKEDBM} - ipnodes.byname; \ ${STDHOSTS} -n ${.ALLSRC} | \ ${AWK} 'BEGIN { OFS="\t"; } { print $$1, $$0 }' | \ ${SORT} | ${MAKEDBM} - ipnodes.byaddr; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated ipnodes"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} ipnodes.byname; \ ${YPPUSH} -d ${DOMAIN} ipnodes.byaddr; \ ${ECHO} "pushed ipnodes"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi netgroup.time: ${DIR}/netgroup -@if [ -f ${.ALLSRC} ]; then \ ${CAT} ${.ALLSRC} | ${SORT} | ${MAKEDBM} - netgroup; \ ${CAT} ${.ALLSRC} | ${REVNETGROUP} -u -f - | \ ${SORT} | ${MAKEDBM} - netgroup.byuser; \ ${CAT} ${.ALLSRC} | ${REVNETGROUP} -h -f - | \ ${SORT} | ${MAKEDBM} - netgroup.byhost; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated netgroup"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} netgroup; \ ${YPPUSH} -d ${DOMAIN} netgroup.byuser; \ ${YPPUSH} -d ${DOMAIN} netgroup.byhost; \ ${ECHO} "pushed netgroup"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi networks.time: ${DIR}/networks -@if [ -f ${.ALLSRC} ]; then \ ${SED} -e "/^#/d" -e s/#.*$$// ${.ALLSRC} | \ ${AWK} '{print $$1, $$0; \ for (i = 3;i <= NF;i++) print $$i,$$0}' | \ ${SORT} | ${MAKEDBM} - networks.byname; \ ${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \ ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - networks.byaddr; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated networks"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} networks.byname; \ ${YPPUSH} -d ${DOMAIN} networks.byaddr; \ ${ECHO} "pushed networks"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi protocols.time: ${DIR}/protocols -@if [ -f ${.ALLSRC} ]; then \ ${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \ ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - protocols.bynumber; \ ${SED} -e "/^#/d" -e s/#.*$$// ${.ALLSRC} | \ ${AWK} '{print $$1, $$0; \ for (i = 3;i <= NF;i++) print $$i,$$0}' | \ ${SORT} | ${MAKEDBM} - protocols.byname; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated protocols"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} protocols.bynumber; \ ${YPPUSH} -d ${DOMAIN} protocols.byname; \ ${ECHO} "pushed protocols"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi rpc.time: ${DIR}/rpc -@if [ -f ${.ALLSRC} ]; then \ ${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \ ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - rpc.bynumber; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated rpc"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} rpc.bynumber; \ ${ECHO} "pushed rpc"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi services.time: ${DIR}/services -@if [ -f ${.ALLSRC} ]; then \ ${AWK} 'BEGIN { OFS="\t"; } $$1 !~ /^#/ { print $$2, $$0 }' \ ${.ALLSRC} | \ ${SORT} | ${MAKEDBM} - services.byname; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated services"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} services.byname; \ ${ECHO} "pushed services"; \ else \ : ; \ fi \ else \ ${ECHO} "couldn't find ${.ALLSRC}"; \ fi netid.time: ${DIR}/passwd ${DIR}/group ${DIR}/hosts ${DIR}/netid -@${MKNETID} -q -d ${DOMAIN} -p ${DIR}/passwd -g ${DIR}/group -h \ ${DIR}/hosts -m ${DIR}/netid | \ ${SORT} | ${MAKEDBM} - netid.byname; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated netid"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} netid.byname; \ ${ECHO} "pushed netid"; \ else \ : ; \ fi ypservers.time: ${.CURDIR}/ypservers -@${MAKEDBM} ypservers ypservers; \ ${TOUCH} ${.TARGET}; \ ${ECHO} "updated ypservers"; \ if [ ! ${NOPUSH} ]; then \ ${YPPUSH} -d ${DOMAIN} ypservers; \ ${ECHO} "pushed ypservers"; \ else \ : ; \ fi passwd: passwd.time group: group.time hosts: hosts.time ipnodes: ipnodes.time aliases: aliases.time amd.home: amd.home.time ethers: ethers.time netgroup: netgroup.time networks: networks.time rpc: rpc.time services: services.time protocols: protocols.time netid: netid.time ypservers: ypservers.time ${DIR}/passwd: ${DIR}/group: ${DIR}/hosts: ${DIR}/aliases: ${AMDDIR}/amd.home: ${DIR}/ethers: ${DIR}/master.passwd: ${DIR}/netgroup: ${DIR}/networks: ${DIR}/rpc: ${DIR}/services: ${DIR}/protocols: ${DIR}/netid: