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 adminstrators are often confused regarding network access controls and what is the best way to
13 provide users with the type of access they need while protecting resources from the consequences
14 of untoward access capabilities.
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 expections, 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 orr
70 connection setup process. Samba uses this user identity to validate
71 whether or not the user should be given access to file system resources
72 (files and directories). This chapter provides an overview for those
73 to whom the Unix permissions and controls are a little strange or unknown.
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 paltforms 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 withing 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 <para><emphasis>Name Space</emphasis></para>
154 MS Windows NT4 / 200x/ XP files names may be up to 254 characters long, Unix file names
155 may be 1023 characters long. In MS Windows file extensions indicate particular file types,
156 in Unix this is not so rigorously observed as all names are considered arbitrary.
159 What MS Windows calls a Folder, Unix calls a directory,
164 <para><emphasis>Case Sensitivity</emphasis></para>
166 MS Windows file names are generally Upper Case if made up of 8.3 (ie: 8 character file name
167 and 3 character extension. If longer than 8.3 file names are Case Preserving, and Case
171 Unix file and directory names are Case Sensitive and Case Preserving. Samba implements the
172 MS Windows file name behaviour, but it does so as a user application. The Unix file system
173 provides no mechanism to perform case insensitive file name lookups. MS Windows does this
174 by default. This means that Samba has to carry the processing overhead to provide features
175 that are NOT native to the Unix operating system environment.
178 Consider the following, all are unique Unix names but one single MS Windows file name:
184 So clearly, In an MS Windows file name space these three files CAN NOT co-exist! But in Unix
185 they can. So what should Samba do if all three are present? Answer, the one that is lexically
186 first will be accessible to MS Windows users, the others are invisible and unaccessible - any
187 other solution would be suicidal.
192 <para><emphasis>Directory Separators</emphasis></para>
194 MS Windows and DOS uses the back-slash '\' as a directory delimiter, Unix uses the forward-slash '/'
195 as it's directory delimiter. This is transparently handled by Samba.
200 <para><emphasis>Drive Identification</emphasis></para>
202 MS Windows products support a notion of drive letters, like <command>C:</command> to represent
203 disk partitions. Unix has NO concept if separate identifiers for file partitions since each
204 such file system is <filename>mounted</filename> to become part of the over-all directory tree.
205 The Unix directory tree begins at '/', just like the root of a DOS drive is specified like
206 <command>C:\</command>.
211 <para><emphasis>File Naming Conventions</emphasis></para>
213 MS Windows generally never experiences file names that begin with a '.', while in Unix these
214 are commonly found in a user's home directory. Files that begin with a '.' are typically
215 either start up files for various Unix applications, or they may be files that contain
216 start-up configuration data.
221 <para><emphasis>Links and Short-Cuts</emphasis></para>
223 MS Windows make use of "links and Short-Cuts" that are actually special types of files that will
224 redirect an attempt to execute the file to the real location of the file. Unix knows of file and directory
225 links, but they are entirely different from what MS Windows users are used to.
228 Symbolic links are files in Unix that contain the actual location of the data (file OR directory). An
229 operation (like read or write) will operate directly on the file referenced. Symbolic links are also
230 referred to as 'soft links'. A hard link is something that MS Windows is NOT familiar with. It allows
231 one physical file to be known simulataneously by more than one file name.
237 There are many other subtle differences that may cause the MS Windows administrator some temporary discomfort
238 in the process of becoming familiar with Unix/Linux. These are best left for a text that is dedicated to the
239 purpose of Unix/Linux training/education.
245 <title>Managing Directories</title>
248 There are three basic operations for managing directories, <command>create, delete, rename</command>.
250 Action MS Windows Command Unix Command
251 ------ ------------------ ------------
252 create md folder mkdir folder
253 delete rd folder rmdir folder
254 rename rename oldname newname mv oldname newname
261 <title>File and Directory Access Control</title>
264 The network administrator is strongly advised to read foundational training manuals and reference materials
265 regarding file and directory permissions maintenance. Much can be achieved with the basic Unix permissions
266 without having to resort to more complex facilities like POSIX Access Control Lists (ACLs) or Extended
271 Unix/Linux file and directory access permissions invloves setting three (3) primary sets of data and one (1) control set.
272 A Unix file listing looks as follows:-
275 jht@frodo:~/stuff> ls -la
277 drwxr-xr-x 13 jht users 816 2003-05-12 22:56 .
278 drwxr-xr-x 37 jht users 3800 2003-05-12 22:29 ..
279 d--------- 2 jht users 48 2003-05-12 22:29 muchado00
280 d--x--x--x 2 jht users 48 2003-05-12 22:29 muchado01
281 dr-xr-xr-x 2 jht users 48 2003-05-12 22:29 muchado02
282 drwxrwxrwx 2 jht users 48 2003-05-12 22:29 muchado03
283 drw-rw-rw- 2 jht users 48 2003-05-12 22:29 muchado04
284 d-w--w--w- 2 jht users 48 2003-05-12 22:29 muchado05
285 dr--r--r-- 2 jht users 48 2003-05-12 22:29 muchado06
286 drwxrwxrwt 2 jht users 48 2003-05-12 22:29 muchado07
287 drwsrwsrwx 2 jht users 48 2003-05-12 22:29 muchado08
288 ---------- 1 jht users 1242 2003-05-12 22:31 mydata00.lst
289 ---x--x--x 1 jht users 1674 2003-05-12 22:33 mydata01.lst
290 --w--w--w- 1 jht users 7754 2003-05-12 22:33 mydata02.lst
291 --wx-wx-wx 1 jht users 260179 2003-05-12 22:33 mydata03.lst
292 -r--r--r-- 1 jht users 21017 2003-05-12 22:32 mydata04.lst
293 -r-xr-xr-x 1 jht users 206339 2003-05-12 22:32 mydata05.lst
294 -rw-rw-rw- 1 jht users 41105 2003-05-12 22:32 mydata06.lst
295 -rwxrwxrwx 1 jht users 19312 2003-05-12 22:32 mydata07.lst
301 The columns above represent (from left to right): permissions, no blocks used, owner, group, size (bytes), access date, access time, file name.
305 The permissions field is made up of:
308 [ type ] [ users ] [ group ] [ others ] [File, Directory Permissions]
309 [ d | l ] [ r w x ] [ r w x ] [ r w x ]
310 | | | | | | | | | | |
311 | | | | | | | | | | |-----> Can Execute, List files
312 | | | | | | | | | |-------> Can Write, Create files
313 | | | | | | | | |---------> Can Read, Read files
314 | | | | | | | |---------------> Can Execute, List files
315 | | | | | | |-----------------> Can Write, Create files
316 | | | | | |-------------------> Can Read, Read files
317 | | | | |-------------------------> Can Execute, List files
318 | | | |---------------------------> Can Write, Create files
319 | | |-----------------------------> Can Read, Read files
320 | |-----------------------------------> Is a symbolic Link
321 |---------------------------------------> Is a directory
326 Any bit flag may be unset. An unset bit flag is the equivalent of 'Can NOT' and is represented as a '-' character.
328 <title>Example File</title>
329 -rwxr-x--- Means: The owner (user) can read, write, execute
330 the group can read and execute
331 everyone else can NOT do anything with it
336 Additional posibilities in the [type] field are: c = character device, b = block device, p = pipe device, s = Unix Domain Socket.
340 The letters `rwxXst' set permissions for the user, group and others as: read (r), write (w), execute (or access for directories) (x),r
341 execute only if the file is a directory or already has execute permission for some user (X), set user or group ID on execution (s),
346 When the sticky bit is set on a directory, files in that directory may be unlinked (deleted) or renamed only by root or their owner.
347 Without the sticky bit, anyone able to write to the directory can delete or rename files. The sticky bit is commonly found on
348 directories, such as /tmp, that are world-writable.
352 When the set user or group ID bit (s) is set on a directory, then all files created within it will be owned by the user and/or
353 group whose 'set user or group' bit is set. This can be very helpful in setting up directories that for which it is desired that
354 all users who are in a group should be able to write to and read from a file, particularly when it is undesirable for that file
355 to be exclusively owned by a user who's primary group is not the group that all such users belong to.
359 When a directory is set <command>drw-r-----</command> this means that the owner can read and create (write) files in it, but because
360 the (x) execute flags are not set files can not be listed (seen) in the directory by anyone. The group can read files in the
361 directory but can NOT create new files. NOTE: If files in the directory are set to be readable and writable for the group, then
362 group members will be able to write to (or delete) them.
370 <title>Share Definition Access Controls</title>
373 The following parameters in the &smb.conf; file sections that define a share control or affect access controls.
374 Before using any of the following options please refer to the man page for &smb.conf;.
378 <title>User and Group Based Controls</title>
381 User and group based controls can prove very useful. In some situations it is distinctly desirable to affect all
382 file system operations as if a single user is doing this, the use of the <emphasis>force user</emphasis> and
383 <emphasis>force group</emphasis> behaviour will achieve this. In other situations it may be necessary to affect a
384 paranoia level of control to ensure that only particular authorised persons will be able to access a share or
385 it's contents, here the use of the <emphasis>valid users</emphasis> or the <emphasis>invalid users</emphasis> may
390 As always, it is highly advisable to use the least difficult to maintain and the least ambiguous method for
391 controlling access. Remember, that when you leave the scene someone else will need to provide assistance and
392 if that person finds to great a mess, or if they do not understand what you have done then there is risk of
393 Samba being removed and an alternative solution being adopted.
396 <table frame='all'><title>User and Group Based Controls</title>
400 <entry align="center">Control Parameter</entry>
401 <entry align="center">Description - Action - Notes</entry>
406 <entry>admin users</entry>
408 List of users who will be granted administrative privileges on the share.
409 They will do all file operations as the super-user (root).
410 Any user in this list will be able to do anything they like on the share,
411 irrespective of file permissions.
415 <entry>force group</entry>
417 Specifies a UNIX group name that will be assigned as the default primary group
418 for all users connecting to this service.
422 <entry>force user</entry>
424 Specifies a UNIX user name that will be assigned as the default user for all users connecting to this service.
425 This is useful for sharing files. Incorrect use can cause security problems.
429 <entry>guest ok</entry>
431 If this parameter is set for a service, then no password is required to connect to the service. Privileges will be
432 those of the guest account.
436 <entry>invalid users</entry>
438 List of users that should not be allowed to login to this service.
442 <entry>only user</entry>
444 Controls whether connections with usernames not in the user list will be allowed.
448 <entry>read list</entry>
450 List of users that are given read-only access to a service. Users in this list
451 will not be given write access, no matter what the read only option is set to.
455 <entry>username</entry>
457 Refer to the &smb.conf; man page for more information - this is a complex and potentially misused parameter.
461 <entry>valid users</entry>
463 List of users that should be allowed to login to this service.
467 <entry>write list</entry>
469 List of users that are given read-write access to a service.
479 <title>File and Directory Permissions Based Controls</title>
482 The following file and directory permission based controls, if misused, can result in considerable difficulty to
483 diagnose the cause of mis-configuration. Use them sparingly and carefully. By gradually introducing each one by one
484 undesirable side-effects may be detected. In the event of a problem, always comment all of them out and then gradually
485 re-instroduce them in a controlled fashion.
488 <table frame='all'><title>File and Directory Permission Based Controls</title>
492 <entry align="center">Control Parameter</entry>
493 <entry align="center">Description - Action - Notes</entry>
498 <entry>create mask</entry>
500 Refer to the &smb.conf; man page.
504 <entry>directory mask</entry>
506 The octal modes used when converting DOS modes to UNIX modes when creating UNIX directories.
507 See also: directory security mask.
508 </para></entry></row>
510 <entry>dos filemode</entry>
512 Enabling this parameter allows a user who has write access to the file to modify the permissions on it.
516 <entry>force create mode</entry>
518 This parameter specifies a set of UNIX mode bit permissions that will always be set on a file created by Samba.
522 <entry>force directory mode</entry>
524 This parameter specifies a set of UNIX mode bit permissions that will always be set on a directory created by Samba.
528 <entry>force directory security mode</entry>
530 Controls UNIX permission bits modified when a Windows NT client is manipulating UNIX permissions on a directory
534 <entry>force security mode</entry>
536 Controls UNIX permission bits modified when a Windows NT client manipulates UNIX permissions.
540 <entry>hide unreadable</entry>
542 Prevents clients from seeing the existance of files that cannot be read.
546 <entry>hide unwriteable files</entry>
548 Prevents clients from seeing the existance of files that cannot be written to. Unwriteable directories are shown as usual.
552 <entry>nt acl support</entry>
554 This parameter controls whether smbd will attempt to map UNIX permissions into Windows NT access control lists.
558 <entry>security mask</entry>
560 Controls UNIX permission bits modified when a Windows NT client is manipulating the UNIX permissions on a file.
570 <title>Miscellaneous Controls</title>
573 The following are documented because of the prevalence of administrators creating inadvertant barriers to file
574 access by not understanding the full implications of &smb.conf; file settings.
577 <table frame='all'><title>Other Controls</title>
581 <entry align="center">Control Parameter</entry>
582 <entry align="center">Description - Action - Notes</entry>
587 <entry>case sensitive, default case, short preserve case</entry>
589 This means that all file name lookup will be done in a case sensitive manner.
590 Files will be created with the precise filename Samba received from the MS Windows client.
594 <entry>csc policy</entry>
596 Client Side Caching Policy - parallels MS Windows client side file caching capabilities.
600 <entry>dont descend</entry>
602 Allows to specify a comma-delimited list of directories that the server should always show as empty.
606 <entry>dos filetime resolution</entry>
608 This option is mainly used as a compatibility option for Visual C++ when used against Samba shares.
612 <entry>dos filetimes</entry>
614 DOS and Windows allows users to change file time stamps if they can write to the file. POSIX semantics prevent this.
615 This options allows DOS and Windows behaviour.
619 <entry>fake oplocks</entry>
621 Oplocks are the way that SMB clients get permission from a server to locally cache file operations. If a server grants an
622 oplock then the client is free to assume that it is the only one accessing the file and it will aggressively cache file data.
626 <entry>hide dot files, hide files, veto files</entry>
628 Note: MS Windows Explorer allows over-ride of files marked as hidden so they will still be visible.
632 <entry>read only</entry>
634 If this parameter is yes, then users of a service may not create or modify files in the service's directory.
638 <entry>veto files</entry>
640 List of files and directories that are neither visible nor accessible.
652 <title>Access Controls on Shares</title>
655 This section deals with how to configure Samba per share access control restrictions.
656 By default samba sets no restrictions on the share itself. Restrictions on the share itself
657 can be set on MS Windows NT4/200x/XP shares. This can be a very effective way to limit who can
658 connect to a share. In the absence of specific restrictions the default setting is to allow
659 the global user <emphasis>Everyone</emphasis> Full Control (ie: Full control, Change and Read).
663 At this time Samba does NOT provide a tool for configuring access control setting on the Share
664 itself. Samba does have the capacity to store and act on access control settings, but the only
665 way to create those settings is to use either the NT4 Server Manager or the Windows 200x MMC for
670 Samba stores the per share access control settings in a file called <filename>share_info.tdb</filename>.
671 The location of this file on your system will depend on how samba was compiled. The default location
672 for samba's tdb files is under <filename>/usr/local/samba/var</filename>. If the <filename>tdbdump</filename>
673 utility has been compiled and installed on your system then you can examine the contents of this file
674 by: <userinput>tdbdump share_info.tdb</userinput>.
678 <title>Share Permissions Management</title>
681 The best tool for the task is platform dependant. Choose the best tool for your environmemt.
685 <title>Windows NT4 Workstation/Server</title>
687 The tool you need to use to manage share permissions on a Samba server is the NT Server Manager.
688 Server Manager is shipped with Windows NT4 Server products but not with Windows NT4 Workstation.
689 You can obtain the NT Server Manager for MS Windows NT4 Workstation from Microsoft - see details below.
693 <title>Instructions</title>
695 Launch the NT4 Server Manager, click on the Samba server you want to administer, then from the menu
696 select Computer, then click on the Shared Directories entry.
700 Now click on the share that you wish to manage, then click on the Properties tab, next click on
701 the Permissions tab. Now you can Add or change access control settings as you wish.
708 <title>Windows 200x/XP</title>
711 On MS Windows NT4/200x/XP system access control lists on the share itself are set using native
712 tools, usually from filemanager. For example, in Windows 200x: right click on the shared folder,
713 then select 'Sharing', then click on 'Permissions'. The default Windows NT4/200x permission allows
714 <emphasis>Everyone</emphasis> Full Control on the Share.
718 MS Windows 200x and later all comes with a tool called the 'Computer Management' snap-in for the
719 Microsoft Management Console (MMC). This tool is located by clicking on <filename>Control Panel ->
720 Administrative Tools -> Computer Management</filename>.
724 <title>Instructions</title>
726 After launching the MMC with the Computer Management snap-in, click on the menu item 'Action',
727 select 'Connect to another computer'. If you are not logged onto a domain you will be prompted
728 to enter a domain login user identifier and a password. This will authenticate you to the domain.
729 If you where already logged in with administrative privilidge this step is not offered.
733 If the Samba server is not shown in the Select Computer box, then type in the name of the target
734 Samba server in the field 'Name:'. Now click on the [+] next to 'System Tools', then on the [+]
735 next to 'Shared Folders' in the left panel.
739 Now in the right panel, double-click on the share you wish to set access control permissions on.
740 Then click on the tab 'Share Permissions'. It is now possible to add access control entities
741 to the shared folder. Do NOT forget to set what type of access (full control, change, read) you
742 wish to assign for each entry.
748 Be careful. If you take away all permissions from the Everyone user without removing this user
749 then effectively no user will be able to access the share. This is a result of what is known as
750 ACL precidence. ie: Everyone with NO ACCESS means that MaryK who is part of the group Everyone
751 will have no access even if this user is given explicit full control access.
761 <title>MS Windows Access Control Lists and Unix Interoperability</title>
764 <title>Managing UNIX permissions Using NT Security Dialogs</title>
766 <para>Windows NT clients can use their native security settings
767 dialog box to view and modify the underlying UNIX permissions.</para>
769 <para>Note that this ability is careful not to compromise
770 the security of the UNIX host Samba is running on, and
771 still obeys all the file permission rules that a Samba
772 administrator can set.</para>
776 All access to Unix/Linux system file via Samba is controlled at
777 the operating system file access control level. When trying to
778 figure out file access problems it is vitally important to identify
779 the identity of the Windows user as it is presented by Samba at
780 the point of file access. This can best be determined from the
787 <title>Viewing File Security on a Samba Share</title>
789 <para>From an NT4/2000/XP client, single-click with the right
790 mouse button on any file or directory in a Samba mounted
791 drive letter or UNC path. When the menu pops-up, click
792 on the <emphasis>Properties</emphasis> entry at the bottom of
793 the menu. This brings up the file properties dialog
794 box. Click on the tab <emphasis>Security</emphasis> and you
795 will see three buttons, <emphasis>Permissions</emphasis>,
796 <emphasis>Auditing</emphasis>, and <emphasis>Ownership</emphasis>.
797 The <emphasis>Auditing</emphasis> button will cause either
798 an error message <errorname>A requested privilege is not held
799 by the client</errorname> to appear if the user is not the
800 NT Administrator, or a dialog which is intended to allow an
801 Administrator to add auditing requirements to a file if the
802 user is logged on as the NT Administrator. This dialog is
803 non-functional with a Samba share at this time, as the only
804 useful button, the <command>Add</command> button will not currently
805 allow a list of users to be seen.</para>
810 <title>Viewing file ownership</title>
812 <para>Clicking on the <command>"Ownership"</command> button
813 brings up a dialog box telling you who owns the given file. The
814 owner name will be of the form :</para>
816 <para><command>"SERVER\user (Long name)"</command></para>
818 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
819 the Samba server, <replaceable>user</replaceable> is the user name of
820 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
821 is the descriptive string identifying the user (normally found in the
822 GECOS field of the UNIX password database). Click on the <command>Close
823 </command> button to remove this dialog.</para>
825 <para>If the parameter <parameter>nt acl support</parameter>
826 is set to <constant>false</constant> then the file owner will
827 be shown as the NT user <command>"Everyone"</command>.</para>
829 <para>The <command>Take Ownership</command> button will not allow
830 you to change the ownership of this file to yourself (clicking on
831 it will display a dialog box complaining that the user you are
832 currently logged onto the NT client cannot be found). The reason
833 for this is that changing the ownership of a file is a privileged
834 operation in UNIX, available only to the <emphasis>root</emphasis>
835 user. As clicking on this button causes NT to attempt to change
836 the ownership of a file to the current user logged into the NT
837 client this will not work with Samba at this time.</para>
839 <para>There is an NT chown command that will work with Samba
840 and allow a user with Administrator privilege connected
841 to a Samba server as root to change the ownership of
842 files on both a local NTFS filesystem or remote mounted NTFS
843 or Samba drive. This is available as part of the <emphasis>Seclib
844 </emphasis> NT security library written by Jeremy Allison of
845 the Samba Team, available from the main Samba ftp site.</para>
850 <title>Viewing File or Directory Permissions</title>
852 <para>The third button is the <command>"Permissions"</command>
853 button. Clicking on this brings up a dialog box that shows both
854 the permissions and the UNIX owner of the file or directory.
855 The owner is displayed in the form :</para>
857 <para><command>"SERVER\user (Long name)"</command></para>
859 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
860 the Samba server, <replaceable>user</replaceable> is the user name of
861 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
862 is the descriptive string identifying the user (normally found in the
863 GECOS field of the UNIX password database).</para>
865 <para>If the parameter <parameter>nt acl support</parameter>
866 is set to <constant>false</constant> then the file owner will
867 be shown as the NT user <command>"Everyone"</command> and the
868 permissions will be shown as NT "Full Control".</para>
871 <para>The permissions field is displayed differently for files
872 and directories, so I'll describe the way file permissions
873 are displayed first.</para>
876 <title>File Permissions</title>
878 <para>The standard UNIX user/group/world triple and
879 the corresponding "read", "write", "execute" permissions
880 triples are mapped by Samba into a three element NT ACL
881 with the 'r', 'w', and 'x' bits mapped into the corresponding
882 NT permissions. The UNIX world permissions are mapped into
883 the global NT group <command>Everyone</command>, followed
884 by the list of permissions allowed for UNIX world. The UNIX
885 owner and group permissions are displayed as an NT
886 <command>user</command> icon and an NT <command>local
887 group</command> icon respectively followed by the list
888 of permissions allowed for the UNIX user and group.</para>
890 <para>As many UNIX permission sets don't map into common
891 NT names such as <command>"read"</command>, <command>
892 "change"</command> or <command>"full control"</command> then
893 usually the permissions will be prefixed by the words <command>
894 "Special Access"</command> in the NT display list.</para>
896 <para>But what happens if the file has no permissions allowed
897 for a particular UNIX user group or world component ? In order
898 to allow "no permissions" to be seen and modified then Samba
899 overloads the NT <command>"Take Ownership"</command> ACL attribute
900 (which has no meaning in UNIX) and reports a component with
901 no permissions as having the NT <command>"O"</command> bit set.
902 This was chosen of course to make it look like a zero, meaning
903 zero permissions. More details on the decision behind this will
904 be given below.</para>
908 <title>Directory Permissions</title>
910 <para>Directories on an NT NTFS file system have two
911 different sets of permissions. The first set of permissions
912 is the ACL set on the directory itself, this is usually displayed
913 in the first set of parentheses in the normal <command>"RW"</command>
914 NT style. This first set of permissions is created by Samba in
915 exactly the same way as normal file permissions are, described
916 above, and is displayed in the same way.</para>
918 <para>The second set of directory permissions has no real meaning
919 in the UNIX permissions world and represents the <command>
920 "inherited"</command> permissions that any file created within
921 this directory would inherit.</para>
923 <para>Samba synthesises these inherited permissions for NT by
924 returning as an NT ACL the UNIX permission mode that a new file
925 created by Samba on this share would receive.</para>
930 <title>Modifying file or directory permissions</title>
932 <para>Modifying file and directory permissions is as simple
933 as changing the displayed permissions in the dialog box, and
934 clicking the <command>OK</command> button. However, there are
935 limitations that a user needs to be aware of, and also interactions
936 with the standard Samba permission masks and mapping of DOS
937 attributes that need to also be taken into account.</para>
939 <para>If the parameter <parameter>nt acl support</parameter>
940 is set to <constant>false</constant> then any attempt to set
941 security permissions will fail with an <command>"Access Denied"
942 </command> message.</para>
944 <para>The first thing to note is that the <command>"Add"</command>
945 button will not return a list of users in Samba (it will give
946 an error message of <command>"The remote procedure call failed
947 and did not execute"</command>). This means that you can only
948 manipulate the current user/group/world permissions listed in
949 the dialog box. This actually works quite well as these are the
950 only permissions that UNIX actually has.</para>
952 <para>If a permission triple (either user, group, or world)
953 is removed from the list of permissions in the NT dialog box,
954 then when the <command>"OK"</command> button is pressed it will
955 be applied as "no permissions" on the UNIX side. If you then
956 view the permissions again the "no permissions" entry will appear
957 as the NT <command>"O"</command> flag, as described above. This
958 allows you to add permissions back to a file or directory once
959 you have removed them from a triple component.</para>
961 <para>As UNIX supports only the "r", "w" and "x" bits of
962 an NT ACL then if other NT security attributes such as "Delete
963 access" are selected then they will be ignored when applied on
964 the Samba server.</para>
966 <para>When setting permissions on a directory the second
967 set of permissions (in the second set of parentheses) is
968 by default applied to all files within that directory. If this
969 is not what you want you must uncheck the <command>"Replace
970 permissions on existing files"</command> checkbox in the NT
971 dialog before clicking <command>"OK"</command>.</para>
973 <para>If you wish to remove all permissions from a
974 user/group/world component then you may either highlight the
975 component and click the <command>"Remove"</command> button,
976 or set the component to only have the special <command>"Take
977 Ownership"</command> permission (displayed as <command>"O"
978 </command>) highlighted.</para>
982 <title>Interaction with the standard Samba create mask
985 <para>There are four parameters
986 to control interaction with the standard Samba create mask parameters.
989 <para><parameter>security mask</parameter></para>
990 <para><parameter>force security mode</parameter></para>
991 <para><parameter>directory security mask</parameter></para>
992 <para><parameter>force directory security mode</parameter></para>
994 <para>Once a user clicks <command>"OK"</command> to apply the
995 permissions Samba maps the given permissions into a user/group/world
996 r/w/x triple set, and then will check the changed permissions for a
997 file against the bits set in the <ulink url="smb.conf.5.html#SECURITYMASK">
998 <parameter>security mask</parameter></ulink> parameter. Any bits that
999 were changed that are not set to '1' in this parameter are left alone
1000 in the file permissions.</para>
1002 <para>Essentially, zero bits in the <parameter>security mask</parameter>
1003 mask may be treated as a set of bits the user is <emphasis>not</emphasis>
1004 allowed to change, and one bits are those the user is allowed to change.
1007 <para>If not set explicitly this parameter is set to the same value as
1008 the <ulink url="smb.conf.5.html#CREATEMASK"><parameter>create mask
1009 </parameter></ulink> parameter. To allow a user to modify all the
1010 user/group/world permissions on a file, set this parameter
1013 <para>Next Samba checks the changed permissions for a file against
1014 the bits set in the <ulink url="smb.conf.5.html#FORCESECURITYMODE">
1015 <parameter>force security mode</parameter></ulink> parameter. Any bits
1016 that were changed that correspond to bits set to '1' in this parameter
1017 are forced to be set.</para>
1019 <para>Essentially, bits set in the <parameter>force security mode
1020 </parameter> parameter may be treated as a set of bits that, when
1021 modifying security on a file, the user has always set to be 'on'.</para>
1023 <para>If not set explicitly this parameter is set to the same value
1024 as the <ulink url="smb.conf.5.html#FORCECREATEMODE"><parameter>force
1025 create mode</parameter></ulink> parameter.
1026 To allow a user to modify all the user/group/world permissions on a file
1027 with no restrictions set this parameter to 000.</para>
1029 <para>The <parameter>security mask</parameter> and <parameter>force
1030 security mode</parameter> parameters are applied to the change
1031 request in that order.</para>
1033 <para>For a directory Samba will perform the same operations as
1034 described above for a file except using the parameter <parameter>
1035 directory security mask</parameter> instead of <parameter>security
1036 mask</parameter>, and <parameter>force directory security mode
1037 </parameter> parameter instead of <parameter>force security mode
1038 </parameter>.</para>
1040 <para>The <parameter>directory security mask</parameter> parameter
1041 by default is set to the same value as the <parameter>directory mask
1042 </parameter> parameter and the <parameter>force directory security
1043 mode</parameter> parameter by default is set to the same value as
1044 the <parameter>force directory mode</parameter> parameter. </para>
1046 <para>In this way Samba enforces the permission restrictions that
1047 an administrator can set on a Samba share, whilst still allowing users
1048 to modify the permission bits within that restriction.</para>
1050 <para>If you want to set up a share that allows users full control
1051 in modifying the permission bits on their files and directories and
1052 doesn't force any particular bits to be set 'on', then set the following
1053 parameters in the &smb.conf; file in that share specific section :</para>
1055 <para><parameter>security mask = 0777</parameter></para>
1056 <para><parameter>force security mode = 0</parameter></para>
1057 <para><parameter>directory security mask = 0777</parameter></para>
1058 <para><parameter>force directory security mode = 0</parameter></para>
1062 <title>Interaction with the standard Samba file attribute
1065 <para>Samba maps some of the DOS attribute bits (such as "read
1066 only") into the UNIX permissions of a file. This means there can
1067 be a conflict between the permission bits set via the security
1068 dialog and the permission bits set by the file attribute mapping.
1071 <para>One way this can show up is if a file has no UNIX read access
1072 for the owner it will show up as "read only" in the standard
1073 file attributes tabbed dialog. Unfortunately this dialog is
1074 the same one that contains the security info in another tab.</para>
1076 <para>What this can mean is that if the owner changes the permissions
1077 to allow themselves read access using the security dialog, clicks
1078 <command>"OK"</command> to get back to the standard attributes tab
1079 dialog, and then clicks <command>"OK"</command> on that dialog, then
1080 NT will set the file permissions back to read-only (as that is what
1081 the attributes still say in the dialog). This means that after setting
1082 permissions and clicking <command>"OK"</command> to get back to the
1083 attributes dialog you should always hit <command>"Cancel"</command>
1084 rather than <command>"OK"</command> to ensure that your changes
1085 are not overridden.</para>
1090 <title>Common Errors</title>
1093 File, Directory and Share access problems are very common on the mailing list. The following
1094 are examples taken from the mailing list in recent times.
1099 <title>Users can not write to a public share</title>
1102 We are facing some troubles with file / directory permissions. I can log on the domain as admin user(root),
1103 and theres a public share, on which everyone needs to have permission to create / modify files, but only
1104 root can change the file, no one else can. We need to constantly go to server to
1105 <command>chgrp -R users *</command> and <command>chown -R nobody *</command> to allow others users to change the file.
1109 There are many ways to solve this problem, here are a few hints:
1113 <title>Example Solution:</title>
1116 Go to the top of the directory that is shared
1122 Set the ownership to what ever public owner and group you want
1124 find 'directory_name' -type d -exec chown user.group {}\;
1125 find 'directory_name' -type d -exec chmod 6775 'directory_name'
1126 find 'directory_name' -type f -exec chmod 0775 {} \;
1127 find 'directory_name' -type f -exec chown user.group {}\;
1132 Note: The above will set the 'sticky bit' on all directories. Read your
1133 Unix/Linux man page on what that does. It causes the OS to assign to all
1134 files created in the directories the ownership of the directory.
1139 Directory is: /foodbar
1140 chown jack.engr /foodbar
1142 Note: This is the same as doing:
1151 drwsrwsr-x 2 jack engr 48 2003-02-04 09:55 foodbar
1162 You should see that the file 'Afile' created by Jill will have ownership
1163 and permissions of Jack, as follows:
1165 -rw-r--r-- 1 jack engr 0 2003-02-04 09:57 Afile
1172 Now in your smb.conf for the share add:
1174 force create mode = 0775
1175 force direcrtory mode = 6775
1180 Note: The above are only needed IF your users are NOT members of the group
1181 you have used. ie: Within the OS do not have write permission on the directory.
1185 An alternative is to set in the smb.conf entry for the share: