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