金子邦彦研究室コンピュータ管理・活用のノウハウSolarisSolaris で samba (Solaris のファイルを Windows に提供)

Solaris で samba (Solaris のファイルを Windows に提供)

目次


 

sambaとは?

Samba は UNIX マシンを SMB サーバに仕立てあげるサーバソフトです。 UNIXマシンをLanManager、Windows 95/NT、OS/2のファイル・サーバや プリンタ・サーバにすることが可能。 付属のソフト(smbclientなど)を使用することで クライアントにすることもできる。


 

インストール法

インストール

下では、samba-2.2.8 を書いているが、必ず最新の samba をインストールしましょう(セキュリティ上の理由).

samba-2.2.11-ja-1.0.tar.bz2 を持ってくる
gtar -xvjof samba-2.2.11-ja-1.0.tar.bz2
cd samba-2.2.11-ja-1.0
cd source
./configure sparc-sun-solaris8
make
cp /usr/local/samba/lib/smb.conf /tmp
sh /etc/rc2.d/S78samba stop
pkill smbd
pkill nmbd
/bin/ps -e | grep samba
rm -f /usr/local/samba/tmp/*
rm -rf /usr/local/samba/var/*
rm -rf /usr/local/samba/var/locks
make install
cp /tmp/smb.conf /usr/local/samba/lib/smb.conf
sh /etc/rc2.d/S78samba start

設定


 

設定例

設定方針

naigsa, madoka, hitomi で samba を動かすことにしました(NFS サーバ上で動く). 内部ネットユーザにのみサービスを提供します(hosts allow 行で設定)。設定内容は次の通りです.

[共有名]場所

プリンタ設定

ソラリスマシンからの印刷設定を admintool を使って、あらかじめ行なって おくこと。

Printer Name | Server | Description
lp3          | junko  | lp4210 at S-309
lp_ps3       | junko  | lp4210 at S-309
lp3c         | megumi | C2220  at S-309
lp4          | lp4    | lp4210 at N-417
lp_ps        | lp4    | lp4210 at N-417
lp4c         | lp4c   | C2220  at N-417

設定ファイル

研究室(4階)のsmb.confです.
/usr/local/samba/lib に各種設定ファイルを置きます. 設定はsmb.confを直接見るか,testparamというコマンドで見ることができる.

;
; smb.conf  2002/01/31
;
[global]
   workgroup = WAKASHI
   interfaces = hme*

   server string = Makinouchi Lab Samba
   hosts allow = 192.168.0. 255.255.255. 127.
   hosts deny = 0.0.0.0/0
# If you want to automatically load your printer list rather
# than setting them up individually then you'll need this
   load printers = no
   printing = sysv
   printcap name = lpstat
# Uncomment this if you want a guest account, you must add this to /etc/passwd
# otherwise the user "nobody" is used
;   guest account = nobody

   log file = /usr/local/samba/var/log.%m
# Put a capping on the size of the log files (in Kb).
   max log size = 50

   socket options = TCP_NODELAY
   invalid users = root

[homes]
   comment = %U Home Directories (Read Only)
   read only = yes
   writable = no
   browseable = no
   public = no
   create mask = 0644                                  
   directory mask = 0755

[home_pc]
   comment = %U's ~/pc (Read/Write)
   path= %H/pc
   writable = yes
   browseable = yes
   public = no
   create mask = 0644                                  
   directory mask = 0755

[pc_archive]
   comment = pc archive (hitomi:/home/pc,Read/Write)
   path = /home/pc
   writable = yes
   browseable = yes
   public = no
   create mask = 0644                                  
   directory mask = 0755

[ACM]
   comment = ACM (kei:/home/db/ACM)
   path = /home/db/ACM
   read only = yes
   writable = no
   browseable = yes
   public = yes
   create mask = 0644                                  
   directory mask = 0755

[lp3]
   comment = lp3 (Mono. Printer at S-309)
   browseable = yes
   available = yes
   public = no
   writable = no
   printable = yes
   printer name = lp3
   path = /tmp
   create mode = 0700
   print command = /usr/bin/lp -d%p -s %s; rm %s

[lp3c]
   comment = lp3c (Color Printer at S-309)
   browseable = yes
   available = yes
   public = no
   writable = no
   printable = yes
   printer name = lp3c
   path = /tmp
   create mode = 0700
   print command = /usr/bin/lp -d%p -s %s; rm %s

[lp4]
   comment = lp4 (Mono. Printer at N-417)
   browseable = yes
   available = yes
   public = no
   writable = no
   printable = yes
   printer name = lp4
   path = /tmp
   create mode = 0700
   print command = /usr/bin/lp -d%p -s %s; rm %s

[lp4c]
   comment = lp4c (Color Printer at N-417)
   browseable = yes
   available = yes
   public = no
   writable = no
   printable = yes
   printer name = lp4c
   path = /tmp
   create mode = 0700
   print command = /usr/bin/lp -d%p -s %s; rm %s

[global]

/etc/rc2.d/S78samba

/etc/rc2.d/S78samba の設定例
#!/sbin/sh
smbspool=/var/spool/samba
pidfiledir=/usr/local/samba/var/locks
smbd=/usr/local/samba/bin/smbd
nmbd=/usr/local/samba/bin/nmbd

case "$1" in
'start')
    if [ -f $smbd ]; then
        if [ -d $smbspool ]; then
            rm -f $smbspool/*
        fi
    echo ' Samba'
    $smbd -D
    $nmbd -D
    fi
    ;;
'stop')
    kill `cat $pidfiledir/smbd.pid`
    kill `cat $pidfiledir/nmbd.pid`
    ;;

*)
    echo "Usage: $0 { start | stop }"
    exit 1
    ;;
esac
exit 0

 

セキュリティについて

samba 2.2.6までのバージョンには,セキュリティホールがあります.最新版の samba を入れるのが有効な手です。 現在(2003年9月)の最新安定版は2.2.8です.