af82548d3a53f52785cb0c8a526268ac9f76d66a
[ab/samba.git/.git] / howto4.txt
1 Samba4 developer howto
2 ======================
3
4 tridge@samba.org, December 2004
5
6 A more up to date version of this howto can be found in the wiki 
7 at http://wiki.samba.org/index.php/Samba4/HOWTO.
8
9 This is a very basic document on how to setup a simple Samba4
10 server. This is aimed at developers who are already familiar with
11 Samba3 and wish to participate in Samba4 development. This is not
12 aimed at production use of Samba4.
13
14 .. contents::
15
16 Step 1: download Samba4
17 -----------------------
18
19 If you have downloaded the Samba4 code via a tarball released from the
20 samba.org website, Step 1 has already been completed for you.  For testing
21 with the version released in the tarball, you may continue on to Step 2.  Note
22 that the references below to the top-level directory named "samba4" will
23 instead be based on the name of the tarball downloaded (e.g.
24 "samba-4.0.0alpha3" for the tarball samba-4.0.0alpha3.tar.gz).
25
26 There are 2 methods of doing this:
27
28   method 1:  "rsync -avz samba.org::ftp/unpacked/samba_4_0_test/ samba4"
29
30   method 2:  "git clone git://git.samba.org/samba.git samba4; cd samba4 && git checkout -b v4-0-test origin/v4-0-test; cd .."
31
32 both methods will create a directory called "samba4" in the current
33 directory. If you don't have rsync or git then install one of them. 
34
35 Since only released versions of Samba contain a pregenerated configure script, 
36 you will have to generate it by hand::
37
38  $ cd samba4/source
39  $ ./autogen.sh
40
41 Note that the above rsync command will give you a checked out git
42 repository. So if you also have git you can update it to the latest
43 version at some future date using::
44
45   $ cd samba4
46   $ git pull origin v4-0-test
47
48 Step 2: compile Samba4
49 ----------------------
50
51 Recommended optional development libraries:
52 - acl and xattr development libraries
53 - gnutls
54 - readline
55
56 Run this::
57
58   $ cd samba4/source
59   $ ./configure
60   $ make
61
62
63 Step 2bis: recompile Samba4
64 ---------------------------
65
66 This part only apply for those who are recompiling samba 4 after updating the code (with rsync or git).
67
68 Due to some imperfection in the our build system it recommended to do the following sequence after updating the code:
69
70   $ cd samba4/source
71   $ make clean
72   $ ./autogen.sh
73   $ ./configure
74   $ make idl_full
75   $ make
76
77 Not all the steps are needed everytime but doing so insure that you won't have old compiled objects mixed with new code.
78 It also insure that change in the idl are correctly catched up.
79
80 Step 3: install Samba4
81 ----------------------
82
83 Run this as a user who have permission to write to the install
84 directory (defaults to /usr/local/samba). Use --prefix option to
85 configure above to change this.
86
87 ::
88  
89   # make install
90
91 Step 4: provision Samba4
92 ------------------------
93
94 The "provision" step sets up a basic user database. Be warned that this
95 removes all preexisting database data (if any)!
96
97 It must be run as a user with permission to write to the install directory
98 (typically "root").
99
100 ::
101
102   # cd source
103   # ./setup/provision --realm=YOUR.REALM --domain=YOURDOM \
104   #  --adminpass=SOMEPASSWORD --server-role='domain controller'
105
106 'YOURDOM' is the NT4 style domain name. 'YOUR.REALM' is your kerberos
107 realm, which is typically your DNS domain name.
108
109 If you provisioned a more recent Samba4 system already you should be able to
110 use the procedures shown in "upgrading-samba4.txt" to upgrade it and keep all
111 data.
112
113 When you are using Samba3 at the moment you could try the experimental script
114 "upgrade_from_s3" under the "setup" directory of the source
115 distribution (it isn't included in binary distributions yet).
116
117 Step 5: Create a simple smb.conf
118 --------------------------------
119
120 The provisioning will create a very simple smb.conf with no shares by
121 default. You will need to update it to add at least one share. For
122 example::
123
124   [test]
125         path = /data/test
126         read only = no
127
128 Step 6: starting Samba4
129 -----------------------
130
131 The simplest is to just run "samba", but as a developer you may find
132 the following more useful::
133
134    # samba -i -M single
135
136 that means "start samba without messages in stdout, and running a
137 single process. That mode of operation makes debugging samba with gdb
138 particularly easy.
139
140 Note that now it is no longer necessary to have an instance of nmbd
141 from Samba 3 running.  If you are running any smbd or nmbd processes
142 they need to be stopped before starting samba from Samba 4.
143
144 Make sure you put the bin and sbin directories from your new install
145 in your $PATH. Make sure you run the right version!
146
147 Step 7: testing Samba4
148 ----------------------
149
150 try this command::
151
152   $ smbclient //localhost/test -Uadministrator%SOMEPASSWORD
153
154
155 NOTE about filesystem support
156 -----------------------------
157
158 To use the advanced features of Samba4 you need a filesystem that
159 supports both the "user" and "system" xattr namespaces.
160
161 If you run Linux with a 2.6 kernel and ext3 this means you need to
162 include the option "user_xattr" in your /etc/fstab. For example::
163
164    /dev/hda3            /home                   ext3    user_xattr     1 1
165
166 You also need to compile your kernel with the XATTR and SECURITY
167 options for your filesystem. For ext3 that means you need::
168
169    CONFIG_EXT3_FS_XATTR=y
170    CONFIG_EXT3_FS_SECURITY=y
171
172 If you are running a Linux 2.6 kernel with CONFIG_IKCONFIG_PROC
173 defined you can check this with the following command::
174
175    $ zgrep CONFIG_EXT3_FS /proc/config.gz
176
177 If you don't have a filesystem with xattr support, then you can
178 simulate it by using the option::
179
180    posix:eadb = /usr/local/samba/eadb.tdb
181
182 that will place all extra file attributes (NT ACLs, DOS EAs, streams
183 etc), in that tdb. It is not efficient, and doesn't scale well, but at
184 least it gives you a choice when you don't have a modern filesystem.
185
186 Testing your filesystem
187 -----------------------
188
189 To test your filesystem support, install the 'attr' package and run
190 the following 4 commands as root::
191
192   # touch test.txt
193   # setfattr -n user.test -v test test.txt
194   # setfattr -n security.test -v test2 test.txt
195   # getfattr -d test.txt
196   # getfattr -n security.test -d test.txt
197
198 You should see output like this::
199
200   # file: test.txt
201   user.test="test"
202   
203   # file: test.txt
204   security.test="test2"
205
206 If you get any "Operation not supported" errors then it means your
207 kernel is not configured correctly, or your filesystem is not mounted
208 with the right options.
209
210 If you get any "Operation not permitted" errors then it probably means
211 you didn't try the test as root.
212
213 ..
214         vim: ft=rest