- Add &author.mimir; entity
[Samba/gebeck_regimport.git] / docs / docbook / projdoc / NT_Security.sgml
blob9bff25337c3c68675e5de08db5b7ed2106b1d8cf
1 <chapter id="unix-permissions">
2 <chapterinfo>
3 &author.jeremy;
4 <pubdate>12 Apr 1999</pubdate>
5 </chapterinfo>
7 <title>UNIX Permission Bits and Windows NT Access Control Lists</title>
9 <sect1>
10 <title>Viewing and changing UNIX permissions using the NT
11 security dialogs</title>
13 <para>Windows NT clients can use their native security settings
14 dialog box to view and modify the underlying UNIX permissions.</para>
16 <para>Note that this ability is careful not to compromise
17 the security of the UNIX host Samba is running on, and
18 still obeys all the file permission rules that a Samba
19 administrator can set.</para>
21 <note>
22 <para>
23 All access to Unix/Linux system file via Samba is controlled at
24 the operating system file access control level. When trying to
25 figure out file access problems it is vitally important to identify
26 the identity of the Windows user as it is presented by Samba at
27 the point of file access. This can best be determined from the
28 Samba log files.
29 </para>
30 </note>
31 </sect1>
33 <sect1>
34 <title>How to view file security on a Samba share</title>
36 <para>From an NT4/2000/XP client, single-click with the right
37 mouse button on any file or directory in a Samba mounted
38 drive letter or UNC path. When the menu pops-up, click
39 on the <emphasis>Properties</emphasis> entry at the bottom of
40 the menu. This brings up the file properties dialog
41 box. Click on the tab <emphasis>Security</emphasis> and you
42 will see three buttons, <emphasis>Permissions</emphasis>,
43 <emphasis>Auditing</emphasis>, and <emphasis>Ownership</emphasis>.
44 The <emphasis>Auditing</emphasis> button will cause either
45 an error message <errorname>A requested privilege is not held
46 by the client</errorname> to appear if the user is not the
47 NT Administrator, or a dialog which is intended to allow an
48 Administrator to add auditing requirements to a file if the
49 user is logged on as the NT Administrator. This dialog is
50 non-functional with a Samba share at this time, as the only
51 useful button, the <command>Add</command> button will not currently
52 allow a list of users to be seen.</para>
54 </sect1>
56 <sect1>
57 <title>Viewing file ownership</title>
59 <para>Clicking on the <command>"Ownership"</command> button
60 brings up a dialog box telling you who owns the given file. The
61 owner name will be of the form :</para>
63 <para><command>"SERVER\user (Long name)"</command></para>
65 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
66 the Samba server, <replaceable>user</replaceable> is the user name of
67 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
68 is the descriptive string identifying the user (normally found in the
69 GECOS field of the UNIX password database). Click on the <command>Close
70 </command> button to remove this dialog.</para>
72 <para>If the parameter <parameter>nt acl support</parameter>
73 is set to <constant>false</constant> then the file owner will
74 be shown as the NT user <command>"Everyone"</command>.</para>
76 <para>The <command>Take Ownership</command> button will not allow
77 you to change the ownership of this file to yourself (clicking on
78 it will display a dialog box complaining that the user you are
79 currently logged onto the NT client cannot be found). The reason
80 for this is that changing the ownership of a file is a privileged
81 operation in UNIX, available only to the <emphasis>root</emphasis>
82 user. As clicking on this button causes NT to attempt to change
83 the ownership of a file to the current user logged into the NT
84 client this will not work with Samba at this time.</para>
86 <para>There is an NT chown command that will work with Samba
87 and allow a user with Administrator privilege connected
88 to a Samba server as root to change the ownership of
89 files on both a local NTFS filesystem or remote mounted NTFS
90 or Samba drive. This is available as part of the <emphasis>Seclib
91 </emphasis> NT security library written by Jeremy Allison of
92 the Samba Team, available from the main Samba ftp site.</para>
94 </sect1>
96 <sect1>
97 <title>Viewing file or directory permissions</title>
99 <para>The third button is the <command>"Permissions"</command>
100 button. Clicking on this brings up a dialog box that shows both
101 the permissions and the UNIX owner of the file or directory.
102 The owner is displayed in the form :</para>
104 <para><command>"SERVER\user (Long name)"</command></para>
106 <para>Where <replaceable>SERVER</replaceable> is the NetBIOS name of
107 the Samba server, <replaceable>user</replaceable> is the user name of
108 the UNIX user who owns the file, and <replaceable>(Long name)</replaceable>
109 is the descriptive string identifying the user (normally found in the
110 GECOS field of the UNIX password database).</para>
112 <para>If the parameter <parameter>nt acl support</parameter>
113 is set to <constant>false</constant> then the file owner will
114 be shown as the NT user <command>"Everyone"</command> and the
115 permissions will be shown as NT "Full Control".</para>
118 <para>The permissions field is displayed differently for files
119 and directories, so I'll describe the way file permissions
120 are displayed first.</para>
122 <sect2>
123 <title>File Permissions</title>
125 <para>The standard UNIX user/group/world triple and
126 the corresponding "read", "write", "execute" permissions
127 triples are mapped by Samba into a three element NT ACL
128 with the 'r', 'w', and 'x' bits mapped into the corresponding
129 NT permissions. The UNIX world permissions are mapped into
130 the global NT group <command>Everyone</command>, followed
131 by the list of permissions allowed for UNIX world. The UNIX
132 owner and group permissions are displayed as an NT
133 <command>user</command> icon and an NT <command>local
134 group</command> icon respectively followed by the list
135 of permissions allowed for the UNIX user and group.</para>
137 <para>As many UNIX permission sets don't map into common
138 NT names such as <command>"read"</command>, <command>
139 "change"</command> or <command>"full control"</command> then
140 usually the permissions will be prefixed by the words <command>
141 "Special Access"</command> in the NT display list.</para>
143 <para>But what happens if the file has no permissions allowed
144 for a particular UNIX user group or world component ? In order
145 to allow "no permissions" to be seen and modified then Samba
146 overloads the NT <command>"Take Ownership"</command> ACL attribute
147 (which has no meaning in UNIX) and reports a component with
148 no permissions as having the NT <command>"O"</command> bit set.
149 This was chosen of course to make it look like a zero, meaning
150 zero permissions. More details on the decision behind this will
151 be given below.</para>
152 </sect2>
154 <sect2>
155 <title>Directory Permissions</title>
157 <para>Directories on an NT NTFS file system have two
158 different sets of permissions. The first set of permissions
159 is the ACL set on the directory itself, this is usually displayed
160 in the first set of parentheses in the normal <command>"RW"</command>
161 NT style. This first set of permissions is created by Samba in
162 exactly the same way as normal file permissions are, described
163 above, and is displayed in the same way.</para>
165 <para>The second set of directory permissions has no real meaning
166 in the UNIX permissions world and represents the <command>
167 "inherited"</command> permissions that any file created within
168 this directory would inherit.</para>
170 <para>Samba synthesises these inherited permissions for NT by
171 returning as an NT ACL the UNIX permission mode that a new file
172 created by Samba on this share would receive.</para>
173 </sect2>
174 </sect1>
176 <sect1>
177 <title>Modifying file or directory permissions</title>
179 <para>Modifying file and directory permissions is as simple
180 as changing the displayed permissions in the dialog box, and
181 clicking the <command>OK</command> button. However, there are
182 limitations that a user needs to be aware of, and also interactions
183 with the standard Samba permission masks and mapping of DOS
184 attributes that need to also be taken into account.</para>
186 <para>If the parameter <parameter>nt acl support</parameter>
187 is set to <constant>false</constant> then any attempt to set
188 security permissions will fail with an <command>"Access Denied"
189 </command> message.</para>
191 <para>The first thing to note is that the <command>"Add"</command>
192 button will not return a list of users in Samba (it will give
193 an error message of <command>"The remote procedure call failed
194 and did not execute"</command>). This means that you can only
195 manipulate the current user/group/world permissions listed in
196 the dialog box. This actually works quite well as these are the
197 only permissions that UNIX actually has.</para>
199 <para>If a permission triple (either user, group, or world)
200 is removed from the list of permissions in the NT dialog box,
201 then when the <command>"OK"</command> button is pressed it will
202 be applied as "no permissions" on the UNIX side. If you then
203 view the permissions again the "no permissions" entry will appear
204 as the NT <command>"O"</command> flag, as described above. This
205 allows you to add permissions back to a file or directory once
206 you have removed them from a triple component.</para>
208 <para>As UNIX supports only the "r", "w" and "x" bits of
209 an NT ACL then if other NT security attributes such as "Delete
210 access" are selected then they will be ignored when applied on
211 the Samba server.</para>
213 <para>When setting permissions on a directory the second
214 set of permissions (in the second set of parentheses) is
215 by default applied to all files within that directory. If this
216 is not what you want you must uncheck the <command>"Replace
217 permissions on existing files"</command> checkbox in the NT
218 dialog before clicking <command>"OK"</command>.</para>
220 <para>If you wish to remove all permissions from a
221 user/group/world component then you may either highlight the
222 component and click the <command>"Remove"</command> button,
223 or set the component to only have the special <command>"Take
224 Ownership"</command> permission (displayed as <command>"O"
225 </command>) highlighted.</para>
226 </sect1>
228 <sect1>
229 <title>Interaction with the standard Samba create mask
230 parameters</title>
232 <para>There are four parameters
233 to control interaction with the standard Samba create mask parameters.
234 These are :</para>
236 <para><parameter>security mask</parameter></para>
237 <para><parameter>force security mode</parameter></para>
238 <para><parameter>directory security mask</parameter></para>
239 <para><parameter>force directory security mode</parameter></para>
241 <para>Once a user clicks <command>"OK"</command> to apply the
242 permissions Samba maps the given permissions into a user/group/world
243 r/w/x triple set, and then will check the changed permissions for a
244 file against the bits set in the <ulink url="smb.conf.5.html#SECURITYMASK">
245 <parameter>security mask</parameter></ulink> parameter. Any bits that
246 were changed that are not set to '1' in this parameter are left alone
247 in the file permissions.</para>
249 <para>Essentially, zero bits in the <parameter>security mask</parameter>
250 mask may be treated as a set of bits the user is <emphasis>not</emphasis>
251 allowed to change, and one bits are those the user is allowed to change.
252 </para>
254 <para>If not set explicitly this parameter is set to the same value as
255 the <ulink url="smb.conf.5.html#CREATEMASK"><parameter>create mask
256 </parameter></ulink> parameter. To allow a user to modify all the
257 user/group/world permissions on a file, set this parameter
258 to 0777.</para>
260 <para>Next Samba checks the changed permissions for a file against
261 the bits set in the <ulink url="smb.conf.5.html#FORCESECURITYMODE">
262 <parameter>force security mode</parameter></ulink> parameter. Any bits
263 that were changed that correspond to bits set to '1' in this parameter
264 are forced to be set.</para>
266 <para>Essentially, bits set in the <parameter>force security mode
267 </parameter> parameter may be treated as a set of bits that, when
268 modifying security on a file, the user has always set to be 'on'.</para>
270 <para>If not set explicitly this parameter is set to the same value
271 as the <ulink url="smb.conf.5.html#FORCECREATEMODE"><parameter>force
272 create mode</parameter></ulink> parameter.
273 To allow a user to modify all the user/group/world permissions on a file
274 with no restrictions set this parameter to 000.</para>
276 <para>The <parameter>security mask</parameter> and <parameter>force
277 security mode</parameter> parameters are applied to the change
278 request in that order.</para>
280 <para>For a directory Samba will perform the same operations as
281 described above for a file except using the parameter <parameter>
282 directory security mask</parameter> instead of <parameter>security
283 mask</parameter>, and <parameter>force directory security mode
284 </parameter> parameter instead of <parameter>force security mode
285 </parameter>.</para>
287 <para>The <parameter>directory security mask</parameter> parameter
288 by default is set to the same value as the <parameter>directory mask
289 </parameter> parameter and the <parameter>force directory security
290 mode</parameter> parameter by default is set to the same value as
291 the <parameter>force directory mode</parameter> parameter. </para>
293 <para>In this way Samba enforces the permission restrictions that
294 an administrator can set on a Samba share, whilst still allowing users
295 to modify the permission bits within that restriction.</para>
297 <para>If you want to set up a share that allows users full control
298 in modifying the permission bits on their files and directories and
299 doesn't force any particular bits to be set 'on', then set the following
300 parameters in the &smb.conf; file in that share specific section :</para>
302 <para><parameter>security mask = 0777</parameter></para>
303 <para><parameter>force security mode = 0</parameter></para>
304 <para><parameter>directory security mask = 0777</parameter></para>
305 <para><parameter>force directory security mode = 0</parameter></para>
306 </sect1>
308 <sect1>
309 <title>Interaction with the standard Samba file attribute
310 mapping</title>
312 <para>Samba maps some of the DOS attribute bits (such as "read
313 only") into the UNIX permissions of a file. This means there can
314 be a conflict between the permission bits set via the security
315 dialog and the permission bits set by the file attribute mapping.
316 </para>
318 <para>One way this can show up is if a file has no UNIX read access
319 for the owner it will show up as "read only" in the standard
320 file attributes tabbed dialog. Unfortunately this dialog is
321 the same one that contains the security info in another tab.</para>
323 <para>What this can mean is that if the owner changes the permissions
324 to allow themselves read access using the security dialog, clicks
325 <command>"OK"</command> to get back to the standard attributes tab
326 dialog, and then clicks <command>"OK"</command> on that dialog, then
327 NT will set the file permissions back to read-only (as that is what
328 the attributes still say in the dialog). This means that after setting
329 permissions and clicking <command>"OK"</command> to get back to the
330 attributes dialog you should always hit <command>"Cancel"</command>
331 rather than <command>"OK"</command> to ensure that your changes
332 are not overridden.</para>
333 </sect1>
335 </chapter>