The commands in the Makefile are preceded by at signs (@) to suppress command echo when make is executing them. rcp moves the file over to the secondary master server, and the script invoked by rsh rebuilds the maps on server ono. Superuser privileges are not always extended from one NIS server to another, and this scheme works only if the rsh and rcp commands can be executed. In order to get the maps copied to the secondary master server, you need to be able to access that server as root. You might justifiably be concerned about the security implications, since the rcp and rsh commands work without password prompts. One alternative is to leave the source files out-of-date and simply move the map file to the secondary master and have it distributed to slave servers in the second domain. Another alternative is to use Kerberos V5 versions of rcp and rsh or to use the secure shell (ssh). Kerberos V5 and ssh are available as free software or in commercial form. Your vendor might even provide one or both. For Solaris 2.6 and upward, you can get the Sun Enterprise Authentication Mechanism (SEAM) product from Sun, which has Kerberos V5, including rcp and rsh using Kerberos V5 security (see Section 12.5.5.2, "SEAM: Kerberos V5 for Solaris"). If you use SEAM, you'll want to prefix rcp and rsh in the Makefile with /usr/krb5/bin/. The following script can be run out of cron on the secondary master server to pick up the host maps from NIS server mahimahi, the master server for domain nesales:hosts.time: .... rebuild hosts.byname and hosts.byaddr @touch hosts.time; @echo "updated hosts"; @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) hosts.byname; fi @if [ ! $(NOPUSH) ]; then $(YPPUSH) -d $(DOM) hosts.byaddr; fi @if [ ! $(NOPUSH) ]; then echo "pushed hosts"; fi @echo "copying hosts file to NIS server ono" @rcp /etc/hosts ono:/etc/hosts @echo "updating NIS maps on ono" @rsh ono "( cd /var/yp; make hosts )"
The ypxfr commands get the maps from the primary master server, and then the yppush commands distribute them in the local, secondary NIS domain. The -h option to ypxfr specifies the hostname from which to initiate the transfer, and overrides the map's master record. The -s option indicates the domain from which the map is to be taken. Note that in this approach, the hosts map points to mahimahi as the master in both domains. If the rcp-based transfer is used, then the hosts map in each domain points to the master server in that domain. The master server record in the map always indicates the host containing a source file from which the map can be rebuilt.#! /bin/sh /usr/lib/netsvc/yp/ypxfr -h mahimahi -s nesales hosts.byname /usr/lib/netsvc/yp/ypxfr -h mahimahi -s nesales hosts.byaddr /usr/lib/netsvc/yp/yppush -d `domainname` hosts.byname /usr/lib/netsvc/yp/yppush -d `domainname` hosts.byaddr
4.3. Advanced NIS server administration | 5. Living with Multiple Directory Servers |
Copyright © 2002 O'Reilly & Associates. All rights reserved.