Extending Samba Access Control Info
[sfrench/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                 Unix file and directory permissions
64                 </para></listitem>
65
66                 <listitem><para>
67                 Samba Share Definitions
68                 </para></listitem>
69
70                 <listitem><para>
71                 Samba Share ACLs
72                 </para></listitem>
73
74                 <listitem><para>
75                 MS Windows ACLs through Unix POSIX ACLs
76                 </para></listitem>
77         </itemizedlist>
78
79 </sect1>
80
81 <sect1>
82 <title>File System Access Controls</title>
83
84 <para>
85 Explain here how Unix file and permissions work
86 </para>
87
88 </sect1>
89
90 <sect1>
91 <title>Share Definition Access Controls</title>
92
93 <para>
94 Explain here about the smb.conf [share] parameters
95 </para>
96
97 </sect1>
98
99 <sect1>
100 <title>Access Controls on Shares</title>
101
102         <para>
103         This section deals with how to configure Samba per share access control restrictions.
104         By default samba sets no restrictions on the share itself. Restrictions on the share itself
105         can be set on MS Windows NT4/200x/XP shares. This can be a very effective way to limit who can
106         connect to a share. In the absence of specific restrictions the default setting is to allow
107         the global user <emphasis>Everyone</emphasis> Full Control (ie: Full control, Change and Read).
108         </para>
109
110         <para>
111         At this time Samba does NOT provide a tool for configuring access control setting on the Share
112         itself. Samba does have the capacity to store and act on access control settings, but  the only
113         way to create those settings is to use either the NT4 Server Manager or the Windows 200x MMC for
114         Computer Management.
115         </para>
116
117         <para>
118         Samba stores the per share access control settings in a file called <filename>share_info.tdb</filename>.
119         The location of this file on your system will depend on how samba was compiled. The default location
120         for samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
121         utility has been compiled and installed on your system then you can examine the contents of this file
122         by: <userinput>tdbdump share_info.tdb</userinput>.
123         </para>
124
125         <sect2>
126         <title>Share Permissions Management</title>
127
128                 <para>
129                 The best tool for the task is platform dependant. Choose the best tool for your environmemt.
130                 </para>
131
132                         <sect3>
133                         <title>Windows NT4 Workstation/Server</title>
134                         <para>
135                         The tool you need to use to manage share permissions on a Samba server is the NT Server Manager.
136                         Server Manager is shipped with Windows NT4 Server products but not with Windows NT4 Workstation.
137                         You can obtain the NT Server Manager for MS Windows NT4 Workstation from Microsoft - see details below.
138                         </para>
139
140                         <procedure>
141                         <title>Instructions</title>
142                         <step><para>
143                         Launch the NT4 Server Manager, click on the Samba server you want to administer, then from the menu
144                         select Computer, then click on the Shared Directories entry.
145                         </para></step>
146
147                         <step><para>
148                                 Now click on the share that you wish to manage, then click on the Properties tab, next click on
149                                 the Permissions tab. Now you can Add or change access control settings as you wish.
150                         </para></step>
151                         </procedure>
152
153                         </sect3>
154
155                         <sect3>
156                         <title>Windows 200x/XP</title>
157
158                         <para>
159                         On MS Windows NT4/200x/XP system access control lists on the share itself are set using native
160                         tools, usually from filemanager. For example, in Windows 200x: right click on the shared folder,
161                         then select 'Sharing', then click on 'Permissions'. The default Windows NT4/200x permission allows
162                         <emphasis>Everyone</emphasis> Full Control on the Share.
163                         </para>
164
165                         <para>
166                         MS Windows 200x and later all comes with a tool called the 'Computer Management' snap-in for the
167                         Microsoft Management Console (MMC). This tool is located by clicking on <filename>Control Panel ->
168                         Administrative Tools -> Computer Management</filename>.
169                         </para>
170
171                         <procedure>
172                         <title>Instructions</title>
173                         <step><para>
174                                 After launching the MMC with the Computer Management snap-in, click on the menu item 'Action',
175                                 select 'Connect to another computer'. If you are not logged onto a domain you will be prompted
176                                 to enter a domain login user identifier and a password. This will authenticate you to the domain.
177                                 If you where already logged in with administrative privilidge this step is not offered.
178                         </para></step>
179
180                         <step><para>
181                         If the Samba server is not shown in the Select Computer box, then type in the name of the target
182                         Samba server in the field 'Name:'. Now click on the [+] next to 'System Tools', then on the [+]
183                         next to 'Shared Folders' in the left panel.
184                         </para></step>
185
186                         <step><para>
187                         Now in the right panel, double-click on the share you wish to set access control permissions on.
188                         Then click on the tab 'Share Permissions'. It is now possible to add access control entities
189                         to the shared folder. Do NOT forget to set what type of access (full control, change, read) you
190                         wish to assign for each entry.
191                         </para></step>
192                         </procedure>
193
194                         <warning>
195                         <para>
196                         Be careful. If you take away all permissions from the Everyone user without removing this user
197                         then effectively no user will be able to access the share. This is a result of what is known as
198                         ACL precidence. ie: Everyone with NO ACCESS means that MaryK who is part of the group Everyone
199                         will have no access even if this user is given explicit full control access.
200                         </para>
201                         </warning>
202
203                         </sect3>
204                 </sect2>
205
206 </sect1>
207
208 <sect1>
209 <title>MS Windows Access Control Lists and Unix Interoperability</title>
210
211         <sect2>
212                 <title>Viewing and changing UNIX permissions using the NT 
213                 security dialogs</title>
214
215                 <para>Windows NT clients can use their native security settings 
216                 dialog box to view and modify the underlying UNIX permissions.</para>
217
218                 <para>Note that this ability is careful not to compromise 
219                 the security of the UNIX host Samba is running on, and 
220                 still obeys all the file permission rules that a Samba 
221                 administrator can set.</para>
222
223                 <note>
224                 <para>
225                 All access to Unix/Linux system file via Samba is controlled at
226                 the operating system file access control level. When trying to
227                 figure out file access problems it is vitally important to identify
228                 the identity of the Windows user as it is presented by Samba at
229                 the point of file access. This can best be determined from the
230                 Samba log files.
231                 </para>
232                 </note>
233         </sect2>
234
235         <sect2>
236                 <title>How to view file security on a Samba share</title>
237
238                 <para>From an NT4/2000/XP client, single-click with the right 
239                 mouse button on any file or directory in a Samba mounted 
240                 drive letter or UNC path. When the menu pops-up, click 
241                 on the <emphasis>Properties</emphasis> entry at the bottom of 
242                 the menu. This brings up the file properties dialog
243                 box. Click on the tab <emphasis>Security</emphasis> and you 
244                 will see three buttons, <emphasis>Permissions</emphasis>,       
245                 <emphasis>Auditing</emphasis>, and <emphasis>Ownership</emphasis>. 
246                 The <emphasis>Auditing</emphasis> button will cause either 
247                 an error message <errorname>A requested privilege is not held 
248                 by the client</errorname> to appear if the user is not the 
249                 NT Administrator, or a dialog which is intended to allow an 
250                 Administrator to add auditing requirements to a file if the 
251                 user is logged on as the NT Administrator. This dialog is 
252                 non-functional with a Samba share at this time, as the only 
253                 useful button, the <command>Add</command> button will not currently 
254                 allow a list of users to be seen.</para>
255
256         </sect2>
257
258         <sect2>
259                 <title>Viewing file ownership</title>
260
261                 <para>Clicking on the <command>"Ownership"</command> button 
262                 brings up a dialog box telling you who owns the given file. The 
263                 owner name will be of the form :</para>
264
265                 <para><command>"SERVER\user (Long name)"</command></para>
266
267                 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of 
268                 the Samba server, <replaceable>user</replaceable> is the user name of 
269                 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
270                 is the descriptive string identifying the user (normally found in the
271                 GECOS field of the UNIX password database). Click on the <command>Close
272                 </command> button to remove this dialog.</para>
273
274                 <para>If the parameter <parameter>nt acl support</parameter>
275                 is set to <constant>false</constant> then the file owner will 
276                 be shown as the NT user <command>"Everyone"</command>.</para>
277
278                 <para>The <command>Take Ownership</command> button will not allow 
279                 you to change the ownership of this file to yourself (clicking on 
280                 it will display a dialog box complaining that the user you are 
281                 currently logged onto the NT client cannot be found). The reason 
282                 for this is that changing the ownership of a file is a privileged 
283                 operation in UNIX, available only to the <emphasis>root</emphasis> 
284                 user. As clicking on this button causes NT to attempt to change 
285                 the ownership of a file to the current user logged into the NT 
286                 client this will not work with Samba at this time.</para>
287
288                 <para>There is an NT chown command that will work with Samba 
289                 and allow a user with Administrator privilege connected 
290                 to a Samba server as root to change the ownership of 
291                 files on both a local NTFS filesystem or remote mounted NTFS 
292                 or Samba drive. This is available as part of the <emphasis>Seclib
293                 </emphasis> NT security library written by Jeremy Allison of 
294                 the Samba Team, available from the main Samba ftp site.</para>
295
296         </sect2>
297
298         <sect2>
299                 <title>Viewing file or directory permissions</title>
300
301                 <para>The third button is the <command>"Permissions"</command> 
302                 button. Clicking on this brings up a dialog box that shows both 
303                 the permissions and the UNIX owner of the file or directory. 
304                 The owner is displayed in the form :</para>
305
306                 <para><command>"SERVER\user (Long name)"</command></para>
307
308                 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of 
309                 the Samba server, <replaceable>user</replaceable> is the user name of 
310                 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
311                 is the descriptive string identifying the user (normally found in the
312                 GECOS field of the UNIX password database).</para>
313
314                 <para>If the parameter <parameter>nt acl support</parameter>
315                 is set to <constant>false</constant> then the file owner will 
316                 be shown as the NT user <command>"Everyone"</command> and the 
317                 permissions will be shown as NT "Full Control".</para>
318
319
320                 <para>The permissions field is displayed differently for files 
321                 and directories, so I'll describe the way file permissions 
322                 are displayed first.</para>
323
324                 <sect3>
325                         <title>File Permissions</title>
326
327                         <para>The standard UNIX user/group/world triple and 
328                         the corresponding "read", "write", "execute" permissions 
329                         triples are mapped by Samba into a three element NT ACL 
330                         with the 'r', 'w', and 'x' bits mapped into the corresponding 
331                         NT permissions. The UNIX world permissions are mapped into 
332                         the global NT group <command>Everyone</command>, followed 
333                         by the list of permissions allowed for UNIX world. The UNIX 
334                         owner and group permissions are displayed as an NT 
335                         <command>user</command> icon and an NT <command>local 
336                         group</command> icon respectively followed by the list 
337                         of permissions allowed for the UNIX user and group.</para>
338
339                         <para>As many UNIX permission sets don't map into common 
340                         NT names such as <command>"read"</command>, <command>
341                         "change"</command> or <command>"full control"</command> then 
342                         usually the permissions will be prefixed by the words <command>
343                         "Special Access"</command> in the NT display list.</para>
344
345                         <para>But what happens if the file has no permissions allowed 
346                         for a particular UNIX user group or world component ? In order 
347                         to  allow "no permissions" to be seen and modified then Samba 
348                         overloads the NT <command>"Take Ownership"</command> ACL attribute 
349                         (which has no meaning in UNIX) and reports a component with 
350                         no permissions as having the NT <command>"O"</command> bit set. 
351                         This was chosen of course to make it look like a zero, meaning 
352                         zero permissions. More details on the decision behind this will 
353                         be given below.</para>
354                 </sect3>
355                 
356                 <sect3>
357                         <title>Directory Permissions</title>
358
359                         <para>Directories on an NT NTFS file system have two 
360                         different sets of permissions. The first set of permissions 
361                         is the ACL set on the directory itself, this is usually displayed 
362                         in the first set of parentheses in the normal <command>"RW"</command> 
363                         NT style. This first set of permissions is created by Samba in 
364                         exactly the same way as normal file permissions are, described 
365                         above, and is displayed in the same way.</para>
366
367                         <para>The second set of directory permissions has no real meaning 
368                         in the UNIX permissions world and represents the <command>
369                         "inherited"</command> permissions that any file created within 
370                         this directory would inherit.</para>
371
372                         <para>Samba synthesises these inherited permissions for NT by 
373                         returning as an NT ACL the UNIX permission mode that a new file 
374                         created by Samba on this share would receive.</para>
375                 </sect3>
376         </sect2>
377                 
378         <sect2>
379                 <title>Modifying file or directory permissions</title>
380
381                 <para>Modifying file and directory permissions is as simple 
382                 as changing the displayed permissions in the dialog box, and 
383                 clicking the <command>OK</command> button. However, there are 
384                 limitations that a user needs to be aware of, and also interactions 
385                 with the standard Samba permission masks and mapping of DOS 
386                 attributes that need to also be taken into account.</para>
387
388                 <para>If the parameter <parameter>nt acl support</parameter>
389                 is set to <constant>false</constant> then any attempt to set 
390                 security permissions will fail with an <command>"Access Denied"
391                 </command> message.</para>
392
393                 <para>The first thing to note is that the <command>"Add"</command> 
394                 button will not return a list of users in Samba (it will give 
395                 an error message of <command>"The remote procedure call failed 
396                 and did not execute"</command>). This means that you can only 
397                 manipulate the current user/group/world permissions listed in 
398                 the dialog box. This actually works quite well as these are the 
399                 only permissions that UNIX actually has.</para>
400
401                 <para>If a permission triple (either user, group, or world) 
402                 is removed from the list of permissions in the NT dialog box, 
403                 then when the <command>"OK"</command> button is pressed it will 
404                 be applied as "no permissions" on the UNIX side. If you then 
405                 view the permissions again the "no permissions" entry will appear 
406                 as the NT <command>"O"</command> flag, as described above. This 
407                 allows you to add permissions back to a file or directory once 
408                 you have removed them from a triple component.</para>
409
410                 <para>As UNIX supports only the "r", "w" and "x" bits of 
411                 an NT ACL then if other NT security attributes such as "Delete 
412                 access" are selected then they will be ignored when applied on 
413                 the Samba server.</para>
414
415                 <para>When setting permissions on a directory the second 
416                 set of permissions (in the second set of parentheses) is 
417                 by default applied to all files within that directory. If this 
418                 is not what you want you must uncheck the <command>"Replace 
419                 permissions on existing files"</command> checkbox in the NT 
420                 dialog before clicking <command>"OK"</command>.</para>
421
422                 <para>If you wish to remove all permissions from a 
423                 user/group/world  component then you may either highlight the 
424                 component and click the <command>"Remove"</command> button, 
425                 or set the component to only have the special <command>"Take
426                 Ownership"</command> permission (displayed as <command>"O"
427                 </command>) highlighted.</para>
428         </sect2>
429
430         <sect2>
431                 <title>Interaction with the standard Samba create mask 
432                 parameters</title>
433
434                 <para>There are four parameters 
435                 to control interaction with the standard Samba create mask parameters.
436                 These are :</para>
437
438                 <para><parameter>security mask</parameter></para>
439                 <para><parameter>force security mode</parameter></para>
440                 <para><parameter>directory security mask</parameter></para>
441                 <para><parameter>force directory security mode</parameter></para>
442
443                 <para>Once a user clicks <command>"OK"</command> to apply the 
444                 permissions Samba maps the given permissions into a user/group/world 
445                 r/w/x triple set, and then will check the changed permissions for a 
446                 file against the bits set in the <ulink url="smb.conf.5.html#SECURITYMASK"> 
447                 <parameter>security mask</parameter></ulink> parameter. Any bits that 
448                 were changed that are not set to '1' in this parameter are left alone 
449                 in the file permissions.</para>
450
451                 <para>Essentially, zero bits in the <parameter>security mask</parameter>
452                 mask may be treated as a set of bits the user is <emphasis>not</emphasis> 
453                 allowed to change, and one bits are those the user is allowed to change.
454                 </para>
455
456                 <para>If not set explicitly this parameter is set to the same value as 
457                 the <ulink url="smb.conf.5.html#CREATEMASK"><parameter>create mask
458                 </parameter></ulink> parameter. To allow a user to modify all the
459                 user/group/world permissions on a file, set this parameter 
460                 to 0777.</para>
461
462                 <para>Next Samba checks the changed permissions for a file against 
463                 the bits set in the <ulink url="smb.conf.5.html#FORCESECURITYMODE">
464                 <parameter>force security mode</parameter></ulink> parameter. Any bits 
465                 that were changed that correspond to bits set to '1' in this parameter 
466                 are forced to be set.</para>
467
468                 <para>Essentially, bits set in the <parameter>force security mode
469                 </parameter> parameter may be treated as a set of bits that, when 
470                 modifying security on a file, the user has always set to be 'on'.</para>
471
472                 <para>If not set explicitly this parameter is set to the same value 
473                 as the <ulink url="smb.conf.5.html#FORCECREATEMODE"><parameter>force 
474                 create mode</parameter></ulink> parameter.
475                 To allow a user to modify all the user/group/world permissions on a file
476                 with no restrictions set this parameter to 000.</para>
477
478                 <para>The <parameter>security mask</parameter> and <parameter>force 
479                 security mode</parameter> parameters are applied to the change 
480                 request in that order.</para>
481
482                 <para>For a directory Samba will perform the same operations as 
483                 described above for a file except using the parameter <parameter>
484                 directory security mask</parameter> instead of <parameter>security 
485                 mask</parameter>, and <parameter>force directory security mode
486                 </parameter> parameter instead of <parameter>force security mode
487                 </parameter>.</para>
488
489                 <para>The <parameter>directory security mask</parameter> parameter 
490                 by default is set to the same value as the <parameter>directory mask
491                 </parameter> parameter and the <parameter>force directory security 
492                 mode</parameter> parameter by default is set to the same value as 
493                 the <parameter>force directory mode</parameter> parameter. </para>
494
495                 <para>In this way Samba enforces the permission restrictions that 
496                 an administrator can set on a Samba share, whilst still allowing users 
497                 to modify the permission bits within that restriction.</para>
498
499                 <para>If you want to set up a share that allows users full control
500                 in modifying the permission bits on their files and directories and
501                 doesn't force any particular bits to be set 'on', then set the following
502                 parameters in the &smb.conf; file in that share specific section :</para>
503
504                 <para><parameter>security mask = 0777</parameter></para>
505                 <para><parameter>force security mode = 0</parameter></para>
506                 <para><parameter>directory security mask = 0777</parameter></para>
507                 <para><parameter>force directory security mode = 0</parameter></para>
508         </sect2>
509
510         <sect2>
511                 <title>Interaction with the standard Samba file attribute 
512                 mapping</title>
513
514                 <para>Samba maps some of the DOS attribute bits (such as "read 
515                 only") into the UNIX permissions of a file. This means there can 
516                 be a conflict between the permission bits set via the security 
517                 dialog and the permission bits set by the file attribute mapping.
518                 </para>
519
520                 <para>One way this can show up is if a file has no UNIX read access
521                 for the owner it will show up as "read only" in the standard 
522                 file attributes tabbed dialog. Unfortunately this dialog is
523                 the same one that contains the security info in another tab.</para>
524
525                 <para>What this can mean is that if the owner changes the permissions
526                 to allow themselves read access using the security dialog, clicks
527                 <command>"OK"</command> to get back to the standard attributes tab 
528                 dialog, and then clicks <command>"OK"</command> on that dialog, then 
529                 NT will set the file permissions back to read-only (as that is what 
530                 the attributes still say in the dialog). This means that after setting 
531                 permissions and clicking <command>"OK"</command> to get back to the 
532                 attributes dialog you should always hit <command>"Cancel"</command> 
533                 rather than <command>"OK"</command> to ensure that your changes 
534                 are not overridden.</para>
535         </sect2>
536 </sect1>
537
538 <sect1>
539 <title>Common Errors</title>
540
541 <para>
542 Stuff here
543 </para>
544
545 </sect1>
546
547 </chapter>