1 <chapter id="AccessControls">
5 <pubdate>May 10, 2003</pubdate>
7 <title>File, Directory and Share Access Controls</title>
10 Advanced MS Windows users are frequently perplexed when file, directory and share manipulation of
11 resources shared via Samba do not behave in the manner they might expect. MS Windows network
12 administrators are often confused regarding network access controls and what is the best way to
13 provide users with the type of access they need while protecting resources from the consequences
14 of untoward access capabilities.
18 Unix administrators frequently are not familiar with the MS Windows environment and in particular
19 have difficulty in visualizing what the MS Windows user wishes to achieve in attempts to set file
20 and directory access permissions.
24 The problem lies in the differences in how file and directory permissions and controls work
25 between the two environments. This difference is one that Samba can not completely hide, even
26 though it does try to make the chasm transparent.
30 POSIX Access Control List technology has been available (along with Extended Attributes)
31 for Unix for many years, yet there is little evidence today of any significant use. This
32 explains to some extent the slow adoption of ACLs into commercial Linux products. MS Windows
33 administrators are astounded at this given that ACLs were a foundational capability of the now
34 decade old MS Windows NT operating system.
38 The purpose of this chapter is to present each of the points of control that are possible with
39 Samba-3 in the hope that this will help the network administrator to find the optimum method
40 for delivering the best environment for MS Windows desktop users.
44 This is an opportune point to mention that it should be borne in mind that Samba was created to
45 provide a means of interoperability and interchange of data between two operating environments
46 that are quite different. It was never the intent to make Unix/Linux like MS Windows NT. Instead
47 the purpose was an is to provide a sufficient level of exchange of data between the two environments.
48 What is available today extends well beyond early plans and expectations, yet the gap continues to
53 <title>Features and Benefits</title>
56 Samba offers a lot of flexibility in file system access management. These are the key access control
57 facilities present in Samba today:
61 <title>Samba Access Control Facilities</title>
63 <emphasis>Unix File and Directory Permissions</emphasis>
67 Samba honours and implements Unix file system access controls. Users
68 who access a Samba server will do so as a particular MS Windows user.
69 This information is passed to the Samba server as part of the logon or
70 connection setup process. Samba uses this user identity to validate
71 whether or not the user should be given access to file system resources
72 (files and directories). This chapter provides an overview for those
73 to whom the Unix permissions and controls are a little strange or unknown.
78 <emphasis>Samba Share Definitions</emphasis>
82 In configuring share settings and controls in the &smb.conf; file
83 the network administrator can exercise over-rides to native file
84 system permissions and behaviours. This can be handy and convenient
85 to affect behaviour that is more like what MS Windows NT users expect
86 but it is seldom the <emphasis>best</emphasis> way to achieve this.
87 The basic options and techniques are described herein.
92 <emphasis>Samba Share ACLs</emphasis>
96 Just like it is possible in MS Windows NT to set ACLs on shares
97 themselves, so it is possible to do this in Samba.
98 Very few people make use of this facility, yet it remains on of the
99 easiest ways to affect access controls (restrictions) and can often
100 do so with minimum invasiveness compared with other methods.
105 <emphasis>MS Windows ACLs through Unix POSIX ACLs</emphasis>
109 The use of POSIX ACLs on Unix/Linux is possible ONLY if the underlying
110 operating system supports them. If not, then this option will not be
111 available to you. Current Unix technology platforms have native support
112 for POSIX ACLs. There are patches for the Linux kernel that provide
113 this also. Sadly, few Linux platforms ship today with native ACLs and
114 Extended Attributes enabled. This chapter has pertinent information
115 for users of platforms that support them.
123 <title>File System Access Controls</title>
126 Perhaps the most important recognition to be made is the simple fact that MS Windows NT4 / 200x / XP
127 implement a totally divergent file system technology from what is provided in the Unix operating system
128 environment. Firstly we should consider what the most significant differences are, then we shall look
129 at how Samba helps to bridge the differences.
133 <title>MS Windows NTFS Comparison with Unix File Systems</title>
136 Samba operates on top of the Unix file system. This means it is subject to Unix file system conventions
137 and permissions. It also means that if the MS Windows networking environment requires file system
138 behaviour that differs from unix file system behaviour then somehow Samba is responsible for emulating
139 that in a transparent and consistent manner.
143 It is good news that Samba does this to a very large extent and on top of that provides a high degree
144 of optional configuration to over-ride the default behaviour. We will look at some of these over-rides,
145 but for the greater part we will stay within the bounds of default behaviour. Those wishing to explore
146 to depths of control ability should review the &smb.conf; man page.
150 <title>File System Feature Comparison</title>
152 <term>Name Space</term>
155 MS Windows NT4 / 200x/ XP files names may be up to 254 characters long, Unix file names
156 may be 1023 characters long. In MS Windows file extensions indicate particular file types,
157 in Unix this is not so rigorously observed as all names are considered arbitrary.
160 What MS Windows calls a Folder, Unix calls a directory,
166 <term>Case Sensitivity</term>
169 MS Windows file names are generally Upper Case if made up of 8.3 (ie: 8 character file name
170 and 3 character extension. If longer than 8.3 file names are Case Preserving, and Case
174 Unix file and directory names are Case Sensitive and Case Preserving. Samba implements the
175 MS Windows file name behaviour, but it does so as a user application. The Unix file system
176 provides no mechanism to perform case insensitive file name lookups. MS Windows does this
177 by default. This means that Samba has to carry the processing overhead to provide features
178 that are NOT native to the Unix operating system environment.
181 Consider the following, all are unique Unix names but one single MS Windows file name:
187 So clearly, In an MS Windows file name space these three files CAN NOT co-exist! But in Unix
188 they can. So what should Samba do if all three are present? Answer, the one that is lexically
189 first will be accessible to MS Windows users, the others are invisible and unaccessible - any
190 other solution would be suicidal.
196 <term>Directory Separators</term>
199 MS Windows and DOS uses the back-slash '\' as a directory delimiter, Unix uses the forward-slash '/'
200 as it's directory delimiter. This is transparently handled by Samba.
206 <term>Drive Identification</term>
209 MS Windows products support a notion of drive letters, like <command>C:</command> to represent
210 disk partitions. Unix has NO concept if separate identifiers for file partitions since each
211 such file system is <filename>mounted</filename> to become part of the over-all directory tree.
212 The Unix directory tree begins at '/', just like the root of a DOS drive is specified like
213 <command>C:\</command>.
219 <term>File Naming Conventions</term>
222 MS Windows generally never experiences file names that begin with a '.', while in Unix these
223 are commonly found in a user's home directory. Files that begin with a '.' are typically
224 either start up files for various Unix applications, or they may be files that contain
225 start-up configuration data.
231 <term>Links and Short-Cuts</term>
234 MS Windows make use of "links and Short-Cuts" that are actually special types of files that will
235 redirect an attempt to execute the file to the real location of the file. Unix knows of file and directory
236 links, but they are entirely different from what MS Windows users are used to.
239 Symbolic links are files in Unix that contain the actual location of the data (file OR directory). An
240 operation (like read or write) will operate directly on the file referenced. Symbolic links are also
241 referred to as 'soft links'. A hard link is something that MS Windows is NOT familiar with. It allows
242 one physical file to be known simultaneously by more than one file name.
249 There are many other subtle differences that may cause the MS Windows administrator some temporary discomfort
250 in the process of becoming familiar with Unix/Linux. These are best left for a text that is dedicated to the
251 purpose of Unix/Linux training/education.
257 <title>Managing Directories</title>
260 There are three basic operations for managing directories, <command>create, delete, rename</command>.
262 <title>Managing directories with unix and windows</title>
263 <tgroup align="center" cols="3">
265 <row><entry>Action</entry><entry>MS Windows Command</entry><entry>Unix Command</entry></row>
269 <row><entry>create</entry><entry>md folder</entry><entry>mkdir folder</entry></row>
270 <row><entry>delete</entry><entry>rd folder</entry><entry>rmdir folder</entry></row>
271 <row><entry>rename</entry><entry>rename oldname newname</entry><entry>mv oldname newname</entry></row>
280 <title>File and Directory Access Control</title>
283 The network administrator is strongly advised to read foundational training manuals and reference materials
284 regarding file and directory permissions maintenance. Much can be achieved with the basic Unix permissions
285 without having to resort to more complex facilities like POSIX Access Control Lists (ACLs) or Extended
290 Unix/Linux file and directory access permissions involves setting three (3) primary sets of data and one (1) control set.
291 A Unix file listing looks as follows:-
294 <prompt>jht@frodo:~/stuff> </prompt><userinput>ls -la</userinput>
296 drwxr-xr-x 13 jht users 816 2003-05-12 22:56 .
297 drwxr-xr-x 37 jht users 3800 2003-05-12 22:29 ..
298 d--------- 2 jht users 48 2003-05-12 22:29 muchado00
299 d--x--x--x 2 jht users 48 2003-05-12 22:29 muchado01
300 dr-xr-xr-x 2 jht users 48 2003-05-12 22:29 muchado02
301 drwxrwxrwx 2 jht users 48 2003-05-12 22:29 muchado03
302 drw-rw-rw- 2 jht users 48 2003-05-12 22:29 muchado04
303 d-w--w--w- 2 jht users 48 2003-05-12 22:29 muchado05
304 dr--r--r-- 2 jht users 48 2003-05-12 22:29 muchado06
305 drwxrwxrwt 2 jht users 48 2003-05-12 22:29 muchado07
306 drwsrwsrwx 2 jht users 48 2003-05-12 22:29 muchado08
307 ---------- 1 jht users 1242 2003-05-12 22:31 mydata00.lst
308 ---x--x--x 1 jht users 1674 2003-05-12 22:33 mydata01.lst
309 --w--w--w- 1 jht users 7754 2003-05-12 22:33 mydata02.lst
310 --wx-wx-wx 1 jht users 260179 2003-05-12 22:33 mydata03.lst
311 -r--r--r-- 1 jht users 21017 2003-05-12 22:32 mydata04.lst
312 -r-xr-xr-x 1 jht users 206339 2003-05-12 22:32 mydata05.lst
313 -rw-rw-rw- 1 jht users 41105 2003-05-12 22:32 mydata06.lst
314 -rwxrwxrwx 1 jht users 19312 2003-05-12 22:32 mydata07.lst
315 <prompt>jht@frodo:~/stuff></prompt>
320 The columns above represent (from left to right): permissions, no blocks used, owner, group, size (bytes), access date, access time, file name.
324 The permissions field is made up of:
327 <comment> JRV: Put this into a diagram of some sort</comment>
328 [ type ] [ users ] [ group ] [ others ] [File, Directory Permissions]
329 [ d | l ] [ r w x ] [ r w x ] [ r w x ]
330 | | | | | | | | | | |
331 | | | | | | | | | | |-----> Can Execute, List files
332 | | | | | | | | | |-------> Can Write, Create files
333 | | | | | | | | |---------> Can Read, Read files
334 | | | | | | | |---------------> Can Execute, List files
335 | | | | | | |-----------------> Can Write, Create files
336 | | | | | |-------------------> Can Read, Read files
337 | | | | |-------------------------> Can Execute, List files
338 | | | |---------------------------> Can Write, Create files
339 | | |-----------------------------> Can Read, Read files
340 | |-----------------------------------> Is a symbolic Link
341 |---------------------------------------> Is a directory
346 Any bit flag may be unset. An unset bit flag is the equivalent of 'Can NOT' and is represented as a '-' character.
349 <title>Example File</title>
351 -rwxr-x--- Means: The owner (user) can read, write, execute
352 the group can read and execute
353 everyone else can NOT do anything with it
360 Additional possibilities in the [type] field are: c = character device, b = block device, p = pipe device, s = Unix Domain Socket.
364 The letters `rwxXst' set permissions for the user, group and others as: read (r), write (w), execute (or access for directories) (x),
365 execute only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s),
370 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.
371 Without the sticky bit, anyone able to write to the directory can delete or rename files. The sticky bit is commonly found on
372 directories, such as /tmp, that are world-writable.
376 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
377 group whose 'set user or group' bit is set. This can be very helpful in setting up directories that for which it is desired that
378 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
379 to be exclusively owned by a user who's primary group is not the group that all such users belong to.
383 When a directory is set <constant>drw-r-----</constant> this means that the owner can read and create (write) files in it, but because
384 the (x) execute flags are not set files can not be listed (seen) in the directory by anyone. The group can read files in the
385 directory but can NOT create new files. NOTE: If files in the directory are set to be readable and writable for the group, then
386 group members will be able to write to (or delete) them.
394 <title>Share Definition Access Controls</title>
397 The following parameters in the &smb.conf; file sections that define a share control or affect access controls.
398 Before using any of the following options please refer to the man page for &smb.conf;.
402 <title>User and Group Based Controls</title>
405 User and group based controls can prove very useful. In some situations it is distinctly desirable to affect all
406 file system operations as if a single user is doing this, the use of the <parameter>force user</parameter> and
407 <parameter>force group</parameter> behaviour will achieve this. In other situations it may be necessary to affect a
408 paranoia level of control to ensure that only particular authorised persons will be able to access a share or
409 it's contents, here the use of the <parameter>valid users</parameter> or the <parameter>invalid users</parameter> may
414 As always, it is highly advisable to use the least difficult to maintain and the least ambiguous method for
415 controlling access. Remember, that when you leave the scene someone else will need to provide assistance and
416 if that person finds too great a mess, or if they do not understand what you have done then there is risk of
417 Samba being removed and an alternative solution being adopted.
420 <table frame='all'><title>User and Group Based Controls</title>
424 <entry align="center">Control Parameter</entry>
425 <entry align="center">Description - Action - Notes</entry>
430 <entry>admin users</entry>
432 List of users who will be granted administrative privileges on the share.
433 They will do all file operations as the super-user (root).
434 Any user in this list will be able to do anything they like on the share,
435 irrespective of file permissions.
439 <entry>force group</entry>
441 Specifies a UNIX group name that will be assigned as the default primary group
442 for all users connecting to this service.
446 <entry>force user</entry>
448 Specifies a UNIX user name that will be assigned as the default user for all users connecting to this service.
449 This is useful for sharing files. Incorrect use can cause security problems.
453 <entry>guest ok</entry>
455 If this parameter is set for a service, then no password is required to connect to the service. Privileges will be
456 those of the guest account.
460 <entry>invalid users</entry>
462 List of users that should not be allowed to login to this service.
466 <entry>only user</entry>
468 Controls whether connections with usernames not in the user list will be allowed.
472 <entry>read list</entry>
474 List of users that are given read-only access to a service. Users in this list
475 will not be given write access, no matter what the read only option is set to.
479 <entry>username</entry>
481 Refer to the &smb.conf; man page for more information - this is a complex and potentially misused parameter.
485 <entry>valid users</entry>
487 List of users that should be allowed to login to this service.
491 <entry>write list</entry>
493 List of users that are given read-write access to a service.
503 <title>File and Directory Permissions Based Controls</title>
506 The following file and directory permission based controls, if misused, can result in considerable difficulty to
507 diagnose the cause of mis-configuration. Use them sparingly and carefully. By gradually introducing each one by one
508 undesirable side-effects may be detected. In the event of a problem, always comment all of them out and then gradually
509 re-introduce them in a controlled fashion.
512 <table frame='all'><title>File and Directory Permission Based Controls</title>
516 <entry align="center">Control Parameter</entry>
517 <entry align="center">Description - Action - Notes</entry>
522 <entry>create mask</entry>
524 Refer to the &smb.conf; man page.
528 <entry>directory mask</entry>
530 The octal modes used when converting DOS modes to UNIX modes when creating UNIX directories.
531 See also: directory security mask.
532 </para></entry></row>
534 <entry>dos filemode</entry>
536 Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
540 <entry>force create mode</entry>
542 This parameter specifies a set of UNIX mode bit permissions that will always be set on a file created by Samba.
546 <entry>force directory mode</entry>
548 This parameter specifies a set of UNIX mode bit permissions that will always be set on a directory created by Samba.
552 <entry>force directory security mode</entry>
554 Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory
558 <entry>force security mode</entry>
560 Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
564 <entry>hide unreadable</entry>
566 Prevents clients from seeing the existence of files that cannot be read.
570 <entry>hide unwriteable files</entry>
572 Prevents clients from seeing the existence of files that cannot be written to. Unwriteable directories are shown as usual.
576 <entry>nt acl support</entry>
578 This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT access control lists.
582 <entry>security mask</entry>
584 Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
594 <title>Miscellaneous Controls</title>
597 The following are documented because of the prevalence of administrators creating inadvertant barriers to file
598 access by not understanding the full implications of &smb.conf; file settings.
601 <table frame='all'><title>Other Controls</title>
605 <entry align="center">Control Parameter</entry>
606 <entry align="center">Description - Action - Notes</entry>
611 <entry>case sensitive, default case, short preserve case</entry>
613 This means that all file name lookup will be done in a case sensitive manner.
614 Files will be created with the precise filename Samba received from the MS Windows client.
618 <entry>csc policy</entry>
620 Client Side Caching Policy - parallels MS Windows client side file caching capabilities.
624 <entry>dont descend</entry>
626 Allows to specify a comma-delimited list of directories that the server should always show as empty.
630 <entry>dos filetime resolution</entry>
632 This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
636 <entry>dos filetimes</entry>
638 DOS and Windows allows users to change file time stamps if they can write to the file. POSIX semantics prevent this.
639 This options allows DOS and Windows behaviour.
643 <entry>fake oplocks</entry>
645 Oplocks are the way that SMB clients get permission from a server to locally cache file operations. If a server grants an
646 oplock then the client is free to assume that it is the only one accessing the file and it will aggressively cache file data.
650 <entry>hide dot files, hide files, veto files</entry>
652 Note: MS Windows Explorer allows over-ride of files marked as hidden so they will still be visible.
656 <entry>read only</entry>
658 If this parameter is yes, then users of a service may not create or modify files in the service's directory.
662 <entry>veto files</entry>
664 List of files and directories that are neither visible nor accessible.
676 <title>Access Controls on Shares</title>
679 This section deals with how to configure Samba per share access control restrictions.
680 By default, Samba sets no restrictions on the share itself. Restrictions on the share itself
681 can be set on MS Windows NT4/200x/XP shares. This can be a very effective way to limit who can
682 connect to a share. In the absence of specific restrictions the default setting is to allow
683 the global user <constant>Everyone</constant> Full Control (ie: Full control, Change and Read).
687 At this time Samba does NOT provide a tool for configuring access control setting on the Share
688 itself. Samba does have the capacity to store and act on access control settings, but the only
689 way to create those settings is to use either the NT4 Server Manager or the Windows 200x MMC for
694 Samba stores the per share access control settings in a file called <filename>share_info.tdb</filename>.
695 The location of this file on your system will depend on how samba was compiled. The default location
696 for Samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
697 utility has been compiled and installed on your system, then you can examine the contents of this file
698 by: <userinput>tdbdump share_info.tdb</userinput>.
702 <title>Share Permissions Management</title>
705 The best tool for the task is platform dependant. Choose the best tool for your environment.
709 <title>Windows NT4 Workstation/Server</title>
711 The tool you need to use to manage share permissions on a Samba server is the NT Server Manager.
712 Server Manager is shipped with Windows NT4 Server products but not with Windows NT4 Workstation.
713 You can obtain the NT Server Manager for MS Windows NT4 Workstation from Microsoft - see details below.
717 <title>Instructions</title>
719 Launch the <application>NT4 Server Manager</application>, click on the Samba server you want to administer, then from the menu
720 select <guimenu>Computer</guimenu>, then click on the <guimenuitem>Shared Directories</guimenuitem> entry.
724 Now click on the share that you wish to manage, then click on the <guilabel>Properties</guilabel> tab, next click on
725 the <guilabel>Permissions</guilabel> tab. Now you can add or change access control settings as you wish.
732 <title>Windows 200x/XP</title>
735 On <application>MS Windows NT4/200x/XP</application> system access control lists on the share itself are set using native
736 tools, usually from filemanager. For example, in Windows 200x: right click on the shared folder,
737 then select <guimenuitem>Sharing</guimenuitem>, then click on <guilabel>Permissions</guilabel>. The default
738 Windows NT4/200x permission allows <emphasis>Everyone</emphasis> Full Control on the Share.
742 MS Windows 200x and later all comes with a tool called the <application>Computer Management</application> snap-in for the
743 Microsoft Management Console (MMC). This tool is located by clicking on <filename>Control Panel ->
744 Administrative Tools -> Computer Management</filename>.
748 <title>Instructions</title>
750 After launching the MMC with the Computer Management snap-in, click on the menu item <guimenuitem>Action</guimenuitem>,
751 select <guilabel>Connect to another computer</guilabel>. If you are not logged onto a domain you will be prompted
752 to enter a domain login user identifier and a password. This will authenticate you to the domain.
753 If you where already logged in with administrative privilege this step is not offered.
757 If the Samba server is not shown in the <guilabel>Select Computer</guilabel> box, then type in the name of the target
758 Samba server in the field <guilabel>Name:</guilabel>. Now click on the <guibutton>[+]</guibutton> next to
759 <guilabel>System Tools</guilabel>, then on the <guibutton>[+]</guibutton> next to <guilabel>Shared Folders</guilabel> in the
764 Now in the right panel, double-click on the share you wish to set access control permissions on.
765 Then click on the tab <guilabel>Share Permissions</guilabel>. It is now possible to add access control entities
766 to the shared folder. Do NOT forget to set what type of access (full control, change, read) you
767 wish to assign for each entry.
773 Be careful. If you take away all permissions from the <constant>Everyone</constant> user without removing this user
774 then effectively no user will be able to access the share. This is a result of what is known as
775 ACL precedence. ie: Everyone with <emphasis>no access</emphasis> means that MaryK who is part of the group
776 <constant>Everyone</constant> will have no access even if this user is given explicit full control access.
786 <title>MS Windows Access Control Lists and Unix Interoperability</title>
789 <title>Managing UNIX permissions Using NT Security Dialogs</title>
791 <para>Windows NT clients can use their native security settings
792 dialog box to view and modify the underlying UNIX permissions.</para>
794 <para>Note that this ability is careful not to compromise
795 the security of the UNIX host Samba is running on, and
796 still obeys all the file permission rules that a Samba
797 administrator can set.</para>
801 All access to Unix/Linux system file via Samba is controlled at
802 the operating system file access control level. When trying to
803 figure out file access problems it is vitally important to identify
804 the identity of the Windows user as it is presented by Samba at
805 the point of file access. This can best be determined from the
812 <title>Viewing File Security on a Samba Share</title>
814 <para>From an NT4/2000/XP client, single-click with the right
815 mouse button on any file or directory in a Samba mounted
816 drive letter or UNC path. When the menu pops-up, click
817 on the <guilabel>Properties</guilabel> entry at the bottom of
818 the menu. This brings up the file properties dialog
819 box. Click on the tab <guilabel>Security</guilabel> and you
820 will see three buttons, <guibutton>Permissions</guibutton>,
821 <guibutton>Auditing</guibutton>, and <guibutton>Ownership</guibutton>.
822 The <guibutton>Auditing</guibutton> button will cause either
823 an error message <errorname>A requested privilege is not held
824 by the client</errorname> to appear if the user is not the
825 NT Administrator, or a dialog which is intended to allow an
826 Administrator to add auditing requirements to a file if the
827 user is logged on as the NT Administrator. This dialog is
828 non-functional with a Samba share at this time, as the only
829 useful button, the <guibutton>Add</guibutton> button will not currently
830 allow a list of users to be seen.</para>
835 <title>Viewing file ownership</title>
837 <para>Clicking on the <guibutton>Ownership</guibutton> button
838 brings up a dialog box telling you who owns the given file. The
839 owner name will be of the form :</para>
841 <para><command>"SERVER\user (Long name)"</command></para>
843 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
844 the Samba server, <replaceable>user</replaceable> is the user name of
845 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
846 is the descriptive string identifying the user (normally found in the
847 GECOS field of the UNIX password database). Click on the
848 <guibutton>Close </guibutton> button to remove this dialog.</para>
850 <para>If the parameter <parameter>nt acl support</parameter>
851 is set to <constant>false</constant> then the file owner will
852 be shown as the NT user <constant>"Everyone"</constant>.</para>
854 <para>The <guibutton>Take Ownership</guibutton> button will not allow
855 you to change the ownership of this file to yourself (clicking on
856 it will display a dialog box complaining that the user you are
857 currently logged onto the NT client cannot be found). The reason
858 for this is that changing the ownership of a file is a privileged
859 operation in UNIX, available only to the <emphasis>root</emphasis>
860 user. As clicking on this button causes NT to attempt to change
861 the ownership of a file to the current user logged into the NT
862 client this will not work with Samba at this time.</para>
864 <para>There is an NT chown command that will work with Samba
865 and allow a user with Administrator privilege connected
866 to a Samba server as root to change the ownership of
867 files on both a local NTFS filesystem or remote mounted NTFS
868 or Samba drive. This is available as part of the <application>Seclib
869 </application> NT security library written by Jeremy Allison of
870 the Samba Team, available from the main Samba ftp site.</para>
875 <title>Viewing File or Directory Permissions</title>
877 <para>The third button is the <guibutton>Permissions</guibutton>
878 button. Clicking on this brings up a dialog box that shows both
879 the permissions and the UNIX owner of the file or directory.
880 The owner is displayed in the form :</para>
882 <para><command>"<replaceable>SERVER</replaceable>\
883 <replaceable>user</replaceable>
884 <replaceable>(Long name)</replaceable>"</command></para>
886 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
887 the Samba server, <replaceable>user</replaceable> is the user name of
888 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
889 is the descriptive string identifying the user (normally found in the
890 GECOS field of the UNIX password database).</para>
892 <para>If the parameter <parameter>nt acl support</parameter>
893 is set to <constant>false</constant> then the file owner will
894 be shown as the NT user <constant>"Everyone"</constant> and the
895 permissions will be shown as NT "Full Control".</para>
898 <para>The permissions field is displayed differently for files
899 and directories, so I'll describe the way file permissions
900 are displayed first.</para>
903 <title>File Permissions</title>
905 <para>The standard UNIX user/group/world triplet and
906 the corresponding "read", "write", "execute" permissions
907 triplets are mapped by Samba into a three element NT ACL
908 with the 'r', 'w', and 'x' bits mapped into the corresponding
909 NT permissions. The UNIX world permissions are mapped into
910 the global NT group <constant>Everyone</constant>, followed
911 by the list of permissions allowed for UNIX world. The UNIX
912 owner and group permissions are displayed as an NT
913 <guiicon>user</guiicon> icon and an NT <guiicon>local
914 group</guiicon> icon respectively followed by the list
915 of permissions allowed for the UNIX user and group.</para>
917 <para>As many UNIX permission sets don't map into common
918 NT names such as <constant>read</constant>, <constant>
919 "change"</constant> or <constant>full control</constant> then
920 usually the permissions will be prefixed by the words <constant>
921 "Special Access"</constant> in the NT display list.</para>
923 <para>But what happens if the file has no permissions allowed
924 for a particular UNIX user group or world component ? In order
925 to allow "no permissions" to be seen and modified then Samba
926 overloads the NT <command>"Take Ownership"</command> ACL attribute
927 (which has no meaning in UNIX) and reports a component with
928 no permissions as having the NT <command>"O"</command> bit set.
929 This was chosen of course to make it look like a zero, meaning
930 zero permissions. More details on the decision behind this will
931 be given below.</para>
935 <title>Directory Permissions</title>
937 <para>Directories on an NT NTFS file system have two
938 different sets of permissions. The first set of permissions
939 is the ACL set on the directory itself, this is usually displayed
940 in the first set of parentheses in the normal <constant>"RW"</constant>
941 NT style. This first set of permissions is created by Samba in
942 exactly the same way as normal file permissions are, described
943 above, and is displayed in the same way.</para>
945 <para>The second set of directory permissions has no real meaning
946 in the UNIX permissions world and represents the <constant>
947 inherited</constant> permissions that any file created within
948 this directory would inherit.</para>
950 <para>Samba synthesises these inherited permissions for NT by
951 returning as an NT ACL the UNIX permission mode that a new file
952 created by Samba on this share would receive.</para>
957 <title>Modifying file or directory permissions</title>
959 <para>Modifying file and directory permissions is as simple
960 as changing the displayed permissions in the dialog box, and
961 clicking the <guibutton>OK</guibutton> button. However, there are
962 limitations that a user needs to be aware of, and also interactions
963 with the standard Samba permission masks and mapping of DOS
964 attributes that need to also be taken into account.</para>
966 <para>If the parameter <parameter>nt acl support</parameter>
967 is set to <constant>false</constant> then any attempt to set
968 security permissions will fail with an <errorname>"Access Denied"
969 </errorname> message.</para>
971 <para>The first thing to note is that the <guibutton>"Add"</guibutton>
972 button will not return a list of users in Samba (it will give
973 an error message of <errorname>The remote procedure call failed
974 and did not execute</errorname>). This means that you can only
975 manipulate the current user/group/world permissions listed in
976 the dialog box. This actually works quite well as these are the
977 only permissions that UNIX actually has.</para>
979 <para>If a permission triplet (either user, group, or world)
980 is removed from the list of permissions in the NT dialog box,
981 then when the <guibutton>OK</guibutton> button is pressed it will
982 be applied as "no permissions" on the UNIX side. If you then
983 view the permissions again the "no permissions" entry will appear
984 as the NT <command>"O"</command> flag, as described above. This
985 allows you to add permissions back to a file or directory once
986 you have removed them from a triplet component.</para>
988 <para>As UNIX supports only the "r", "w" and "x" bits of
989 an NT ACL then if other NT security attributes such as "Delete
990 access" are selected then they will be ignored when applied on
991 the Samba server.</para>
993 <para>When setting permissions on a directory the second
994 set of permissions (in the second set of parentheses) is
995 by default applied to all files within that directory. If this
996 is not what you want you must uncheck the <guilabel>Replace
997 permissions on existing files</guilabel> checkbox in the NT
998 dialog before clicking <guibutton>OK</guibutton>.</para>
1000 <para>If you wish to remove all permissions from a
1001 user/group/world component then you may either highlight the
1002 component and click the <guibutton>Remove</guibutton> button,
1003 or set the component to only have the special <constant>Take
1004 Ownership</constant> permission (displayed as <command>"O"
1005 </command>) highlighted.</para>
1009 <title>Interaction with the standard Samba create mask
1012 <para>There are four parameters
1013 to control interaction with the standard Samba create mask parameters.
1017 <member><parameter>security mask</parameter></member>
1018 <member><parameter>force security mode</parameter></member>
1019 <member><parameter>directory security mask</parameter></member>
1020 <member><parameter>force directory security mode</parameter></member>
1025 <para>Once a user clicks <guibutton>OK</guibutton> to apply the
1026 permissions Samba maps the given permissions into a user/group/world
1027 r/w/x triplet set, and then will check the changed permissions for a
1028 file against the bits set in the <ulink url="smb.conf.5.html#SECURITYMASK">
1029 <parameter>security mask</parameter></ulink> parameter. Any bits that
1030 were changed that are not set to '1' in this parameter are left alone
1031 in the file permissions.</para>
1033 <para>Essentially, zero bits in the <parameter>security mask</parameter>
1034 mask may be treated as a set of bits the user is <emphasis>not</emphasis>
1035 allowed to change, and one bits are those the user is allowed to change.
1038 <para>If not set explicitly this parameter is set to the same value as
1039 the <ulink url="smb.conf.5.html#CREATEMASK"><parameter>create mask
1040 </parameter></ulink> parameter. To allow a user to modify all the
1041 user/group/world permissions on a file, set this parameter
1044 <para>Next Samba checks the changed permissions for a file against
1045 the bits set in the <ulink url="smb.conf.5.html#FORCESECURITYMODE">
1046 <parameter>force security mode</parameter></ulink> parameter. Any bits
1047 that were changed that correspond to bits set to '1' in this parameter
1048 are forced to be set.</para>
1050 <para>Essentially, bits set in the <parameter>force security mode
1051 </parameter> parameter may be treated as a set of bits that, when
1052 modifying security on a file, the user has always set to be 'on'.</para>
1054 <para>If not set explicitly this parameter is set to the same value
1055 as the <ulink url="smb.conf.5.html#FORCECREATEMODE"><parameter>force
1056 create mode</parameter></ulink> parameter.
1057 To allow a user to modify all the user/group/world permissions on a file
1058 with no restrictions set this parameter to 000.</para>
1060 <para>The <parameter>security mask</parameter> and <parameter>force
1061 security mode</parameter> parameters are applied to the change
1062 request in that order.</para>
1064 <para>For a directory Samba will perform the same operations as
1065 described above for a file except using the parameter <parameter>
1066 directory security mask</parameter> instead of <parameter>security
1067 mask</parameter>, and <parameter>force directory security mode
1068 </parameter> parameter instead of <parameter>force security mode
1069 </parameter>.</para>
1071 <para>The <parameter>directory security mask</parameter> parameter
1072 by default is set to the same value as the <parameter>directory mask
1073 </parameter> parameter and the <parameter>force directory security
1074 mode</parameter> parameter by default is set to the same value as
1075 the <parameter>force directory mode</parameter> parameter. </para>
1077 <para>In this way Samba enforces the permission restrictions that
1078 an administrator can set on a Samba share, whilst still allowing users
1079 to modify the permission bits within that restriction.</para>
1081 <para>If you want to set up a share that allows users full control
1082 in modifying the permission bits on their files and directories and
1083 doesn't force any particular bits to be set 'on', then set the following
1084 parameters in the &smb.conf; file in that share specific section :
1088 <member><parameter>security mask = 0777</parameter></member>
1089 <member><parameter>force security mode = 0</parameter></member>
1090 <member><parameter>directory security mask = 0777</parameter></member>
1091 <member><parameter>force directory security mode = 0</parameter></member>
1096 <title>Interaction with the standard Samba file attribute
1099 <para>Samba maps some of the DOS attribute bits (such as "read
1100 only") into the UNIX permissions of a file. This means there can
1101 be a conflict between the permission bits set via the security
1102 dialog and the permission bits set by the file attribute mapping.
1105 <para>One way this can show up is if a file has no UNIX read access
1106 for the owner it will show up as "read only" in the standard
1107 file attributes tabbed dialog. Unfortunately this dialog is
1108 the same one that contains the security info in another tab.</para>
1110 <para>What this can mean is that if the owner changes the permissions
1111 to allow themselves read access using the security dialog, clicks
1112 <guibutton>OK</guibutton> to get back to the standard attributes tab
1113 dialog, and then clicks <guibutton>OK</guibutton> on that dialog, then
1114 NT will set the file permissions back to read-only (as that is what
1115 the attributes still say in the dialog). This means that after setting
1116 permissions and clicking <guibutton>OK</guibutton> to get back to the
1117 attributes dialog you should always hit <guibutton>Cancel</guibutton>
1118 rather than <guibutton>OK</guibutton> to ensure that your changes
1119 are not overridden.</para>
1124 <title>Common Errors</title>
1127 File, Directory and Share access problems are very common on the mailing list. The following
1128 are examples taken from the mailing list in recent times.
1133 <title>Users can not write to a public share</title>
1137 We are facing some troubles with file / directory permissions. I can log on the domain as admin user(root),
1138 and there's a public share, on which everyone needs to have permission to create / modify files, but only
1139 root can change the file, no one else can. We need to constantly go to server to
1140 <userinput>chgrp -R users *</userinput> and <userinput>chown -R nobody *</userinput> to allow others users to change the file.
1145 There are many ways to solve this problem, here are a few hints:
1149 <title>Example Solution:</title>
1152 Go to the top of the directory that is shared
1158 Set the ownership to what ever public owner and group you want
1160 find 'directory_name' -type d -exec chown user.group {}\;
1161 find 'directory_name' -type d -exec chmod 6775 'directory_name'
1162 find 'directory_name' -type f -exec chmod 0775 {} \;
1163 find 'directory_name' -type f -exec chown user.group {}\;
1168 The above will set the 'sticky bit' on all directories. Read your
1169 Unix/Linux man page on what that does. It causes the OS to assign
1170 to all files created in the directories the ownership of the
1177 Directory is: <replaceable>/foodbar</replaceable>
1179 <prompt>$ </prompt><userinput>chown jack.engr /foodbar</userinput>
1184 <para>This is the same as doing:</para>
1186 <prompt>$ </prompt><userinput>chown jack /foodbar</userinput>
1187 <prompt>$ </prompt><userinput>chgrp engr /foodbar</userinput>
1195 <prompt>$ </prompt><userinput>chmod 6775 /foodbar</userinput>
1196 <prompt>$ </prompt><userinput>ls -al /foodbar/..</userinput>
1201 <para>You should see:
1203 drwsrwsr-x 2 jack engr 48 2003-02-04 09:55 foodbar
1211 <prompt>$ </prompt><userinput>su - jill</userinput>
1212 <prompt>$ </prompt><userinput>cd /foodbar</userinput>
1213 <prompt>$ </prompt><userinput>touch Afile</userinput>
1214 <prompt>$ </prompt><userinput>ls -al</userinput>
1219 You should see that the file <filename>Afile</filename> created by Jill will have ownership
1220 and permissions of Jack, as follows:
1222 -rw-r--r-- 1 jack engr 0 2003-02-04 09:57 Afile
1229 Now in your &smb.conf; for the share add:
1231 force create mode = 0775
1232 force directory mode = 6775
1237 The above are only needed <emphasis>if</emphasis> your users are <emphasis>not</emphasis> members of the group
1238 you have used. ie: Within the OS do not have write permission on the directory.
1243 An alternative is to set in the &smb.conf; entry for the share:
1255 <title>I have set force user and Samba still makes <emphasis>root</emphasis> the owner of all the files
1258 When you have a user in 'admin users', Samba will always do file operations for
1259 this user as <emphasis>root</emphasis>, even if <parameter>force user</parameter> has been set.