~zulcss/samba/server-dailies-3.4

« back to all changes in this revision

Viewing changes to docs-xml/Samba3-HOWTO/TOSHARG-AccessControls.xml

  • Committer: Chuck Short
  • Date: 2010-09-28 20:38:39 UTC
  • Revision ID: zulcss@ubuntu.com-20100928203839-pgjulytsi9ue63x1
Initial version

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE chapter PUBLIC "-//Samba-Team//DTD DocBook V4.2-Based Variant V1.0//EN" "http://www.samba.org/samba/DTD/samba-doc">
 
3
 
 
4
<chapter id="AccessControls">
 
5
<chapterinfo>
 
6
        &author.jht;
 
7
        &author.jeremy;
 
8
        <author>&person.jelmer;<contrib>drawing</contrib></author>
 
9
        <pubdate>May 10, 2003</pubdate>
 
10
</chapterinfo>
 
11
<title>File, Directory, and Share Access Controls</title>
 
12
 
 
13
<para>
 
14
<indexterm><primary>ACLs</primary></indexterm>
 
15
<indexterm><primary>share</primary></indexterm>
 
16
<indexterm><primary>network access controls</primary></indexterm>
 
17
<indexterm><primary>unauthorized access</primary></indexterm>
 
18
Advanced MS Windows users are frequently perplexed when file, directory, and share manipulation of
 
19
resources shared via Samba do not behave in the manner they might expect. MS Windows network
 
20
administrators are often confused regarding network access controls and how to
 
21
provide users with the access they need while protecting resources from unauthorized access.
 
22
</para>
 
23
 
 
24
<para>
 
25
<indexterm><primary>file access permissions</primary></indexterm>
 
26
<indexterm><primary>directory access permissions</primary></indexterm>
 
27
Many UNIX administrators are unfamiliar with the MS Windows environment and in particular
 
28
have difficulty in visualizing what the MS Windows user wishes to achieve in attempts to set file
 
29
and directory access permissions. 
 
30
</para>
 
31
 
 
32
<para>
 
33
<indexterm><primary>bridge</primary></indexterm>
 
34
<indexterm><primary>directory controls</primary></indexterm>
 
35
<indexterm><primary>directory permissions</primary></indexterm>
 
36
<indexterm><primary></primary></indexterm>
 
37
The problem lies in the differences in how file and directory permissions and controls work
 
38
between the two environments. This difference is one that Samba cannot completely hide, even
 
39
though it does try to bridge the chasm to a degree.
 
40
</para>
 
41
 
 
42
<para>
 
43
<indexterm><primary>Extended Attributes</primary></indexterm>
 
44
<indexterm><primary>ACLs</primary><secondary>POSIX</secondary></indexterm>
 
45
<indexterm><primary>Access Control List</primary></indexterm>
 
46
<indexterm><primary>commercial Linux products</primary></indexterm>
 
47
POSIX Access Control List technology has been available (along with extended attributes)
 
48
for UNIX for many years, yet there is little evidence today of any significant use. This
 
49
explains to some extent the slow adoption of ACLs into commercial Linux products. MS Windows
 
50
administrators are astounded at this, given that ACLs were a foundational capability of the now
 
51
decade-old MS Windows NT operating system.
 
52
</para>
 
53
 
 
54
<para>
 
55
<indexterm><primary>network administrator</primary></indexterm>
 
56
The purpose of this chapter is to present each of the points of control that are possible with
 
57
Samba-3 in the hope that this will help the network administrator to find the optimum method
 
58
for delivering the best environment for MS Windows desktop users.
 
59
</para>
 
60
 
 
61
<para>
 
62
<indexterm><primary>interoperability</primary></indexterm>
 
63
<indexterm><primary>data interchange</primary></indexterm>
 
64
This is an opportune point to mention that Samba was created to provide a means of interoperability
 
65
and interchange of data between differing operating environments. Samba has no intent to change
 
66
UNIX/Linux into a platform like MS Windows. Instead the purpose was and is to provide a sufficient
 
67
level of exchange of data between the two environments. What is available today extends well
 
68
beyond early plans and expectations, yet the gap continues to shrink.
 
69
</para>
 
70
 
 
71
<sect1>
 
72
<title>Features and Benefits</title>
 
73
 
 
74
        <para>
 
75
        Samba offers much flexibility in file system access management. These are the key access control
 
76
        facilities present in Samba today:
 
77
        </para>
 
78
 
 
79
        <itemizedlist>
 
80
        <title>Samba Access Control Facilities</title>
 
81
                <listitem><para>
 
82
                <indexterm><primary>permissions</primary><secondary>UNIX file and directory</secondary></indexterm>
 
83
                <emphasis>UNIX File and Directory Permissions</emphasis>
 
84
                </para>
 
85
 
 
86
                        <para>
 
87
<indexterm><primary>UNIX file system access controls</primary></indexterm>
 
88
<indexterm><primary>access controls</primary></indexterm>
 
89
<indexterm><primary>permissions and controls</primary></indexterm>
 
90
                        Samba honors and implements UNIX file system access controls. Users
 
91
                        who access a Samba server will do so as a particular MS Windows user.
 
92
                        This information is passed to the Samba server as part of the logon or
 
93
                        connection setup process. Samba uses this user identity to validate
 
94
                        whether or not the user should be given access to file system resources
 
95
                        (files and directories). This chapter provides an overview for those
 
96
                        to whom the UNIX permissions and controls are a little strange or unknown.
 
97
                        </para>
 
98
                </listitem>
 
99
 
 
100
                <listitem><para>
 
101
                <emphasis>Samba Share Definitions</emphasis>
 
102
                </para>
 
103
 
 
104
                        <para>
 
105
<indexterm><primary>share settings</primary></indexterm>
 
106
                        In configuring share settings and controls in the &smb.conf; file,
 
107
                        the network administrator can exercise overrides to native file
 
108
                        system permissions and behaviors. This can be handy and convenient
 
109
                        to effect behavior that is more like what MS Windows NT users expect,
 
110
                        but it is seldom the <emphasis>best</emphasis> way to achieve this.
 
111
                        The basic options and techniques are described herein.
 
112
                        </para>
 
113
                </listitem>
 
114
 
 
115
                <listitem><para>
 
116
                <emphasis>Samba Share ACLs</emphasis>
 
117
                <indexterm><primary>ACLs</primary><secondary>share</secondary></indexterm>
 
118
                </para>
 
119
 
 
120
                        <para>
 
121
<indexterm><primary>ACLs on shares</primary></indexterm>
 
122
                        Just as it is possible in MS Windows NT to set ACLs on shares
 
123
                        themselves, so it is possible to do in Samba.
 
124
                        Few people make use of this facility, yet it remains one of the
 
125
                        easiest ways to affect access controls (restrictions) and can often
 
126
                        do so with minimum invasiveness compared with other methods.
 
127
                        </para>
 
128
                </listitem>
 
129
 
 
130
                <listitem><para>
 
131
                                <indexterm><primary>ACLs</primary><secondary>POSIX</secondary></indexterm>
 
132
                                <indexterm><primary>ACLs</primary><secondary>Windows</secondary></indexterm>
 
133
                <emphasis>MS Windows ACLs through UNIX POSIX ACLs</emphasis>
 
134
                </para>
 
135
 
 
136
                        <para>
 
137
<indexterm><primary>native ACLs</primary></indexterm>
 
138
                        The use of POSIX ACLs on UNIX/Linux is possible only if the underlying
 
139
                        operating system supports them. If not, then this option will not be
 
140
                        available to you. Current UNIX technology platforms have native support
 
141
                        for POSIX ACLs. There are patches for the Linux kernel that also provide
 
142
                        this support. Sadly, few Linux platforms ship today with native ACLs and
 
143
                        extended attributes enabled. This chapter has pertinent information
 
144
                        for users of platforms that support them.
 
145
                        </para>
 
146
                </listitem>
 
147
        </itemizedlist>
 
148
 
 
149
</sect1>
 
150
 
 
151
<sect1>
 
152
<title>File System Access Controls</title>
 
153
 
 
154
<para>
 
155
Perhaps the most important recognition to be made is the simple fact that MS Windows NT4/200x/XP
 
156
implement a totally divergent file system technology from what is provided in the UNIX operating system
 
157
environment. First we consider what the most significant differences are, then we look
 
158
at how Samba helps to bridge the differences.
 
159
</para>
 
160
 
 
161
        <sect2>
 
162
        <title>MS Windows NTFS Comparison with UNIX File Systems</title>
 
163
 
 
164
        <para>
 
165
        <indexterm><primary>NTFS</primary></indexterm>
 
166
        <indexterm><primary>File System</primary></indexterm>
 
167
        <indexterm><primary>File System</primary><secondary>UNIX</secondary></indexterm>
 
168
        <indexterm><primary>File System</primary><secondary>Windows</secondary></indexterm>
 
169
        Samba operates on top of the UNIX file system. This means it is subject to UNIX file system conventions
 
170
        and permissions. It also means that if the MS Windows networking environment requires file system
 
171
        behavior, that differs from UNIX file system behavior then somehow Samba is responsible for emulating
 
172
        that in a transparent and consistent manner.
 
173
        </para>
 
174
 
 
175
        <para>
 
176
        It is good news that Samba does this to a large extent, and on top of that, provides a high degree
 
177
        of optional configuration to override the default behavior. We look at some of these overrides,
 
178
        but for the greater part we stay within the bounds of default behavior. Those wishing to explore
 
179
        the depths of control ability should review the &smb.conf; man page.
 
180
        </para>
 
181
 
 
182
        <para>The following compares file system features for UNIX with those of MS Windows NT/200x:
 
183
        <indexterm><primary>File System</primary><secondary>feature comparison</secondary></indexterm>
 
184
        
 
185
        </para>
 
186
 
 
187
        <variablelist>
 
188
                <varlistentry>
 
189
                        <term>Name Space</term>
 
190
                        <listitem>
 
191
                <para>
 
192
                MS Windows NT4/200x/XP file names may be up to 254 characters long, and UNIX file names
 
193
                may be 1023 characters long. In MS Windows, file extensions indicate particular file types;
 
194
                in UNIX this is not so rigorously observed because all names are considered arbitrary. 
 
195
                </para>
 
196
                <para>
 
197
                What MS Windows calls a folder, UNIX calls a directory.
 
198
                </para>
 
199
                        </listitem>
 
200
                </varlistentry>
 
201
 
 
202
                <varlistentry>
 
203
                        <term>Case Sensitivity</term>
 
204
                        <listitem>
 
205
                <para>
 
206
                <indexterm><primary>8.3 file names</primary></indexterm>
 
207
                <indexterm><primary>File System</primary><secondary>case sensitivity</secondary></indexterm>
 
208
                MS Windows file names are generally uppercase if made up of 8.3 (8-character file name
 
209
                and 3 character extension. File names that are longer than 8.3 are case preserving and case
 
210
                insensitive.
 
211
                </para>
 
212
 
 
213
                <para>
 
214
                UNIX file and directory names are case sensitive and case preserving. Samba implements the
 
215
                MS Windows file name behavior, but it does so as a user application. The UNIX file system
 
216
                provides no mechanism to perform case-insensitive file name lookups. MS Windows does this
 
217
                by default. This means that Samba has to carry the processing overhead to provide features
 
218
                that are not native to the UNIX operating system environment.
 
219
                </para>
 
220
 
 
221
                <para>
 
222
                Consider the following. All are unique UNIX names but one single MS Windows file name:
 
223
                <screen>
 
224
                                MYFILE.TXT
 
225
                                MyFile.txt
 
226
                                myfile.txt
 
227
                </screen></para>
 
228
 
 
229
                <para>
 
230
                So clearly, in an MS Windows file namespace these three files cannot co-exist, but in UNIX
 
231
                they can.
 
232
                </para>
 
233
 
 
234
                <para>
 
235
                So what should Samba do if all three are present? That which is lexically first will be
 
236
                accessible to MS Windows users; the others are invisible and unaccessible &smbmdash; any
 
237
                other solution would be suicidal. The Windows client will ask for a case-insensitive file
 
238
                lookup, and that is the reason for which Samba must offer a consistent selection in the
 
239
                event that the UNIX directory contains multiple files that would match a case insensitive
 
240
                file listing.
 
241
                </para></listitem>
 
242
                </varlistentry>
 
243
 
 
244
                <varlistentry>
 
245
                <term>Directory Separators</term>
 
246
                <listitem><para>
 
247
                <indexterm><primary>Directory Separators</primary></indexterm>
 
248
                MS Windows and DOS use the backslash <constant>\</constant> as a directory delimiter, and UNIX uses
 
249
                the forward-slash <constant>/</constant> as its directory delimiter. This is handled transparently by Samba.
 
250
                </para></listitem>
 
251
                </varlistentry>
 
252
 
 
253
                <varlistentry>
 
254
                <term>Drive Identification</term>
 
255
                <listitem><para>
 
256
                <indexterm><primary>Drive Identification</primary></indexterm>
 
257
                MS Windows products support a notion of drive letters, like <command>C:</command>, to represent
 
258
                disk partitions. UNIX has no concept of separate identifiers for file partitions; each
 
259
                such file system is mounted to become part of the overall directory tree.
 
260
                The UNIX directory tree begins at <constant>/</constant> just as the root of a DOS drive is specified as
 
261
                <constant>C:\</constant>.
 
262
                </para></listitem>
 
263
                </varlistentry>
 
264
 
 
265
                <varlistentry>
 
266
                <term>File Naming Conventions</term>
 
267
                <listitem><para>
 
268
                <indexterm><primary>File Naming Conventions</primary></indexterm>
 
269
                MS Windows generally never experiences file names that begin with a dot (<constant>.</constant>), while in UNIX these
 
270
                are commonly found in a user's home directory. Files that begin with a dot (<constant>.</constant>) are typically
 
271
                startup files for various UNIX applications, or they may be files that contain
 
272
                startup configuration data.
 
273
                </para></listitem>
 
274
                </varlistentry>
 
275
 
 
276
                <varlistentry>
 
277
                <term>Links and Short-Cuts</term>
 
278
                <listitem><para>
 
279
                <indexterm><primary>Links</primary><secondary>hard</secondary></indexterm>
 
280
                <indexterm><primary>Links</primary><secondary>soft</secondary></indexterm>
 
281
                <indexterm><primary>Shortcuts</primary></indexterm>
 
282
                MS Windows make use of <emphasis>links and shortcuts</emphasis> that are actually special types of files that will
 
283
                redirect an attempt to execute the file to the real location of the file. UNIX knows of file and directory
 
284
                links, but they are entirely different from what MS Windows users are used to.
 
285
                </para>
 
286
 
 
287
                <para>
 
288
                Symbolic links are files in UNIX that contain the actual location of the data (file or directory). An
 
289
                operation (like read or write) will operate directly on the file referenced. Symbolic links are also
 
290
                referred to as <quote>soft links.</quote> A hard link is something that MS Windows is not familiar with. It allows
 
291
                one physical file to be known simultaneously by more than one file name.
 
292
                </para></listitem>
 
293
                </varlistentry>
 
294
        </variablelist>
 
295
 
 
296
        <para>
 
297
        There are many other subtle differences that may cause the MS Windows administrator some temporary discomfort
 
298
        in the process of becoming familiar with UNIX/Linux. These are best left for a text that is dedicated to the
 
299
        purpose of UNIX/Linux training and education.
 
300
        </para>
 
301
 
 
302
        </sect2>
 
303
 
 
304
        <sect2>
 
305
        <title>Managing Directories</title>
 
306
 
 
307
        <para>
 
308
<indexterm><primary>create</primary></indexterm>
 
309
<indexterm><primary>delete</primary></indexterm>
 
310
<indexterm><primary>rename</primary></indexterm>
 
311
        There are three basic operations for managing directories: <command>create</command>, <command>delete</command>,
 
312
        <command>rename</command>. <link linkend="TOSH-Accesstbl">Managing Directories with UNIX and
 
313
        Windows</link> compares the commands in Windows and UNIX that implement these operations.
 
314
        </para>
 
315
 
 
316
        <table frame="all" id="TOSH-Accesstbl">
 
317
                <title>Managing Directories with UNIX and Windows</title>
 
318
                <tgroup align="center" cols="3">
 
319
                <thead>
 
320
                <row><entry>Action</entry><entry>MS Windows Command</entry><entry>UNIX Command</entry></row>
 
321
                </thead>
 
322
        
 
323
                <tbody>
 
324
                        <row><entry>create</entry><entry>md folder</entry><entry>mkdir folder</entry></row>
 
325
                        <row><entry>delete</entry><entry>rd folder</entry><entry>rmdir folder</entry></row>
 
326
                        <row><entry>rename</entry><entry>rename oldname newname</entry><entry>mv oldname newname</entry></row>
 
327
                </tbody>
 
328
        </tgroup>
 
329
        </table>
 
330
 
 
331
        </sect2>
 
332
 
 
333
        <sect2>
 
334
        <title>File and Directory Access Control</title>
 
335
 
 
336
        <para>
 
337
        <indexterm><primary>ACLs</primary><secondary>File System</secondary></indexterm>
 
338
<indexterm><primary>POSIX ACLs</primary></indexterm>
 
339
<indexterm><primary>EAs</primary></indexterm>
 
340
        The network administrator is strongly advised to read basic UNIX training manuals and reference materials
 
341
        regarding file and directory permissions maintenance. Much can be achieved with the basic UNIX permissions
 
342
        without having to resort to more complex facilities like POSIX ACLs or extended attributes (EAs).
 
343
        </para>
 
344
 
 
345
        <para>
 
346
        UNIX/Linux file and directory access permissions involves setting three primary sets of data and one control set.
 
347
        A UNIX file listing looks as follows:
 
348
<screen>
 
349
&prompt;<userinput>ls -la</userinput>
 
350
total 632
 
351
drwxr-xr-x   13 maryo   gnomes      816 2003-05-12 22:56 .
 
352
drwxrwxr-x   37 maryo   gnomes     3800 2003-05-12 22:29 ..
 
353
dr-xr-xr-x    2 maryo   gnomes       48 2003-05-12 22:29 muchado02
 
354
drwxrwxrwx    2 maryo   gnomes       48 2003-05-12 22:29 muchado03
 
355
drw-rw-rw-    2 maryo   gnomes       48 2003-05-12 22:29 muchado04
 
356
d-w--w--w-    2 maryo   gnomes       48 2003-05-12 22:29 muchado05
 
357
dr--r--r--    2 maryo   gnomes       48 2003-05-12 22:29 muchado06
 
358
drwsrwsrwx    2 maryo   gnomes       48 2003-05-12 22:29 muchado08
 
359
----------    1 maryo   gnomes     1242 2003-05-12 22:31 mydata00.lst
 
360
--w--w--w-    1 maryo   gnomes     7754 2003-05-12 22:33 mydata02.lst
 
361
-r--r--r--    1 maryo   gnomes    21017 2003-05-12 22:32 mydata04.lst
 
362
-rw-rw-rw-    1 maryo   gnomes    41105 2003-05-12 22:32 mydata06.lst
 
363
&prompt;
 
364
</screen>
 
365
        </para>
 
366
 
 
367
        <para>
 
368
        The columns represent (from left to right) permissions, number of hard links to file, owner, group, size
 
369
        (bytes), access date, time of last modification, and file name.
 
370
        </para>
 
371
 
 
372
        <para>
 
373
        An overview of the permissions field is shown in <link linkend="access1">Overview of UNIX permissions
 
374
        field</link>.
 
375
        </para>
 
376
 
 
377
        <figure id="access1">
 
378
                <title>Overview of UNIX permissions field.</title>
 
379
                <imagefile scale="40">access1</imagefile>
 
380
        </figure>
 
381
 
 
382
        <para>
 
383
                Any bit flag may be unset. An unset bit flag is the equivalent of "cannot" and is represented
 
384
                as a <quote>-</quote> character (see <link linkend="access2"/>)
 
385
<indexterm><primary>read</primary></indexterm>
 
386
<indexterm><primary>write</primary></indexterm>
 
387
<indexterm><primary>execute</primary></indexterm>
 
388
<indexterm><primary>user</primary></indexterm>
 
389
<indexterm><primary>group</primary></indexterm>
 
390
<indexterm><primary>other</primary></indexterm>
 
391
        </para>
 
392
 
 
393
<example id="access2">
 
394
<title>Example File</title>
 
395
<programlisting>
 
396
-rwxr-x---   Means: 
 
397
 ^^^                The owner (user) can read, write, execute
 
398
    ^^^             the group can read and execute
 
399
       ^^^          everyone else cannot do anything with it.
 
400
</programlisting>
 
401
</example>
 
402
 
 
403
 
 
404
        <para>
 
405
<indexterm><primary>character device</primary></indexterm>
 
406
<indexterm><primary>block device</primary></indexterm>
 
407
<indexterm><primary>pipe device</primary></indexterm>
 
408
<indexterm><primary>UNIX Domain Socket</primary></indexterm>
 
409
        Additional possibilities in the [type] field are c = character device, b = block device, p = pipe device,
 
410
        s = UNIX Domain Socket.
 
411
        </para>
 
412
 
 
413
        <para>
 
414
<indexterm><primary>read</primary></indexterm>
 
415
<indexterm><primary>write</primary></indexterm>
 
416
<indexterm><primary>execute</primary></indexterm>
 
417
<indexterm><primary>SGID</primary></indexterm>
 
418
<indexterm><primary>SUID</primary></indexterm>
 
419
        The letters <constant>rwxXst</constant> set permissions for the user, group, and others as read (r), write (w),
 
420
        execute (or access for directories) (x), execute  only  if  the  file  is a directory or already has execute
 
421
        permission for some user (X), set user (SUID) or group ID (SGID) on execution (s), sticky (t).
 
422
        </para>
 
423
 
 
424
        <para>
 
425
<indexterm><primary>sticky bit</primary></indexterm>
 
426
<indexterm><primary>unlinked</primary></indexterm>
 
427
<indexterm><primary>/tmp</primary></indexterm>
 
428
<indexterm><primary>world-writable</primary></indexterm>
 
429
        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. 
 
430
        Without the sticky  bit, anyone able to write to the directory can delete or rename files. The sticky bit is commonly found on
 
431
        directories, such as <filename>/tmp</filename>, that are world-writable.
 
432
        </para>
 
433
 
 
434
        <para>
 
435
<indexterm><primary>write</primary></indexterm>
 
436
<indexterm><primary>read</primary></indexterm>
 
437
<indexterm><primary>setting up directories</primary></indexterm>
 
438
<indexterm><primary>set user id</primary><see>SUID</see></indexterm>
 
439
<indexterm><primary>set group id</primary><see>SGID</see></indexterm>
 
440
        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
 
441
        group whose `set user or group' bit is set. This can be helpful in setting up directories for which it is desired that
 
442
        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
 
443
        to be exclusively owned by a user whose primary group is not the group that all such users belong to.
 
444
        </para>
 
445
 
 
446
        <para>
 
447
        When a directory is set <constant>d-wx--x---</constant>, the owner can read and create (write) files in it, but because
 
448
        the (r) read flags are not set, files cannot be listed (seen) in the directory by anyone. The group can read files in the
 
449
        directory but cannot create new files. If files in the directory are set to be readable and writable for the group, then
 
450
        group members will be able to write to (or delete) them.
 
451
        </para>
 
452
 
 
453
        <sect3>
 
454
        <title>Protecting Directories and Files from Deletion</title>
 
455
 
 
456
        <para>
 
457
<indexterm><primary>protect files</primary></indexterm>
 
458
<indexterm><primary>protect directories</primary></indexterm>
 
459
<indexterm><primary>access controls</primary></indexterm>
 
460
<indexterm><primary>capability to delete</primary></indexterm>
 
461
        People have asked on the Samba mailing list how is it possible to protect files or directories from deletion by users.
 
462
        For example, Windows NT/2K/XP provides the capacity to set access controls on a directory into which people can
 
463
        write files but not delete them. It is possible to set an ACL on a Windows file that permits the file to be written to
 
464
        but not deleted. Such concepts are foreign to the UNIX operating system file space. Within the UNIX file system
 
465
        anyone who has the ability to create a file can write to it. Anyone who has write permission on the
 
466
        directory that contains a file and has write permission for it has the capability to delete it.
 
467
        </para>
 
468
 
 
469
        <para>
 
470
<indexterm><primary>directory permissions</primary></indexterm>
 
471
<indexterm><primary>delete a file</primary></indexterm>
 
472
<indexterm><primary>write access</primary></indexterm>
 
473
        For the record, in the UNIX environment the ability to delete a file is controlled by the permissions on
 
474
        the directory that the file is in. In other words, a user can delete a file in a directory to which that
 
475
        user has write access, even if that user does not own the file.
 
476
        </para>
 
477
        
 
478
        <para>
 
479
<indexterm><primary>file system capabilities</primary></indexterm>
 
480
<indexterm><primary>inheritance</primary></indexterm>
 
481
<indexterm><primary>POSIX ACLs</primary></indexterm>
 
482
<indexterm><primary>extended attributes</primary></indexterm>
 
483
        Of necessity, Samba is subject to the file system semantics of the host operating system. Samba is therefore
 
484
        limited in the file system capabilities that can be made available through Windows ACLs, and therefore performs
 
485
        a "best fit" translation to POSIX ACLs. Some UNIX file systems do, however support, a feature known
 
486
        as extended attributes. Only the Windows concept of <emphasis>inheritance</emphasis> is implemented by Samba through
 
487
        the appropriate extended attribute.
 
488
        </para> 
 
489
 
 
490
        <para>
 
491
<indexterm><primary>extended attributes</primary></indexterm>
 
492
<indexterm><primary>immutible</primary></indexterm>
 
493
<indexterm><primary>chattr</primary></indexterm>
 
494
<indexterm><primary>CAP_LINUX_IMMUTABLE</primary></indexterm>
 
495
        The specific semantics of the extended attributes are not consistent across UNIX and UNIX-like systems such as Linux.
 
496
        For example, it is possible on some implementations of the extended attributes to set a flag that prevents the directory
 
497
        or file from being deleted. The extended attribute that may achieve this is called the <constant>immutible</constant> bit.
 
498
        Unfortunately, the implementation of the immutible flag is NOT consistent with published documentation. For example, the
 
499
        man page for the <command>chattr</command> on SUSE Linux 9.2 says:
 
500
<screen>
 
501
A file with the i attribute cannot be modified: it cannot be deleted
 
502
or renamed, no link can be created to this file and no data can be
 
503
written to the file. Only the superuser or a process possessing the
 
504
CAP_LINUX_IMMUTABLE capability can set or clear this attribute.
 
505
</screen>
 
506
        A simple test can be done to check if the immutible flag is supported on files in the file system of the Samba host
 
507
        server.
 
508
        </para>
 
509
 
 
510
        <procedure>
 
511
        <title>Test for File Immutibility Support</title>
 
512
 
 
513
        <step><para>
 
514
        Create a file called <filename>filename</filename>.
 
515
        </para></step>
 
516
 
 
517
        <step><para>
 
518
        Login as the <constant>root</constant> user, then set the immutibile flag on a test file as follows:
 
519
<screen>
 
520
&rootprompt; chattr +i `filename'
 
521
</screen>
 
522
        </para></step>
 
523
 
 
524
        <step><para>
 
525
        Login as the user who owns the file (not root) and attempt to remove the file as follows:
 
526
<screen>
 
527
mystic:/home/hannibal > rm filename
 
528
</screen>
 
529
        It will not be possible to delete the file if the immutible flag is correctly honored.
 
530
        </para></step>
 
531
        </procedure>
 
532
 
 
533
        <para>
 
534
        On operating systems and file system types that support the immutible bit, it is possible to create directories
 
535
        that cannot be deleted. Check the man page on your particular host system to determine whether or not
 
536
        immutable directories are writable. If they are not, then the entire directory and its contents will effectively
 
537
        be protected from writing (file creation also) and deletion.
 
538
        </para>
 
539
 
 
540
        </sect3>
 
541
 
 
542
        </sect2>
 
543
 
 
544
</sect1>
 
545
 
 
546
<sect1>
 
547
<title>Share Definition Access Controls</title>
 
548
 
 
549
 
 
550
        <para>
 
551
        <indexterm><primary>permissions</primary><secondary>share</secondary></indexterm>
 
552
        The following parameters in the &smb.conf; file sections define a share control or affect access controls.
 
553
        Before using any of the following options, please refer to the man page for &smb.conf;.
 
554
        </para>
 
555
 
 
556
        <sect2>
 
557
        <title>User- and Group-Based Controls</title>
 
558
 
 
559
        <para>
 
560
        User- and group-based controls can prove quite useful. In some situations it is distinctly desirable to
 
561
        force all file system operations as if a single user were doing so. The use of the
 
562
        <smbconfoption name="force user"/> and <smbconfoption name="force group"/> behavior will achieve this.
 
563
        In other situations it may be necessary to use a paranoia level of control to ensure that only particular
 
564
        authorized persons will be able to access a share or its contents. Here the use of the
 
565
        <smbconfoption name="valid users"/> or the <smbconfoption name="invalid users"/> parameter may be useful.
 
566
        </para>
 
567
 
 
568
        <para>
 
569
        As always, it is highly advisable to use the easiest to maintain and the least ambiguous method for
 
570
        controlling access. Remember, when you leave the scene, someone else will need to provide assistance, and
 
571
        if he or she finds too great a mess or does not understand what you have done, there is risk of
 
572
        Samba being removed and an alternative solution being adopted.
 
573
        </para>
 
574
 
 
575
        <para>
 
576
        <link linkend="ugbc">User and Group Based Controls</link> enumerates these controls.
 
577
        </para>
 
578
 
 
579
        <table frame='all' pgwide='0' id="ugbc"><title>User- and Group-Based Controls</title>
 
580
        <tgroup cols='2'>
 
581
                <colspec align="left"/>
 
582
                <colspec align="justify" colwidth="1*"/>
 
583
                <thead>
 
584
                <row>
 
585
                        <entry align="center">Control Parameter</entry>
 
586
                        <entry align="center">Description, Action, Notes</entry>
 
587
                </row>
 
588
                </thead>
 
589
                <tbody>
 
590
                <row>
 
591
                        <entry><smbconfoption name="admin users"/></entry>
 
592
                        <entry><para>
 
593
                        List of users who will be granted administrative privileges on the share.
 
594
                        They will do all file operations as the superuser (root). 
 
595
                        Users in this list will be able to do anything they like on the share,
 
596
                        irrespective of file permissions.
 
597
                        </para></entry>
 
598
                </row>
 
599
                <row>
 
600
                        <entry><smbconfoption name="force group"/></entry>
 
601
                        <entry><para>
 
602
                        Specifies a UNIX group name that will be assigned as the default primary group
 
603
                        for all users connecting to this service.
 
604
                        </para></entry>
 
605
                </row>
 
606
                <row>
 
607
                        <entry><smbconfoption name="force user"/></entry>
 
608
                        <entry><para>
 
609
                        Specifies a UNIX username that will be assigned as the default user for all users connecting to this service.
 
610
                        This is useful for sharing files. Incorrect use can cause security problems.
 
611
                        </para></entry>
 
612
                </row>
 
613
                <row>
 
614
                        <entry><smbconfoption name="guest ok"/></entry>
 
615
                        <entry><para>
 
616
                        If this parameter is set for a service, then no password is required to connect to the service. Privileges will be 
 
617
                        those of the  guest account.
 
618
                        </para></entry>
 
619
                </row>
 
620
                <row>
 
621
                        <entry><smbconfoption name="invalid users"/></entry>
 
622
                        <entry><para>
 
623
                        List of users that should not be allowed to login to this service.
 
624
                        </para></entry>
 
625
                </row>
 
626
                <row>
 
627
                        <entry><smbconfoption name="only user"/></entry>
 
628
                        <entry><para>
 
629
                        Controls whether connections with usernames not in the user list will be allowed.
 
630
                        </para></entry>
 
631
                </row>
 
632
                <row>
 
633
                        <entry><smbconfoption name="read list"/></entry>
 
634
                        <entry><para>
 
635
                        List of users that are given read-only access to a service. Users in this list
 
636
                        will not be given write access, no matter what the  read-only  option is set to. 
 
637
                        </para></entry>
 
638
                </row>
 
639
                <row>
 
640
                        <entry><smbconfoption name="username"/></entry>
 
641
                        <entry><para>
 
642
                        Refer to the &smb.conf; man page for more information; this is a complex and potentially misused parameter.
 
643
                        </para></entry>
 
644
                </row>
 
645
                <row>
 
646
                        <entry><smbconfoption name="valid users"/></entry>
 
647
                        <entry><para>
 
648
                        List of users that should be allowed to login to this service.
 
649
                        </para></entry>
 
650
                </row>
 
651
                <row>
 
652
                        <entry><smbconfoption name="write list"/></entry>
 
653
                        <entry><para>
 
654
                        List of users that are given read-write access to a service.
 
655
                        </para></entry>
 
656
                </row>
 
657
                </tbody>
 
658
        </tgroup>
 
659
        </table>
 
660
 
 
661
        </sect2>
 
662
 
 
663
        <sect2>
 
664
        <title>File and Directory Permissions-Based Controls</title>
 
665
 
 
666
        <para>
 
667
        Directory permission-based controls, if misused, can result in considerable difficulty in diagnosing the causes of 
 
668
        misconfiguration. Use them sparingly and carefully. By gradually introducing each, one at a time, undesirable side 
 
669
        effects may be detected. In the event of a problem, always comment all of them out and then gradually reintroduce 
 
670
        them in a controlled way.
 
671
        </para>
 
672
 
 
673
        <para>
 
674
        Refer to <link linkend="fdpbc">File and Directory Permission Based Controls</link> for information 
 
675
        regarding the parameters that may be used to set file and directory permission-based access controls.
 
676
        </para>
 
677
 
 
678
        <table frame='all' id="fdpbc"><title>File and Directory Permission-Based Controls</title>
 
679
                <tgroup cols='2'>
 
680
                        <colspec align="left"/>
 
681
                        <colspec align="justify" colwidth="1*"/>
 
682
                <thead>
 
683
                <row>
 
684
                        <entry align="center">Control Parameter</entry>
 
685
                        <entry align="center">Description, Action, Notes</entry>
 
686
                </row>
 
687
                </thead>
 
688
                <tbody>
 
689
                <row>
 
690
                        <entry><smbconfoption name="create mask"/></entry>
 
691
                        <entry><para>
 
692
                        Refer to the &smb.conf; man page.
 
693
                        </para></entry>
 
694
                </row>
 
695
                <row>
 
696
                        <entry><smbconfoption name="directory mask"/></entry>
 
697
                        <entry><para>
 
698
                        The octal modes used when converting DOS modes to UNIX modes when creating UNIX directories.
 
699
                        See also directory security mask.
 
700
                        </para></entry></row>
 
701
                <row>
 
702
                        <entry><smbconfoption name="dos filemode"/></entry>
 
703
                        <entry><para>
 
704
                        Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
 
705
                        </para></entry>
 
706
                </row>
 
707
                <row>
 
708
                        <entry><smbconfoption name="force create mode"/></entry>
 
709
                        <entry><para>
 
710
                        This parameter specifies a set of UNIX-mode bit permissions that will always be set on a file created by Samba.
 
711
                        </para></entry>
 
712
                </row>
 
713
                <row>
 
714
                        <entry><smbconfoption name="force directory mode"/></entry>
 
715
                        <entry><para>
 
716
                        This parameter specifies a set of UNIX-mode bit permissions that will always be set on a directory created by Samba.
 
717
                        </para></entry>
 
718
                </row>
 
719
                <row>
 
720
                        <entry><smbconfoption name="force directory security mode"/></entry>
 
721
                        <entry><para>
 
722
                        Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory.
 
723
                        </para></entry>
 
724
                </row>
 
725
                <row>
 
726
                        <entry><smbconfoption name="force security mode"/></entry>
 
727
                        <entry><para>
 
728
                        Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
 
729
                        </para></entry>
 
730
                </row>
 
731
                <row>
 
732
                        <entry><smbconfoption name="hide unreadable"/></entry>
 
733
                        <entry><para>
 
734
                        Prevents clients from seeing the existence of files that cannot be read.
 
735
                        </para></entry>
 
736
                </row>
 
737
                <row>
 
738
                        <entry><smbconfoption name="hide unwriteable files"/></entry>
 
739
                        <entry><para>
 
740
                        Prevents clients from seeing the existence of files that cannot be written to. Unwritable directories are shown as usual. 
 
741
                        </para></entry>
 
742
                </row>
 
743
                <row>
 
744
                        <entry><smbconfoption name="nt acl support"/></entry>
 
745
                        <entry><para>
 
746
                        This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT ACLs.
 
747
                        </para></entry>
 
748
                </row>
 
749
                <row>
 
750
                        <entry><smbconfoption name="security mask"/></entry>
 
751
                        <entry><para>
 
752
                        Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
 
753
                        </para></entry>
 
754
                </row>
 
755
                </tbody>
 
756
        </tgroup>
 
757
        </table>
 
758
 
 
759
        </sect2>
 
760
 
 
761
        <sect2>
 
762
        <title>Miscellaneous Controls</title>
 
763
 
 
764
        <para>
 
765
        The parameters documented in <link linkend="mcoc">Other Controls</link> are often used by administrators
 
766
        in ways that create inadvertent barriers to file access. Such are the consequences of not understanding the 
 
767
        full implications of &smb.conf; file settings.
 
768
        </para>
 
769
 
 
770
        <table frame='all' id="mcoc"><title>Other Controls</title>
 
771
        <tgroup cols='2'>
 
772
                <colspec align="justify" colwidth="1*"/>
 
773
                <colspec align="justify" colwidth="1*"/>
 
774
                <thead>
 
775
                <row>
 
776
                        <entry align="center">Control Parameter</entry>
 
777
                        <entry align="center">Description, Action, Notes</entry>
 
778
                </row>
 
779
                </thead>
 
780
                <tbody>
 
781
                <row>
 
782
                        <entry>
 
783
                        <smbconfoption name="case sensitive"/>,
 
784
                        <smbconfoption name="default case"/>,
 
785
                        <smbconfoption name="short preserve case"/>
 
786
                        </entry>
 
787
                        <entry><para>
 
788
                        This means that all file name lookup will be done in a case-sensitive manner. 
 
789
                        Files will be created with the precise file name Samba received from the MS Windows client.
 
790
                        </para></entry>
 
791
                </row>
 
792
                <row>
 
793
                        <entry><smbconfoption name="csc policy"/></entry>
 
794
                        <entry><para>
 
795
                        Client-side caching policy parallels MS Windows client-side file caching capabilities.
 
796
                        </para></entry>
 
797
                </row>
 
798
                <row>
 
799
                        <entry><smbconfoption name="dont descend"/></entry>
 
800
                        <entry><para>
 
801
                        Allows specifying a comma-delimited list of directories that the server should always show as empty.
 
802
                        </para></entry>
 
803
                </row>
 
804
                <row>
 
805
                        <entry><smbconfoption name="dos filetime resolution"/></entry>
 
806
                        <entry><para>
 
807
                        This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
 
808
                        </para></entry>
 
809
                </row>
 
810
                <row>
 
811
                        <entry><smbconfoption name="dos filetimes"/></entry>
 
812
                        <entry><para>
 
813
                        DOS and Windows allow users to change file timestamps if they can write to the file. POSIX semantics prevent this.
 
814
                        This option allows DOS and Windows behavior.
 
815
                        </para></entry>
 
816
                </row>
 
817
                <row>
 
818
                        <entry><smbconfoption name="fake oplocks"/></entry>
 
819
                        <entry><para>
 
820
                        Oplocks are the way that SMB clients get permission from a server to locally cache file operations. If a server grants an
 
821
                        oplock, the client is free to assume that it is the only one accessing the file, and it will aggressively cache file data.
 
822
                        </para></entry>
 
823
                </row>
 
824
                <row>
 
825
                        <entry>
 
826
                        <smbconfoption name="hide dot files"/>,
 
827
                        <smbconfoption name="hide files"/>,
 
828
                        <smbconfoption name="veto files"/>
 
829
                        </entry>
 
830
                        <entry><para>
 
831
                        Note: MS Windows Explorer allows override of files marked as hidden so they will still be visible.
 
832
                        </para></entry>
 
833
                </row>
 
834
                <row>
 
835
                        <entry><smbconfoption name="read only"/></entry>
 
836
                        <entry><para>
 
837
                        If this parameter is yes, then users of a service may not create or modify files in the service's directory.
 
838
                        </para></entry>
 
839
                </row>
 
840
                <row>
 
841
                        <entry><smbconfoption name="veto files"/></entry>
 
842
                        <entry><para>
 
843
                        List of files and directories that are neither visible nor accessible.
 
844
                        </para></entry>
 
845
                </row>
 
846
                </tbody>
 
847
        </tgroup>
 
848
        </table>
 
849
 
 
850
        </sect2>
 
851
 
 
852
</sect1>
 
853
 
 
854
<sect1>
 
855
<title>Access Controls on Shares</title>
 
856
 
 
857
 
 
858
        <para>
 
859
<indexterm><primary>per-share access control</primary></indexterm>
 
860
<indexterm><primary>Everyone - Full Control</primary></indexterm>
 
861
<indexterm><primary>specific restrictions</primary></indexterm>
 
862
<indexterm><primary>share access</primary></indexterm>
 
863
        <indexterm><primary>permissions</primary><secondary>share ACLs</secondary></indexterm>
 
864
        This section deals with how to configure Samba per-share access control restrictions.
 
865
        By default, Samba sets no restrictions on the share itself. Restrictions on the share itself
 
866
        can be set on MS Windows NT4/200x/XP shares. This can be an effective way to limit who can
 
867
        connect to a share. In the absence of specific restrictions, the default setting is to allow
 
868
        the global user <constant>Everyone - Full Control</constant> (full control, change and read).
 
869
        </para>
 
870
 
 
871
        <para>
 
872
<indexterm><primary>access control</primary></indexterm>
 
873
<indexterm><primary>MMC</primary></indexterm>
 
874
<indexterm><primary>Computer Management</primary></indexterm>
 
875
        At this time Samba does not provide a tool for configuring access control settings on the share
 
876
        itself the only way to create those settings is to use either the NT4 Server Manager or the Windows 200x
 
877
        Microsoft Management Console (MMC) for Computer Management. There are currently no plans to provide
 
878
        this capability in the Samba command-line tool set.
 
879
        </para>
 
880
 
 
881
        <para>
 
882
<indexterm><primary>share_info.tdb</primary></indexterm>
 
883
<indexterm><primary>/usr/local/samba/var</primary></indexterm>
 
884
<indexterm><primary>tdbdump</primary></indexterm>
 
885
<indexterm><primary>tdb files</primary></indexterm>
 
886
        Samba stores the per-share access control settings in a file called <filename>share_info.tdb</filename>.
 
887
        The location of this file on your system will depend on how Samba was compiled. The default location
 
888
        for Samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
 
889
        utility has been compiled and installed on your system, then you can examine the contents of this file
 
890
        by executing <command>tdbdump share_info.tdb</command> in the directory containing the tdb files.
 
891
        </para>
 
892
 
 
893
        <sect2>
 
894
        <title>Share Permissions Management</title>
 
895
 
 
896
                <para>
 
897
                The best tool for share permissions management is platform-dependent. Choose the best tool for your environment.
 
898
                </para>
 
899
 
 
900
                        <sect3>
 
901
                        <title>Windows NT4 Workstation/Server</title>
 
902
                        <para>
 
903
<indexterm><primary>manage share permissions</primary></indexterm>
 
904
<indexterm><primary>share permissions</primary></indexterm>
 
905
<indexterm><primary>NT Server Manager</primary></indexterm>
 
906
<indexterm><primary>Windows NT4</primary></indexterm>
 
907
                        The tool you need to manage share permissions on a Samba server from a Windows NT4 Workstation or Server
 
908
                        is the NT Server Manager.  Server Manager is shipped with Windows NT4 Server products but not with Windows
 
909
                        NT4 Workstation.  You can obtain the NT Server Manager for MS Windows NT4 Workstation from the Microsoft
 
910
                        web site <ulink url="http://support.microsoft.com/default.aspx?scid=kb;en-us;173673">support</ulink> section.
 
911
                        </para>
 
912
 
 
913
                        <procedure>
 
914
                        <title>Instructions</title>
 
915
 
 
916
                        <step><para>
 
917
                        Launch the <application>NT4 Server Manager</application> and click on the Samba server you want to
 
918
                        administer. From the menu select <guimenu>Computer</guimenu>, then click on
 
919
                        <guimenuitem>Shared Directories</guimenuitem>.
 
920
                        </para></step>
 
921
 
 
922
                        <step><para>
 
923
                        Click on the share that you wish to manage and click the <guilabel>Properties</guilabel> tab, then click
 
924
                        the <guilabel>Permissions</guilabel> tab. Now you can add or change access control settings as you wish.
 
925
                        </para></step>
 
926
                        </procedure>
 
927
 
 
928
                        </sect3>
 
929
 
 
930
                        <sect3>
 
931
                        <title>Windows 200x/XP</title>
 
932
 
 
933
                        <para>
 
934
<indexterm><primary>Windows NT4/200x/XP</primary></indexterm>
 
935
<indexterm><primary>ACLs on share</primary></indexterm>
 
936
<indexterm><primary>Sharing</primary></indexterm>
 
937
<indexterm><primary>Permissions</primary></indexterm>
 
938
                        On <application>MS Windows NT4/200x/XP</application> systems, ACLs on the share itself are set using
 
939
                        tools like the MS Explorer. For example, in Windows 200x, right-click on the shared folder,
 
940
                        then select <guimenuitem>Sharing</guimenuitem>, then click on <guilabel>Permissions</guilabel>. The default 
 
941
                        Windows NT4/200x permissions allow the group "Everyone" full control on the share.
 
942
                        </para>
 
943
 
 
944
                        <para>
 
945
<indexterm><primary>Computer Management</primary></indexterm>
 
946
<indexterm><primary>MMC</primary></indexterm>
 
947
<indexterm><primary>tool</primary></indexterm>
 
948
                        MS Windows 200x and later versions come with a tool called the <application>Computer Management</application>
 
949
                        snap-in for the MMC. This tool can be accessed via <guimenu>Control Panel ->
 
950
                        Administrative Tools -> Computer Management</guimenu>.
 
951
                        </para>
 
952
 
 
953
                        <procedure>
 
954
                        <title>Instructions</title>
 
955
                        <step><para>
 
956
                        After launching the MMC with the Computer Management snap-in, click the menu item <guimenuitem>Action</guimenuitem>
 
957
                        and select <guilabel>Connect to another computer</guilabel>. If you are not logged onto a domain you will be prompted
 
958
                        to enter a domain login user identifier and a password. This will authenticate you to the domain.
 
959
                        If you are already logged in with administrative privilege, this step is not offered.
 
960
                        </para></step>
 
961
 
 
962
                        <step><para>
 
963
                        If the Samba server is not shown in the <guilabel>Select Computer</guilabel> box, type in the name of the target
 
964
                        Samba server in the field <guilabel>Name:</guilabel>. Now click the on <guibutton>[+]</guibutton> next to 
 
965
                        <guilabel>System Tools</guilabel>, then on the <guibutton>[+]</guibutton> next to
 
966
                        <guilabel>Shared Folders</guilabel> in the left panel.
 
967
                        </para></step>
 
968
 
 
969
                        <step><para>
 
970
<indexterm><primary>Share Permissions</primary></indexterm>
 
971
                        In the right panel, double-click on the share on which you wish to set access control permissions.
 
972
                        Then click the tab <guilabel>Share Permissions</guilabel>. It is now possible to add access control entities
 
973
                        to the shared folder. Remember to set what type of access (full control, change, read) you
 
974
                        wish to assign for each entry.
 
975
                        </para></step>
 
976
                        </procedure>
 
977
 
 
978
                        <warning>
 
979
                        <para>
 
980
                        Be careful. If you take away all permissions from the <constant>Everyone</constant> user without removing
 
981
                        this user, effectively no user will be able to access the share. This is a result of what is known as
 
982
                        ACL precedence. Everyone with <emphasis>no access</emphasis> means that <constant>MaryK</constant> who is
 
983
                        part of the group <constant>Everyone</constant> will have no access even if she is given explicit full
 
984
                        control access.
 
985
                        </para>
 
986
                        </warning>
 
987
 
 
988
                        </sect3>
 
989
                </sect2>
 
990
 
 
991
</sect1>
 
992
 
 
993
<sect1>
 
994
<title>MS Windows Access Control Lists and UNIX Interoperability</title>
 
995
 
 
996
        <sect2>
 
997
                <title>Managing UNIX Permissions Using NT Security Dialogs</title>
 
998
 
 
999
 
 
1000
                <para>
 
1001
                <indexterm><primary>permissions</primary><secondary>file/directory ACLs</secondary></indexterm>
 
1002
                Windows NT clients can use their native security settings dialog box to view and modify the
 
1003
                underlying UNIX permissions.
 
1004
                </para>
 
1005
 
 
1006
                <para>
 
1007
                This ability is careful not to compromise the security of the UNIX host on which Samba is running and 
 
1008
                still obeys all the file permission rules that a Samba administrator can set.
 
1009
                </para>
 
1010
 
 
1011
                <para>
 
1012
                Samba does not attempt to go beyond POSIX ACLs, so the various finer-grained access control
 
1013
                options provided in Windows are actually ignored.
 
1014
                </para> 
 
1015
 
 
1016
                <note>
 
1017
                <para>
 
1018
                All access to UNIX/Linux system files via Samba is controlled by the operating system file access controls.
 
1019
                When trying to figure out file access problems, it is vitally important to find the identity of the Windows
 
1020
                user as it is presented by Samba at the point of file access. This can best be determined from the
 
1021
                Samba log files.
 
1022
                </para>
 
1023
                </note>
 
1024
        </sect2>
 
1025
 
 
1026
        <sect2>
 
1027
                <title>Viewing File Security on a Samba Share</title>
 
1028
 
 
1029
                <para>
 
1030
                From an NT4/2000/XP client, right-click on any file or directory in a Samba-mounted drive letter
 
1031
                or UNC path. When the menu pops up, click on the <guilabel>Properties</guilabel> entry at the bottom
 
1032
                of the menu. This brings up the file <constant>Properties</constant> dialog box. Click on the 
 
1033
                <guilabel>Security</guilabel> tab and you will see three buttons: <guibutton>Permissions</guibutton>,
 
1034
                <guibutton>Auditing</guibutton>, and <guibutton>Ownership</guibutton>. The <guibutton>Auditing</guibutton>
 
1035
                button will cause either an error message <errorname>"A requested privilege is not held by the client"</errorname>
 
1036
                to appear if the user is not the NT administrator, or a dialog intended to allow an administrator
 
1037
                to add auditing requirements to a file if the user is logged on as the NT administrator. This dialog is
 
1038
                nonfunctional with a Samba share at this time, because the only useful button, the <guibutton>Add</guibutton>
 
1039
                button, will not currently allow a list of users to be seen.
 
1040
                </para>
 
1041
 
 
1042
        </sect2>
 
1043
 
 
1044
        <sect2>
 
1045
                <title>Viewing File Ownership</title>
 
1046
 
 
1047
                <para>
 
1048
                Clicking on the <guibutton>Ownership</guibutton> button brings up a dialog box telling you who owns
 
1049
                the given file. The owner name will be displayed like this:
 
1050
                <screen>
 
1051
                <constant>SERVER\user (Long name)</constant>
 
1052
                </screen>
 
1053
                <replaceable>SERVER</replaceable> is the NetBIOS name of the Samba server, <replaceable>user</replaceable>
 
1054
                is the username of the UNIX user who owns the file, and <replaceable>(Long name)</replaceable> is the
 
1055
                descriptive string identifying the user (normally found in the GECOS field of the UNIX password database).
 
1056
                Click on the <guibutton>Close</guibutton> button to remove this dialog.
 
1057
                </para>
 
1058
 
 
1059
                <para>
 
1060
                If the parameter <smbconfoption name="nt acl support"/> is set to <constant>false</constant>,
 
1061
                the file owner will be shown as the NT user <emphasis>Everyone</emphasis>.
 
1062
                </para>
 
1063
 
 
1064
                <para>
 
1065
<indexterm><primary>Take Ownership</primary></indexterm>
 
1066
                The <guibutton>Take Ownership</guibutton> button will not allow you to change the ownership of this file to
 
1067
                yourself (clicking it will display a dialog box complaining that the user as whom you are currently logged onto
 
1068
                the NT client cannot be found). The reason for this is that changing the ownership of a file is a privileged
 
1069
                operation in UNIX, available only to the <emphasis>root</emphasis> user. Because clicking on this button causes
 
1070
                NT to attempt to change the ownership of a file to the current user logged into the NT client, this will
 
1071
                not work with Samba at this time.
 
1072
                </para>
 
1073
 
 
1074
                <para>
 
1075
<indexterm><primary>chown</primary></indexterm>
 
1076
<indexterm><primary>ownership</primary></indexterm>
 
1077
<indexterm><primary>Seclib</primary></indexterm>
 
1078
                There is an NT <command>chown</command> command that will work with Samba and allow a user with administrator
 
1079
                privilege connected to a Samba server as root to change the ownership of files on both a local NTFS file system
 
1080
                or remote mounted NTFS or Samba drive. This is available as part of the <application>Seclib</application> NT
 
1081
                security library written by Jeremy Allison of the Samba Team and is downloadable from the main Samba FTP site.
 
1082
                </para>
 
1083
 
 
1084
        </sect2>
 
1085
 
 
1086
        <sect2>
 
1087
                <title>Viewing File or Directory Permissions</title>
 
1088
 
 
1089
                <para>
 
1090
                The third button is the <guibutton>Permissions</guibutton> button. Clicking on it brings up a dialog box
 
1091
                that shows both the permissions and the UNIX owner of the file or directory. The owner is displayed like this:
 
1092
                </para>
 
1093
 
 
1094
                <para><command><replaceable>SERVER</replaceable>\
 
1095
                                <replaceable>user</replaceable> 
 
1096
                                <replaceable>(Long name)</replaceable></command></para>
 
1097
 
 
1098
                <para><replaceable>SERVER</replaceable> is the NetBIOS name of the Samba server,
 
1099
                <replaceable>user</replaceable> is the username of the UNIX user who owns the file, and
 
1100
                <replaceable>(Long name)</replaceable> is the descriptive string identifying the user (normally found in the
 
1101
                GECOS field of the UNIX password database).</para>
 
1102
 
 
1103
                <para>
 
1104
                If the parameter <smbconfoption name="nt acl support"/> is set to <constant>false</constant>,
 
1105
                the file owner will be shown as the NT user <constant>Everyone</constant>, and the permissions will be
 
1106
                shown as NT <emphasis>Full Control</emphasis>.
 
1107
                </para>
 
1108
 
 
1109
 
 
1110
                <para>
 
1111
                The permissions field is displayed differently for files and directories. Both are discussed next.
 
1112
                </para>
 
1113
 
 
1114
                <sect3>
 
1115
                <title>File Permissions</title>
 
1116
 
 
1117
                <para>
 
1118
                The standard UNIX user/group/world triplet and the corresponding <constant>read, write,
 
1119
                execute</constant> permissions triplets are mapped by Samba into a three-element NT ACL with the
 
1120
                <quote>r</quote>, <quote>w</quote>, and <quote>x</quote> bits mapped into the corresponding NT
 
1121
                permissions. The UNIX world permissions are mapped into the global NT group <constant>Everyone</constant>, followed 
 
1122
                by the list of permissions allowed for the UNIX world. The UNIX owner and group permissions are displayed as an NT 
 
1123
                <guiicon>user</guiicon> icon and an NT <guiicon>local group</guiicon> icon, respectively, followed by the list 
 
1124
                of permissions allowed for the UNIX user and group.
 
1125
                </para>
 
1126
 
 
1127
                <para>
 
1128
                Because many UNIX permission sets do not map into common NT names such as <constant>read</constant>,
 
1129
                <constant>change</constant>, or <constant>full control</constant>, usually the permissions will be prefixed
 
1130
                by the words <constant>Special Access</constant> in the NT display list.
 
1131
                </para>
 
1132
 
 
1133
                <para>
 
1134
                But what happens if the file has no permissions allowed for a particular UNIX user group or world component?
 
1135
                In order to  allow <emphasis>no permissions</emphasis> to be seen and modified, Samba then overloads the NT
 
1136
                <constant>Take Ownership</constant> ACL attribute (which has no meaning in UNIX) and reports a component with
 
1137
                no permissions as having the NT <command>O</command> bit set.  This was chosen, of course, to make it look
 
1138
                like a zero, meaning zero permissions. More details on the decision behind this action are given below.
 
1139
                </para>
 
1140
 
 
1141
                </sect3>
 
1142
                
 
1143
                <sect3>
 
1144
                <title>Directory Permissions</title>
 
1145
 
 
1146
                <para>
 
1147
                Directories on an NT NTFS file system have two different sets of permissions. The first set is the ACL set on the
 
1148
                directory itself, which is usually displayed in the first set of parentheses in the normal <constant>RW</constant> 
 
1149
                NT style. This first set of permissions is created by Samba in exactly the same way as normal file permissions are, described 
 
1150
                above, and is displayed in the same way.
 
1151
                </para>
 
1152
 
 
1153
                <para>
 
1154
                The second set of directory permissions has no real meaning in the UNIX permissions world and represents the <constant>
 
1155
                inherited</constant> permissions that any file created within this directory would inherit.
 
1156
                </para>
 
1157
 
 
1158
                <para>
 
1159
                Samba synthesizes these inherited permissions for NT by returning as an NT ACL the UNIX permission mode that a new file 
 
1160
                created by Samba on this share would receive.
 
1161
                </para>
 
1162
 
 
1163
                </sect3>
 
1164
 
 
1165
        </sect2>
 
1166
                
 
1167
        <sect2>
 
1168
        <title>Modifying File or Directory Permissions</title>
 
1169
 
 
1170
        <para>
 
1171
        Modifying file and directory permissions is as simple as changing the displayed permissions in the dialog box
 
1172
        and clicking on <guibutton>OK</guibutton>. However, there are limitations that a user needs to be aware of,
 
1173
        and also interactions with the standard Samba permission masks and mapping of DOS attributes that also need to
 
1174
        be taken into account.
 
1175
        </para>
 
1176
 
 
1177
        <para>
 
1178
        If the parameter <smbconfoption name="nt acl support"/> is set to <constant>false</constant>, any attempt to
 
1179
        set security permissions will fail with an <errorname>"Access Denied" </errorname> message.
 
1180
        </para>
 
1181
 
 
1182
        <para>
 
1183
        The first thing to note is that the <guibutton>Add</guibutton> button will not return a list of users in Samba
 
1184
        (it will give an error message saying <errorname>"The remote procedure call failed and did not
 
1185
        execute"</errorname>). This means that you can only manipulate the current user/group/world permissions listed
 
1186
        in the dialog box. This actually works quite well because these are the only permissions that UNIX actually
 
1187
        has.
 
1188
        </para>
 
1189
 
 
1190
        <para>
 
1191
        If a permission triplet (either user, group, or world) is removed from the list of permissions in the NT
 
1192
        dialog box, then when the <guibutton>OK</guibutton> button is pressed, it will be applied as <emphasis>no
 
1193
        permissions</emphasis> on the UNIX side. If you view the permissions again, the <emphasis>no
 
1194
        permissions</emphasis> entry will appear as the NT <command>O</command> flag, as described above. This allows
 
1195
        you to add permissions back to a file or directory once you have removed them from a triplet component.
 
1196
        </para>
 
1197
 
 
1198
        <para>
 
1199
        Because UNIX supports only the <quote>r</quote>, <quote>w</quote>, and <quote>x</quote> bits of an NT ACL, if
 
1200
        other NT security attributes such as <constant>Delete Access</constant> are selected, they will be ignored
 
1201
        when applied on the Samba server.
 
1202
        </para>
 
1203
 
 
1204
        <para>
 
1205
        When setting permissions on a directory, the second set of permissions (in the second set of parentheses) is
 
1206
        by default applied to all files within that directory. If this is not what you want, you must uncheck the
 
1207
        <guilabel>Replace permissions on existing files</guilabel> checkbox in the NT dialog before clicking on
 
1208
        <guibutton>OK</guibutton>.
 
1209
        </para>
 
1210
 
 
1211
        <para>
 
1212
        If you wish to remove all permissions from a user/group/world  component, you may either highlight the
 
1213
        component and click on the <guibutton>Remove</guibutton> button or set the component to only have the special
 
1214
        <constant>Take Ownership</constant> permission (displayed as <command>O</command>) highlighted.
 
1215
        </para>
 
1216
 
 
1217
        </sect2>
 
1218
 
 
1219
<?latex \newpage ?>
 
1220
        <sect2>
 
1221
        <title>Interaction with the Standard Samba <quote>create mask</quote> Parameters</title>
 
1222
 
 
1223
        <para>There are four parameters that control interaction with the standard Samba <parameter>create mask</parameter> parameters:
 
1224
        
 
1225
 
 
1226
        <itemizedlist>
 
1227
                <listitem><para><smbconfoption name="security mask"/></para></listitem>
 
1228
                <listitem><para><smbconfoption name="force security mode"/></para></listitem>
 
1229
                <listitem><para><smbconfoption name="directory security mask"/></para></listitem>
 
1230
                <listitem><para><smbconfoption name="force directory security mode"/></para></listitem>
 
1231
        </itemizedlist>
 
1232
 
 
1233
        </para>
 
1234
 
 
1235
        <para>
 
1236
        When a user clicks on <guibutton>OK</guibutton> to apply the 
 
1237
        permissions, Samba maps the given permissions into a user/group/world 
 
1238
        r/w/x triplet set, and then checks the changed permissions for a 
 
1239
        file against the bits set in the  
 
1240
        <smbconfoption name="security mask"/> parameter. Any bits that 
 
1241
        were changed that are not set to <emphasis>1</emphasis> in this parameter are left alone 
 
1242
        in the file permissions.</para>
 
1243
 
 
1244
        <para>
 
1245
        Essentially, zero bits in the <smbconfoption name="security mask"/>
 
1246
        may be treated as a set of bits the user is <emphasis>not</emphasis> 
 
1247
        allowed to change, and one bits are those the user is allowed to change.
 
1248
        </para>
 
1249
 
 
1250
        <para>
 
1251
        If not explicitly set, this parameter defaults to the same value as 
 
1252
        the <smbconfoption name="create mask"/> parameter. To allow a user to modify all the
 
1253
        user/group/world permissions on a file, set this parameter to 0777.
 
1254
        </para>
 
1255
 
 
1256
        <para>
 
1257
        Next Samba checks the changed permissions for a file against the bits set in the 
 
1258
        <smbconfoption name="force security mode"/> parameter. Any bits 
 
1259
        that were changed that correspond to bits set to <emphasis>1</emphasis> in this parameter 
 
1260
        are forced to be set.</para>
 
1261
 
 
1262
        <para>
 
1263
        Essentially, bits set in the <parameter>force security mode</parameter> parameter
 
1264
        may be treated as a set of bits that, when modifying security on a file, the user 
 
1265
        has always set to be <emphasis>on</emphasis>.</para>
 
1266
 
 
1267
        <para>
 
1268
        If not explicitly set, this parameter defaults to the same value 
 
1269
        as the <smbconfoption name="force create mode"/> parameter.
 
1270
        To allow a user to modify all the user/group/world permissions on a file
 
1271
        with no restrictions, set this parameter to 000. The
 
1272
        <smbconfoption name="security mask"/> and <parameter>force 
 
1273
        security mode</parameter> parameters are applied to the change 
 
1274
        request in that order.</para>
 
1275
 
 
1276
        <para>
 
1277
        For a directory, Samba performs the same operations as 
 
1278
        described above for a file except it uses the parameter <parameter>
 
1279
        directory security mask</parameter> instead of <parameter>security 
 
1280
        mask</parameter>, and <parameter>force directory security mode
 
1281
        </parameter> parameter instead of <parameter>force security mode
 
1282
        </parameter>.</para>
 
1283
 
 
1284
        <para>
 
1285
        The <smbconfoption name="directory security mask"/> parameter 
 
1286
        by default is set to the same value as the <parameter>directory mask
 
1287
        </parameter> parameter and the <parameter>force directory security 
 
1288
        mode</parameter> parameter by default is set to the same value as 
 
1289
        the <smbconfoption name="force directory mode"/> parameter.
 
1290
        In this way Samba enforces the permission restrictions that 
 
1291
        an administrator can set on a Samba share, while still allowing users 
 
1292
        to modify the permission bits within that restriction.</para>
 
1293
 
 
1294
        <para>
 
1295
        If you want to set up a share that allows users full control
 
1296
        in modifying the permission bits on their files and directories and
 
1297
        does not force any particular bits to be set <emphasis>on</emphasis>,
 
1298
        then set the following parameters in the &smb.conf; file in that
 
1299
        share-specific section:
 
1300
        </para>
 
1301
 
 
1302
<?latex \newpage ?>
 
1303
        <smbconfblock>
 
1304
                <smbconfoption name="security mask">0777</smbconfoption>
 
1305
                <smbconfoption name="force security mode">0</smbconfoption>
 
1306
                <smbconfoption name="directory security mask">0777</smbconfoption>
 
1307
                <smbconfoption name="force directory security mode">0</smbconfoption>
 
1308
        </smbconfblock>
 
1309
 
 
1310
</sect2>
 
1311
 
 
1312
<sect2>
 
1313
        <title>Interaction with the Standard Samba File Attribute Mapping</title>
 
1314
 
 
1315
        <note>
 
1316
        <para>
 
1317
        Samba maps some of the DOS attribute bits (such as <quote>read-only</quote>)
 
1318
        into the UNIX permissions of a file. This means there can 
 
1319
        be a conflict between the permission bits set via the security 
 
1320
        dialog and the permission bits set by the file attribute mapping.
 
1321
        </para>
 
1322
        </note>
 
1323
 
 
1324
        <para>
 
1325
        If a file has no UNIX read access for the owner, it will show up
 
1326
        as <quote>read-only</quote> in the standard file attributes tabbed dialog.
 
1327
        Unfortunately, this dialog is the same one that contains the security information
 
1328
        in another tab.
 
1329
        </para>
 
1330
 
 
1331
        <para>
 
1332
        What this can mean is that if the owner changes the permissions
 
1333
        to allow himself or herself read access using the security dialog, clicks on
 
1334
        <guibutton>OK</guibutton> to get back to the standard attributes tab 
 
1335
        dialog, and clicks on <guibutton>OK</guibutton> on that dialog, then 
 
1336
        NT will set the file permissions back to read-only (as that is what 
 
1337
        the attributes still say in the dialog). This means that after setting 
 
1338
        permissions and clicking on <guibutton>OK</guibutton> to get back to the 
 
1339
        attributes dialog, you should always press <guibutton>Cancel</guibutton> 
 
1340
        rather than <guibutton>OK</guibutton> to ensure that your changes 
 
1341
        are not overridden.
 
1342
        </para>
 
1343
 
 
1344
        </sect2>
 
1345
 
 
1346
        <sect2>
 
1347
        <title>Windows NT/200X ACLs and POSIX ACLs Limitations</title>
 
1348
 
 
1349
        <para>
 
1350
        Windows administrators are familiar with simple ACL controls, and they typically
 
1351
        consider that UNIX user/group/other (ugo) permissions are inadequate and not
 
1352
        sufficiently fine-grained.
 
1353
        </para>
 
1354
 
 
1355
        <para>
 
1356
        Competing SMB implementations differ in how they handle Windows ACLs. Samba handles
 
1357
        Windows ACLs from the perspective of UNIX file system administration and thus adopts
 
1358
        the limitations of POSIX ACLs. Therefore, where POSIX ACLs lack a capability of the
 
1359
        Windows NT/200X ACLs, the POSIX semantics and limitations are imposed on the Windows
 
1360
        administrator.
 
1361
        </para>
 
1362
 
 
1363
        <para>
 
1364
        POSIX ACLs present an interesting challenge to the UNIX administrator and therefore
 
1365
        force a compromise to be applied to Windows ACLs administration. POSIX ACLs are not
 
1366
        covered by an official standard; rather, the latest standard is a draft standard
 
1367
        1003.1e revision 17. This is the POSIX document on which the Samba implementation has
 
1368
        been implemented.
 
1369
        </para>
 
1370
 
 
1371
        <para>
 
1372
        UNIX vendors differ in the manner in which POSIX ACLs are implemented. There are a
 
1373
        number of Linux file systems that support ACLs. Samba has to provide a way to make
 
1374
        transparent all the differences between the various implementations of POSIX ACLs.
 
1375
        The pressure for ACLs support in Samba has noticeably increased the pressure to
 
1376
        standardize ACLs support in the UNIX world.
 
1377
        </para>
 
1378
 
 
1379
        <para>
 
1380
        Samba has to deal with the complicated matter of handling the challenge of the Windows
 
1381
        ACL that implements <emphasis>inheritance</emphasis>, a concept not anticipated by POSIX
 
1382
        ACLs as implemented in UNIX file systems. Samba provides support for <emphasis>masks</emphasis>
 
1383
        that permit normal ugo and ACLs functionality to be overrided. This further complicates
 
1384
        the way in which Windows ACLs must be implemented.
 
1385
        </para>
 
1386
 
 
1387
        <sect3>
 
1388
        <title>UNIX POSIX ACL Overview</title>
 
1389
 
 
1390
        <para>
 
1391
        In examining POSIX ACLs we must consider the manner in which they operate for 
 
1392
        both files and directories. File ACLs have the following significance:
 
1393
<screen>
 
1394
# file: testfile      &lt;- the file name
 
1395
# owner: jeremy       &lt;-- the file owner
 
1396
# group: users        &lt;-- the POSIX group owner
 
1397
user::rwx             &lt;-- perms for the file owner (user)
 
1398
user:tpot:r-x         &lt;-- perms for the additional user `tpot'
 
1399
group::r--            &lt;-- perms for the file group owner (group)
 
1400
group:engrs:r--       &lt;-- perms for the additonal group `engineers'
 
1401
mask:rwx              &lt;-- the mask that is `ANDed' with groups
 
1402
other::---            &lt;-- perms applied to everyone else (other)
 
1403
</screen>
 
1404
        Directory ACLs have the following signficance:
 
1405
<screen>
 
1406
# file: testdir       &lt;-- the directory name
 
1407
# owner: jeremy       &lt;-- the directory owner
 
1408
# group: jeremy       &lt;-- the POSIX group owner
 
1409
user::rwx             &lt;-- directory perms for owner (user)
 
1410
group::rwx            &lt;-- directory perms for owning group (group)
 
1411
mask::rwx             &lt;-- the mask that is `ANDed' with group perms
 
1412
other:r-x             &lt;-- perms applied to everyone else (other)
 
1413
default:user::rwx     &lt;-- inherited owner perms
 
1414
default:user:tpot:rwx &lt;-- inherited extra perms for user `tpot'
 
1415
default:group::r-x    &lt;-- inherited group perms
 
1416
default:mask:rwx      &lt;-- inherited default mask
 
1417
default:other:---     &lt;-- inherited permissions for everyone (other)
 
1418
</screen>
 
1419
        </para>
 
1420
 
 
1421
        </sect3>
 
1422
 
 
1423
        <sect3>
 
1424
        <title>Mapping of Windows File ACLs to UNIX POSIX ACLs</title>
 
1425
 
 
1426
        <para>
 
1427
        Microsoft Windows NT4/200X ACLs must of necessity be mapped to POSIX ACLs.
 
1428
        The mappings for file permissions are shown in <link linkend="fdsacls">How
 
1429
        Windows File ACLs Map to UNIX POSIX File ACLs</link>.
 
1430
        The # character means this flag is set only when the Windows administrator
 
1431
        sets the <constant>Full Control</constant> flag on the file.
 
1432
        </para>
 
1433
 
 
1434
        <table frame='all' pgwide='0' id="fdsacls"><title>How Windows File ACLs Map to UNIX POSIX File ACLs</title>
 
1435
        <tgroup cols='2'>
 
1436
                <colspec align="left"/>
 
1437
                <colspec align="center"/>
 
1438
                <thead>
 
1439
                <row>
 
1440
                        <entry align="left">Windows ACE</entry>
 
1441
                        <entry align="center">File Attribute Flag</entry>
 
1442
                </row>
 
1443
                </thead>
 
1444
                <tbody>
 
1445
                <row>
 
1446
                        <entry><para>Full Control</para></entry>
 
1447
                        <entry><para>#</para></entry>
 
1448
                </row>
 
1449
                <row>
 
1450
                        <entry><para>Traverse Folder/Execute File</para></entry>
 
1451
                        <entry><para>x</para></entry>
 
1452
                </row>
 
1453
                <row>
 
1454
                        <entry><para>List Folder/Read Data</para></entry>
 
1455
                        <entry><para>r</para></entry>
 
1456
                </row>
 
1457
                <row>
 
1458
                        <entry><para>Read Attributes</para></entry>
 
1459
                        <entry><para>r</para></entry>
 
1460
                </row>
 
1461
                <row>
 
1462
                        <entry><para>Read Extended Attribures</para></entry>
 
1463
                        <entry><para>r</para></entry>
 
1464
                </row>
 
1465
                <row>
 
1466
                        <entry><para>Create Files/Write Data</para></entry>
 
1467
                        <entry><para>w</para></entry>
 
1468
                </row>
 
1469
                <row>
 
1470
                        <entry><para>Create Folders/Append Data</para></entry>
 
1471
                        <entry><para>w</para></entry>
 
1472
                </row>
 
1473
                <row>
 
1474
                        <entry><para>Write Attributes</para></entry>
 
1475
                        <entry><para>w</para></entry>
 
1476
                </row>
 
1477
                <row>
 
1478
                        <entry><para>Write Extended Attributes</para></entry>
 
1479
                        <entry><para>w</para></entry>
 
1480
                </row>
 
1481
                <row>
 
1482
                        <entry><para>Delete Subfolders and Files</para></entry>
 
1483
                        <entry><para>w</para></entry>
 
1484
                </row>
 
1485
                <row>
 
1486
                        <entry><para>Delete</para></entry>
 
1487
                        <entry><para>#</para></entry>
 
1488
                </row>
 
1489
                <row>
 
1490
                        <entry><para>Read Permissions</para></entry>
 
1491
                        <entry><para>all</para></entry>
 
1492
                </row>
 
1493
                <row>
 
1494
                        <entry><para>Change Permissions</para></entry>
 
1495
                        <entry><para>#</para></entry>
 
1496
                </row>
 
1497
                <row>
 
1498
                        <entry><para>Take Ownership</para></entry>
 
1499
                        <entry><para>#</para></entry>
 
1500
                </row>
 
1501
                </tbody>
 
1502
        </tgroup>
 
1503
        </table>
 
1504
 
 
1505
        <para>
 
1506
        As can be seen from the mapping table, there is no one-to-one mapping capability, and therefore
 
1507
        Samba must make a logical mapping that will permit Windows to operate more-or-less the way
 
1508
        that is intended by the administrator.
 
1509
        </para>
 
1510
 
 
1511
        <para>
 
1512
        In general the mapping of UNIX POSIX user/group/other permissions will be mapped to
 
1513
        Windows ACLs. This has precedence over the creation of POSIX ACLs. POSIX ACLs are necessary
 
1514
        to establish access controls for users and groups other than the user and group that
 
1515
        own the file or directory.
 
1516
        </para>
 
1517
 
 
1518
        <para>
 
1519
        The UNIX administrator can set any directory permission from within the UNIX environment.
 
1520
        The Windows administrator is more restricted in that it is not possible from within 
 
1521
        Windows Explorer to remove read permission for the file owner.
 
1522
        </para>
 
1523
 
 
1524
        </sect3>
 
1525
 
 
1526
        <sect3>
 
1527
        <title>Mapping of Windows Directory ACLs to UNIX POSIX ACLs</title>
 
1528
 
 
1529
        <para>
 
1530
        Interesting things happen in the mapping of UNIX POSIX directory permissions and
 
1531
        UNIX POSIX ACLs to Windows ACEs (Access Control Entries, the discrete components of
 
1532
        an ACL) are mapped to Windows directory ACLs.
 
1533
        </para>
 
1534
 
 
1535
        <para>
 
1536
        Directory permissions function in much the same way as shown for file permissions, but
 
1537
        there are some notable exceptions and a few peculiarities that the astute administrator
 
1538
        will want to take into account in the setting up of directory permissions.
 
1539
        </para>
 
1540
 
 
1541
        </sect3>
 
1542
 
 
1543
        </sect2>
 
1544
</sect1>
 
1545
 
 
1546
<sect1>
 
1547
<title>Common Errors</title>
 
1548
 
 
1549
<para>
 
1550
File, directory, and share access problems are common topics on the mailing list. The following
 
1551
are examples recently taken from the mailing list.
 
1552
</para>
 
1553
 
 
1554
 
 
1555
        <sect2>
 
1556
        <title>Users Cannot Write to a Public Share</title>
 
1557
 
 
1558
        <para>
 
1559
        The following complaint has frequently been voiced on the Samba mailing list: 
 
1560
        <quote>
 
1561
        We are facing some troubles with file/directory permissions. I can log on the domain as admin user (root),
 
1562
        and there's a public share on which everyone needs to have permission to create/modify files, but only
 
1563
        root can change the file, no one else can. We need to constantly go to the server to
 
1564
        <userinput>chgrp -R users *</userinput> and <userinput>chown -R nobody *</userinput> to allow
 
1565
        other users to change the file.
 
1566
        </quote>
 
1567
        </para>
 
1568
 
 
1569
        <para>
 
1570
        Here is one way the problem can be solved:
 
1571
        </para>
 
1572
 
 
1573
        <procedure>
 
1574
                <step>
 
1575
                        <para>
 
1576
                        Go to the top of the directory that is shared.
 
1577
                        </para>
 
1578
                </step>
 
1579
 
 
1580
                <step>
 
1581
                        <para>
 
1582
                        Set the ownership to whatever public user and group you want
 
1583
<screen>
 
1584
&prompt;find `directory_name' -type d -exec chown user:group {}\;
 
1585
&prompt;find `directory_name' -type d -exec chmod 2775 {}\;
 
1586
&prompt;find `directory_name' -type f -exec chmod 0775 {}\;
 
1587
&prompt;find `directory_name' -type f -exec chown user:group {}\;
 
1588
</screen>
 
1589
                        </para>
 
1590
 
 
1591
                        <note><para>
 
1592
                        The above will set the <constant>SGID bit</constant> on all directories. Read your
 
1593
                        UNIX/Linux man page on what that does. This ensures that all files and directories
 
1594
                        that are created in the directory tree will be owned by the current user and will
 
1595
                        be owned by the group that owns the directory in which it is created.
 
1596
                        </para></note>
 
1597
                </step>
 
1598
                <step>
 
1599
                        <para>
 
1600
                        Directory is <replaceable>/foodbar</replaceable>:
 
1601
<screen>
 
1602
&prompt;<userinput>chown jack:engr /foodbar</userinput>
 
1603
</screen>
 
1604
                        </para>
 
1605
 
 
1606
                        <note>
 
1607
                        <para>This is the same as doing:</para>
 
1608
<screen>
 
1609
&prompt;<userinput>chown jack /foodbar</userinput>
 
1610
&prompt;<userinput>chgrp engr /foodbar</userinput>
 
1611
</screen>
 
1612
                        </note>
 
1613
                </step>
 
1614
                <step>
 
1615
                        <para>Now type: 
 
1616
 
 
1617
<screen>
 
1618
&prompt;<userinput>chmod 2775 /foodbar</userinput>
 
1619
&prompt;<userinput>ls -al /foodbar/..</userinput>
 
1620
</screen>
 
1621
                        </para>
 
1622
                
 
1623
                        <para>You should see:
 
1624
<screen>
 
1625
drwxrwsr-x  2 jack  engr    48 2003-02-04 09:55 foodbar
 
1626
</screen>
 
1627
                        </para>
 
1628
                </step>
 
1629
                <step>
 
1630
 
 
1631
                <para>Now type:
 
1632
<screen>
 
1633
&prompt;<userinput>su - jill</userinput>
 
1634
&prompt;<userinput>cd /foodbar</userinput>
 
1635
&prompt;<userinput>touch Afile</userinput>
 
1636
&prompt;<userinput>ls -al</userinput>
 
1637
</screen>
 
1638
                </para>
 
1639
 
 
1640
                <para>
 
1641
                You should see that the file <filename>Afile</filename> created by Jill will have ownership
 
1642
                and permissions of Jack, as follows:
 
1643
<screen>
 
1644
-rw-r--r--  1 jill  engr     0 2007-01-18 19:41 Afile
 
1645
</screen>
 
1646
                </para>
 
1647
                </step>
 
1648
 
 
1649
                <step>
 
1650
                <para>
 
1651
                If the user that must have write permission in the directory is not a member of the group
 
1652
                <emphasis>engr</emphasis> set in the &smb.conf; entry for the share:
 
1653
                <smbconfblock>
 
1654
<smbconfoption name="force group">engr</smbconfoption>
 
1655
                </smbconfblock>
 
1656
                </para>
 
1657
        </step>
 
1658
        </procedure>
 
1659
        </sect2>
 
1660
 
 
1661
 
 
1662
        <sect2>
 
1663
                <title>File Operations Done as <emphasis>root</emphasis> with <emphasis>force user</emphasis> Set</title>
 
1664
 
 
1665
                <para>
 
1666
                When you have a user in <smbconfoption name="admin users"/>, Samba will always do file operations for
 
1667
                this user as <emphasis>root</emphasis>, even if <smbconfoption name="force user"/> has been set.
 
1668
                </para>
 
1669
        </sect2>
 
1670
        
 
1671
        <sect2>
 
1672
                <title>MS Word with Samba Changes Owner of File</title>
 
1673
 
 
1674
                <para>
 
1675
                <emphasis>Question:</emphasis> <quote>When user B saves a word document that is owned by user A,
 
1676
                the updated file is now owned by user B.  Why is Samba doing this? How do I fix this?</quote>
 
1677
                </para>
 
1678
 
 
1679
                <para>
 
1680
                <emphasis>Answer:</emphasis> Word does the following when you modify/change a Word document: MS Word creates a new document with
 
1681
                a temporary name. Word then closes the old document and deletes it, then renames the new document to the original document name.
 
1682
                There is no mechanism by which Samba can in any way know that the new document really should be owned by the owners
 
1683
                of the original file. Samba has no way of knowing that the file will be renamed by MS Word. As far as Samba is able
 
1684
                to tell, the file that gets created is a new file, not one that the application (Word) is updating.
 
1685
                </para>
 
1686
 
 
1687
                <para>
 
1688
                There is a workaround to solve the permissions problem. It involves understanding how you can manage file
 
1689
                system behavior from within the &smb.conf; file, as well as understanding how UNIX file systems work. Set on the directory
 
1690
                in which you are changing Word documents: <command>chmod g+s `directory_name'.</command> This ensures that all files will
 
1691
                be created with the group that owns the directory. In &smb.conf; share declaration section set:
 
1692
                </para>
 
1693
 
 
1694
                <para>
 
1695
                <smbconfblock>
 
1696
                <smbconfoption name="force create mode">0660</smbconfoption>
 
1697
                <smbconfoption name="force directory mode">0770</smbconfoption>
 
1698
                </smbconfblock>
 
1699
                </para>
 
1700
 
 
1701
                <para>
 
1702
                These two settings will ensure that all directories and files that get created in the share will be readable/writable by the
 
1703
                owner and group set on the directory itself.
 
1704
                </para>
 
1705
                
 
1706
        </sect2>
 
1707
 
 
1708
</sect1>
 
1709
 
 
1710
</chapter>