38c3475d34d62a4b109a2ab92a10c2f583fc3db5
[gd/samba-autobuild/.git] / docs / docbook / projdoc / AccessControls.xml
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>
8
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>
16
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>
22
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>
28
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>
36
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>
42
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>
51
52 <sect1>
53 <title>Features and Benefits</title>
54
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>
59
60         <itemizedlist>
61         <title>Samba Access Control Facilities</title>
62                 <listitem><para>
63                 <emphasis>Unix File and Directory Permissions</emphasis>
64                 </para>
65
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>
76
77                 <listitem><para>
78                 <emphasis>Samba Share Definitions</emphasis>
79                 </para>
80
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>
90
91                 <listitem><para>
92                 <emphasis>Samba Share ACLs</emphasis>
93                 </para>
94
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>
103
104                 <listitem><para>
105                 <emphasis>MS Windows ACLs through Unix POSIX ACLs</emphasis>
106                 </para>
107
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>
119
120 </sect1>
121
122 <sect1>
123 <title>File System Access Controls</title>
124
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>
131
132         <sect2>
133         <title>MS Windows NTFS Comparison with Unix File Systems</title>
134
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>
141
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>
148
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>
162
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                         <programlisting>
180                                 MYFILE.TXT
181                                 MyFile.txt
182                                 myfile.txt
183                         </programlisting>
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>
190
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>
198
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>
209
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>
235
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>
241
242         </sect2>
243
244         <sect2>
245         <title>Managing Directories</title>
246
247         <para>
248         There are three basic operations for managing directories, <command>create, delete, rename</command>.
249         <programlisting>
250                 Action    MS Windows Command         Unix Command
251                 ------    ------------------         ------------
252                 create    md folder                 mkdir folder
253                 delete    rd folder                 rmdir folder
254                 rename    rename oldname newname    mv oldname newname
255         </programlisting>
256         </para>
257
258         </sect2>
259
260         <sect2>
261         <title>File and Directory Access Control</title>
262
263         <para>
264         The network administrator is strongly advised to read foundational training manuals and reference materials
265         regarding file and directory permissions maintenance. Much can be achieved with the basic Unix permissions
266         without having to resort to more complex facilities like POSIX Access Control Lists (ACLs) or Extended
267         Attributes (EAs).
268         </para>
269
270         <para>
271         Unix/Linux file and directory access permissions invloves setting three (3) primary sets of data and one (1) control set.
272         A Unix file listing looks as follows:-
273
274         <programlisting>
275         jht@frodo:~/stuff> ls -la
276         total 632
277         drwxr-xr-x   13 jht   users      816 2003-05-12 22:56 .
278         drwxr-xr-x   37 jht   users     3800 2003-05-12 22:29 ..
279         d---------    2 jht   users       48 2003-05-12 22:29 muchado00
280         d--x--x--x    2 jht   users       48 2003-05-12 22:29 muchado01
281         dr-xr-xr-x    2 jht   users       48 2003-05-12 22:29 muchado02
282         drwxrwxrwx    2 jht   users       48 2003-05-12 22:29 muchado03
283         drw-rw-rw-    2 jht   users       48 2003-05-12 22:29 muchado04
284         d-w--w--w-    2 jht   users       48 2003-05-12 22:29 muchado05
285         dr--r--r--    2 jht   users       48 2003-05-12 22:29 muchado06
286         drwxrwxrwt    2 jht   users       48 2003-05-12 22:29 muchado07
287         drwsrwsrwx    2 jht   users       48 2003-05-12 22:29 muchado08
288         ----------    1 jht   users     1242 2003-05-12 22:31 mydata00.lst
289         ---x--x--x    1 jht   users     1674 2003-05-12 22:33 mydata01.lst
290         --w--w--w-    1 jht   users     7754 2003-05-12 22:33 mydata02.lst
291         --wx-wx-wx    1 jht   users   260179 2003-05-12 22:33 mydata03.lst
292         -r--r--r--    1 jht   users    21017 2003-05-12 22:32 mydata04.lst
293         -r-xr-xr-x    1 jht   users   206339 2003-05-12 22:32 mydata05.lst
294         -rw-rw-rw-    1 jht   users    41105 2003-05-12 22:32 mydata06.lst
295         -rwxrwxrwx    1 jht   users    19312 2003-05-12 22:32 mydata07.lst
296         jht@frodo:~/stuff>
297         </programlisting>
298         </para>
299
300         <para>
301         The columns above represent (from left to right): permissions, no blocks used, owner, group, size (bytes), access date, access time, file name.
302         </para>
303
304         <para>
305         The permissions field is made up of:
306
307         <programlisting>
308         [ type  ] [ users ] [ group ] [ others ]   [File, Directory Permissions]
309         [ d | l ] [ r w x ] [ r w x ] [ r w x  ]
310           |   |     | | |     | | |     | | |
311           |   |     | | |     | | |     | | |-----> Can Execute, List files
312           |   |     | | |     | | |     | |-------> Can Write,   Create files
313           |   |     | | |     | | |     |---------> Can Read,    Read files
314           |   |     | | |     | | |---------------> Can Execute, List files
315           |   |     | | |     | |-----------------> Can Write,   Create files
316           |   |     | | |     |-------------------> Can Read,    Read files
317           |   |     | | |-------------------------> Can Execute, List files
318           |   |     | |---------------------------> Can Write,   Create files
319           |   |     |-----------------------------> Can Read,    Read files
320           |   |-----------------------------------> Is a symbolic Link
321           |---------------------------------------> Is a directory
322         </programlisting>
323         </para>
324
325         <para>
326         Any bit flag may be unset. An unset bit flag is the equivalent of 'Can NOT' and is represented as a '-' character.
327         <programlisting>
328         <title>Example File</title>
329                 -rwxr-x---   Means: The owner (user) can read, write, execute
330                                     the group can read and execute
331                                     everyone else can NOT do anything with it
332         </programlisting>
333         </para>
334
335         <para>
336         Additional posibilities in the [type] field are: c = character device, b = block device, p = pipe device, s = Unix Domain Socket.
337         </para>
338
339         <para>
340         The letters `rwxXst' set permissions for the user, group and others as: read (r), write (w), execute (or access for directories) (x),r
341         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),
342         sticky (t).
343         </para>
344
345         <para>
346         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. 
347         Without the sticky  bit, anyone able to write to the directory can delete or rename files. The sticky bit is commonly found on
348         directories, such as /tmp, that are world-writable.
349         </para>
350
351         <para>
352         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
353         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
354         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
355         to be exclusively owned by a user who's primary group is not the group that all such users belong to.
356         </para>
357
358         <para>
359         When a directory is set <command>drw-r-----</command> this means that the owner can read and create (write) files in it, but because
360         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
361         directory but can NOT create new files. NOTE: If files in the directory are set to be readable and writable for the group, then
362         group members will be able to write to (or delete) them.
363         </para>
364
365         </sect2>
366
367 </sect1>
368
369 <sect1>
370 <title>Share Definition Access Controls</title>
371
372 <para>
373 The following parameters in the &smb.conf; file sections that define a share control or affect access controls.
374 Before using any of the following options please refer to the man page for &smb.conf;.
375 </para>
376
377         <sect2>
378         <title>User and Group Based Controls</title>
379
380         <para>
381         User and group based controls can prove very useful. In some situations it is distinctly desirable to affect all
382         file system operations as if a single user is doing this, the use of the <emphasis>force user</emphasis> and 
383         <emphasis>force group</emphasis> behaviour will achieve this. In other situations it may be necessary to affect a
384         paranoia level of control to ensure that only particular authorised persons will be able to access a share or
385         it's contents, here the use of the <emphasis>valid users</emphasis> or the <emphasis>invalid users</emphasis> may
386         be most useful.
387         </para>
388
389         <para>
390         As always, it is highly advisable to use the least difficult to maintain and the least ambiguous method for
391         controlling access. Remember, that when you leave the scene someone else will need to provide assistance and
392         if that person finds to great a mess, or if they do not understand what you have done then there is risk of
393         Samba being removed and an alternative solution being adopted.
394         </para>
395
396         <table frame='all'><title>User and Group Based Controls</title>
397         <tgroup cols='2'>
398                 <thead>
399                 <row>
400                         <entry align="center">Control Parameter</entry>
401                         <entry align="center">Description - Action - Notes</entry>
402                 </row>
403                 </thead>
404                 <tbody>
405                 <row>
406                         <entry>admin users</entry>
407                         <entry><para>
408                         List of users who will be granted administrative privileges on the share.
409                         They will do all file operations as the super-user (root).  
410                         Any user in this list will be able to do anything they like on the share,
411                         irrespective of file permissions.
412                         </para></entry>
413                 </row>
414                 <row>
415                         <entry>force group</entry>
416                         <entry><para>
417                         Specifies a UNIX group name that will be assigned as the default primary group
418                         for all users connecting to this service.
419                         </para></entry>
420                 </row>
421                 <row>
422                         <entry>force user</entry>
423                         <entry><para>
424                         Specifies a UNIX user name that will be assigned as the default user for all users connecting to this service.
425                         This is useful for sharing files. Incorrect use can cause security problems.
426                         </para></entry>
427                 </row>
428                 <row>
429                         <entry>guest ok</entry>
430                         <entry><para>
431                         If this parameter is set for a service, then no password is required to connect to the service. Privileges will be 
432                         those of the  guest account.
433                         </para></entry>
434                 </row>
435                 <row>
436                         <entry>invalid users</entry>
437                         <entry><para>
438                         List of users that should not be allowed to login to this service.
439                         </para></entry>
440                 </row>
441                 <row>
442                         <entry>only user</entry>
443                         <entry><para>
444                         Controls whether connections with usernames not in the user list will be allowed.
445                         </para></entry>
446                 </row>
447                 <row>
448                         <entry>read list</entry>
449                         <entry><para>
450                         List of users that are given read-only access to a service. Users in this list
451                         will not be given write access, no matter what the  read only  option is set to. 
452                         </para></entry>
453                 </row>
454                 <row>
455                         <entry>username</entry>
456                         <entry><para>
457                         Refer to the &smb.conf; man page for more information - this is a complex and potentially misused parameter.
458                         </para></entry>
459                 </row>
460                 <row>
461                         <entry>valid users</entry>
462                         <entry><para>
463                         List of users that should be allowed to login to this service.
464                         </para></entry>
465                 </row>
466                 <row>
467                         <entry>write list</entry>
468                         <entry><para>
469                         List of users that are given read-write access to a service.
470                         </para></entry>
471                 </row>
472                 </tbody>
473         </tgroup>
474         </table>
475
476         </sect2>
477
478         <sect2>
479         <title>File and Directory Permissions Based Controls</title>
480
481         <para>
482         The following file and directory permission based controls, if misused, can result in considerable difficulty to
483         diagnose the cause of mis-configuration. Use them sparingly and carefully. By gradually introducing each one by one
484         undesirable side-effects may be detected. In the event of a problem, always comment all of them out and then gradually
485         re-instroduce them in a controlled fashion.
486         </para>
487
488         <table frame='all'><title>File and Directory Permission Based Controls</title>
489         <tgroup cols='2'>
490                 <thead>
491                 <row>
492                         <entry align="center">Control Parameter</entry>
493                         <entry align="center">Description - Action - Notes</entry>
494                 </row>
495                 </thead>
496                 <tbody>
497                 <row>
498                         <entry>create mask</entry>
499                         <entry><para>
500                         Refer to the &smb.conf; man page.
501                         </para></entry>
502                 </row>
503                 <row>
504                         <entry>directory mask</entry>
505                         <entry><para>
506                         The octal modes used when converting DOS modes to UNIX modes when creating UNIX directories.
507                         See also: directory security mask.
508                         </para></entry></row>
509                 <row>
510                         <entry>dos filemode</entry>
511                         <entry><para>
512                         Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
513                         </para></entry>
514                 </row>
515                 <row>
516                         <entry>force create mode</entry>
517                         <entry><para>
518                         This parameter specifies a set of UNIX mode bit permissions that will always be set on a file created by Samba.
519                         </para></entry>
520                 </row>
521                 <row>
522                         <entry>force directory mode</entry>
523                         <entry><para>
524                         This parameter specifies a set of UNIX mode bit permissions that will always be set on a directory created by Samba.
525                         </para></entry>
526                 </row>
527                 <row>
528                         <entry>force directory security mode</entry>    
529                         <entry><para>
530                         Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory
531                         </para></entry>
532                 </row>
533                 <row>
534                         <entry>force security mode</entry>
535                         <entry><para>
536                         Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
537                         </para></entry>
538                 </row>
539                 <row>
540                         <entry>hide unreadable</entry>
541                         <entry><para>
542                         Prevents clients from seeing the existance of files that cannot be read.
543                         </para></entry>
544                 </row>
545                 <row>
546                         <entry>hide unwriteable files</entry>
547                         <entry><para>
548                         Prevents clients from seeing the existance of files that cannot be written to. Unwriteable directories are shown as usual. 
549                         </para></entry>
550                 </row>
551                 <row>
552                         <entry>nt acl support</entry>
553                         <entry><para>
554                         This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT access control lists.
555                         </para></entry>
556                 </row>
557                 <row>
558                         <entry>security mask</entry>
559                         <entry><para>
560                         Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
561                         </para></entry>
562                 </row>
563                 </tbody>
564         </tgroup>
565         </table>
566
567         </sect2>
568
569         <sect2>
570         <title>Miscellaneous Controls</title>
571
572         <para>
573         The following are documented because of the prevalence of administrators creating inadvertant barriers to file
574         access by not understanding the full implications of &smb.conf; file settings.
575         </para>
576
577         <table frame='all'><title>Other Controls</title>
578         <tgroup cols='2'>
579                 <thead>
580                 <row>
581                         <entry align="center">Control Parameter</entry>
582                         <entry align="center">Description - Action - Notes</entry>
583                 </row>
584                 </thead>
585                 <tbody>
586                 <row>
587                         <entry>case sensitive, default case, short preserve case</entry>
588                         <entry><para>
589                         This means that all file name lookup will be done in a case sensitive manner. 
590                         Files will be created with the precise filename Samba received from the MS Windows client.
591                         </para></entry>
592                 </row>
593                 <row>
594                         <entry>csc policy</entry>
595                         <entry><para>
596                         Client Side Caching Policy - parallels MS Windows client side file caching capabilities.
597                         </para></entry>
598                 </row>
599                 <row>
600                         <entry>dont descend</entry>
601                         <entry><para>
602                         Allows to specify a comma-delimited list of directories that the server should always show as empty.
603                         </para></entry>
604                 </row>
605                 <row>
606                         <entry>dos filetime resolution</entry>
607                         <entry><para>
608                         This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
609                         </para></entry>
610                 </row>
611                 <row>
612                         <entry>dos filetimes</entry>
613                         <entry><para>
614                         DOS and Windows allows users to change file time stamps if they can write to the file. POSIX semantics prevent this.
615                         This options allows DOS and Windows behaviour.
616                         </para></entry>
617                 </row>
618                 <row>
619                         <entry>fake oplocks</entry>
620                         <entry><para>
621                         Oplocks are the way that SMB clients get permission from a server to locally cache file operations. If a server grants an
622                         oplock then the client is free to assume that it is the only one accessing the file and it will aggressively cache file data.
623                         </para></entry>
624                 </row>
625                 <row>
626                         <entry>hide dot files, hide files, veto files</entry>
627                         <entry><para>
628                         Note: MS Windows Explorer allows over-ride of files marked as hidden so they will still be visible.
629                         </para></entry>
630                 </row>
631                 <row>
632                         <entry>read only</entry>
633                         <entry><para>
634                         If this parameter is yes, then users of a service may not create or modify files in the service's directory.
635                         </para></entry>
636                 </row>
637                 <row>
638                         <entry>veto files</entry>
639                         <entry><para>
640                         List of files and directories that are neither visible nor accessible.
641                         </para></entry>
642                 </row>
643                 </tbody>
644         </tgroup>
645         </table>
646
647         </sect2>
648
649 </sect1>
650
651 <sect1>
652 <title>Access Controls on Shares</title>
653
654         <para>
655         This section deals with how to configure Samba per share access control restrictions.
656         By default samba sets no restrictions on the share itself. Restrictions on the share itself
657         can be set on MS Windows NT4/200x/XP shares. This can be a very effective way to limit who can
658         connect to a share. In the absence of specific restrictions the default setting is to allow
659         the global user <emphasis>Everyone</emphasis> Full Control (ie: Full control, Change and Read).
660         </para>
661
662         <para>
663         At this time Samba does NOT provide a tool for configuring access control setting on the Share
664         itself. Samba does have the capacity to store and act on access control settings, but  the only
665         way to create those settings is to use either the NT4 Server Manager or the Windows 200x MMC for
666         Computer Management.
667         </para>
668
669         <para>
670         Samba stores the per share access control settings in a file called <filename>share_info.tdb</filename>.
671         The location of this file on your system will depend on how samba was compiled. The default location
672         for samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
673         utility has been compiled and installed on your system then you can examine the contents of this file
674         by: <userinput>tdbdump share_info.tdb</userinput>.
675         </para>
676
677         <sect2>
678         <title>Share Permissions Management</title>
679
680                 <para>
681                 The best tool for the task is platform dependant. Choose the best tool for your environmemt.
682                 </para>
683
684                         <sect3>
685                         <title>Windows NT4 Workstation/Server</title>
686                         <para>
687                         The tool you need to use to manage share permissions on a Samba server is the NT Server Manager.
688                         Server Manager is shipped with Windows NT4 Server products but not with Windows NT4 Workstation.
689                         You can obtain the NT Server Manager for MS Windows NT4 Workstation from Microsoft - see details below.
690                         </para>
691
692                         <procedure>
693                         <title>Instructions</title>
694                         <step><para>
695                         Launch the NT4 Server Manager, click on the Samba server you want to administer, then from the menu
696                         select Computer, then click on the Shared Directories entry.
697                         </para></step>
698
699                         <step><para>
700                                 Now click on the share that you wish to manage, then click on the Properties tab, next click on
701                                 the Permissions tab. Now you can Add or change access control settings as you wish.
702                         </para></step>
703                         </procedure>
704
705                         </sect3>
706
707                         <sect3>
708                         <title>Windows 200x/XP</title>
709
710                         <para>
711                         On MS Windows NT4/200x/XP system access control lists on the share itself are set using native
712                         tools, usually from filemanager. For example, in Windows 200x: right click on the shared folder,
713                         then select 'Sharing', then click on 'Permissions'. The default Windows NT4/200x permission allows
714                         <emphasis>Everyone</emphasis> Full Control on the Share.
715                         </para>
716
717                         <para>
718                         MS Windows 200x and later all comes with a tool called the 'Computer Management' snap-in for the
719                         Microsoft Management Console (MMC). This tool is located by clicking on <filename>Control Panel ->
720                         Administrative Tools -> Computer Management</filename>.
721                         </para>
722
723                         <procedure>
724                         <title>Instructions</title>
725                         <step><para>
726                                 After launching the MMC with the Computer Management snap-in, click on the menu item 'Action',
727                                 select 'Connect to another computer'. If you are not logged onto a domain you will be prompted
728                                 to enter a domain login user identifier and a password. This will authenticate you to the domain.
729                                 If you where already logged in with administrative privilidge this step is not offered.
730                         </para></step>
731
732                         <step><para>
733                         If the Samba server is not shown in the Select Computer box, then type in the name of the target
734                         Samba server in the field 'Name:'. Now click on the [+] next to 'System Tools', then on the [+]
735                         next to 'Shared Folders' in the left panel.
736                         </para></step>
737
738                         <step><para>
739                         Now in the right panel, double-click on the share you wish to set access control permissions on.
740                         Then click on the tab 'Share Permissions'. It is now possible to add access control entities
741                         to the shared folder. Do NOT forget to set what type of access (full control, change, read) you
742                         wish to assign for each entry.
743                         </para></step>
744                         </procedure>
745
746                         <warning>
747                         <para>
748                         Be careful. If you take away all permissions from the Everyone user without removing this user
749                         then effectively no user will be able to access the share. This is a result of what is known as
750                         ACL precidence. ie: Everyone with NO ACCESS means that MaryK who is part of the group Everyone
751                         will have no access even if this user is given explicit full control access.
752                         </para>
753                         </warning>
754
755                         </sect3>
756                 </sect2>
757
758 </sect1>
759
760 <sect1>
761 <title>MS Windows Access Control Lists and Unix Interoperability</title>
762
763         <sect2>
764                 <title>Managing UNIX permissions Using NT Security Dialogs</title>
765
766                 <para>Windows NT clients can use their native security settings 
767                 dialog box to view and modify the underlying UNIX permissions.</para>
768
769                 <para>Note that this ability is careful not to compromise 
770                 the security of the UNIX host Samba is running on, and 
771                 still obeys all the file permission rules that a Samba 
772                 administrator can set.</para>
773
774                 <note>
775                 <para>
776                 All access to Unix/Linux system file via Samba is controlled at
777                 the operating system file access control level. When trying to
778                 figure out file access problems it is vitally important to identify
779                 the identity of the Windows user as it is presented by Samba at
780                 the point of file access. This can best be determined from the
781                 Samba log files.
782                 </para>
783                 </note>
784         </sect2>
785
786         <sect2>
787                 <title>Viewing File Security on a Samba Share</title>
788
789                 <para>From an NT4/2000/XP client, single-click with the right 
790                 mouse button on any file or directory in a Samba mounted 
791                 drive letter or UNC path. When the menu pops-up, click 
792                 on the <emphasis>Properties</emphasis> entry at the bottom of 
793                 the menu. This brings up the file properties dialog
794                 box. Click on the tab <emphasis>Security</emphasis> and you 
795                 will see three buttons, <emphasis>Permissions</emphasis>,        
796                 <emphasis>Auditing</emphasis>, and <emphasis>Ownership</emphasis>. 
797                 The <emphasis>Auditing</emphasis> button will cause either 
798                 an error message <errorname>A requested privilege is not held 
799                 by the client</errorname> to appear if the user is not the 
800                 NT Administrator, or a dialog which is intended to allow an 
801                 Administrator to add auditing requirements to a file if the 
802                 user is logged on as the NT Administrator. This dialog is 
803                 non-functional with a Samba share at this time, as the only 
804                 useful button, the <command>Add</command> button will not currently 
805                 allow a list of users to be seen.</para>
806
807         </sect2>
808
809         <sect2>
810                 <title>Viewing file ownership</title>
811
812                 <para>Clicking on the <command>"Ownership"</command> button 
813                 brings up a dialog box telling you who owns the given file. The 
814                 owner name will be of the form :</para>
815
816                 <para><command>"SERVER\user (Long name)"</command></para>
817
818                 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of 
819                 the Samba server, <replaceable>user</replaceable> is the user name of 
820                 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
821                 is the descriptive string identifying the user (normally found in the
822                 GECOS field of the UNIX password database). Click on the <command>Close
823                 </command> button to remove this dialog.</para>
824
825                 <para>If the parameter <parameter>nt acl support</parameter>
826                 is set to <constant>false</constant> then the file owner will 
827                 be shown as the NT user <command>"Everyone"</command>.</para>
828
829                 <para>The <command>Take Ownership</command> button will not allow 
830                 you to change the ownership of this file to yourself (clicking on 
831                 it will display a dialog box complaining that the user you are 
832                 currently logged onto the NT client cannot be found). The reason 
833                 for this is that changing the ownership of a file is a privileged 
834                 operation in UNIX, available only to the <emphasis>root</emphasis> 
835                 user. As clicking on this button causes NT to attempt to change 
836                 the ownership of a file to the current user logged into the NT 
837                 client this will not work with Samba at this time.</para>
838
839                 <para>There is an NT chown command that will work with Samba 
840                 and allow a user with Administrator privilege connected 
841                 to a Samba server as root to change the ownership of 
842                 files on both a local NTFS filesystem or remote mounted NTFS 
843                 or Samba drive. This is available as part of the <emphasis>Seclib
844                 </emphasis> NT security library written by Jeremy Allison of 
845                 the Samba Team, available from the main Samba ftp site.</para>
846
847         </sect2>
848
849         <sect2>
850                 <title>Viewing File or Directory Permissions</title>
851
852                 <para>The third button is the <command>"Permissions"</command> 
853                 button. Clicking on this brings up a dialog box that shows both 
854                 the permissions and the UNIX owner of the file or directory. 
855                 The owner is displayed in the form :</para>
856
857                 <para><command>"SERVER\user (Long name)"</command></para>
858
859                 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of 
860                 the Samba server, <replaceable>user</replaceable> is the user name of 
861                 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
862                 is the descriptive string identifying the user (normally found in the
863                 GECOS field of the UNIX password database).</para>
864
865                 <para>If the parameter <parameter>nt acl support</parameter>
866                 is set to <constant>false</constant> then the file owner will 
867                 be shown as the NT user <command>"Everyone"</command> and the 
868                 permissions will be shown as NT "Full Control".</para>
869
870
871                 <para>The permissions field is displayed differently for files 
872                 and directories, so I'll describe the way file permissions 
873                 are displayed first.</para>
874
875                 <sect3>
876                         <title>File Permissions</title>
877
878                         <para>The standard UNIX user/group/world triple and 
879                         the corresponding "read", "write", "execute" permissions 
880                         triples are mapped by Samba into a three element NT ACL 
881                         with the 'r', 'w', and 'x' bits mapped into the corresponding 
882                         NT permissions. The UNIX world permissions are mapped into 
883                         the global NT group <command>Everyone</command>, followed 
884                         by the list of permissions allowed for UNIX world. The UNIX 
885                         owner and group permissions are displayed as an NT 
886                         <command>user</command> icon and an NT <command>local 
887                         group</command> icon respectively followed by the list 
888                         of permissions allowed for the UNIX user and group.</para>
889
890                         <para>As many UNIX permission sets don't map into common 
891                         NT names such as <command>"read"</command>, <command>
892                         "change"</command> or <command>"full control"</command> then 
893                         usually the permissions will be prefixed by the words <command>
894                         "Special Access"</command> in the NT display list.</para>
895
896                         <para>But what happens if the file has no permissions allowed 
897                         for a particular UNIX user group or world component ? In order 
898                         to  allow "no permissions" to be seen and modified then Samba 
899                         overloads the NT <command>"Take Ownership"</command> ACL attribute 
900                         (which has no meaning in UNIX) and reports a component with 
901                         no permissions as having the NT <command>"O"</command> bit set. 
902                         This was chosen of course to make it look like a zero, meaning 
903                         zero permissions. More details on the decision behind this will 
904                         be given below.</para>
905                 </sect3>
906                 
907                 <sect3>
908                         <title>Directory Permissions</title>
909
910                         <para>Directories on an NT NTFS file system have two 
911                         different sets of permissions. The first set of permissions 
912                         is the ACL set on the directory itself, this is usually displayed 
913                         in the first set of parentheses in the normal <command>"RW"</command> 
914                         NT style. This first set of permissions is created by Samba in 
915                         exactly the same way as normal file permissions are, described 
916                         above, and is displayed in the same way.</para>
917
918                         <para>The second set of directory permissions has no real meaning 
919                         in the UNIX permissions world and represents the <command>
920                         "inherited"</command> permissions that any file created within 
921                         this directory would inherit.</para>
922
923                         <para>Samba synthesises these inherited permissions for NT by 
924                         returning as an NT ACL the UNIX permission mode that a new file 
925                         created by Samba on this share would receive.</para>
926                 </sect3>
927         </sect2>
928                 
929         <sect2>
930                 <title>Modifying file or directory permissions</title>
931
932                 <para>Modifying file and directory permissions is as simple 
933                 as changing the displayed permissions in the dialog box, and 
934                 clicking the <command>OK</command> button. However, there are 
935                 limitations that a user needs to be aware of, and also interactions 
936                 with the standard Samba permission masks and mapping of DOS 
937                 attributes that need to also be taken into account.</para>
938
939                 <para>If the parameter <parameter>nt acl support</parameter>
940                 is set to <constant>false</constant> then any attempt to set 
941                 security permissions will fail with an <command>"Access Denied"
942                 </command> message.</para>
943
944                 <para>The first thing to note is that the <command>"Add"</command> 
945                 button will not return a list of users in Samba (it will give 
946                 an error message of <command>"The remote procedure call failed 
947                 and did not execute"</command>). This means that you can only 
948                 manipulate the current user/group/world permissions listed in 
949                 the dialog box. This actually works quite well as these are the 
950                 only permissions that UNIX actually has.</para>
951
952                 <para>If a permission triple (either user, group, or world) 
953                 is removed from the list of permissions in the NT dialog box, 
954                 then when the <command>"OK"</command> button is pressed it will 
955                 be applied as "no permissions" on the UNIX side. If you then 
956                 view the permissions again the "no permissions" entry will appear 
957                 as the NT <command>"O"</command> flag, as described above. This 
958                 allows you to add permissions back to a file or directory once 
959                 you have removed them from a triple component.</para>
960
961                 <para>As UNIX supports only the "r", "w" and "x" bits of 
962                 an NT ACL then if other NT security attributes such as "Delete 
963                 access" are selected then they will be ignored when applied on 
964                 the Samba server.</para>
965
966                 <para>When setting permissions on a directory the second 
967                 set of permissions (in the second set of parentheses) is 
968                 by default applied to all files within that directory. If this 
969                 is not what you want you must uncheck the <command>"Replace 
970                 permissions on existing files"</command> checkbox in the NT 
971                 dialog before clicking <command>"OK"</command>.</para>
972
973                 <para>If you wish to remove all permissions from a 
974                 user/group/world  component then you may either highlight the 
975                 component and click the <command>"Remove"</command> button, 
976                 or set the component to only have the special <command>"Take
977                 Ownership"</command> permission (displayed as <command>"O"
978                 </command>) highlighted.</para>
979         </sect2>
980
981         <sect2>
982                 <title>Interaction with the standard Samba create mask 
983                 parameters</title>
984
985                 <para>There are four parameters 
986                 to control interaction with the standard Samba create mask parameters.
987                 These are :</para>
988
989                 <para><parameter>security mask</parameter></para>
990                 <para><parameter>force security mode</parameter></para>
991                 <para><parameter>directory security mask</parameter></para>
992                 <para><parameter>force directory security mode</parameter></para>
993
994                 <para>Once a user clicks <command>"OK"</command> to apply the 
995                 permissions Samba maps the given permissions into a user/group/world 
996                 r/w/x triple set, and then will check the changed permissions for a 
997                 file against the bits set in the <ulink url="smb.conf.5.html#SECURITYMASK"> 
998                 <parameter>security mask</parameter></ulink> parameter. Any bits that 
999                 were changed that are not set to '1' in this parameter are left alone 
1000                 in the file permissions.</para>
1001
1002                 <para>Essentially, zero bits in the <parameter>security mask</parameter>
1003                 mask may be treated as a set of bits the user is <emphasis>not</emphasis> 
1004                 allowed to change, and one bits are those the user is allowed to change.
1005                 </para>
1006
1007                 <para>If not set explicitly this parameter is set to the same value as 
1008                 the <ulink url="smb.conf.5.html#CREATEMASK"><parameter>create mask
1009                 </parameter></ulink> parameter. To allow a user to modify all the
1010                 user/group/world permissions on a file, set this parameter 
1011                 to 0777.</para>
1012
1013                 <para>Next Samba checks the changed permissions for a file against 
1014                 the bits set in the <ulink url="smb.conf.5.html#FORCESECURITYMODE">
1015                 <parameter>force security mode</parameter></ulink> parameter. Any bits 
1016                 that were changed that correspond to bits set to '1' in this parameter 
1017                 are forced to be set.</para>
1018
1019                 <para>Essentially, bits set in the <parameter>force security mode
1020                 </parameter> parameter may be treated as a set of bits that, when 
1021                 modifying security on a file, the user has always set to be 'on'.</para>
1022
1023                 <para>If not set explicitly this parameter is set to the same value 
1024                 as the <ulink url="smb.conf.5.html#FORCECREATEMODE"><parameter>force 
1025                 create mode</parameter></ulink> parameter.
1026                 To allow a user to modify all the user/group/world permissions on a file
1027                 with no restrictions set this parameter to 000.</para>
1028
1029                 <para>The <parameter>security mask</parameter> and <parameter>force 
1030                 security mode</parameter> parameters are applied to the change 
1031                 request in that order.</para>
1032
1033                 <para>For a directory Samba will perform the same operations as 
1034                 described above for a file except using the parameter <parameter>
1035                 directory security mask</parameter> instead of <parameter>security 
1036                 mask</parameter>, and <parameter>force directory security mode
1037                 </parameter> parameter instead of <parameter>force security mode
1038                 </parameter>.</para>
1039
1040                 <para>The <parameter>directory security mask</parameter> parameter 
1041                 by default is set to the same value as the <parameter>directory mask
1042                 </parameter> parameter and the <parameter>force directory security 
1043                 mode</parameter> parameter by default is set to the same value as 
1044                 the <parameter>force directory mode</parameter> parameter. </para>
1045
1046                 <para>In this way Samba enforces the permission restrictions that 
1047                 an administrator can set on a Samba share, whilst still allowing users 
1048                 to modify the permission bits within that restriction.</para>
1049
1050                 <para>If you want to set up a share that allows users full control
1051                 in modifying the permission bits on their files and directories and
1052                 doesn't force any particular bits to be set 'on', then set the following
1053                 parameters in the &smb.conf; file in that share specific section :</para>
1054
1055                 <para><parameter>security mask = 0777</parameter></para>
1056                 <para><parameter>force security mode = 0</parameter></para>
1057                 <para><parameter>directory security mask = 0777</parameter></para>
1058                 <para><parameter>force directory security mode = 0</parameter></para>
1059         </sect2>
1060
1061         <sect2>
1062                 <title>Interaction with the standard Samba file attribute 
1063                 mapping</title>
1064
1065                 <para>Samba maps some of the DOS attribute bits (such as "read 
1066                 only") into the UNIX permissions of a file. This means there can 
1067                 be a conflict between the permission bits set via the security 
1068                 dialog and the permission bits set by the file attribute mapping.
1069                 </para>
1070
1071                 <para>One way this can show up is if a file has no UNIX read access
1072                 for the owner it will show up as "read only" in the standard 
1073                 file attributes tabbed dialog. Unfortunately this dialog is
1074                 the same one that contains the security info in another tab.</para>
1075
1076                 <para>What this can mean is that if the owner changes the permissions
1077                 to allow themselves read access using the security dialog, clicks
1078                 <command>"OK"</command> to get back to the standard attributes tab 
1079                 dialog, and then clicks <command>"OK"</command> on that dialog, then 
1080                 NT will set the file permissions back to read-only (as that is what 
1081                 the attributes still say in the dialog). This means that after setting 
1082                 permissions and clicking <command>"OK"</command> to get back to the 
1083                 attributes dialog you should always hit <command>"Cancel"</command> 
1084                 rather than <command>"OK"</command> to ensure that your changes 
1085                 are not overridden.</para>
1086         </sect2>
1087 </sect1>
1088
1089 <sect1>
1090 <title>Common Errors</title>
1091
1092 <para>
1093 File, Directory and Share access problems are very common on the mailing list. The following
1094 are examples taken from the mailing list in recent times.
1095 </para>
1096
1097
1098         <sect2>
1099         <title>Users can not write to a public share</title>
1100
1101         <para>
1102         We are facing some troubles with file / directory permissions. I can log on the domain as admin user(root),
1103         and theres a public share, on which everyone needs to have permission to create / modify files, but only
1104         root can change the file, no one else can. We need to constantly go to server to
1105         <command>chgrp -R users *</command> and <command>chown -R nobody *</command> to allow others users to change the file.
1106         </para>
1107
1108         <para>
1109         There are many ways to solve this problem, here are a few hints:
1110         </para>
1111
1112         <procedure>
1113         <title>Example Solution:</title>
1114                 <step>
1115                 <para>
1116                 Go to the top of the directory that is shared
1117                 </para>
1118                 </step>
1119
1120                 <step>
1121                 <para>
1122                 Set the ownership to what ever public owner and group you want
1123                 <programlisting>
1124                 find 'directory_name' -type d -exec chown user.group {}\;
1125                 find 'directory_name' -type d -exec chmod 6775 'directory_name'
1126                 find 'directory_name' -type f -exec chmod 0775 {} \;
1127                 find 'directory_name' -type f -exec chown user.group {}\;
1128                 </programlisting>
1129                 </para>
1130
1131                 <para>
1132                 Note: The above will set the 'sticky bit' on all directories. Read your
1133                 Unix/Linux man page on what that does. It causes the OS to assign to all
1134                 files created in the directories the ownership of the directory.
1135                 </para>
1136
1137                 <para>
1138                 <programlisting>
1139                 Directory is: /foodbar
1140                         chown jack.engr /foodbar
1141
1142                 Note: This is the same as doing:
1143                         chown jack /foodbar
1144                         chgrp engr /foodbar
1145
1146                 Now do:
1147                         chmod 6775 /foodbar
1148                         ls -al /foodbar/..
1149
1150                 You should see:
1151                 drwsrwsr-x  2 jack  engr    48 2003-02-04 09:55 foodbar
1152
1153                 Now do:
1154                         su - jill
1155                         cd /foodbar
1156                         touch Afile
1157                         ls -al
1158                 </programlisting>
1159                 </para>
1160
1161                 <para>
1162                 You should see that the file 'Afile' created by Jill will have ownership
1163                 and permissions of Jack, as follows:
1164                 <programlisting>
1165                 -rw-r--r--  1 jack  engr     0 2003-02-04 09:57 Afile
1166                 </programlisting>
1167                 </para>
1168                 </step>
1169
1170                 <step>
1171                 <para>
1172                 Now in your smb.conf for the share add:
1173                 <programlisting>
1174                 force create mode = 0775
1175                 force direcrtory mode = 6775
1176                 </programlisting>
1177                 </para>
1178
1179                 <para>
1180                 Note: The above are only needed IF your users are NOT members of the group
1181                 you have used. ie: Within the OS do not have write permission on the directory.
1182                 </para>
1183
1184                 <para>
1185                 An alternative is to set in the smb.conf entry for the share:
1186                 <programlisting>
1187                 force user = jack
1188                 force group = engr
1189                 </programlisting>
1190                 </para>
1191         </step>
1192         </procedure>
1193         </sect2>
1194
1195
1196 </sect1>
1197
1198 </chapter>