1
2
3
4
5
6
7<html><head><title>Viewing and changing UNIX permissions using the NT security dialogs in Samba 2.0.4</title>
8
9<link rev="made" href="mailto:samba@samba.org">
10</head>
11<body>
12
13<hr>
14
15<h1>Viewing and changing UNIX permissions using the NT security dialogs in Samba 2.0.4</h1>
16<h2>Jeremy Allison, Samba Team</h2>
17<h2>12th April 1999</h2>
18
19<h1>Table of Contents </h1><p></p>
20 
21<p><hr><p><br>
22<p><center><strong>Viewing and changing UNIX permissions using the NT security dialogs</strong> </center><br>
23<center><strong>-------------------------------------------------------------------</strong> </center>
24<p>New in the <strong>Samba 2.0.4</strong> release is the
25ability for Windows NT clients to use their native security
26settings dialog box to view and modify the underlying UNIX
27permissions.
28<p>Note that this ability is careful not to compromise the security
29of the UNIX host Samba is running on, and still obeys all the
30file permission rules that a Samba administrator can set.
31<p>In Samba 2.0.4 and above the default value of the parameter
32<a href="smb.conf.5.html#ntaclsupport"><strong>"nt acl support"</strong></a> has been
33changed from "false" to "true", so manipulation of permissions is
34turned on by default.
35<p><strong>How to view file security on a Samba share</strong><br>
36<strong>------------------------------------------</strong>
37<p>From an NT 4.0 client, single-click with the right mouse button on
38any file or directory in a Samba mounted drive letter or UNC path.
39When the menu pops-up, click on the <code>Properties</code> entry at the 
40bottom of the menu. This brings up the normal file properties dialog
41box, but with Samba 2.0.4 this will have a new tab along the top
42marked <code>Security</code>. Click on this tab and you will see three buttons,
43<em>Permissions</em>, <em>Auditing</em>, and <em>Ownership</em>. The <em>Auditing</em>
44button will cause either an error message <code>"A requested privilege is
45not held by the client"</code> to appear if the user is not the NT Administrator,
46or a dialog which is intended to allow an Administrator to add
47auditing requirements to a file if the user is logged on as the
48NT Administrator. This dialog is non-functional with a Samba
49share at this time, as the only useful button, the <code>Add</code> button
50will not currently allow a list of users to be seen.
51<p><strong>Viewing file ownership</strong><br>
52<strong>----------------------</strong>
53<p>Clicking on the <code>"Ownership"</code> button brings up a dialog box telling
54you who owns the given file. The owner name will be of the form :
55<p><code>"SERVER\user (Long name)"</code>
56<p>Where <code>SERVER</code> is the NetBIOS name of the Samba server, <code>user</code>
57is the user name of the UNIX user who owns the file, and <code>(Long name)</code>
58is the discriptive string identifying the user (normally found in the
59GECOS field of the UNIX password database). Click on the <code>Close</code>
60button to remove this dialog.
61<p>If the parameter <a href="smb.conf.5.html#ntaclsupport"><strong>"nt acl support"</strong></a>
62is set to "false" then the file owner will be shown as the NT user
63<code>"Everyone"</code>.
64<p>The <code>Take Ownership</code> button will not allow you to change the
65ownership of this file to yourself (clicking on it will display a
66dialog box complaining that the user you are currently logged onto
67the NT client cannot be found). The reason for this is that changing
68the ownership of a file is a privilaged operation in UNIX, available
69only to the <em>root</em> user. As clicking on this button causes NT to
70attempt to change the ownership of a file to the current user logged
71into the NT client this will not work with Samba at this time.
72<p>There is an NT chown command that will work with Samba and allow
73a user with Administrator privillage connected to a Samba 2.0.4
74server as root to change the ownership of files on both a local NTFS
75filesystem or remote mounted NTFS or Samba drive. This is available
76as part of the <strong>Seclib</strong> NT security library written by Jeremy
77Allison of the Samba Team, available from the main Samba ftp site.
78<p><strong>Viewing file or directory permissions</strong><br>
79<strong>-------------------------------------</strong>
80<p>The third button is the <code>"Permissions"</code> button. Clicking on this
81brings up a dialog box that shows both the permissions and the UNIX
82owner of the file or directory. The owner is displayed in the form :
83<p><code>"SERVER\user (Long name)"</code>
84<p>Where <code>SERVER</code> is the NetBIOS name of the Samba server, <code>user</code>
85is the user name of the UNIX user who owns the file, and <code>(Long name)</code>
86is the discriptive string identifying the user (normally found in the
87GECOS field of the UNIX password database).
88<p>If the parameter <a href="smb.conf.5.html#ntaclsupport"><strong>"nt acl support"</strong></a>
89is set to "false" then the file owner will be shown as the NT user
90<code>"Everyone"</code> and the permissions will be shown as NT <code>"Full Control"</code>.
91<p>The permissions field is displayed differently for files and directories,
92so I'll describe the way file permissions are displayed first.
93<p><strong>File Permissions</strong><br>
94<strong>----------------</strong>
95<p>The standard UNIX user/group/world triple and the correspinding
96"read", "write", "execute" permissions triples are mapped by Samba
97into a three element NT ACL with the 'r', 'w', and 'x' bits mapped
98into the corresponding NT permissions. The UNIX world permissions are mapped
99into the global NT group <code>Everyone</code>, followed by the list of permissions
100allowed for UNIX world. The UNIX owner and group permissions
101are displayed as an NT <code>user</code> icon and an NT <code>local group</code> icon
102respectively followed by the list of permissions allowed for the
103UNIX user and group.
104<p>As many UNIX permission sets don't map into common NT names such as
105<code>"read"</code>, <code>"change"</code> or <code>"full control"</code> then usually the permissions
106will be prefixed by the words <code>"Special Access"</code> in the NT display 
107list.
108<p>But what happens if the file has no permissions allowed for a
109particular UNIX user group or world component ? In order to 
110allow "no permissions" to be seen and modified then Samba overloads
111the NT <code>"Take Ownership"</code> ACL attribute (which has no meaning in
112UNIX) and reports a component with no permissions as having the NT
113<code>"O"</code> bit set. This was chosen of course to make it look like a
114zero, meaning zero permissions. More details on the decision behind
115this will be given below.
116<p><strong>Directory Permissions</strong><br>
117<strong>---------------------</strong>
118<p>Directories on an NT NTFS file system have two different sets of
119permissions. The first set of permissions is the ACL set on the
120directory itself, this is usually displayed in the first set of
121parentheses in the normal <code>"RW"</code> NT style. This first set of
122permissions is created by Samba in exactly the same way as normal
123file permissions are, described above, and is displayed in the
124same way.
125<p>The second set of directory permissions has no real meaning in the
126UNIX permissions world and represents the <code>"inherited"</code> permissions
127that any file created within this directory would inherit.
128<p>Samba synthesises these inherited permissions for NT by returning as
129an NT ACL the UNIX permission mode that a new file created by Samba
130on this share would receive.
131<p><strong>Modifying file or directory permissions</strong><br>
132<strong>---------------------------------------</strong>
133<p>Modifying file and directory permissions is as simple as changing
134the displayed permissions in the dialog box, and clicking the <code>OK</code>
135button. However, there are limitations that a user needs to be aware
136of, and also interactions with the standard Samba permission masks
137and mapping of DOS attributes that need to also be taken into account.
138<p>If the parameter <a href="smb.conf.5.html#ntaclsupport"><strong>"nt acl support"</strong></a>
139is set to "false" then any attempt to set security permissions will
140fail with an <code>"Access Denied"</code> message.
141<p>The first thing to note is that the <code>"Add"</code> button will not return
142a list of users in Samba 2.0.4 (it will give an error message of
143<code>"The remote proceedure call failed and did not execute"</code>). This
144means that you can only manipulate the current user/group/world
145permissions listed in the dialog box. This actually works quite well
146as these are the only permissions that UNIX actually has.
147<p>If a permission triple (either user, group, or world) is removed from
148the list of permissions in the NT dialog box, then when the <code>"OK"</code>
149button is pressed it will be applied as "no permissions" on the UNIX
150side. If you then view the permissions again the "no permissions" entry
151will appear as the NT <code>"O"</code> flag, as described above. This allows you
152to add permissions back to a file or directory once you have removed
153them from a triple component.
154<p>As UNIX supports only the "r", "w" and "x" bits of an NT ACL
155then if other NT security attributes such as "Delete access"
156are selected then they will be ignored when applied on the 
157Samba server.
158<p>When setting permissions on a directory the second set of permissions
159(in the second set of parentheses) is by default applied to all
160files within that directory. If this is not what you want you
161must uncheck the <code>"Replace permissions on existing files"</code> checkbox
162in the NT dialog before clicking <code>"OK"</code>.
163<p>If you wish to remove all permissions from a user/group/world 
164component then you may either highlight the component and click
165the <code>"Remove"</code> button, or set the component to only have the special
166<code>"Take Ownership"</code> permission (dsplayed as <code>"O"</code>) highlighted.
167<p><strong>Interaction with the standard Samba create mask parameters</strong><br>
168<strong>----------------------------------------------------------</strong>
169<p>Note that with Samba 2.0.5 there are four new parameters to
170control this interaction.
171<p>These are :
172<p><code>security mask</code>
173<code>force security mode</code>
174<code>directory security mask</code>
175<code>force directory security mode</code>
176<p>Once a user clicks <code>"OK"</code> to apply the permissions Samba maps
177the given permissions into a user/group/world r/w/x triple set,
178and then will check the changed permissions for a file against
179the bits set in the <a href="smb.conf.5.html#securitymask"><strong>"security mask"</strong></a>
180parameter. Any bits that were changed that are not set to '1'
181in this parameter are left alone in the file permissions.
182<p>Essentially, zero bits in the <a href="smb.conf.5.html#securitymask"><strong>"security mask"</strong></a>
183mask may be treated as a set of bits the user is <em>not</em> allowed to change,
184and one bits are those the user is allowed to change.
185<p>If not set explicitly this parameter is set to the same value as the
186<a href="smb.conf.5.html#createmask"><strong>"create mask"</strong></a> parameter to provide compatibility
187with Samba 2.0.4 where this permission change facility was introduced.
188To allow a user to modify all the user/group/world permissions on a file,
189set this parameter to 0777.
190<p>Next Samba checks the changed permissions for a file against the
191bits set in the <a href="smb.conf.5.html#forcesecuritymode"><strong>"force security mode"</strong></a>
192parameter. Any bits that were changed that correspond to bits set
193to '1' in this parameter are forced to be set.
194<p>Essentially, bits set in the <a href="smb.conf.5.html#forcesecuritymode"><strong>"force security mode"</strong></a>
195parameter may be treated as a set of bits that, when modifying security on a file, the
196user has always set to be 'on'.
197<p>If not set explicitly this parameter is set to the same value as the
198<a href="smb.conf.5.html#forcecreatemode"><strong>"force create mode"</strong></a> parameter to provide compatibility
199with Samba 2.0.4 where the permission change facility was introduced.
200To allow a user to modify all the user/group/world permissions on a file,
201with no restrictions set this parameter to 000.
202<p>The <a href="smb.conf.5.html#securitymask"><strong>"security mask"</strong></a> and
203<a href="smb.conf.5.html#forcesecuritymode"><strong>"force security mode"</strong></a> parameters
204are applied to the change request in that order.
205<p>For a directory Samba will perform the same operations as described above
206for a file except using the parameter <a href="smb.conf.5.html#directorysecuritymask"><strong>"directory security mask"</strong></a>
207instead of <a href="smb.conf.5.html#securitymask"><strong>"security mask"</strong></a>, and 
208<a href="smb.conf.5.html#forcedirectorysecuritymode"><strong>"force directory security mode"</strong></a> parameter instead
209of <a href="smb.conf.5.html#forcesecuritymode"><strong>"force security mode"</strong></a>.
210<p>The <a href="smb.conf.5.html#directorysecuritymask"><strong>"directory security mask"</strong></a>
211parameter by default is set to the same value as the <a href="smb.conf.5.html#directorymask"><strong>"directory mask"</strong></a>
212parameter and the <a href="smb.conf.5.html#forcedirectorysecuritymode"><strong>"force directory security mode"</strong></a>
213parameter by default is set to the same value as the 
214iurl(<strong>"force directory mode"</strong>)(smb.conf.5.html#forcedirectorymode) parameter
215to provide compatibility with Samba 2.0.4 where the permission change facility was introduced.
216<p>In this way Samba enforces the permission restrictions that an administrator
217can set on a Samba share, whilst still allowing users to modify the
218permission bits within that restriction.
219<p>If you want to set up a share that allows users full control
220in modifying the permission bits on their files and directories and
221doesn't force any particular bits to be set 'on', then set the following
222parameters in the <a href="smb.conf.5.html"><strong>smb.conf.5</strong></a> file in
223that share specific section :
224<p><code>security mask = 0777</code>
225<code>force security mode = 0</code>
226<code>directory security mask = 0777</code>
227<code>force directory security mode = 0</code>
228<p>As described, in Samba 2.0.4 the parameters :
229<p><code>create mask</code>
230<code>force create mode</code>
231<code>directory mask</code>
232<code>force directory mode</code>
233<p>were used instead of the parameters discussed here.
234<p><strong>Interaction with the standard Samba file attribute mapping</strong><br>
235<strong>----------------------------------------------------------</strong>
236<p>Samba maps some of the DOS attribute bits (such as "read only")
237into the UNIX permissions of a file. This means there can be a
238conflict between the permission bits set via the security dialog
239and the permission bits set by the file attribute mapping.
240<p>One way this can show up is if a file has no UNIX read access
241for the owner it will show up as "read only" in the standard 
242file attributes tabbed dialog. Unfortunately this dialog is
243the same one that contains the security info in another tab.
244<p>What this can mean is that if the owner changes the permissions
245to allow themselves read access using the security dialog, clicks
246<code>"OK"</code> to get back to the standard attributes tab dialog, and
247then clicks <code>"OK"</code> on that dialog, then NT will set the file
248permissions back to read-only (as that is what the attributes
249still say in the dialog). This means that after setting permissions
250and clicking <code>"OK"</code> to get back to the attributes dialog you
251should always hit <code>"Cancel"</code> rather than <code>"OK"</code> to ensure
252that your changes are not overridden.
253</body>
254</html>
255