Fix indentation in Pearson XML output
[Samba.git] / docs / Samba-HOWTO-Collection / AccessControls.xml
blob3e933bf01babed13f5d3b44ce97864287d42dd68
1 <?xml version="1.0" encoding="iso-8859-1"?>
2 <!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3                 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4   <!ENTITY % global_entities SYSTEM '../entities/global.entities'>
5   %global_entities;
6 ]>
8 <chapter id="AccessControls">
9 <chapterinfo>
10         &author.jht;
11         &author.jeremy;
12         <author>&person.jelmer;<contrib>drawing</contrib></author>
13         <pubdate>May 10, 2003</pubdate>
14 </chapterinfo>
15 <title>File, Directory and Share Access Controls</title>
17 <para>
18 <indexterm><primary>ACLs</primary></indexterm>
19 Advanced MS Windows users are frequently perplexed when file, directory and share manipulation of
20 resources shared via Samba do not behave in the manner they might expect. MS Windows network
21 administrators are often confused regarding network access controls and how to
22 provide users with the access they need while protecting resources from unauthorized access.
23 </para>
25 <para>
26 Many UNIX administrators are unfamiliar with the MS Windows environment and in particular
27 have difficulty in visualizing what the MS Windows user wishes to achieve in attempts to set file
28 and directory access permissions. 
29 </para>
31 <para>
32 The problem lies in the differences in how file and directory permissions and controls work
33 between the two environments. This difference is one that Samba cannot completely hide, even
34 though it does try to bridge the chasm to a degree.
35 </para>
37 <para>
38 <indexterm><primary>Extended Attributes</primary></indexterm>
39 <indexterm><primary>ACLs</primary><secondary>POSIX</secondary></indexterm>
41 POSIX Access Control List technology has been available (along with Extended Attributes)
42 for UNIX for many years, yet there is little evidence today of any significant use. This
43 explains to some extent the slow adoption of ACLs into commercial Linux products. MS Windows
44 administrators are astounded at this, given that ACLs were a foundational capability of the now
45 decade-old MS Windows NT operating system.
46 </para>
48 <para>
49 The purpose of this chapter is to present each of the points of control that are possible with
50 Samba-3 in the hope that this will help the network administrator to find the optimum method
51 for delivering the best environment for MS Windows desktop users.
52 </para>
54 <para>
55 This is an opportune point to mention that Samba was created to provide a means of interoperability
56 and interchange of data between differing operating environments. Samba has no intent to change
57 UNIX/Linux into a platform like MS Windows. Instead the purpose was and is to provide a sufficient
58 level of exchange of data between the two environments. What is available today extends well
59 beyond early plans and expectations, yet the gap continues to shrink.
60 </para>
62 <sect1>
63 <title>Features and Benefits</title>
65         <para>
66         Samba offers a lot of flexibility in file system access management. These are the key access control
67         facilities present in Samba today:
68         </para>
70         <itemizedlist>
71         <title>Samba Access Control Facilities</title>
72                 <listitem><para>
73                                 <indexterm><primary>permissions</primary><secondary>UNIX file and directory</secondary></indexterm>
74                 <emphasis>UNIX File and Directory Permissions</emphasis>
75                 </para>
77                         <para>
78                         Samba honors and implements UNIX file system access controls. Users
79                         who access a Samba server will do so as a particular MS Windows user.
80                         This information is passed to the Samba server as part of the logon or
81                         connection setup process. Samba uses this user identity to validate
82                         whether or not the user should be given access to file system resources
83                         (files and directories). This chapter provides an overview for those
84                         to whom the UNIX permissions and controls are a little strange or unknown.
85                         </para>
86                 </listitem>
88                 <listitem><para>
89                 <emphasis>Samba Share Definitions</emphasis>
90                 </para>
92                         <para>
93                         In configuring share settings and controls in the &smb.conf; file,
94                         the network administrator can exercise overrides to native file
95                         system permissions and behaviors. This can be handy and convenient
96                         to effect behavior that is more like what MS Windows NT users expect
97                         but it is seldom the <emphasis>best</emphasis> way to achieve this.
98                         The basic options and techniques are described herein.
99                         </para>
100                 </listitem>
102                 <listitem><para>
103                 <emphasis>Samba Share ACLs</emphasis>
104                 <indexterm><primary>ACLs</primary><secondary>share</secondary></indexterm>
105                 </para>
107                         <para>
108                         Just like it is possible in MS Windows NT to set ACLs on shares
109                         themselves, so it is possible to do this in Samba.
110                         Few people make use of this facility, yet it remains one of the
111                         easiest ways to affect access controls (restrictions) and can often
112                         do so with minimum invasiveness compared with other methods.
113                         </para>
114                 </listitem>
116                 <listitem><para>
117                                 <indexterm><primary>ACLs</primary><secondary>POSIX</secondary></indexterm>
118                                 <indexterm><primary>ACLs</primary><secondary>Windows</secondary></indexterm>
119                 <emphasis>MS Windows ACLs through UNIX POSIX ACLs</emphasis>
120                 </para>
122                         <para>
123                         The use of POSIX ACLs on UNIX/Linux is possible only if the underlying
124                         operating system supports them. If not, then this option will not be
125                         available to you. Current UNIX technology platforms have native support
126                         for POSIX ACLs. There are patches for the Linux kernel that also provide
127                         this. Sadly, few Linux platforms ship today with native ACLs and
128                         Extended Attributes enabled. This chapter has pertinent information
129                         for users of platforms that support them.
130                         </para>
131                 </listitem>
132         </itemizedlist>
134 </sect1>
136 <sect1>
137 <title>File System Access Controls</title>
139 <para>
140 Perhaps the most important recognition to be made is the simple fact that MS Windows NT4/200x/XP
141 implement a totally divergent file system technology from what is provided in the UNIX operating system
142 environment. First we consider what the most significant differences are, then we look
143 at how Samba helps to bridge the differences.
144 </para>
146         <sect2>
147         <title>MS Windows NTFS Comparison with UNIX File Systems</title>
149         <para>
150 <indexterm><primary>NTFS</primary></indexterm>
151 <indexterm><primary>File System</primary></indexterm>
152 <indexterm><primary>File System</primary><secondary>UNIX</secondary></indexterm>
153 <indexterm><primary>File System</primary><secondary>Windows</secondary></indexterm>
155         Samba operates on top of the UNIX file system. This means it is subject to UNIX file system conventions
156         and permissions. It also means that if the MS Windows networking environment requires file system
157         behavior that differs from UNIX file system behavior then somehow Samba is responsible for emulating
158         that in a transparent and consistent manner.
159         </para>
161         <para>
162         It is good news that Samba does this to a large extent and on top of that provides a high degree
163         of optional configuration to override the default behavior. We look at some of these over-rides,
164         but for the greater part we will stay within the bounds of default behavior. Those wishing to explore
165         the depths of control ability should review the &smb.conf; man page.
166         </para>
168         <para>The following compares file system features for UNIX with those of Microsoft Windows NT/200x:
169         <indexterm><primary>File System</primary><secondary>feature comparison</secondary></indexterm>
170         
171         </para>
173         <variablelist>
174                 <varlistentry>
175                         <term>Name Space</term>
176                         <listitem>
177                 <para>
178                 MS Windows NT4/200x/XP files names may be up to 254 characters long, and UNIX file names
179                 may be 1023 characters long. In MS Windows, file extensions indicate particular file types,
180                 in UNIX this is not so rigorously observed as all names are considered arbitrary. 
181                 </para>
182                 <para>
183                 What MS Windows calls a folder, UNIX calls a directory.
184                 </para>
185                         </listitem>
186                 </varlistentry>
188                 <varlistentry>
189                         <term>Case Sensitivity</term>
190                         <listitem>
191                 <para>
192                 <indexterm><primary>8.3 file names</primary></indexterm>
193                 <indexterm><primary>File System</primary><secondary>case sensitivity</secondary></indexterm>
194                 MS Windows file names are generally upper case if made up of 8.3 (8 character file name
195                 and 3 character extension. File names that are longer than 8.3 are case preserving and case
196                 insensitive.
197                 </para>
199                 <para>
200                 UNIX file and directory names are case sensitive and case preserving. Samba implements the
201                 MS Windows file name behavior, but it does so as a user application. The UNIX file system
202                 provides no mechanism to perform case insensitive file name lookups. MS Windows does this
203                 by default. This means that Samba has to carry the processing overhead to provide features
204                 that are not native to the UNIX operating system environment.
205                 </para>
206                 <para>
207                 Consider the following. All are unique UNIX names but one single MS Windows file name:
208                 <screen>
209                                 MYFILE.TXT
210                                 MyFile.txt
211                                 myfile.txt
212                 </screen></para>
214                 <para>
215                 So clearly, in an MS Windows file name space these three files cannot co-exist, but in UNIX
216                 they can.
217                 </para>
218                 <para>
219                 So what should Samba do if all three are present? That which is lexically first will be
220                 accessible to MS Windows users, the others are invisible and unaccessible &smbmdash; any
221                 other solution would be suicidal.
222                 </para>
223                         </listitem>
224                 </varlistentry>
226                 <varlistentry>
227                         <term>Directory Separators</term>
228                         <listitem>
230                 <para>
231                                 <indexterm><primary>Directory Separators</primary></indexterm>
232                 MS Windows and DOS uses the backslash <constant>\</constant> as a directory delimiter, and UNIX uses
233                 the forward-slash <constant>/</constant> as its directory delimiter. This is handled transparently by Samba.
234                 </para>
235                         </listitem>
236                 </varlistentry>
238                 <varlistentry>
239                         <term>Drive Identification</term>
240                         <listitem>
241                 <para>
242                         <indexterm><primary>Drive Identification</primary></indexterm>
243                 MS Windows products support a notion of drive letters, like <command>C:</command> to represent
244                 disk partitions. UNIX has no concept of separate identifiers for file partitions, each
245                 such file system is mounted to become part of the overall directory tree.
246                 The UNIX directory tree begins at <constant>/</constant> just like the root of a DOS drive is specified as
247                 <constant>C:\</constant>.
248                 </para>
249                         </listitem>
250                 </varlistentry>
252                 <varlistentry>
253                         <term>File Naming Conventions</term>
254                         <listitem>
255                 <para>
256                         <indexterm><primary>File Naming Conventions</primary></indexterm>
257                 MS Windows generally never experiences file names that begin with a dot (<constant>.</constant>) while in UNIX these
258                 are commonly found in a user's home directory. Files that begin with a dot (<constant>.</constant>) are typically
259                 either start-up files for various UNIX applications, or they may be files that contain
260                 start-up configuration data.
261                 </para>
262                         </listitem>
263                 </varlistentry>
265                 <varlistentry>
266                         <term>Links and Short-Cuts</term>
267                         <listitem>
268                 <para>
269                 <indexterm><primary>Links</primary><secondary>hard</secondary></indexterm>
270                 <indexterm><primary>Links</primary><secondary>soft</secondary></indexterm>
271                 <indexterm><primary>Short-Cuts</primary></indexterm>
272                 MS Windows make use of <quote>links and short-cuts</quote> that are actually special types of files that will
273                 redirect an attempt to execute the file to the real location of the file. UNIX knows of file and directory
274                 links, but they are entirely different from what MS Windows users are used to.
275                 </para>
276                 <para>
277                 Symbolic links are files in UNIX that contain the actual location of the data (file or directory). An
278                 operation (like read or write) will operate directly on the file referenced. Symbolic links are also
279                 referred to as <quote>soft links.</quote> A hard link is something that MS Windows is not familiar with. It allows
280                 one physical file to be known simultaneously by more than one file name.
281                 </para>
282                         </listitem>
283                 </varlistentry>
284         </variablelist>
286         <para>
287         There are many other subtle differences that may cause the MS Windows administrator some temporary discomfort
288         in the process of becoming familiar with UNIX/Linux. These are best left for a text that is dedicated to the
289         purpose of UNIX/Linux training and education.
290         </para>
292         </sect2>
294         <sect2>
295         <title>Managing Directories</title>
297         <para>
298         There are three basic operations for managing directories: <command>create, delete, rename</command>.
299         <table frame="all">
300                 <title>Managing Directories with UNIX and Windows</title>
301                 <tgroup align="center" cols="3">
302                 <thead>
303                 <row><entry>Action</entry><entry>MS Windows Command</entry><entry>UNIX Command</entry></row>
304                 </thead>
305         
306                 <tbody>
307                         <row><entry>create</entry><entry>md folder</entry><entry>mkdir folder</entry></row>
308                         <row><entry>delete</entry><entry>rd folder</entry><entry>rmdir folder</entry></row>
309                         <row><entry>rename</entry><entry>rename oldname newname</entry><entry>mv oldname newname</entry></row>
310                 </tbody>
311         </tgroup>
312         </table>
313         </para>
315         </sect2>
317         <sect2>
318         <title>File and Directory Access Control</title>
321         <para>
322         <indexterm><primary>ACLs</primary><secondary>File System</secondary></indexterm>
323         The network administrator is strongly advised to read foundational training manuals and reference materials
324         regarding file and directory permissions maintenance. Much can be achieved with the basic UNIX permissions
325         without having to resort to more complex facilities like POSIX Access Control Lists (ACLs) or Extended
326         Attributes (EAs).
327         </para>
329         <para>
330         UNIX/Linux file and directory access permissions involves setting three primary sets of data and one control set.
331         A UNIX file listing looks as follows:
332 <screen>
333 &prompt;<userinput>ls -la</userinput>
334 total 632
335 drwxr-xr-x   13 maryo   gnomes      816 2003-05-12 22:56 .
336 drwxrwxr-x   37 maryo   gnomes     3800 2003-05-12 22:29 ..
337 dr-xr-xr-x    2 maryo   gnomes       48 2003-05-12 22:29 muchado02
338 drwxrwxrwx    2 maryo   gnomes       48 2003-05-12 22:29 muchado03
339 drw-rw-rw-    2 maryo   gnomes       48 2003-05-12 22:29 muchado04
340 d-w--w--w-    2 maryo   gnomes       48 2003-05-12 22:29 muchado05
341 dr--r--r--    2 maryo   gnomes       48 2003-05-12 22:29 muchado06
342 drwsrwsrwx    2 maryo   gnomes       48 2003-05-12 22:29 muchado08
343 ----------    1 maryo   gnomes     1242 2003-05-12 22:31 mydata00.lst
344 --w--w--w-    1 maryo   gnomes     7754 2003-05-12 22:33 mydata02.lst
345 -r--r--r--    1 maryo   gnomes    21017 2003-05-12 22:32 mydata04.lst
346 -rw-rw-rw-    1 maryo   gnomes    41105 2003-05-12 22:32 mydata06.lst
347 &prompt;
348 </screen>
349         </para>
351         <para>
352         The columns above represent (from left to right): permissions, number of hard links to file, owner, group, size (bytes), access date, access time, file name.
353         </para>
355         <para>
356         An overview of the permissions field can be found in <link linkend="access1">Overview of UNIX permissions field</link>.
357         </para>
359         <image id="access1" scale="40"><imagedescription>Overview of UNIX permissions field.</imagedescription><imagefile>access1</imagefile></image>
361         <para>
362         Any bit flag may be unset. An unset bit flag is the equivalent of <quote>cannot</quote> and is represented as a <quote>-</quote> character.
364         <example>
365                 <title>Example File</title>
366                 <programlisting>
367                 -rwxr-x---   Means: The owner (user) can read, write, execute
368                                     the group can read and execute
369                                     everyone else cannot do anything with it.
370                 </programlisting>
371         </example>
373         </para>
375         <para>
376         Additional possibilities in the [type] field are: c = character device, b = block device, p = pipe device, s = UNIX Domain Socket.
377         </para>
379         <para>
380         The letters <constant>rwxXst</constant> set permissions for the user, group and others as: read (r), write (w), execute (or access for directories) (x),
381         execute  only  if  the  file  is a directory or already has execute permission for some user (X), set user or group ID on execution (s),
382         sticky (t).
383         </para>
385         <para>
386         When the sticky bit is set on a directory, files in that directory may be unlinked (deleted) or renamed only by root or their owner. 
387         Without the sticky  bit, anyone able to write to the directory can delete or rename files. The sticky bit is commonly found on
388         directories, such as <filename>/tmp</filename>, that are world-writable.
389         </para>
391         <para>
392         When the set user or group ID bit (s) is set on a directory, then all files created within it will be owned by the user and/or
393         group whose `set user or group' bit is set. This can be helpful in setting up directories for which it is desired that
394         all users who are in a group should be able to write to and read from a file, particularly when it is undesirable for that file
395         to be exclusively owned by a user whose primary group is not the group that all such users belong to.
396         </para>
398         <para>
399         When a directory is set <constant>d-wx--x---</constant> this means that the owner can read and create (write) files in it, but because
400         the (r) read flags are not set, files cannot be listed (seen) in the directory by anyone. The group can read files in the
401         directory but cannot create new files. If files in the directory are set to be readable and writable for the group, then
402         group members will be able to write to (or delete) them.
403         </para>
405         </sect2>
407 </sect1>
409 <sect1>
410 <title>Share Definition Access Controls</title>
413 <para>
414 <indexterm><primary>permissions</primary><secondary>share</secondary></indexterm>
415 The following parameters in the &smb.conf; file sections define a share control or effect access controls.
416 Before using any of the following options, please refer to the man page for &smb.conf;.
417 </para>
419         <sect2>
420         <title>User and Group-Based Controls</title>
422         <para>
423         User and group-based controls can prove quite useful. In some situations it is distinctly desirable to affect all
424         file system operations as if a single user were doing so. The use of the <smbconfoption><name>force user</name></smbconfoption> and 
425         <smbconfoption><name>force group</name></smbconfoption> behavior will achieve this. In other situations it may be necessary to effect a
426         paranoia level of control to ensure that only particular authorized persons will be able to access a share or
427         its contents. Here the use of the <smbconfoption><name>valid users</name></smbconfoption> or the
428         <smbconfoption><name>invalid users</name></smbconfoption> may be most useful.
429         </para>
431         <para>
432         As always, it is highly advisable to use the least difficult to maintain and the least ambiguous method for
433         controlling access. Remember, when you leave the scene someone else will need to provide assistance and
434         if he finds too great a mess or does not understand what you have done, there is risk of
435         Samba being removed and an alternative solution being adopted.
436         </para>
438         <para>
439         <link linkend="ugbc">Following table</link> enumerates these controls.
440         </para>
442         <table frame='all' pgwide='0' id="ugbc"><title>User and Group Based Controls</title>
443         <tgroup cols='2'>
444                 <colspec align="left"/>
445                 <colspec align="justify" colwidth="1*"/>
446                 <thead>
447                 <row>
448                         <entry align="center">Control Parameter</entry>
449                         <entry align="center">Description - Action - Notes</entry>
450                 </row>
451                 </thead>
452                 <tbody>
453                 <row>
454                         <entry><smbconfoption><name>admin users</name></smbconfoption></entry>
455                         <entry><para>
456                         List of users who will be granted administrative privileges on the share.
457                         They will do all file operations as the super-user (root). 
458                         Any user in this list will be able to do anything they like on the share,
459                         irrespective of file permissions.
460                         </para></entry>
461                 </row>
462                 <row>
463                         <entry><smbconfoption><name>force group</name></smbconfoption></entry>
464                         <entry><para>
465                         Specifies a UNIX group name that will be assigned as the default primary group
466                         for all users connecting to this service.
467                         </para></entry>
468                 </row>
469                 <row>
470                         <entry><smbconfoption><name>force user</name></smbconfoption></entry>
471                         <entry><para>
472                         Specifies a UNIX user name that will be assigned as the default user for all users connecting to this service.
473                         This is useful for sharing files. Incorrect use can cause security problems.
474                         </para></entry>
475                 </row>
476                 <row>
477                         <entry><smbconfoption><name>guest ok</name></smbconfoption></entry>
478                         <entry><para>
479                         If this parameter is set for a service, then no password is required to connect to the service. Privileges will be 
480                         those of the  guest account.
481                         </para></entry>
482                 </row>
483                 <row>
484                         <entry><smbconfoption><name>invalid users</name></smbconfoption></entry>
485                         <entry><para>
486                         List of users that should not be allowed to login to this service.
487                         </para></entry>
488                 </row>
489                 <row>
490                         <entry><smbconfoption><name>only user</name></smbconfoption></entry>
491                         <entry><para>
492                         Controls whether connections with usernames not in the user list will be allowed.
493                         </para></entry>
494                 </row>
495                 <row>
496                         <entry><smbconfoption><name>read list</name></smbconfoption></entry>
497                         <entry><para>
498                         List of users that are given read-only access to a service. Users in this list
499                         will not be given write access, no matter what the  read only  option is set to. 
500                         </para></entry>
501                 </row>
502                 <row>
503                         <entry><smbconfoption><name>username</name></smbconfoption></entry>
504                         <entry><para>
505                         Refer to the &smb.conf; man page for more information -- this is a complex and potentially misused parameter.
506                         </para></entry>
507                 </row>
508                 <row>
509                         <entry><smbconfoption><name>valid users</name></smbconfoption></entry>
510                         <entry><para>
511                         List of users that should be allowed to login to this service.
512                         </para></entry>
513                 </row>
514                 <row>
515                         <entry><smbconfoption><name>write list</name></smbconfoption></entry>
516                         <entry><para>
517                         List of users that are given read-write access to a service.
518                         </para></entry>
519                 </row>
520                 </tbody>
521         </tgroup>
522         </table>
524         </sect2>
526         <sect2>
527         <title>File and Directory Permissions-Based Controls</title>
529         <para>
530         The following file and directory permission-based controls, if misused, can result in considerable difficulty to
531         diagnose causes of misconfiguration. Use them sparingly and carefully. By gradually introducing each one by one,
532         undesirable side effects may be detected. In the event of a problem, always comment all of them out and then gradually
533         reintroduce them in a controlled way.
534         </para>
536         <para>
537         Refer to <link linkend="fdpbc">the following table</link> for information regarding the parameters that may be used to affect file and
538         directory permission-based access controls.
539         </para>
541         <table frame='all' id="fdpbc"><title>File and Directory Permission Based Controls</title>
542                 <tgroup cols='2'>
543                         <colspec align="left"/>
544                         <colspec align="justify" colwidth="1*"/>
545                 <thead>
546                 <row>
547                         <entry align="center">Control Parameter</entry>
548                         <entry align="center">Description - Action - Notes</entry>
549                 </row>
550                 </thead>
551                 <tbody>
552                 <row>
553                         <entry><smbconfoption><name>create mask</name></smbconfoption></entry>
554                         <entry><para>
555                         Refer to the &smb.conf; man page.
556                         </para></entry>
557                 </row>
558                 <row>
559                         <entry><smbconfoption><name>directory mask</name></smbconfoption></entry>
560                         <entry><para>
561                         The octal modes used when converting DOS modes to UNIX modes when creating UNIX directories.
562                         See also: directory security mask.
563                         </para></entry></row>
564                 <row>
565                         <entry><smbconfoption><name>dos filemode</name></smbconfoption></entry>
566                         <entry><para>
567                         Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
568                         </para></entry>
569                 </row>
570                 <row>
571                         <entry><smbconfoption><name>force create mode</name></smbconfoption></entry>
572                         <entry><para>
573                         This parameter specifies a set of UNIX mode bit permissions that will always be set on a file created by Samba.
574                         </para></entry>
575                 </row>
576                 <row>
577                         <entry><smbconfoption><name>force directory mode</name></smbconfoption></entry>
578                         <entry><para>
579                         This parameter specifies a set of UNIX mode bit permissions that will always be set on a directory created by Samba.
580                         </para></entry>
581                 </row>
582                 <row>
583                         <entry><smbconfoption><name>force directory security mode</name></smbconfoption></entry>
584                         <entry><para>
585                         Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory.
586                         </para></entry>
587                 </row>
588                 <row>
589                         <entry><smbconfoption><name>force security mode</name></smbconfoption></entry>
590                         <entry><para>
591                         Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
592                         </para></entry>
593                 </row>
594                 <row>
595                         <entry><smbconfoption><name>hide unreadable</name></smbconfoption></entry>
596                         <entry><para>
597                         Prevents clients from seeing the existence of files that cannot be read.
598                         </para></entry>
599                 </row>
600                 <row>
601                         <entry><smbconfoption><name>hide unwriteable files</name></smbconfoption></entry>
602                         <entry><para>
603                         Prevents clients from seeing the existence of files that cannot be written to. Unwriteable directories are shown as usual. 
604                         </para></entry>
605                 </row>
606                 <row>
607                         <entry><smbconfoption><name>nt acl support</name></smbconfoption></entry>
608                         <entry><para>
609                         This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT access control lists.
610                         </para></entry>
611                 </row>
612                 <row>
613                         <entry><smbconfoption><name>security mask</name></smbconfoption></entry>
614                         <entry><para>
615                         Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
616                         </para></entry>
617                 </row>
618                 </tbody>
619         </tgroup>
620         </table>
622         </sect2>
624         <sect2>
625         <title>Miscellaneous Controls</title>
627         <para>
628         The following are documented because of the prevalence of administrators creating inadvertent barriers to file
629         access by not understanding the full implications of &smb.conf; file settings. See <link linkend="mcoc">following table</link>.
630         </para>
632         <table frame='all' id="mcoc"><title>Other Controls</title>
633         <tgroup cols='2'>
634                 <colspec align="justify" colwidth="1*"/>
635                 <colspec align="justify" colwidth="1*"/>
636                 <thead>
637                 <row>
638                         <entry align="center">Control Parameter</entry>
639                         <entry align="center">Description - Action - Notes</entry>
640                 </row>
641                 </thead>
642                 <tbody>
643                 <row>
644                         <entry><smbconfoption><name>case sensitive</name></smbconfoption>, <smbconfoption><name>default case</name></smbconfoption>, <smbconfoption><name>short preserve case</name></smbconfoption></entry>
645                         <entry><para>
646                         This means that all file name lookup will be done in a case sensitive manner. 
647                         Files will be created with the precise file name Samba received from the MS Windows client.
648                         </para></entry>
649                 </row>
650                 <row>
651                         <entry><smbconfoption><name>csc policy</name></smbconfoption></entry>
652                         <entry><para>
653                         Client Side Caching Policy - parallels MS Windows client side file caching capabilities.
654                         </para></entry>
655                 </row>
656                 <row>
657                         <entry><smbconfoption><name>dont descend</name></smbconfoption></entry>
658                         <entry><para>
659                         Allows specifying a comma-delimited list of directories that the server should always show as empty.
660                         </para></entry>
661                 </row>
662                 <row>
663                         <entry><smbconfoption><name>dos filetime resolution</name></smbconfoption></entry>
664                         <entry><para>
665                         This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
666                         </para></entry>
667                 </row>
668                 <row>
669                         <entry><smbconfoption><name>dos filetimes</name></smbconfoption></entry>
670                         <entry><para>
671                         DOS and Windows allow users to change file time stamps if they can write to the file. POSIX semantics prevent this.
672                         This option allows DOS and Windows behavior.
673                         </para></entry>
674                 </row>
675                 <row>
676                         <entry><smbconfoption><name>fake oplocks</name></smbconfoption></entry>
677                         <entry><para>
678                         Oplocks are the way that SMB clients get permission from a server to locally cache file operations. If a server grants an
679                         oplock, the client is free to assume that it is the only one accessing the file and it will aggressively cache file data.
680                         </para></entry>
681                 </row>
682                 <row>
683                         <entry><smbconfoption><name>hide dot files</name></smbconfoption>, <smbconfoption><name>hide files</name></smbconfoption>, <smbconfoption><name>veto files</name></smbconfoption></entry>
684                         <entry><para>
685                         Note: MS Windows Explorer allows over-ride of files marked as hidden so they will still be visible.
686                         </para></entry>
687                 </row>
688                 <row>
689                         <entry><smbconfoption><name>read only</name></smbconfoption></entry>
690                         <entry><para>
691                         If this parameter is yes, then users of a service may not create or modify files in the service's directory.
692                         </para></entry>
693                 </row>
694                 <row>
695                         <entry><smbconfoption><name>veto files</name></smbconfoption></entry>
696                         <entry><para>
697                         List of files and directories that are neither visible nor accessible.
698                         </para></entry>
699                 </row>
700                 </tbody>
701         </tgroup>
702         </table>
704         </sect2>
706 </sect1>
708 <sect1>
709 <title>Access Controls on Shares</title>
712         <para>
713 <indexterm><primary>permissions</primary><secondary>share ACLs</secondary></indexterm>
714         This section deals with how to configure Samba per share access control restrictions.
715         By default, Samba sets no restrictions on the share itself. Restrictions on the share itself
716         can be set on MS Windows NT4/200x/XP shares. This can be an effective way to limit who can
717         connect to a share. In the absence of specific restrictions the default setting is to allow
718         the global user <constant>Everyone - Full Control</constant> (full control, change and read).
719         </para>
721         <para>
722         At this time Samba does not provide a tool for configuring access control setting on the share
723         itself. Samba does have the capacity to store and act on access control settings, but  the only
724         way to create those settings is to use either the NT4 Server Manager or the Windows 200x MMC for
725         Computer Management.
726         </para>
728         <para>
729         Samba stores the per share access control settings in a file called <filename>share_info.tdb</filename>.
730         The location of this file on your system will depend on how Samba was compiled. The default location
731         for Samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
732         utility has been compiled and installed on your system, then you can examine the contents of this file
733         by executing: <command>tdbdump share_info.tdb</command> in the directory containing the tdb files.
734         </para>
736         <sect2>
737         <title>Share Permissions Management</title>
739                 <para>
740                 The best tool for the task is platform dependant. Choose the best tool for your environment.
741                 </para>
743                         <sect3>
744                         <title>Windows NT4 Workstation/Server</title>
745                         <para>
746                         The tool you need to use to manage share permissions on a Samba server is the NT Server Manager.
747                         Server Manager is shipped with Windows NT4 Server products but not with Windows NT4 Workstation.
748                         You can obtain the NT Server Manager for MS Windows NT4 Workstation from Microsoft &smbmdash; see details below.
749                         </para>
751                         <?latex \newpage ?>
753                         <procedure>
754                         <title>Instructions</title>
755                         <step><para>
756                         Launch the <application>NT4 Server Manager</application>, click on the Samba server you want to administer. From the menu
757                         select <guimenu>Computer</guimenu>, then click on <guimenuitem>Shared Directories</guimenuitem>.
758                         </para></step>
760                         <step><para>
761                         Click on the share that you wish to manage, then click the <guilabel>Properties</guilabel> tab. then click
762                         the <guilabel>Permissions</guilabel> tab. Now you can add or change access control settings as you wish.
763                         </para></step>
764                         </procedure>
766                         </sect3>
768                         <sect3>
769                         <title>Windows 200x/XP</title>
771                         <para>
772                         On <application>MS Windows NT4/200x/XP</application> system access control lists on the share itself are set using native
773                         tools, usually from File Manager. For example, in Windows 200x, right click on the shared folder,
774                         then select <guimenuitem>Sharing</guimenuitem>, then click on <guilabel>Permissions</guilabel>. The default 
775                         Windows NT4/200x permission allows <quote>Everyone</quote> full control on the share.
776                         </para>
778                         <para>
779                         MS Windows 200x and later versions come with a tool called the <application>Computer Management</application> snap-in for the
780                         Microsoft Management Console (MMC). This tool is located by clicking on <guimenu>Control Panel ->
781                         Administrative Tools -> Computer Management</guimenu>.
782                         </para>
784                         <procedure>
785                         <title>Instructions</title>
786                         <step><para>
787                         After launching the MMC with the Computer Management snap-in, click the menu item <guimenuitem>Action</guimenuitem>,
788                         and select <guilabel>Connect to another computer</guilabel>. If you are not logged onto a domain you will be prompted
789                         to enter a domain login user identifier and a password. This will authenticate you to the domain.
790                         If you are already logged in with administrative privilege, this step is not offered.
791                         </para></step>
793                         <step><para>
794                         If the Samba server is not shown in the <guilabel>Select Computer</guilabel> box, type in the name of the target
795                         Samba server in the field <guilabel>Name:</guilabel>. Now click the on <guibutton>[+]</guibutton> next to 
796                         <guilabel>System Tools</guilabel>, then on the <guibutton>[+]</guibutton> next to <guilabel>Shared Folders</guilabel> in the 
797                         left panel.
798                         </para></step>
800                         <step><para>
801                         In the right panel, double-click on the share on which you wish to set access control permissions.
802                         Then click the tab <guilabel>Share Permissions</guilabel>. It is now possible to add access control entities
803                         to the shared folder. Remember to set what type of access (full control, change, read) you
804                         wish to assign for each entry.
805                         </para></step>
806                         </procedure>
808                         <warning>
809                         <para>
810                         Be careful. If you take away all permissions from the <constant>Everyone</constant> user without removing this user,
811                         effectively no user will be able to access the share. This is a result of what is known as
812                         ACL precedence. Everyone with <emphasis>no access</emphasis> means that <constant>MaryK</constant> who is part of the group 
813                         <constant>Everyone</constant> will have no access even if she is given explicit full control access.
814                         </para>
815                         </warning>
817                         </sect3>
818                 </sect2>
820 </sect1>
822 <sect1>
823 <title>MS Windows Access Control Lists and UNIX Interoperability</title>
825         <sect2>
826                 <title>Managing UNIX Permissions Using NT Security Dialogs</title>
829                 <para>
830 <indexterm><primary>permissions</primary><secondary>file/directory ACLs</secondary></indexterm>
831                 Windows NT clients can use their native security settings dialog box to view and modify the
832                 underlying UNIX permissions.
833                 </para>
835                 <para>
836                 This ability is careful not to compromise the security of the UNIX host on which Samba is running, and 
837                 still obeys all the file permission rules that a Samba administrator can set.
838                 </para>
840                 <para>
841                 Samba does not attempt to go beyond POSIX ACLs, so the various finer-grained access control
842                 options provided in Windows are actually ignored.
843                 </para> 
845                 <note>
846                 <para>
847                 All access to UNIX/Linux system files via Samba is controlled by the operating system file access controls.
848                 When trying to figure out file access problems, it is vitally important to find the identity of the Windows
849                 user as it is presented by Samba at the point of file access. This can best be determined from the
850                 Samba log files.
851                 </para>
852                 </note>
853         </sect2>
855         <sect2>
856                 <title>Viewing File Security on a Samba Share</title>
858                 <para>
859                 From an NT4/2000/XP client, right click on any file or directory in a Samba-mounted drive letter
860                 or UNC path. When the menu pops up, click on the <guilabel>Properties</guilabel> entry at the bottom
861                 of the menu. This brings up the file <constant>Properties</constant> dialog box. Click on the 
862                 <guilabel>Security</guilabel> tab and you will see three buttons: <guibutton>Permissions</guibutton>,
863                 <guibutton>Auditing</guibutton>, and <guibutton>Ownership</guibutton>. The <guibutton>Auditing</guibutton>
864                 button will cause either an error message <errorname>`A requested privilege is not held by the client'</errorname>
865                 to appear if the user is not the NT Administrator, or a dialog which is intended to allow an Administrator
866                 to add auditing requirements to a file if the user is logged on as the NT Administrator. This dialog is
867                 non-functional with a Samba share at this time, as the only useful button, the <guibutton>Add</guibutton>
868                 button, will not currently allow a list of users to be seen.
869                 </para>
871         </sect2>
873         <sect2>
874                 <title>Viewing File Ownership</title>
876                 <para>
877                 Clicking on the <guibutton>Ownership</guibutton> button brings up a dialog box telling you who owns
878                 the given file. The owner name will be displayed like this:
879                 </para>
881                 <para>
882                 <command><quote>SERVER\user (Long name)</quote></command>
883                 </para>
885                 <para>
886                 <replaceable>SERVER</replaceable> is the NetBIOS name of the Samba server, <replaceable>user</replaceable>
887                 is the user name of the UNIX user who owns the file, and <replaceable>(Long name)</replaceable> is the
888                 descriptive string identifying the user (normally found in the GECOS field of the UNIX password database).
889                 Click on the <guibutton>Close </guibutton> button to remove this dialog.
890                 </para>
892                 <para>
893                 If the parameter <smbconfoption><name>nt acl support</name></smbconfoption> is set to <constant>false</constant>,
894                 the file owner will be shown as the NT user <emphasis>Everyone</emphasis>.
895                 </para>
897                 <para>
898                 The <guibutton>Take Ownership</guibutton> button will not allow you to change the ownership of this file to
899                 yourself (clicking it will display a dialog box complaining that the user you are currently logged onto
900                 the NT client cannot be found). The reason for this is that changing the ownership of a file is a privileged
901                 operation in UNIX, available only to the <emphasis>root</emphasis> user. As clicking on this button causes
902                 NT to attempt to change the ownership of a file to the current user logged into the NT client, this will
903                 not work with Samba at this time.</para>
905                 <para>
906                 There is an NT <command>chown</command> command that will work with Samba and allow a user with Administrator privilege connected 
907                 to a Samba server as root to change the ownership of files on both a local NTFS filesystem or remote mounted NTFS 
908                 or Samba drive. This is available as part of the <application>Seclib</application> NT security library written
909                 by Jeremy Allison of the Samba Team, and is available from the main Samba FTP site.</para>
911         </sect2>
913         <sect2>
914                 <title>Viewing File or Directory Permissions</title>
916                 <para>
917                 The third button is the <guibutton>Permissions</guibutton> button. Clicking on this brings up a dialog box
918                 that shows both the permissions and the UNIX owner of the file or directory. The owner is displayed like this:
919                 </para>
921                 <para><command><replaceable>SERVER</replaceable>\
922                                 <replaceable>user</replaceable> 
923                                 <replaceable>(Long name)</replaceable></command></para>
925                 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of the Samba server,
926                 <replaceable>user</replaceable> is the user name of the UNIX user who owns the file, and
927                 <replaceable>(Long name)</replaceable> is the descriptive string identifying the user (normally found in the
928                 GECOS field of the UNIX password database).</para>
930                 <para>
931                 If the parameter <smbconfoption><name>nt acl support</name></smbconfoption> is set to <constant>false</constant>,
932                 the file owner will be shown as the NT user <constant>Everyone</constant> and the permissions will be
933                 shown as NT <quote>Full Control</quote>.
934                 </para>
937                 <para>
938                 The permissions field is displayed differently for files and directories, so I'll describe the way file permissions 
939                 are displayed first.
940                 </para>
942                 <sect3>
943                         <title>File Permissions</title>
945                         <para>The standard UNIX user/group/world triplet and the corresponding <constant>read, write, execute</constant> permissions 
946                         triplets are mapped by Samba into a three element NT ACL with the <quote>r</quote>, <quote>w</quote> and <quote>x</quote> bits mapped into the corresponding 
947                         NT permissions. The UNIX world permissions are mapped into the global NT group <constant>Everyone</constant>, followed 
948                         by the list of permissions allowed for UNIX world. The UNIX owner and group permissions are displayed as an NT 
949                         <guiicon>user</guiicon> icon and an NT <guiicon>local group</guiicon> icon, respectively, followed by the list 
950                         of permissions allowed for the UNIX user and group.</para>
952                         <para>Because many UNIX permission sets do not map into common NT names such as <constant>read</constant>,
953                         <constant>change</constant> or <constant>full control</constant>, usually the permissions will be prefixed
954                         by the words <constant>Special Access</constant> in the NT display list.</para>
956                         <para>But what happens if the file has no permissions allowed for a particular UNIX user group or world component? In order 
957                         to  allow <quote>no permissions</quote> to be seen and modified Samba then overloads the NT <constant>Take Ownership</constant> ACL attribute 
958                         (which has no meaning in UNIX) and reports a component with no permissions as having the NT <command>O</command> bit set. 
959                         This was chosen, of course, to make it look like a zero, meaning zero permissions. More details on the decision behind this is 
960                         given below.</para>
961                 </sect3>
962                 
963                 <sect3>
964                         <title>Directory Permissions</title>
966                         <para>Directories on an NT NTFS file system have two different sets of permissions. The first set is the ACL set on the
967                         directory itself, which is usually displayed in the first set of parentheses in the normal <constant>RW</constant> 
968                         NT style. This first set of permissions is created by Samba in exactly the same way as normal file permissions are, described 
969                         above, and is displayed in the same way.</para>
971                         <para>The second set of directory permissions has no real meaning in the UNIX permissions world and represents the <constant>
972                         inherited</constant> permissions that any file created within this directory would inherit.</para>
974                         <para>Samba synthesizes these inherited permissions for NT by returning as an NT ACL the UNIX permission mode that a new file 
975                         created by Samba on this share would receive.</para>
976                 </sect3>
977         </sect2>
978                 
979         <sect2>
980                 <title>Modifying File or Directory Permissions</title>
982                 <para>Modifying file and directory permissions is as simple 
983                 as changing the displayed permissions in the dialog box, and 
984                 clicking on <guibutton>OK</guibutton>. However, there are 
985                 limitations that a user needs to be aware of, and also interactions 
986                 with the standard Samba permission masks and mapping of DOS 
987                 attributes that need to also be taken into account.</para>
989                 <para>If the parameter <smbconfoption><name>nt acl support</name></smbconfoption>
990                 is set to <constant>false</constant>, any attempt to set 
991                 security permissions will fail with an <errorname>`Access Denied'
992                 </errorname> message.</para>
994                 <para>The first thing to note is that the <guibutton>Add</guibutton> 
995                 button will not return a list of users in Samba (it will give 
996                 an error message saying <errorname>`The remote procedure call failed 
997                 and did not execute'</errorname>). This means that you can only 
998                 manipulate the current user/group/world permissions listed in 
999                 the dialog box. This actually works quite well as these are the 
1000                 only permissions that UNIX actually has.</para>
1002                 <para>If a permission triplet (either user, group, or world) 
1003                 is removed from the list of permissions in the NT dialog box, 
1004                 then when the <guibutton>OK</guibutton> button is pressed it will 
1005                 be applied as <quote>no permissions</quote> on the UNIX side. If you then 
1006                 view the permissions again, the <quote>no permissions</quote> entry will appear 
1007                 as the NT <command>O</command> flag, as described above. This 
1008                 allows you to add permissions back to a file or directory once 
1009                 you have removed them from a triplet component.</para>
1011                 <para>As UNIX supports only the <quote>r</quote>, <quote>w</quote> and <quote>x</quote> bits of 
1012                 an NT ACL, if other NT security attributes such as <constant>Delete Access</constant> are
1013                 selected they will be ignored when applied on the Samba server.</para>
1015                 <para>When setting permissions on a directory, the second 
1016                 set of permissions (in the second set of parentheses) is 
1017                 by default applied to all files within that directory. If this 
1018                 is not what you want, you must un-check the <guilabel>Replace 
1019                 permissions on existing files</guilabel> check-box in the NT 
1020                 dialog before clicking on <guibutton>OK</guibutton>.</para>
1022                 <para>If you wish to remove all permissions from a 
1023                 user/group/world  component, you may either highlight the 
1024                 component and click on the <guibutton>Remove</guibutton> button, 
1025                 or set the component to only have the special <constant>Take
1026                 Ownership</constant> permission (displayed as <command>O
1027                 </command>) highlighted.</para>
1028         </sect2>
1030         <sect2>
1031                 <title>Interaction with the Standard Samba <quote>create mask</quote> Parameters</title>
1033                 <para>There are four parameters that control interaction with the standard Samba <parameter>create mask</parameter> parameters.
1034                 These are:
1036                 <itemizedlist>
1037                         <listitem><smbconfoption><name>security mask</name></smbconfoption></listitem>
1038                         <listitem><smbconfoption><name>force security mode</name></smbconfoption></listitem>
1039                         <listitem><smbconfoption><name>directory security mask</name></smbconfoption></listitem>
1040                         <listitem><smbconfoption><name>force directory security mode</name></smbconfoption></listitem>
1041                 </itemizedlist>
1043                 </para>
1045                 <para>Once a user clicks on <guibutton>OK</guibutton> to apply the 
1046                 permissions, Samba maps the given permissions into a user/group/world 
1047                 r/w/x triplet set, and then checks the changed permissions for a 
1048                 file against the bits set in the  
1049                 <smbconfoption><name>security mask</name></smbconfoption> parameter. Any bits that 
1050                 were changed that are not set to <quote>1</quote> in this parameter are left alone 
1051                 in the file permissions.</para>
1053                 <para>Essentially, zero bits in the <smbconfoption><name>security mask</name></smbconfoption>
1054                 may be treated as a set of bits the user is <emphasis>not</emphasis> 
1055                 allowed to change, and one bits are those the user is allowed to change.
1056                 </para>
1058                 <para>If not explicitly set, this parameter defaults to the same value as 
1059                 the <smbconfoption><name>create mask</name></smbconfoption> parameter. To allow a user to modify all the
1060                 user/group/world permissions on a file, set this parameter to 0777.
1061                 </para>
1063                 <para>Next Samba checks the changed permissions for a file against the bits set in the 
1064                 <smbconfoption><name>force security mode</name></smbconfoption> parameter. Any bits 
1065                 that were changed that correspond to bits set to <quote>1</quote> in this parameter 
1066                 are forced to be set.</para>
1068                 <para>Essentially, bits set in the <parameter>force security mode</parameter> parameter
1069                 may be treated as a set of bits that, when modifying security on a file, the user has always set to be <quote>on</quote>.</para>
1071                 <para>If not explicitly set, this parameter defaults to the same value 
1072                 as the <smbconfoption><name>force create mode</name></smbconfoption> parameter.
1073                 To allow a user to modify all the user/group/world permissions on a file
1074                 with no restrictions set this parameter to 000. The
1075                 <smbconfoption><name>security mask</name></smbconfoption> and <parameter>force 
1076                 security mode</parameter> parameters are applied to the change 
1077                 request in that order.</para>
1079                 <para>For a directory, Samba will perform the same operations as 
1080                 described above for a file except it uses the parameter <parameter>
1081                 directory security mask</parameter> instead of <parameter>security 
1082                 mask</parameter>, and <parameter>force directory security mode
1083                 </parameter> parameter instead of <parameter>force security mode
1084                 </parameter>.</para>
1086                 <para>The <smbconfoption><name>directory security mask</name></smbconfoption> parameter 
1087                 by default is set to the same value as the <parameter>directory mask
1088                 </parameter> parameter and the <parameter>force directory security 
1089                 mode</parameter> parameter by default is set to the same value as 
1090                 the <smbconfoption><name>force directory mode</name></smbconfoption> parameter.
1091                 In this way Samba enforces the permission restrictions that 
1092                 an administrator can set on a Samba share, while still allowing users 
1093                 to modify the permission bits within that restriction.</para>
1095                 <para>If you want to set up a share that allows users full control
1096                 in modifying the permission bits on their files and directories and
1097                 does not force any particular bits to be set <quote>on</quote>, then set the following
1098                 parameters in the &smb.conf; file in that share-specific section:
1099                 </para>
1101                 <smbconfblock>
1102                         <smbconfoption><name>security mask</name><value>0777</value></smbconfoption>
1103                         <smbconfoption><name>force security mode</name><value>0</value></smbconfoption>
1104                         <smbconfoption><name>directory security mask</name><value>0777</value></smbconfoption>
1105                         <smbconfoption><name>force directory security mode</name><value>0</value></smbconfoption>
1106                 </smbconfblock>
1107         </sect2>
1109         <sect2>
1110                 <title>Interaction with the Standard Samba File Attribute Mapping</title>
1112                 <note>
1113                 <para>Samba maps some of the DOS attribute bits (such as <quote>read 
1114                 only</quote>) into the UNIX permissions of a file. This means there can 
1115                 be a conflict between the permission bits set via the security 
1116                 dialog and the permission bits set by the file attribute mapping.
1117                 </para>
1118                 </note>
1120                 <para>If a file has no UNIX read access for the owner, it will show up
1121                 as <quote>read only</quote> in the standard file attributes tabbed dialog.
1122                 Unfortunately, this dialog is the same one that contains the security information
1123                 in another tab.</para>
1125                 <para>What this can mean is that if the owner changes the permissions
1126                 to allow himself read access using the security dialog, clicks on
1127                 <guibutton>OK</guibutton> to get back to the standard attributes tab 
1128                 dialog, and clicks on <guibutton>OK</guibutton> on that dialog, then 
1129                 NT will set the file permissions back to read-only (as that is what 
1130                 the attributes still say in the dialog). This means that after setting 
1131                 permissions and clicking on <guibutton>OK</guibutton> to get back to the 
1132                 attributes dialog, you should always press <guibutton>Cancel</guibutton> 
1133                 rather than <guibutton>OK</guibutton> to ensure that your changes 
1134                 are not overridden.</para>
1135         </sect2>
1136 </sect1>
1138 <sect1>
1139 <title>Common Errors</title>
1141 <para>
1142 File, directory and share access problems are common on the mailing list. The following
1143 are examples taken from the mailing list in recent times.
1144 </para>
1147         <sect2>
1148         <title>Users Cannot Write to a Public Share</title>
1150         <para>
1151         <quote>
1152         We are facing some troubles with file/directory permissions. I can log on the domain as admin user(root),
1153         and there's a public share on which everyone needs to have permission to create/modify files, but only
1154         root can change the file, no one else can. We need to constantly go to the server to
1155         <userinput>chgrp -R users *</userinput> and <userinput>chown -R nobody *</userinput> to allow others users to change the file.
1156         </quote>
1157         </para>
1159         <para>
1160         There are many ways to solve this problem and here are a few hints:
1161         </para>
1163         <procedure>
1164                 <step>
1165                         <para>
1166                         Go to the top of the directory that is shared.
1167                         </para>
1168                 </step>
1170                 <step>
1171                         <para>
1172                         Set the ownership to what ever public owner and group you want
1173 <screen>
1174 &prompt;find 'directory_name' -type d -exec chown user.group {}\;
1175 &prompt;find 'directory_name' -type d -exec chmod 1775 'directory_name'
1176 &prompt;find 'directory_name' -type f -exec chmod 0775 {} \;
1177 &prompt;find 'directory_name' -type f -exec chown user.group {}\;
1178 </screen>
1179                         </para>
1181                         <note><para>
1182                         The above will set the <constant>sticky bit</constant> on all directories. Read your
1183                         UNIX/Linux man page on what that does. It causes the OS to assign 
1184                         to all files created in the directories the ownership of the 
1185                         directory.
1186                         </para></note>
1187                 </step>
1188                 <step>
1189                         <para>
1191                         Directory is: <replaceable>/foodbar</replaceable>
1192 <screen>
1193 &prompt;<userinput>chown jack.engr /foodbar</userinput>
1194 </screen>
1195                         </para>
1197                         <note><para>
1198                                 <para>This is the same as doing:</para>
1199 <screen>
1200 &prompt;<userinput>chown jack /foodbar</userinput>
1201 &prompt;<userinput>chgrp engr /foodbar</userinput>
1202 </screen>
1203                         </para></note>
1204                 </step>
1205                 <step>
1206                         <para>Now type: 
1208 <screen>
1209 &prompt;<userinput>chmod 6775 /foodbar</userinput>
1210 &prompt;<userinput>ls -al /foodbar/..</userinput>
1211 </screen>
1213                         </para>
1214                 
1215                         <para>You should see:
1216 <screen>
1217 drwsrwsr-x  2 jack  engr    48 2003-02-04 09:55 foodbar
1218 </screen>
1219                         </para>
1220                 </step>
1221                 <step>
1223                 <para>Now type:
1224 <screen>
1225 &prompt;<userinput>su - jill</userinput>
1226 &prompt;<userinput>cd /foodbar</userinput>
1227 &prompt;<userinput>touch Afile</userinput>
1228 &prompt;<userinput>ls -al</userinput>
1229 </screen>
1230                 </para>
1232                 <para>
1233                 You should see that the file <filename>Afile</filename> created by Jill will have ownership
1234                 and permissions of Jack, as follows:
1235 <screen>
1236 -rw-r--r--  1 jack  engr     0 2003-02-04 09:57 Afile
1237 </screen>
1238                 </para>
1239                 </step>
1241                 <step>
1242                 <para>
1243                 Now in your &smb.conf; for the share add:
1244                 <smbconfblock>
1245 <smbconfoption><name>force create mode</name><value>0775</value></smbconfoption>
1246 <smbconfoption><name>force directory mode</name><value>6775</value></smbconfoption>
1247                 </smbconfblock>
1248                 </para>
1250                 <note><para>
1251                 These procedures are needed only if your users are not members of the group
1252                 you have used. That is if within the OS do not have write permission on the directory.
1253                 </para>
1254                 </note>
1255                 
1256                 <para>
1257                 An alternative is to set in the &smb.conf; entry for the share:
1258                 <smbconfblock>
1259 <smbconfoption><name>force user</name><value>jack</value></smbconfoption>
1260 <smbconfoption><name>force group</name><value>engr</value></smbconfoption>
1261                 </smbconfblock>
1262                 </para>
1263         </step>
1264         </procedure>
1265         </sect2>
1268         <sect2>
1269                 <title>File Operations Done as <emphasis>root</emphasis> with <emphasis>force user</emphasis> Set</title>
1271                 <para>
1272                 When you have a user in <smbconfoption><name>admin users</name></smbconfoption>, Samba will always do file operations for
1273                 this user as <emphasis>root</emphasis>, even if <smbconfoption><name>force user</name></smbconfoption> has been set.
1274                 </para>
1275         </sect2>
1276         
1277         <sect2>
1278                 <title>MS Word with Samba Changes Owner of File</title>
1280                 <para>
1281                 <emphasis>Question:</emphasis> <quote>When user B saves a word document that is owned by user A the updated file is now owned by user B.
1282                 Why is Samba doing this? How do I fix this?</quote>
1283                 </para>
1285                 <para>
1286                 <emphasis>Answer:</emphasis> Word does the following when you modify/change a Word document: MS Word creates a NEW document with
1287                 a temporary name, Word then closes the old document and deletes it, Word then renames the new document to the original document name.
1288                 There is no mechanism by which Samba can in any way know that the new document really should be owned by the owners
1289                 of the original file. Samba has no way of knowing that the file will be renamed by MS Word. As far as Samba is able
1290                 to tell, the file that gets created is a NEW file, not one that the application (Word) is updating.
1291                 </para>
1293                 <para>
1294                 There is a work-around to solve the permissions problem. That work-around involves understanding how you can manage file
1295                 system behavior from within the &smb.conf; file, as well as understanding how UNIX file systems work. Set on the directory
1296                 in which you are changing Word documents: <command>chmod g+s `directory_name'</command> This ensures that all files will
1297                 be created with the group that owns the directory. In &smb.conf; share declaration section set:
1298                 </para>
1300                 <para>
1301                 <smbconfblock>
1302                 <smbconfoption><name>force create mode</name><value>0660</value></smbconfoption>
1303                 <smbconfoption><name>force directory mode</name><value>0770</value></smbconfoption>
1304                 </smbconfblock>
1305                 </para>
1307                 <para>
1308                 These two settings will ensure that all directories and files that get created in the share will be read/writable by the
1309                 owner and group set on the directory itself.
1310                 </para>
1311                 
1312         </sect2>
1314 </sect1>
1316 </chapter>