Using Samba

Using Samba

Robert Eckstein, David Collier-Brown, Peter Kelly共著
第一版1999年11月
1-56592-449-5, 注文番号: 4495
416ページ, 34.95ドル

ハードコピー版(英語)を購入する

目次


Previous: E. CVS を利用して Samba をダウンロードする方法 Appendix F  
 

Appendix F. 設定ファイルのサンプル

このリファレンスでは、参考例として smb.conf 設定を提供し、 実際にどれくらいのオプションが使用されているか検証する。以下は、我々が会社で使用している5台のLinuxサーバ、5台のWindows for Workgroupクライアント、3台のNTワークステーションの設定の実例をわずかに変更したものである :

# smb.conf -- File Server System for: 1 Example.COM  BSC & Management Office 
[globals]
	workgroup = 1EG_BSC
	interfaces = 10.10.1.14/24 

ホストのインターフェイスの一つにのみサービスを割り与えている。 interfacesオプションではIPアドレスとネットマスクを設定する。 /24はネットマスク 255.255.255.0を使用するのと同じである:

	comment = Samba ver. %v
	preexec = csh -c `echo /usr/samba/bin/smbclient \
                     -M %m -I %I` &

preexecコマンドをすべての接続についてのホスト名(%m)とIPアドレス(%I)の情報を記録するのに使用している:

	# smbstatus will output various info on current status
	status = yes
	browseable = yes
	printing = bsd

	# the username that will be used for access to services
	# specified with 'guest = ok'
	guest account = samba 

デフォルトのゲストアカウントは nobody uid -1であり、これにより"your server is being unfriendly"という内容のログメッセージが一つのホストに作成されていた。そこでブラウジングとプリントのために"Samba"というゲストアカウントを作成した:

	# superuser account - admin privilages to shares, with no
	# restrictions
	# WARNING - use this with care: files can be modified,
	# regardless of file permissions
	admin users = root

	# who is NOT allowed to connect to ANY service
	invalid users = @wheel, mail, deamon, adt

デーモンはSambaを使用できず、ユーザーのみ使用可能である。 invalid ユーザー usersオプションはセキュリティホールを閉じている;これによりデーモンプロセスのふりをして侵入しよう企てる侵入者を防いでいる。

	# hosts that are ALLOWED or DENIED from connecting to ANY service
	hosts allow = 10.10.1.
	hosts deny = 10.10.1.6
	
	# where the lock files will be located
	lock directory = /var/lock/samba/locks
		
	# debug log files 
	# %m = separate log for each NetBIOS name (each machine)
	log file = /var/log/samba/log.%m

	# We send priority 0, 1 and 2 messages to the system logs
	syslog = 2
		
	# If a WinPopup message is sent to the server,
	# redirect it to a user via e-mail
	
	message command = /bin/mail -s 'message from #% on %m' \
						 pkelly < %s; rm %s

# ---------------------------------------------------
# [globals] Performance Tuning
# ---------------------------------------------------
	
	# caching algorithm to reduce time doing getwd() calls.  
	getwd cache = yes

	socket options = TCP_NODELAY

	# tell the server whether the client is present and
	# responding in seconds
	keep alive = 60

	# num minutes of inactivity before a connection is
	# considered dead
	dead time = 30 

	read prediction = yes
	share modes = yes
	max xmit = 17384 
	read size = 512

share modes, max, xmit, read sizeオプションはホスト固有のものである(Appendix B, Sambaのパフォーマンスチューニングを参照して欲しい):

	# locking is done by the server
	locking = yes

	# control whether dos style attributes should be mapped
	# to unix execute bits
	map hidden = yes
	map archive = yes
	map system = yes

この3つの mapオプションは実行可能属性(0111)を含む許可属性を持つ共有に対してのみ有効である。 homes printersの共有では無効である。 しかし、[www]共有では有効である:

# ---------------------------------------------------------
# [globals] Security and Domain Logon Services
# ---------------------------------------------------------	
# connections are made with UID and GID, not as shares
	security = user

# boolean variable that controls whether passwords
# will be encrypted
	encrypt passwords = yes
	passwd chat = "*New password:*" %n\r "*New password (again):*" %n\r \ "*Password changed*"
	passwd program = /usr/bin/passwd %u
	
# Always become the local master browser
	domain master = yes
	preferred master = yes
	os level = 34
	
# For domain logons to work correctly. Samba acts as a
# primary domain controller.
	domain logons = yes
	
# Logon script to run for user off the server each time
# username (%U) logs in.  Set the time, connect to shares,
# virus checks, etc.
	logon script = scripts\%U.bat

[netlogon]
	comment = "Domain Logon Services"
	path = /u/netlogon
	writable = yes
	create mode = 444
	guest ok = no
	volume = "Network"

この共有は、 Chapter 6, ユーザ、セキュリティ、ドメインで取り上げられたもので Windows NTドメインで、円滑にSambaが動作するのに要求される。

# -----------------------------------------------------------
# [homes] User Home Directories
# -----------------------------------------------------------
[homes]
	comment = "Home Directory for : %u "
	path = /u/users/%u

Sambaサーバのパスワードファイルはそれぞれのユーザーのホームディレクトリを /home/machine_name/person に指定し、このディレクトリをNFSの /u/users以下である実際の物理的な場所に変換する。 [homes]共有のpathオプションは(NFSでない)実際のディレクトリの場所をSambaに指定する :

	guest ok = no
	read only = no
	create mode = 644
	writable = yes
	browseable = no 

# -----------------------------------------------------------
# [printers] System Printers
# -----------------------------------------------------------
[printers]
	comment = "Printers"
	path = /var/spool/lpd/samba
	printcap name = /etc/printcap
	printable = yes
	public = no 
	writable = no

	lpq command = /usr/bin/lpq -P%p
	lprm command = /usr/bin/lprm -P%p %j
	lppause command = /usr/sbin/lpc stop %p
	lpresume command = /usr/sbin/lpc start %p

	create mode = 0700

	browseable = no 
	load printers = yes  

# -----------------------------------------------------------
# Specific Descriptions: [programs] [data] [retail]
# -----------------------------------------------------------
[programs]
	comment = "Shared Programs %T"
	volume = "programs"

共有されたプログラムがネットワークコンピュータに表示される。 プログラム名はインストールプログラムが、プログラムをロードしているCD-ROMのラベルを取得しようと試みた際に指定したボリューム名となる:

	path = /u/programs
	public = yes
	writeable = yes
	printable = no
	create mode = 664
[cdrom]
	comment = "Unix CDROM"
	path = /u/cdrom
	public = no 
	writeable = no 
	printable = no
	volume = "cdrom"

[data]
	comment =  "Data Directories %T"
	path = /u/data
	public = no
	create mode = 770
	writeable = yes
	volume = "data"

[nt4]
	comment =  "NT4 Server"
	path = /u/systems/nt4
	public = yes 
	create mode = 770
	writeable = yes
	volume = "nt4_server"

[www]
	comment =  "WWW System"
	path = /usr/www/http
	public = yes 
	create mode = 775
	writeable = yes
	volume = "www_system"

[www]共有はUnixサーバ上でWebページの作業ためのディレクトリである。 Sambaは、アート部門がwebページを更新できるようにするために、ローカルなPCにディレクトリを使用にしている。


Previous: E. CVS を利用して Samba をダウンロードする方法 目次 
E. CVS を利用して Samba をダウンロードする方法 書籍索引  

O'Reilly Home | O'Reilly Bookstores | How to Order | O'Reilly Contacts
International | About O'Reilly | Affiliated Companies

© 1999, O'Reilly & Associates, Inc.