Nis

download Nis

If you can't read please download the document

description

nis

Transcript of Nis

How to configure NIS map fileNIS maps are databases that specify certain system information such as user names, passwords, and host names, in a database format called DBMWhenever you need to modify an NIS map, you should do so on the master server and then propagate the changes to the slave servers.Most maps are constructed from a standard text files by associating an index key with a value.If the NIS master is running the rpc.yppasswdd daemon, any client system can update the NIS password map by using the yppasswd or passwd commands. You need first to ensure that the rpc.yppasswdd daemon is running on the NIS master server./usr/lib/netsvc/yp/rpc.yppasswdd /$PWDIR/passwd -m passwd The make utility receives its instructions from the Makefile file. The Makefile file is very similar to specialized shell and like shell uses variable definitions (called macros), targets, and dependencies. A dependency rule has two parts - a left and right side separated by a : left side : right sideThe sample NIS Makefile file provided by Sun is located in the /var/yp directory and is composed of four main sections: The first section contains macro definitions. The second section contains the first target, all. The third section defines the final target and dependencies. The fourth section contains entries for each of the dependencies.The first section of the Makefile file contains the following macro definitions#B=-bB=DIR =/etcINETDIR=/etc/inetRBACDIR=/etc/securityPWDIR =/etcDOM = domainnameNOPUSH = ""ALIASES = /etc/mail/aliasesYPDIR=/usr/lib/netsvc/ypSBINDIR=/usr/sbinYPDBDIR=/var/ypYPPUSH=$(YPDIR)/yppushMAKEDBM=$(SBINDIR)/makedbmMULTI=$(YPDIR)/multiREVNETGROUP=$(SBINDIR)/revnetgroupSTDETHERS=$(YPDIR)/stdethersSTDHOSTS=$(YPDIR)/stdhostsMKNETID=$(SBINDIR)/mknetidMKALIAS=$(YPDIR)/mkaliasThe second section of the Makefile file contains the list of targets. The first target is all. all: passwd group hosts ipnodes ethers networks rpc services protocols \netgroup bootparams aliases publickey netid netmasks c2secure \timezone auto.master auto.home \auth.attr exec.attr prof.attr user.attr audit.userAs you can see the all target lists all source files that NIS syncroninize and thus enables the entire set of NIS maps to be built by typing: # cd /var/yp; /usr/ccs/bin/makeThe fourth section is covered before the third section, because the fourth section continues the dependency thread introduced by the all target.The fourth section of the Makefile file is pretty trivial and list dependencies in the target files, one per linepasswd: passwd.timegroup: group.timeproject: project.timehosts: hosts.timeipnodes: ipnodes.timeethers: ethers.timenetworks: networks.timerpc: rpc.timeservices: services.timeprotocols: protocols.timenetgroup: netgroup.timebootparams: bootparams.timealiases: aliases.timepublickey: publickey.timenetid: netid.timepasswd.adjunct: passwd.adjunct.timegroup.adjunct: group.adjunct.timenetmasks: netmasks.timetimezone: timezone.timeauto.master: auto.master.timeauto.home: auto.home.timeauth.attr:auth.attr.timeexec.attr:exec.attr.timeprof.attr:prof.attr.timeuser.attr:user.attr.timeaudit.user:audit.user.time$(DIR)/netid:$(DIR)/timezone:$(DIR)/auto_master:$(DIR)/auto_home:$(PWDIR)/shadow:$(DIR)/auth_attr:$(DIR)/exec_attr:$(DIR)/prof_attr:$(DIR)/user_attr:$(DIR)/audit_user:The third section of the Makefile file defines the final target and dependencies, as well as instructions on how to build each map in the domain, for example: auto.direct.time: $(DIR)/auto_direct -@if [ -f $(DIR)/auto_direct ]; then \ sed -e "/^#/d" -e s/#.*$$// $(DIR)/auto_direct \ | $(MAKEDBM) - $(YPDBDIR)/$(DOM)/auto.direct; \ touch auto.direct.time; \ echo "updated auto.direct"; \ if [ ! $(NOPUSH) ]; then \ $(YPPUSH) auto.direct; \ echo "pushed auto.direct"; \ else \ : ; \ fi \ else \ echo "couldn't find $(DIR)/auto_direct"; \ fi=========================================================================================="passwd (NIS): Couldn't change passwd/attributes for user"The rpc.yppasswdd daemon is probably running, but it is not pointing to the directory containing the NIS maps. By default, rpc.yppasswdd looks for NIS maps in /var/yp. If NIS maps are in /var/yp/maps, for example, use the following command to start rpc.yppasswdd:/usr/lib/netsvc/yp/rpc.yppasswdd -D /var/yp/maps========================================================================================Forcing ypbind to use a particular NIS server/usr/lib/netsvc/yp/ypbind -ypsetmeypset NIS_serverypwhich=========================================================================================If NIS appears to hang when pushing maps from the NIS master to NIS slave servers, check the contents of /var/yp/ypxfr.log. "touch" the file if it is not created.========================================================================================How to add New maps to nis server Add the name of the database to the all rule Write the time rule Add the rule for the databaseFor example, in order for the Makefile to work on automounter input files, you would have to add the auto_direct.time and auto_home.time maps to the NIS database.To add these maps to the NIS database: Modify the line that starts with the word all by adding the name(s) of the database you want to add:all: passwd group hosts ethers networks rpc services protocols \netgroup bootparams aliases netid netmasks \auto_direct auto_home auto_direct.time auto_home.timeAdd the following lines at the end of the Makefile:auto_direct: auto_direct.timeauto_home: auto_home.timeAdd an entry for auto_direct.time in the middle of the file.auto_direct.time: $(DIR)/auto_direct @(while read L; do echo $$L; done < $(DIR)/auto_direct $(CHKPIPE)) | \ (sed -e "/^#/d" -e "s/#.*$$//" -e "/^ *$$/d" $(CHKPIPE)) | \ $(MAKEDBM) - $(YPDBDIR)/$(DOM)/auto_direct; @touch auto_direct.time; @echo "updated auto_direct"; @if [ ! $(NOPUSH) ]; then $(YPPUSH) auto_direct; fi @if [ ! $(NOPUSH) ]; then echo "pushed auto_direct"; fiWhere: CHKPIPE makes certain that the operations to the left of the pipe (|) are successfully completed before piping the results to next commands. If the operations to the left of the pipe do not successfully complete, the process is terminated with a "NIS make terminated" message. NOPUSH prevents the makefile from calling yppush to transfer the new map to the slave servers. If NOPUSH is not set, the push is done automatically.The while loop at the beginning is designed to eliminate any backslash-extended lines in the input file. The sed script eliminates comment and empty lines, and feeds the output toThe same procedure should be followed for all other automounter maps such as auto_home, or any other nondefault maps.Run make.# make nameWhere name is the name of the map you want to make. For example, auto_direct.