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