Solaris ネーミングの設定と構成

Makefile の準備

入力ファイルを確認して、それを入力ファイルディレクトリにコピーした後に、NIS サービスが使用する ndbm 形式のマップに、その入力ファイルを変換する必要があります。「ypinit による主サーバーの設定」の節で説明するとおり、これは主サーバーで ypinit が実行されると自動的に行われます。

ypinit スクリプトは、プログラム make を呼び出します。このプログラムは、/var/yp ディレクトリに置かれた Makefile を使用します。例 10-1 のようなデフォルトの Makefile が、/var/yp ディレクトリで提供されます。この Makefile は、入力ファイルの ndbm 形式マップへの変換に必要なコマンドを含みます。

Makefile はそのまま使用でき、必要なら修正もできます。デフォルトの Makefile を修正するときは、将来必要な場合に備えて最初にオリジナルのデフォルト Makefile をコピーして格納してください。次の Makefile への修正のうちの 1 つまたは複数を実行する必要がある場合があります。


例 10-1 修正前のデフォルトの Makefile

# "@(#)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: 

Makefile は、all の下にリストされるデータベースのそれぞれに対して、適切な NIS マップを作成します。データは、makedbm で処理され、mapname.dirmapname.pag の 2 つのファイルに保存されます。この両方は主サーバーの /var/yp/domainname ディレクトリに置かれます。

Makefile は、/PWDIR/passwd/PWDIR/shadow/PWDIR/security/passwd.adjunct ファイルから passwd マップを適宜作成します。