Solaris Naming Setup and Configuration Guide

Preparing the Makefile

After checking the source files and copying them into the source file directory, you now need to convert those source files into the ndbm format maps that the NIS service uses. This is done automatically for you by ypinit when called on the master server, as explained in the next section, "Setting Up the Master Server With ypinit".

The ypinit script calls the program make, which uses the Makefile located in the /var/yp directory. A default Makefile similar to Example 10-1 is provided for you in the /var/yp directory and contains the commands needed to transform the source files into the desired ndbm format maps.

You can use the default Makefile as it is, or modify it if you want. (If you do modify the default Makefile, be sure to first copy and store the original default Makefile in case you need it for future use.) You may need to make one or more of the following modifications to the Makefile:


Example 10-1 Default Makefile Before Modification


# "@(#)Makefile 1.15 95/05/05 SMI"
#
# It is somewhat confusing to note that Solaris 2.x uses
# /etc/auto_master instead of the 4.x /etc/auto.master file name
# because of NIS+ treating a "." in a special way.
#
# Set the following variable to "-b" to have NIS servers use the
# domain name resolver for hosts not in the current domain.
#B=-b
B=
DIR =/etc
#
# If the passwd, shadow and/or adjunct files used by rpc.yppasswdd
# live in directory other than /etc then you'll need to change the
# following line.
# DO NOT indent the line, however, since /etc/init.d/yp attempts
# to find it with grep "^PWDIR" ...
#
PWDIR =/etc
DOM = `domainname`
all: passwd group hosts ethers networks rpc services protocols \
netgroup bootparams aliases publickey netid netmasks c2secure \
timezone auto.master auto.home
passwd.time: $(PWDIR)/passwd $(PWDIR)/shadow
	-@if [ -f $(PWDIR)/security/passwd.adjunct ]; then \
		(nawk 'BEGIN { FS=":"; OFS=":" } /^[a-zA-Z0-9_]/\
		{ $$2 = "##" $$1; printf "%s\t%s\n", \
		$$1, $$0 }' $(PWDIR)/passwd $(CHKPIPE)) | \
		$(MAKEDBM) - $(YPDBDIR)/$(DOM)/passwd.byname; \
	(nawk 'BEGIN { FS=":"; OFS=":" } /^[a-zA-Z0-9_]/ \
		{ $$2 = "##" $$1; printf "%-10d\t%s\n", $$3, $$0 }'\
		$(PWDIR)/passwd $(CHKPIPE)) | \
		$(MAKEDBM) - $(YPDBDIR)/$(DOM)/passwd.byuid; \
	(nawk 'BEGIN { FS=":"; OFS=":"; while ( getline \
		< "$(PWDIR)/shadow" > 0) shadow[$$1] = $$2; } /^[a-zA-Z0-9_]/
		{ $$2 = shadow[$$1]; \
		printf "%-10d\t%s\n",$$3,$$0 }' \
		$(PWDIR)/passwd $(CHKPIPE))| \
		$(MAKEDBM) - $(YPDBDIR)/$(DOM)/passwd.byuid; \
else \
	(awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
		{ print $$1, $$0 }' $(PWDIR)/passwd $(CHKPIPE))| \
		$(MAKEDBM) - $(YPDBDIR)/$(DOM)/passwd.byname; \
	(awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
		{ printf("%-10d ", $$3); print $$0 }' $(PWDIR)/passwd\
		$(CHKPIPE))| $(MAKEDBM) - $(YPDBDIR)/$(DOM)/passwd.byuid;
\
fi
	@touch passwd.time;
	@echo "updated passwd";
	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) passwd.byname;
fi
	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) passwd.byuid; fi
	@if [ ! $(NOPUSH) ]; then echo "pushed passwd"; fi group.time: $(DIR)/group
	@(awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
		{ print $$1, $$0 }' $(DIR)/group $(CHKPIPE))| \
		$(MAKEDBM) - $(YPDBDIR)/$(DOM)/group.byname;
	@(awk 'BEGIN { FS=":"; OFS="\t"; } /^[a-zA-Z0-9_]/ \
		{ printf("%-10d ", $$3); print $$0 }' \
		$(DIR)/group $(CHKPIPE)) | $(MAKEDBM) - \
		$(YPDBDIR)/$(DOM)/group.bygid;
	@touch group.time;
	@echo "updated group";
	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) group.byname; fi
	@if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) group.bygid; fi
	@if [ ! $(NOPUSH) ]; then echo "pushed group"; fi.
.
passwd: passwd.time
group: group.time
hosts: hosts.time
ethers: ethers.time
networks: networks.time
netmasks: netmasks.time
timezone: timezone.time
auto.master: auto.master.time
auto.home: auto.home.time
$(DIR)/netid:
$(DIR)/timezone:
$(DIR)/auto_master:
$(DIR)/auto_home:
$(PWDIR)/shadow:

The function of the Makefile is to create the appropriate NIS maps for each of the databases listed under all. After passing through makedbm the data is collected in two files, mapname.dir and mapname.pag, both in the /var/yp/domainname directory on the master server.

The Makefile builds passwd maps from the /PWDIR/passwd, /PWDIR/shadow, and /PWDIR/security/passwd.adjunct files, as appropriate.