Solaris10でsambaとswatの設定をするには
ここでは、Windowsとファイル共有などで連携するために samba の設定方法を紹介する。
samba自体は Solaris 9 でもバンドルされているし、フリーウェアなのでどこからでも入手できるが、せっかくなので Solaris
10 にバンドルされているもので設定してみる。
プログラム本体は/usr/sfw/sbin 以下にある smbd だ。
bash-3.00#
cd /usr/sfw/sbin
bash-3.00#
ls
bgpdstart
nmbd
ripdstop
smbd
tcpd zebraadm
bgpdstop ospfdstart
safe_finger snmpd
tcpdchk
mysqld ospfdstop
ser
snmptrapd tcpdmatch
mysqld_safe ripdstart
serctl
swat try-from
Solaris 10 3/05 版のデフォルトのバージョンは 3.0.4 だが、パッチ
119757-01
を適用することで 3.0.11 になる。
bash-3.00#
./smbd -V
Version 3.0.11
■ smb.conf ファイルの作成
テンプレートは /etc/sfw/smb.conf-example なのでこれをコピーして使用する。
bash-3.00#
cd /etc/sfw
bash-3.00#
ls
a2ps-site.cfg
mysql
ser
a2ps.cfg
openssl
smb.conf-example
foomatic
private
zebra
bash-3.00#
cp smb.conf-example
smb.conf
ほとんどデフォルトのままだが、PCの環境などにworkgroupなどを合わせるなどの変更を加えた。(太字の部分が変更点)
bash-3.00#
cat smb.conf
#======================= Global Settings========================
[global]
workgroup = WORKGROUP
server string = Samba Server
security = user
hosts allow = 192.168.1.
127.
load printers = no
; printcap name = /etc/printcap
; printcap name = lpstat
; printing = cups
; guest account = pcguest
log file =
/var/samba/log.%m
max log size = 50
; password server = <NT-Server-Name>
; realm = MY_REALM
; passdb backend = tdbsam
; include = /usr/sfw/lib/smb.conf.%m
socket options = TCP_NODELAY
; interfaces = 192.168.12.2/24 192.168.13.2/24
; local master = no
; os level = 33
; domain master = yes
; preferred master = yes
; domain logons = yes
; logon script = %m.bat
; logon script = %U.bat
; logon path = \\%L\Profiles\%U
; wins support = yes
; wins server = w.x.y.z
; wins proxy = yes
dns proxy = no
; add user script = /usr/sbin/useradd %u
; add group script = /usr/sbin/groupadd %g
; add machine script = /usr/sbin/adduser -n -g machines -c
Machine -d /dev/null
-s /bin/false %u
; delete user script = /usr/sbin/userdel %u
; delete user from group script = /usr/sbin/deluser %u %g
; delete group script = /usr/sbin/groupdel %g
#============================ Share Definitions ====================
[homes]
comment = Home Directories
browseable = no
writable = yes
path = /export/home/%S
; [netlogon]
; comment = Network Logon Service
; path = /usr/sfw/lib/netlogon
; guest ok = yes
; writable = no
; share modes = no
;[Profiles]
; path = /usr/local/samba/profiles
; browseable = no
; guest ok = yes
[printers]
comment = All Printers
path = /var/spool/samba
browseable = no
# Set public = yes to allow user 'guest account' to print
guest ok = no
writable = no
printable = yes
# This one is useful for people to share files
;[tmp]
; comment = Temporary file space
; path = /tmp
; read only = no
; public = yes
;[public]
; comment = Public Stuff
; path = /home/samba
; public = yes
; writable = yes
; printable = no
; write list = @staff
;[fredsprn]
; comment = Fred's Printer
; valid users = fred
; path = /homes/fred
; printer = freds_printer
; public = no
; writable = no
; printable = yes
;[fredsdir]
; comment = Fred's Service
; path = /usr/somewhere/private
; valid users = fred
; public = no
; writable = yes
; printable = no
;[pchome]
; comment = PC Directories
; path = /usr/pc/%m
; public = no
; writable = yes
[public]
path = /export/public
public = yes
only guest = yes
writable = yes
printable = no
[myshare]
comment = for user1
path = /export/shared
valid users = user1
public = no
writable = yes
printable = no
create mask = 0765
bash-3.00#
これでとりあえず samba を起動してみる。
bash-3.00#
/etc/init.d/samba start
smbd と nmbd が動作していれば正常だ。
/etc/rc3.d/S90samba があるので再起動時も smb.conf の記述に誤りがなければ自動的に起動する。
また、アクセスするために以下のようにユーザー user1 を登録する。
( user1 はあらかじめシステムのユーザーとして /etc/passwd ファイルに登録されている必要がある)
bash-3.00#
/usr/sfw/bin/smbpasswd -a
user1
New SMB password:
パスワード入力
Retype new SMB password:
再度パスワード入力
Added user user1
上記設定の後、 Windows XP マシンからアクセスしてみた結果が下のイメージだ。
■ swat の設定
swat を動作させるにはまず、/etc/inet/services に以下のエントリを追加する。
bash-3.00#
vi /etc/inet/services
...
swat
901/tcp
次に /etc/inet/inetd.conf に以下のエントリを追加し、inetconv コマンドを実行し、inetd 経由で swat
が起動するように SMF に組み込む。
余計なサービスを追加しないように inetd.conf では swat 以外のエントリを全てコメントアウトしておくことを勧める。
bash-3.00#
vi /etc/inet/inetd.conf
...
swat stream tcp nowait root
/usr/sfw/sbin/swat swat
bash-3.00#
inetconv
swat -> /var/svc/manifest/network/swat-tcp.xml
swat-tcp.xml をインポートしています ...完了
上記の inetconv コマンドで swat 用のマニフェスト swat-tcp.xml が作成され SMF
のサービスとして組み込まれた。ということで以下のようなコマンドでステータスの確認が可能になっている。
bash-3.00#
svcs swat/tcp
STATE
STIME FMRI
online 16:06:32
svc:/network/swat/tcp:default
bash-3.00#
inetadm | grep swat
enabled
online
svc:/network/swat/tcp:default
bash-3.00#
inetadm -l swat/tcp
SCOPE NAME=VALUE
name="swat"
endpoint_type="stream"
proto="tcp"
isrpc=FALSE
wait=FALSE
exec="/usr/sfw/sbin/swat"
user="root"
default bind_addr=""
default bind_fail_max=-1
default bind_fail_interval=-1
default max_con_rate=-1
default max_copies=-1
default con_rate_offline=-1
default failrate_cnt=40
default failrate_interval=60
default inherit_env=TRUE
default tcp_trace=FALSE
default tcp_wrappers=FALSE
swat を利用するにはブラウザで swat が動作するホストのポート901番にアクセスする。
swat によるログインが要求されるが、「ファイル共有」のためのパスワードの設定や、さまざまなサーバー機能の変更などを行うには root
権限でログインする必要がある。
以下がアクセスしたときのイメージ。
Solaris系技術トレーニング一覧