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">
4 <chapter id="AccessControls">
8 <author>&person.jelmer;<contrib>drawing</contrib></author>
9 <pubdate>May 10, 2003</pubdate>
11 <title>File, Directory, and Share Access Controls</title>
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.
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.
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.
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.
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.
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.
72 <title>Features and Benefits</title>
75 Samba offers much flexibility in file system access management. These are the key access control
76 facilities present in Samba today:
80 <title>Samba Access Control Facilities</title>
82 <indexterm><primary>permissions</primary><secondary>UNIX file and directory</secondary></indexterm>
83 <emphasis>UNIX File and Directory Permissions</emphasis>
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.
101 <emphasis>Samba Share Definitions</emphasis>
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.
116 <emphasis>Samba Share ACLs</emphasis>
117 <indexterm><primary>ACLs</primary><secondary>share</secondary></indexterm>
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.
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>
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.
152 <title>File System Access Controls</title>
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.
162 <title>MS Windows NTFS Comparison with UNIX File Systems</title>
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.
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.
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>
189 <term>Name Space</term>
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.
197 What MS Windows calls a folder, UNIX calls a directory.
203 <term>Case Sensitivity</term>
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
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.
222 Consider the following. All are unique UNIX names but one single MS Windows file name:
230 So clearly, in an MS Windows file namespace these three files cannot co-exist, but in UNIX
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
245 <term>Directory Separators</term>
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.
254 <term>Drive Identification</term>
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>.
266 <term>File Naming Conventions</term>
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.
277 <term>Links and Short-Cuts</term>
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.
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.
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.
305 <title>Managing Directories</title>
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.
316 <table frame="all" id="TOSH-Accesstbl">
317 <title>Managing Directories with UNIX and Windows</title>
318 <tgroup align="center" cols="3">
320 <row><entry>Action</entry><entry>MS Windows Command</entry><entry>UNIX Command</entry></row>
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>
334 <title>File and Directory Access Control</title>
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).
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:
349 &prompt;<userinput>ls -la</userinput>
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
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.
373 An overview of the permissions field is shown in <link linkend="access1">Overview of UNIX permissions
377 <figure id="access1">
378 <title>Overview of UNIX permissions field.</title>
379 <imagefile scale="40">access1</imagefile>
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>
393 <example id="access2">
394 <title>Example File</title>
397 ^^^ The owner (user) can read, write, execute
398 ^^^ the group can read and execute
399 ^^^ everyone else cannot do anything with it.
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.
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).
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.
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.
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.
454 <title>Protecting Directories and Files from Deletion</title>
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.
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.
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.
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:
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.
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
511 <title>Test for File Immutibility Support</title>
514 Create a file called <filename>filename</filename>.
518 Login as the <constant>root</constant> user, then set the immutibile flag on a test file as follows:
520 &rootprompt; chatter +i `filename'
525 Login as the user who owns the file (not root) and attempt to remove the file as follows:
527 mystic:/home/hannibal > rm filename
529 It will not be possible to delete the file if the immutible flag is correctly honored.
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.
547 <title>Share Definition Access Controls</title>
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;.
557 <title>User- and Group-Based Controls</title>
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.
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.
576 <link linkend="ugbc">User and Group Based Controls</link> enumerates these controls.
579 <table frame='all' pgwide='0' id="ugbc"><title>User- and Group-Based Controls</title>
581 <colspec align="left"/>
582 <colspec align="justify" colwidth="1*"/>
585 <entry align="center">Control Parameter</entry>
586 <entry align="center">Description, Action, Notes</entry>
591 <entry><smbconfoption name="admin users"/></entry>
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.
600 <entry><smbconfoption name="force group"/></entry>
602 Specifies a UNIX group name that will be assigned as the default primary group
603 for all users connecting to this service.
607 <entry><smbconfoption name="force user"/></entry>
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.
614 <entry><smbconfoption name="guest ok"/></entry>
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.
621 <entry><smbconfoption name="invalid users"/></entry>
623 List of users that should not be allowed to login to this service.
627 <entry><smbconfoption name="only user"/></entry>
629 Controls whether connections with usernames not in the user list will be allowed.
633 <entry><smbconfoption name="read list"/></entry>
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.
640 <entry><smbconfoption name="username"/></entry>
642 Refer to the &smb.conf; man page for more information; this is a complex and potentially misused parameter.
646 <entry><smbconfoption name="valid users"/></entry>
648 List of users that should be allowed to login to this service.
652 <entry><smbconfoption name="write list"/></entry>
654 List of users that are given read-write access to a service.
664 <title>File and Directory Permissions-Based Controls</title>
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.
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.
678 <table frame='all' id="fdpbc"><title>File and Directory Permission-Based Controls</title>
680 <colspec align="left"/>
681 <colspec align="justify" colwidth="1*"/>
684 <entry align="center">Control Parameter</entry>
685 <entry align="center">Description, Action, Notes</entry>
690 <entry><smbconfoption name="create mask"/></entry>
692 Refer to the &smb.conf; man page.
696 <entry><smbconfoption name="directory mask"/></entry>
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>
702 <entry><smbconfoption name="dos filemode"/></entry>
704 Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
708 <entry><smbconfoption name="force create mode"/></entry>
710 This parameter specifies a set of UNIX-mode bit permissions that will always be set on a file created by Samba.
714 <entry><smbconfoption name="force directory mode"/></entry>
716 This parameter specifies a set of UNIX-mode bit permissions that will always be set on a directory created by Samba.
720 <entry><smbconfoption name="force directory security mode"/></entry>
722 Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory.
726 <entry><smbconfoption name="force security mode"/></entry>
728 Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
732 <entry><smbconfoption name="hide unreadable"/></entry>
734 Prevents clients from seeing the existence of files that cannot be read.
738 <entry><smbconfoption name="hide unwriteable files"/></entry>
740 Prevents clients from seeing the existence of files that cannot be written to. Unwritable directories are shown as usual.
744 <entry><smbconfoption name="nt acl support"/></entry>
746 This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT ACLs.
750 <entry><smbconfoption name="security mask"/></entry>
752 Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
762 <title>Miscellaneous Controls</title>
765 The parameter 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.
770 <table frame='all' id="mcoc"><title>Other Controls</title>
772 <colspec align="justify" colwidth="1*"/>
773 <colspec align="justify" colwidth="1*"/>
776 <entry align="center">Control Parameter</entry>
777 <entry align="center">Description, Action, Notes</entry>
783 <smbconfoption name="case sensitive"/>,
784 <smbconfoption name="default case"/>,
785 <smbconfoption name="short preserve case"/>
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.
793 <entry><smbconfoption name="csc policy"/></entry>
795 Client-side caching policy parallels MS Windows client-side file caching capabilities.
799 <entry><smbconfoption name="dont descend"/></entry>
801 Allows specifying a comma-delimited list of directories that the server should always show as empty.
805 <entry><smbconfoption name="dos filetime resolution"/></entry>
807 This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
811 <entry><smbconfoption name="dos filetimes"/></entry>
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.
818 <entry><smbconfoption name="fake oplocks"/></entry>
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.
826 <smbconfoption name="hide dot files"/>,
827 <smbconfoption name="hide files"/>,
828 <smbconfoption name="veto files"/>
831 Note: MS Windows Explorer allows override of files marked as hidden so they will still be visible.
835 <entry><smbconfoption name="read only"/></entry>
837 If this parameter is yes, then users of a service may not create or modify files in the service's directory.
841 <entry><smbconfoption name="veto files"/></entry>
843 List of files and directories that are neither visible nor accessible.
855 <title>Access Controls on Shares</title>
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).
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.
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.
894 <title>Share Permissions Management</title>
897 The best tool for share permissions management is platform-dependent. Choose the best tool for your environment.
901 <title>Windows NT4 Workstation/Server</title>
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.
914 <title>Instructions</title>
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>.
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.
931 <title>Windows 200x/XP</title>
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> system, ACLs on the share itself are set using native
939 tools, usually from File Manager. 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 permission allows "Everyone" full control on the share.
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 is located by clicking on <guimenu>Control Panel ->
950 Administrative Tools -> Computer Management</guimenu>.
954 <title>Instructions</title>
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.
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.
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.
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
994 <title>MS Windows Access Control Lists and UNIX Interoperability</title>
997 <title>Managing UNIX Permissions Using NT Security Dialogs</title>
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.
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.
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.
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
1027 <title>Viewing File Security on a Samba Share</title>
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.
1045 <title>Viewing File Ownership</title>
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:
1051 <constant>SERVER\user (Long name)</constant>
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.
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>.
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.
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.
1087 <title>Viewing File or Directory Permissions</title>
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:
1094 <para><command><replaceable>SERVER</replaceable>\
1095 <replaceable>user</replaceable>
1096 <replaceable>(Long name)</replaceable></command></para>
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>
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>.
1111 The permissions field is displayed differently for files and directories. Both are discussed next.
1115 <title>File Permissions</title>
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.
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.
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.
1144 <title>Directory Permissions</title>
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.
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.
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.
1168 <title>Modifying File or Directory Permissions</title>
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.
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.
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
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.
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.
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>.
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.
1221 <title>Interaction with the Standard Samba <quote>create mask</quote> Parameters</title>
1223 <para>There are four parameters that control interaction with the standard Samba <parameter>create mask</parameter> parameters:
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>
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>
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.
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.
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>
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>
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>
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>
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>
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:
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>
1313 <title>Interaction with the Standard Samba File Attribute Mapping</title>
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.
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
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
1347 <title>Windows NT/200X ACLs and POSIX ACLs Limitations</title>
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.
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
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
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.
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.
1388 <title>UNIX POSIX ACL Overview</title>
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:
1394 # file: testfile <- the file name
1395 # owner: jeremy <-- the file owner
1396 # group: users <-- the POSIX group owner
1397 user::rwx <-- perms for the file owner (user)
1398 user:tpot:r-x <-- perms for the additional user `tpot'
1399 group::r-- <-- perms for the file group owner (group)
1400 group:engrs:r-- <-- perms for the additonal group `engineers'
1401 mask:rwx <-- the mask that is `ANDed' with groups
1402 other::--- <-- perms applied to everyone else (other)
1404 Directory ACLs have the following signficance:
1406 # file: testdir <-- the directory name
1407 # owner: jeremy <-- the directory owner
1408 # group: jeremy <-- the POSIX group owner
1409 user::rwx <-- directory perms for owner (user)
1410 group::rwx <-- directory perms for owning group (group)
1411 mask::rwx <-- the mask that is `ANDed' with group perms
1412 other:r-x <-- perms applied to everyone else (other)
1413 default:user::rwx <-- inherited owner perms
1414 default:user:tpot:rwx <-- inherited extra perms for user `tpot'
1415 default:group::r-x <-- inherited group perms
1416 default:mask:rwx <-- inherited default mask
1417 default:other:--- <-- inherited permissions for everyone (other)
1424 <title>Mapping of Windows File ACLs to UNIX POSIX ACLs</title>
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.
1434 <table frame='all' pgwide='0' id="fdsacls"><title>How Windows File ACLs Map to UNIX POSIX File ACLs</title>
1436 <colspec align="left"/>
1437 <colspec align="center"/>
1440 <entry align="left">Windows ACE</entry>
1441 <entry align="center">File Attribute Flag</entry>
1446 <entry><para>Full Control</para></entry>
1447 <entry><para>#</para></entry>
1450 <entry><para>Traverse Folder/Execute File</para></entry>
1451 <entry><para>x</para></entry>
1454 <entry><para>List Folder/Read Data</para></entry>
1455 <entry><para>r</para></entry>
1458 <entry><para>Read Attributes</para></entry>
1459 <entry><para>r</para></entry>
1462 <entry><para>Read Extended Attribures</para></entry>
1463 <entry><para>r</para></entry>
1466 <entry><para>Create Files/Write Data</para></entry>
1467 <entry><para>w</para></entry>
1470 <entry><para>Create Folders/Append Data</para></entry>
1471 <entry><para>w</para></entry>
1474 <entry><para>Write Attributes</para></entry>
1475 <entry><para>w</para></entry>
1478 <entry><para>Write Extended Attributes</para></entry>
1479 <entry><para>w</para></entry>
1482 <entry><para>Delete Subfolders and Files</para></entry>
1483 <entry><para>w</para></entry>
1486 <entry><para>Delete</para></entry>
1487 <entry><para>#</para></entry>
1490 <entry><para>Read Permissions</para></entry>
1491 <entry><para>all</para></entry>
1494 <entry><para>Change Permissions</para></entry>
1495 <entry><para>#</para></entry>
1498 <entry><para>Take Ownership</para></entry>
1499 <entry><para>#</para></entry>
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.
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.
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.
1527 <title>Mapping of Windows Directory ACLs to UNIX POSIX ACLs</title>
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.
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.
1547 <title>Common Errors</title>
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.
1556 <title>Users Cannot Write to a Public Share</title>
1559 The following complaint has frequently been voiced on the Samba mailing list:
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.
1570 Here is one way the problem can be solved:
1576 Go to the top of the directory that is shared.
1582 Set the ownership to whatever public user and group you want
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 {}\;
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.
1600 Directory is <replaceable>/foodbar</replaceable>:
1602 &prompt;<userinput>chown jack:engr /foodbar</userinput>
1607 <para>This is the same as doing:</para>
1609 &prompt;<userinput>chown jack /foodbar</userinput>
1610 &prompt;<userinput>chgrp engr /foodbar</userinput>
1618 &prompt;<userinput>chmod 2775 /foodbar</userinput>
1619 &prompt;<userinput>ls -al /foodbar/..</userinput>
1623 <para>You should see:
1625 drwxrwsr-x 2 jack engr 48 2003-02-04 09:55 foodbar
1633 &prompt;<userinput>su - jill</userinput>
1634 &prompt;<userinput>cd /foodbar</userinput>
1635 &prompt;<userinput>touch Afile</userinput>
1636 &prompt;<userinput>ls -al</userinput>
1641 You should see that the file <filename>Afile</filename> created by Jill will have ownership
1642 and permissions of Jack, as follows:
1644 -rw-r--r-- 1 jill engr 0 2007-01-18 19:41 Afile
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:
1654 <smbconfoption name="force group">engr</smbconfoption>
1663 <title>File Operations Done as <emphasis>root</emphasis> with <emphasis>force user</emphasis> Set</title>
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.
1672 <title>MS Word with Samba Changes Owner of File</title>
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>
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.
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:
1696 <smbconfoption name="force create mode">0660</smbconfoption>
1697 <smbconfoption name="force directory mode">0770</smbconfoption>
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.