1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
3 <chapter id="upgrades">
4 <title>Updating Samba-3</title>
7 It was a little difficult to select an appropriate title for this chapter.
8 From email messages on the Samba mailing lists it is clear that many people
9 consider the updating and upgrading of Samba to be a migration matter. Others
10 talk about migrating Samba servers when in fact the issue at hand is one of
11 installing a new Samba server to replace an older existing Samba server.
15 There has also been much talk about migration of Samba-3 from an smbpasswd
16 passdb backend to the use of the tdbsam or ldapsam facilities that are new
21 Clearly, there is not a great deal of clarity in the terminology that various
22 people apply to these modes by which Samba servers are updated. This is further
23 highlighted by an email posting that included the following neat remark:
27 I like the <quote>net rpc vampire</quote> on NT4, but that to my surprise does
28 not seem to work against a Samba PDC and, if addressed in the Samba to Samba
29 context in either book, I could not find it.
33 So in response to the significant request for these situations to be better
34 documented this chapter has now been added. Your contributions and documentation
35 of real-world experiences will be a most welcome addition to this chapter.
39 <title>Introduction</title>
42 A Windows network administrator explained in an email what changes he was
43 planning to make and and followed with the question: <quote>Anyone done this before?</quote>.
44 Many of us have upgraded and updated Samba without incident. Others have
45 experienced much pain and user frustration. So it is to be hoped that the
46 notes in this chapter will make a positive difference by assuring that
47 someone will be saved a lot of discomfort.
51 Before anyone commences an upgrade or an update of Samba the one cardinal
52 rule that must be observed is: Backup all Samba configuration files in
53 case it is necessary to revert to the old version. Even if you do not like
54 this precautionary step, users will punish an administrator who
55 fails to take adequate steps to avoid situations that may inflict lost
56 productivity on a user.
60 Samba makes it possible to upgrade and update configuration files, but it
61 is not possible to downgrade the configuration files. Please ensure that
62 all configuration and control files are backed up to permit a down-grade
63 in the rare event that this may be necessary.
68 It is prudent also to backup all data files on the server before attempting
69 to perform a major upgrade. Many administrators have experienced the consequences
70 of failure to take adequate precautions. So what is adequate? That is simple!
71 If data is lost during an upgrade or and update and it can not be restored
72 the precautions take were inadequate. If a backup was not needed, but was available,
73 precaution was on the side of the victor.
77 <title>Cautions and Notes</title>
80 Someone once said, <quote>It is good to be sorry, but better never to need to be!</quote>
81 These are wise words of advice to those contemplating a Samba upgrade or update.
85 This is as good a time as any to define the terms <constant>upgrade</constant> and
86 <constant>update</constant>. The term <constant>upgrade</constant> is used to refer to
87 the installation of a version of Samba that is a whole generation or more ahead of
88 that which is installed. Generations are indicated by the first digit of the version
89 number. So far Samba has been release in generations 1.x, 2.x, 3.x and currently 4.0
94 The term <constant>update</constant> is used to refer to a minor version number installation
95 in place of one of the same generation. For example, updating from Samba 3.0.10 to 3.0.14
96 is an update. The move from Samba 2.0.7 to 3.0.14 is an upgrade.
100 While the use of these terms is an exercise in semantics, what needs to be realized
101 is that there are major functional differences between a Samba 2.x release and a Samba
102 3.0.x release. Such differences may require a significantly different approach to
103 solving the same networking challenge and generally requires careful review of the
104 latest documentation to identify precisely how the new installation may need to be
105 modified to preserve prior functionality.
109 There is an old axiom that says, <quote>The greater the volume of the documentation
110 the greater the risk that no-one will read it, but where there is no documentation
111 no-one can read it!</quote>. While true, some documentation is an evil necessity.
112 It is to be hoped that this update to the documentation will avoid both extremes.
116 <title>Security Identifiers (SIDs)</title>
119 Before the days of Windows NT and OS/2 every Windows and DOS networking client
120 that used the SMB protocols was an entirely autonomous entity. There was no concept
121 of a security identifier for a machine or a user outside of the username, the
122 machine name, and the workgroup name. In actual fact, these were not security identifies
123 in the same context as the way that the SID is used since the development of
128 Versions of Samba prior to 1.9 did not make use of a SID, instead they make exclusive use
129 of the username that is embedded in the SessionSetUpAndX component of the connection
130 setup process between a Windows client and an SMB/CIFS server.
134 Around November 1997 support was added to Samba-1.9 to handle the Windows security
135 rpc based protocols that implemented support for Samba to store a machine SID. This
136 information was stored in a file called <filename>MACHINE.SID.</filename>
140 Within the life time of the early Samba 2.x series the machine SID information was
141 relocated into a tdb file called <filename>secrets.tdb</filename>, which is where is
142 is still located in Samba 3.0.x along with other information that pertains to the
143 local machine and its role within a domain security context.
147 There are two types of SID, those pertaining to the machine itself and the domain to
148 which it may belong, and those pertaining to users and groups within the security
149 context of the local machine (in the case of stand-alone servers (SAS) and domain member
154 When the Samba <command>smbd</command> daemon is first started, if the <filename>secrets.tdb</filename>
155 file does not exist it is created at the first client connection attempt. If this file does
156 exist, <command>smbd</command> checks that there is a machine SID (if it is a domain controller
157 it searches for the domain SID). If <command>smbd</command> does not find one for the current
158 name of the machine or for the current name of the workgroup a new SID will be generated and
159 then written to the <filename>secrets.tdb</filename> file. The SID is generated in a non-determinative
160 manner. This means that each time it is generated for a particular combination of machine name
161 (hostname) and domain name (workgroup) it will be different.
165 The SID is the key used by MS Windows networking for all networking operations. This means
166 that when the machine or domain SID changes all security encoded objects such as profiles
167 and ACLs may become unusable.
171 It is of paramount importance that the machine and domain SID must be backed up so that in
172 the event of a change of hostname (machine name) or domain name (workgroup) the SID can
173 be restored to its previous value.
177 The local machine SID can be backed up using this procedure (Samba-3):
179 &rootprompt; net getlocalsid > /etc/samba/my-local-SID
181 The contents of the file <filename>/etc/samba/my-local-SID</filename> will be:
183 SID for domain FRODO is: S-1-5-21-726309263-4128913605-1168186429
185 This SID can be restored by executing:
187 &rootprompt; net setlocalsid S-1-5-21-726309263-4128913605-1168186429
192 Samba 1.9.x stored the machine SID in the the file <filename>/etc/MACHINE.SID</filename>
193 from which it can be recovered and stored into the <filename>secrets.tdb</filename> file
194 using the procedure shown above.
198 Where the <filename>secrets.tdb</filename> file exists and a version of Samba 2.x or later
199 has been used there is no specific need to go through this update process.
203 In the course of the Samba 2.0.x series the <command>smbpasswd</command> was modified to
204 permit the domain SID to be captured to the <filename>secrets.tdb</filename> file by executing:
206 &rootprompt; smbpasswd -S PDC -Uadministrator%password
211 The release of the Samba 2.2.x series permitted the SID to be obtained by executing:
213 &rootprompt; smbpasswd -S PDC -Uadministrator%password
215 From which the SID could be copied to a file and then it could be written to the
216 <filename>secrets.tdb</filename> file by executing:
218 &rootprompt; smbpasswd -W S-1-5-21-726309263-4128913605-1168186429
223 Domain security information, that includes the domain SID, can be obtained from Samba-2.2.x
224 systems by executing:
226 &rootprompt; rpcclient lsaquery -Uroot%password
228 This can also be done with Samba-3 by executing:
230 &rootprompt; net rpc info -Uroot%password
231 Domain Name: MIDEARTH
232 Domain SID: S-1-5-21-726309263-4128913605-1168186429
233 Sequence number: 1113415916
235 Num domain groups: 86
238 It is a very good practice to store this SID information in a safely kept file, just in
239 case it is ever needed at a later date.
243 Take note that the domain SID is used extensively in Samba. Where LDAP is used for the
244 <parameter>passdb backend</parameter>, all user, group, and trust accounts are encoded
245 with the domain SID. This means that if the domain SID changes for any reason the entire
246 Samba environment can become broken thus requiring extensive corrective action is the
247 original SID can not be restored. Fortunately, it can be recovered from a dump of the
248 LDAP database. A dump of the LDAP directory database can be obtained by executing:
250 &rootprompt; slapcat -v -l filename.ldif
255 When the domain SID has changed roaming profiles will cease to be functional. The recovery
256 of roaming profiles will necessitate resetting of the domain portion of the user SID
257 that owns the profile. This is encoded in the <filename>NTUser.DAT</filename> and can be
258 updated using the Samba <command>profiles</command> utility. Please be aware that not all
259 Linux distributions of the Samba RPMs do include this essential utility. Please do not
260 complain to the Samba Team if this utility is missing, that is an issue that must be
261 addressed to the creator of the RPM package. The Samba Team do their best to make
262 available all the tools needed to manage a Samba based Windows networking environment.
268 <title>Change of hostname</title>
271 Samba uses two (2) methods by which the primary NetBIOS machine name (also known as a computer
272 name or the hostname) may be determined: If the &smb.conf; file contains an entry
273 <parameter>netbios name</parameter> entry its value will be used directly. In the absence
274 of such and entry the UNIX system hostname will be used.
278 Many sites have become victims of lost Samba functionality because the UNIX system
279 hostname was changed for one reason or another. Such a change will cause a new machine
280 SID to be generated. If this happens on a domain controller it will also change the
281 domain SID. These SIDs can be updated (restored) using the procedure outlined above.
285 Do NOT change the hostname or the <parameter>netbios name</parameter>. If this
286 is changed be sure to reset the machine SID to the original setting, otherwise
287 there may be serious interoperability and/or operational problems.
293 <title>Change of workgroup (domain) name</title>
296 The domain name of a Samba server is identical with the workgroup name and is
297 set in the &smb.conf; file using the <parameter>workgroup</parameter> parameter.
298 This has been consistent throughout the history of Samba and across all versions.
302 Be aware that when the workgroup name is changed a new SID will be generated.
303 The old domain SID can be reset using the procedure outlined earlier in this chapter.
309 <title>Location of config files</title>
312 The Samba 1.9.x &smb.conf; file may be found either in the <filename>/etc</filename>
313 directory or in <filename>/usr/local/samba/lib</filename>.
317 During the life of the Samba 2.x release the &smb.conf; file was relocated
318 on Linux systems to the <filename>/etc/samba</filename> directory where it
319 remains located also for Samba 3.0.x installations.
323 Samba 2.x introduced the secrets.tdb file that is also stored in the
324 <filename>/etc/samba</filename> directory, or in the <filename>/usr/local/samba/lib</filename>
325 directory sub-system.
329 The location at which <command>smbd</command> expects to find all configuration and control
330 files is determined at the time of compilation of Samba. For versions of Samba prior to
331 3.0 one way to find the expected location of these files is to execute:
333 &rootprompt; strings /usr/sbin/smbd | grep conf
334 &rootprompt; strings /usr/sbin/smbd | grep secret
335 &rootprompt; strings /usr/sbin/smbd | grep smbpasswd
337 Note: The <command>smbd</command> executable may be located in the path
338 <filename>/usr/local/samba/sbin</filename>.
342 Samba-3 provides a neat new way to track the location of all control files as well as to
343 find the compile-time options used as the Samba package was built. Here is how the dark
344 secrets of the internals of Samba can be uncovered:
346 &rootprompt; smbd -b | less
349 Built on: Mon Apr 11 20:23:27 MDT 2005
351 Build host: Linux frodo 2.6...
352 SRCDIR: /usr/src/packages/BUILD/samba-3.0.15/source
353 BUILDDIR: /usr/src/packages/BUILD/samba-3.0.15/source
358 SWATDIR: /usr/share/samba/swat
359 CONFIGFILE: /etc/samba/smb.conf
360 LOGFILEBASE: /var/log/samba
361 LMHOSTSFILE: /etc/samba/lmhosts
362 LIBDIR: /usr/lib/samba
364 LOCKDIR: /var/lib/samba
365 PIDDIR: /var/run/samba
366 SMB_PASSWD_FILE: /etc/samba/smbpasswd
367 PRIVATE_DIR: /etc/samba
373 It is important that both the &smb.conf; file and the <filename>secrets.tdb</filename> should
374 be backed up before attempting any upgrade. The <filename>secrets.tdb</filename> file is version
375 encoded and therefore a newer version may not work with an older version of Samba. A backup
376 means that it is always possible to revert a failed or problematic upgrade.
386 <title>Upgrading from Samba 1.x and 2.x to Samba-3</title>
389 Sites that are being upgraded from Samba-2 (or earlier versions) to Samba-3
390 may experience little difficulty or may require a lot of effort, depending
391 on the complexity of the configuration. Samba-1.9.x upgrades to Samba-3 will
392 generally be simple and straight forward, although no upgrade should be
393 attempted without proper planning and preparation.
397 There are two basic modes of use of Samba versions prior to Samba-3. The first
398 does not use LDAP, the other does. Samba-1.9.x did not provide LDAP support.
399 Samba-2.x could be compiled with LDAP support.
403 <title>Samba 1.9.x and 2.x Versions Without LDAP</title>
406 Where it is necessary to upgrade an old Samba installation to Samba-3
407 the following procedure can be followed:
410 <procedure id="sbeug2">
412 Stop Samba. This can be done using the appropriate system tool
413 that is particular for each operating system or by executing the
414 <command>kill</command> command on <command>smbd, nmbd</command>
415 and on <command>winbindd</command>.
419 Find the location of the Samba &smb.conf; file - back it up to a
424 Find the location of the <filename>smbpasswd</filename> file -
425 back it up to a safe location.
429 Find the location of the <filename>secrets.tdb</filename> file -
430 back it up to a safe location.
434 Find the location of the lock directory. This is the directory
435 in which Samba stores all its tdb control files. The default
436 location used by the Samba Team is in
437 <filename>/usr/local/samba/var/locks</filename> directory,
438 but on Linux systems the old location was under the
439 <filename>/var/cache/samba</filename> directory, however the
440 Linux Standards Base specified location is now under the
441 <filename>/var/lib/samba</filename> directory. Copy all the
442 tdb files to a safe location.
446 It is now safe to ugrade the Samba installation. On Linux systems
447 it is not necessary to remove the Samba RPMs becasue a simple
448 upgrade installation will automatically remove the old files.
452 On systems that do not support a reliable package management system
453 it is advisable either to delete the Samba old installation , or to
454 move it out of the way by renaming the directories that contain the
459 When the Samba upgrade has been installed the first step that should
460 be completed is to identify the new target locations for the control
461 files. Follow the steps shown in <link linend="sbeug1"/> to locate
462 the correct directories to which each control file must be moved.
466 Do not change the hostname.
470 Do not change the workgroup name.
474 Execute the <command>testparm</command> to validate the smb.conf file.
475 This process will flag any parameters that are no longer supported.
476 It will also flag configuration settings that may be in conflict.
480 One solution that may be used to clean up and to update the &smb.conf;
481 file involves renaming it to <filename>smb.conf.master</filename> and
482 then executing the following:
484 &rootprompt; cd /etc/samba
485 &rootprompt; testparm -s smb.conf.master > smb.conf
487 The resulting &smb.conf; file will be stripped of all comments
488 and will be stripped of all non-conforming configuration settings.
492 It is now safe to start Samba using the appropriate system tool.
493 Alternately, it is possible to just execute <command>nmbd, smbd</command>
494 and <command>winbindd</command> for the command line while logged in
503 <title>Samba-2.x with LDAP support</title>
506 Samba version 2.x could be compiled for use either with, or without, LDAP.
507 The LDAP control settings in the &smb.conf; file in this old version are
508 completely different (and less complete) than they are with Samba-3. This
509 means that after migrating the control files it will be necessary to reconfigure
510 the LDAP settings entirely.
514 Follow the procedure outlined in <link linkend="sbeug2"/> to affect a migration
515 of all files to the correct locations.
519 The Samba SAM schema required for Samba-3 is significantly different from that
520 used with Samba 2.x. This means that the LDAP directory will need to be updated
521 using the procedure outlined in the Samba WHATSNEW.txt file that accompanies
522 all releases of Samba-3. This information is repeated here directly from this
525 ######################################################################
529 This section outlines the new features affecting Samba / LDAP
535 A new object class (sambaSamAccount) has been introduced to replace
536 the old sambaAccount. This change aids us in the renaming of
537 attributes to prevent clashes with attributes from other vendors.
538 There is a conversion script (examples/LDAP/convertSambaAccount) to
539 modify and LDIF file to the new schema.
543 $ ldapsearch .... -b "ou=people,dc=..." > sambaAcct.ldif
544 $ convertSambaAccount --sid=<Domain SID> \
545 --input=sambaAcct.ldif --output=sambaSamAcct.ldif \
546 --changetype=[modify|add]
548 The <DOM SID> can be obtained by running 'net getlocalsid
549 <DOMAINNAME>' on the Samba PDC as root. The changetype determines
550 the format of the generated LDIF output--either create new entries
551 or modify existing entries.
553 The old sambaAccount schema may still be used by specifying the
554 "ldapsam_compat" passdb backend. However, the sambaAccount and
555 associated attributes have been moved to the historical section of
556 the schema file and must be uncommented before use if needed.
557 The 2.2 object class declaration for a sambaAccount has not changed
558 in the 3.0 samba.schema file.
560 Other new object classes and their uses include:
562 * sambaDomain - domain information used to allocate rids
563 for users and groups as necessary. The attributes are added
564 in 'ldap suffix' directory entry automatically if
565 an idmap uid/gid range has been set and the 'ldapsam'
566 passdb backend has been selected.
568 * sambaGroupMapping - an object representing the
569 relationship between a posixGroup and a Windows
570 group/SID. These entries are stored in the 'ldap
571 group suffix' and managed by the 'net groupmap' command.
573 * sambaUnixIdPool - created in the 'ldap idmap suffix' entry
574 automatically and contains the next available 'idmap uid' and
577 * sambaIdmapEntry - object storing a mapping between a
578 SID and a UNIX uid/gid. These objects are created by the
579 idmap_ldap module as needed.
581 * sambaSidEntry - object representing a SID alone, as a Structural
582 class on which to build the sambaIdmapEntry.
585 New Suffix for Searching
586 ------------------------
588 The following new smb.conf parameters have been added to aid in directing
589 certain LDAP queries when 'passdb backend = ldapsam://...' has been
592 * ldap suffix - used to search for user and computer accounts
593 * ldap user suffix - used to store user accounts
594 * ldap machine suffix - used to store machine trust accounts
595 * ldap group suffix - location of posixGroup/sambaGroupMapping entries
596 * ldap idmap suffix - location of sambaIdmapEntry objects
598 If an 'ldap suffix' is defined, it will be appended to all of the
599 remaining sub-suffix parameters. In this case, the order of the suffix
600 listings in smb.conf is important. Always place the 'ldap suffix' first
603 Due to a limitation in Samba's smb.conf parsing, you should not surround
604 the DN's with quotation marks.
613 <title>Updating a Samba-3 Installation</title>
619 <title>Updating from Versions Earlier than 3.0.6</title>
627 <title>Updating from Versions between 3.0.7 and 3.0.10</title>
635 <title>Migrating Samba-3 to a New Server</title>