FreeBSD > samba 3.6 jail minitree 10.2-Release

Top > FreeBSD > samba 3.6 jail minitree 10.2-Release

samba 3.6 jail minitree 10.2-Release



samba 3.6 を jail minitree として導入した備忘的まとめです

samba 3.6 chroot minitree 9.0-Releaseを参考に chroot から jail minitree へ
さらに jail.conf を使用するように変更しています



samba36 jail インストール


基本的にjail fulltree環境での作業になります
事前に /root/maintenance に maintenace ShellScript環境を用意しておきます

ports から samba36 をインストールします

  • config 設定
    PORT以外のオプションを外します
    # cd /usr/ports/net/samba36
    # make config
    
    オプションメニュー
    LDAP        With LDAP support                          
    ADS         With Active Directory support              
    CUPS        With CUPS printing support                 
    WINBIND     With WinBIND support                       
    SWAT        With SWAT WebGUI                           
    ACL_SUPPORT With ACL support                           
    AIO_SUPPORT With Asyncronous IO support                
    FAM_SUPOORT With File Alteration Monitor               
    SYSLOG      With Syslog support                        
    QUOTAS      With Disk quota support                    
    UTMP        With UTMP accounting support               
    PAM_SMBPASS With PAM authentication vs passdb backends 
    DNSUPDATE   With dynamic DNS update(require ADS)       
    AVAHI       With Bonjour service discovery support     
    EXP_MODULES With experimental modules                  
    PORT        With system-wide PORT library              
    IPV6        With IPv6 support                          
    MAX_DEBUG   With maximum debugging                     
    SMBTORTURE  With smbtorture                            
    
  • samba36 のインストール
    途中 tdb 1.2.9,1 , python27 2.7.3_3 , libiconv 1.14 , talloc 2.0.7 , perl 5.14.2_2 , m4 1.4.16_1,1 help2man 1.40.11 のconfig 画面になるのでオプションはそのままでインストールします
    # pkg_replace -vcCN net/samba36
    

maintenance ShellScript用Configファイル作成

  • Configファイルを作成します
    # cd /root/maintenance/config
    # vi samba36.txt
    
    # samba
    /usr/local/sbin/nmbd
    /usr/local/sbin/smbd
    /usr/local/bin/pdbedit
    /usr/local/etc/smb.conf
    /usr/local/etc/smb.conf.sample
    
    #syslog-ng
    /usr/local/sbin/syslog-ng
    /usr/local/sbin/syslog-ng-ctl
    
    # miniroot
    /etc/group
    /etc/host.conf
    /etc/hosts
    /etc/localtime
    /etc/master.passwd
    /etc/passwd
    /etc/printcap
    /etc/pwd.db
    /etc/resolv.conf
    /etc/spwd.db
    /usr/sbin/nologin
    
    # library
    /libexec/ld-elf.so.1
    /usr/local/lib/libiconv/libiconv.so.*
    /usr/local/lib/syslog-ng/*
    
    # directory
    #mkdir /dev
    #mkdir /tmp
    #mkdir /usr/local/etc/samba
    #mkdir /usr/local/private
    #mkdir /var/db/samba
    #mkdir /var/log/samba
    #mkdir /var/run/samba
    
    # share directory
    #mkdir /var/samba
    
    # log.nmdb log.smdb /dev/null
    #comm ln -s /dev/null ./var/log/samba/log.nmbd
    #comm ln -s /dev/null ./var/log/samba/log.smbd
    
  • 必要なファイルを集めます
    # ../makembeddedtree.sh samba36.txt /tmp/samba36
    
  • passwd の編集
    samba に不要なものは削除します
    # vipw -d /tmp/samba36/etc
    
    root:*:0:0::0:0:Charlie &:/root:/usr/sbin/nologin
    toor:*:0:0::0:0:Bourne-again Superuser:/root:
    daemon:*:1:1::0:0:Owner of many system processes:/root:/usr/sbin/nologin
    nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin
    
  • group の編集
    samba に不要なものは削除します
    # vi /tmp/samba36/etc/group
    
    wheel:*:0:root
    daemon:*:1:
    nobody:*:65534:
    
  • hosts.allow の設定
    echo 'ALL : ALL : deny' > /tmp/samba36/etc/hosts.allow
    
  • smb.conf の設定
    # vi /tmp/samba36/usr/local/etc/smb.conf
    
    [global]
      workgroup = WORKGROUP
      netbios name = SAMBA
      server string = Samba %v
      hosts allow = 192.168.1.
      interfaces = re0
      socket address = 192.168.1.232
      bind interfaces only = yes
      nmbd bind explicit broadcast = no
      security = user
      encrypt passwords = yes
      domain logons = yes
      domain master = yes
      local master = yes
      wins support = yes
      preferred master = yes
      os level = 65
      dos charset = eucjp-ms
      unix charset = UTF-8
      display charset = UTF-8
      create mask = 0774
      directory mask = 0774
      passdb backend = tdbsam
      load printers = no
    
    [samba]
      path=/var/samba
      writeable = Yes
    
  • samba 用 group user を用意します
    group id user id は任意の数字でかまいません
    /usr/sbin/pw -V /tmp/samba36/etc groupadd samba -g 20000
    /usr/sbin/pw -V /tmp/samba36/etc useradd tail -u 29999 -g 20000 -s /usr/sbin/nologin -d /nonexistent
    
  • samba36 minimaltree 環境の移動
    samba36 minitree 環境を本来稼動したい位置へ移動します
    zfs で切り分けます
    # exit
    
    # zfs create -o mountpoint=/jail/samba36 tank0/jail/samba36
    # mv /jail/mainte/tmp/samba36/* /jail/samba36
    

samba36 仮稼動・設定


samba36 仮稼動

  • samba36 minitree の仮稼動
    仮稼動のあと、ログファイル(log.nmbdとlog.smbd)ができている確認します
    # mount -t devfs devfs /jail/samba36/dev
    # jail /jail/samba36 test.localdomain 192.168.1.200 /usr/local/sbin/nmbd
    
    # ls -la /jail/samba36/var/log/samba
    

共有ディレクトリの設定

  • sambaグループのみ許可します
    # cd /jail/samba36/var
    # chmod 774 samba
    # chown root:20000 samba
    

自動起動設定

nmbd smbd の順番で起動するように設定します

  • samba36 の自動起動設定
    nullデバイスをマウントするのですが、jail fulltree 10.2-Relasesにてdevfs.rulesにそのルールを設定しているルールを使用します
    jail.conf に追記します
    # vi /etc/jail.conf
    
    samba36	{
    	mount.devfs;
    	devfs_ruleset	   = $devfs_jail_inet;
    	allow.raw_sockets  = "1";
    //	allow.sysvipc	   = "1";
    	jid		   = "232";
    	$ip4addr	   = "192.168.1.232/24";
    /* inet */
    	ip4.addr	   = ${ip4addr};
    	interface	   = ${int_if};
    	exec.prestart	   = "";
    	exec.start	   = "";
    	exec.poststart	   = "";
    	exec.prestop	   = "";
    	exec.stop	   = "";
    	exec.poststop	   = "";
    	vnet.interface	   = "";
    /* inet */
    /* vnet 
    	vnet;
    /* vnet */
    	exec.prestart	  += "";
    	exec.start	  += "/usr/local/sbin/syslog-ng";
    	exec.poststart	  += "jexec $name /usr/local/sbin/nmbd -D -s /usr/local/etc/smb.conf";
    	exec.poststart	  += "jexec $name /usr/local/sbin/smbd -D -s /usr/local/etc/smb.conf";
    	exec.prestop	  += "";
    	exec.stop	  += "";
    	exec.poststop	  += "pkill -F ${path}/var/run/samba/smbd.pid";
    	exec.poststop	  += "pkill -F ${path}/var/run/samba/nmbd.pid";
    /* persist */
    	persist;
    /* depend */
    //	depend;
    }
    
  • rc.conf の jail_list に samba36 を追記します
    # vi /etc/rc.conf
    
    jail_list="..... samba36"
    

Packet Filterの設定

  • pf.conf の設定
    このままでは、nmbd がブロードキャストに応答しませんので、pf を使用して、ブロードキャストをリダイレクトします
    # vi /etc/pf.conf
    
    # interface
    ext_if="re0"
    
    # network address
    table <int_network> const {192.168.1.0/24}
    int_samba  ="192.168.1.232"
    
    # port
    port_nmb  ="{137,138}"
    
    scrub in all
    
    # nat(int)
    rdr pass on $ext_if proto udp from any to ($ext_if:broadcast) port port_nmb -> $int_samba
    
  • rc.conf での設定
    rc.conf に追記します
    # vi /etc/rc.conf
    
    # pf
    pf_enable="YES"
    pf_flags=""
    pflog_enable="YES"
    gateway_enable="YES"
    

user 追加・削除・passwd 変更スクリプトです

  • 以前のものと同じです
    # vi smbuser.sh
    
    #!/bin/sh
    smbDir=/jail/samba36
    smbGroup=20000
    
    case "$1" in
    
    add)
    /usr/sbin/pw -V $smbDir/etc useradd -n $2 -u $3 -g $smbGroup -s /usr/sbin/nologin -d /nonexistent
    chroot $smbDir /usr/local/bin/pdbedit -a -u $2
    ;;
    
    del)
    chroot $smbDir /usr/local/bin/pdbedit -x -u $2
    /usr/sbin/pw -V $smbDir/etc userdel -n $2
    ;;
    
    chpw)
    chroot $smbDir /usr/local/bin/pdbedit -x -u $2
    chroot $smbDir /usr/local/bin/pdbedit -a -u $2
    
    *)
    echo " usage: $0 add username uid"
    echo "        $0 del username"
    echo "        $0 chpw username"
    esac
    

資料

アーカイブ

関連ページ


名前:
コメント:
最終更新:2017年12月24日 09:12