Fedora12でSamba4(Alpha)を使ってみた(1)

まだAlphaということで気が早いかもしれないのだが、Fedora12のSamba4を試してみた。Samba4はドメインコントローラーにもなれる新バージョンのSambaで、実現すれば、WindowsServer無しでのWindowsPC管理に一歩近づく形となる。(もちろんNAPやVPNなどWindows独自の機能を使用している場合には、この限りではないが。。w )

Fedora12でSamba4をビルドするには

Fedora12では既に samba4 としてyumレポジトリに登録が行われているのだが、確認した時点では、まだsamba4 のパッケージには必要なバイナリが含まれておらず、yumでインストールを行うことはできないらしい。

仕方が無いので、SRPMをダウンロードして直接ビルドしてみた。

# yumdownloader --source samba4
# rpm -Uvh ダウンロードしたソースRPM

これで、/root 直下に rpmbuild/{SRPMS,SPECS} などが作成された。バイナリRPMを作成するには、

# rpmbuild -bb /root/rpmbuild/SPECS/samba4.spec

となる。(事前に gcc等の開発用ツールをインストールする必要があるかもしれない。)

# yum groupinstall "Developer Tools"

ビルドが終わった後、 /root/rpmbuild/BUILD 以下にSamba4のバイナリが出来ているので、こちらを使ってみた。(/root/rpmbuild/RPMS 以下にはバイナリRPMもできているのだが、こちらにもバイナリは含まれないらしい。。 orz)

詳しい使い方はこちら。
http://wiki.samba.org/index.php/Samba4/HOWTO

また、こちらのサイトの内容を参考にさせていただいています。。
http://d.hatena.ne.jp/dicdak/20090628/1246206482

Sambaを起動するには

Sambaの起動の前に smb.confを作成する必要があるため、./setup/provision コマンドを実施する。(カレントディレクトリをsource4 直下にしないとパスが通らないらしい。。 orz)
なお、デフォルトだと、/etc/直下に直接書き込みをしてしまうため、--targetdir オプションで出力先を変更した。

[root@fedora-virt7 source4]# ./setup/provision --targetdir=etc/ --realm=EXAMPLE.LOCAL --domain=LOCAL adminpass=sambaadmin --server-role='domain controller'
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
naming_fsmo_init: no cross-ref container present: (skip loading of naming contexts details)

pdc_fsmo_init: no domain object present: (skip loading of domain details)

Erasing data from partitions
Adding DomainDN: DC=example,DC=local
Modifying DomainDN: DC=example,DC=local
Adding configuration container
Modifying configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up sam.ldb users and groups
Setting up self join
Setting up sam.ldb rootDSE marking as synchronized
See /root/rpmbuild/BUILD/samba-4.0.0alpha8_git20090916/source4/etc/private/named.conf for an example configuration include file for BIND
and /root/rpmbuild/BUILD/samba-4.0.0alpha8_git20090916/source4/etc/private/named.txt for further documentation required for secure DNS updates
A Kerberos configuration suitable for Samba 4 has been generated at /root/rpmbuild/BUILD/samba-4.0.0alpha8_git20090916/source4/etc/private/krb5.conf
Please install the phpLDAPadmin configuration located at /root/rpmbuild/BUILD/samba-4.0.0alpha8_git20090916/source4/etc/private/phpldapadmin-config.php into /etc/phpldapadmin/config.php
Once the above files are installed, your Samba4 server will be ready to use
Server Role:           domain controller
Hostname:              fedora-virt7
NetBIOS Domain:        LOCAL
DNS Domain:            example.local
DOMAIN SID:            S-1-5-21-3794198073-3697594170-2420435027
Admin password:    x#niESAnRiqf
[root@fedora-virt7 source4]# 

こんな感じで、 ./etc 以下にsmb.confが作成される。他にnamed用のnamed.conf, zoneファイルが./private以下に作成された。( 何故か --adminpass を指定したにも関わらず、パスワードがランダムになってしまった。。w)
なお、realmとdomainを指定する必要があるが、ADドメインをrealm、NTドメインをdomainで指定する必要があるらしいので注意。ww (NTドメインにドットを含めるとprovisionが動作しない。。 orz )


sambaを起動する時には、 /root/rpmbuild/BUILD/samba-4.0.0alpha8_git20090916/source4/ に移動した後、

# ./bin/samba -i -M single -s ./etc/etc/smb.conf

(smb.confの場所は適宜provisionで作成した場所を指定のこと。。w)

この状態で、smbclientで接続すると

$ smbclient //localhost/netlogon -UAdministrator%passwd

こんな感じの出力になる。

$ smbclient //localhost/netlogon '-UAdministrator%x#niESAnRiqf'
Domain=[LOCAL] OS=[Unix] Server=[Samba 4.0.0alpha9-GIT-8302346]
smb: \> 

ファイルサーバーとして使う時には、作成したsmb.conf の最後にこんな感じの内容を付け加える。

[test]
        path=/var/tmp
        read only = no

再度testに対して接続すると、普段のsmbclientと同じ使い方が出来る。(FTP類似。> ? でコマンドが表示される)

$ smbclient //localhost/test '-UAdministrator%x#niESAnRiqf'

一応、put, getで/var/tmp に読み書きが出来ることまでを確認した。

ここまでで一応ファイルサーバーとして動くことが分かったのだが、この時点ではPCのドメイン追加などを行えていない。これについてはまた。。