update links to 1.6.18; 10.9 gone, signing keys are problematic
[openafs-wiki.git] / UsageFAQ.mdwn
1 [[!toc levels=3]]
2
3 ## 2 Using AFS
4
5 The Usage Section of the [[AFSFrequentlyAskedQuestions]].
6
7 - [[PreambleFAQ]]
8 - [[GeneralFAQ]]
9 - [[AdminFAQ]]
10 - [[ResourcesFAQ]]
11 - [[AboutTheFAQ]]
12 - [[FurtherReading]]
13
14 ### 2.01 What are the differences between AFS and a Unix filesystem?
15
16 Essentially, from a user's point of view, there is little difference between AFS and local Unix filestore. Nearly all the commands normally used to access local files can be used to access files in `/afs`.
17
18 In the following set of sections, I have attempted to "target" each section to an appropriate type of user by including to the right of each section heading one of: User, Programmer, [[SysAdmin]].
19
20 Here is a summary of the differences:
21
22 **Authentication:** [ User ]
23
24 Before a user can access protected AFS files (s)he needs to become
25 authenticated to AFS using the `klog` command (Kerberos login) to get an AFS
26 token. Or, a user can run `aklog` to convert existing krb5 tickets into an AFS
27 token.
28
29 Without a token, an unauthenticated user is given the AFS identity `system:anyuser`, and as such is only able to access files in directories that have ACLs granting `system:anyuser` access.
30
31 Many systems have the `klog`/`aklog` functionality done integrated into their login procecedure. If you use a system where you have
32 to issue the `klog`/`aklog` command after login, then you may want to run the `pagsh` command first (see below).
33
34 AFS provides access control lists to give more precise control to users wishing to protect their files (see AFS ACL below).
35
36 **File permissions:** [ User ]
37
38 Unix mode bits on files are usually ignored. The exception to this are the "owner" bits, which can be used to remove access for almost everyone accessing the file (that is, if you remove the "w" bit from the owner permissions, almost nobody can write to the file).
39
40 Instead of Unix mode bits, you should generally use AFS ACLs to protect your data (see below).
41
42 **Data protection with AFS ACLs:** [ User ]
43
44 Some versions of Unix (e.g. IBM's AIX version 3) allow ACLs on local files. In AFS, ACLs protect directories and used with AFS protection groups (see below) provide a finer granularity of protection than can be achieved with basic Unix file permissions. (AFS ACLs are described in more detail below.)
45
46 **Protection groups:** [ User ]
47
48 Users can create and maintain their own protection groups in AFS - as opposed to Unix where only sysadmins can manage protection groups.
49
50 **Hard links:** [ User ]
51
52 In AFS, hard links (`ln old new`) are only valid within a directory. This is because AFS ACLs protect directories (not individual files), and allowing hard links that span directories would subvert ACL protection.
53
54 Symbolic links work in AFS because they reference a pathname and not an inode directly. (Hard links reference an inode directly.)
55
56 **Changing file protection by moving a file:** [ User ]
57
58 Moving a file to a different directory will change the protection of a file if the ACL on the new directory is different from the ACL on the original directory.
59
60 **chown and chgrp:** [ User ]
61
62 Only members of the AFS group `system:administrators` can use these commands on files in `/afs`. Note that these are only used by non-AFS-aware Unix utilities; AFS itself does not use these values, but instead uses the AFS ACL.
63
64 **Save on close:** [ Programmer ]
65
66 The AFS Cache Manager does not send file modifications to a file server until a `close()` or `fsync()` system call is performed. `write()` system calls only update the local cached copy on the client.
67
68 Note the difference in semantics of writing a file:
69
70 <table border="1">
71   <tr>
72     <th bgcolor="#99CCCC"><strong>local Unix file</strong></th>
73     <td>writes update the file immediately</td>
74   </tr>
75   <tr>
76     <th align="center" bgcolor="#99CCCC"><strong>AFS file</strong></th>
77     <td>local cached copy updated immediately but the server copy is only updated when the file is `close`d or `fsync`ed</td>
78   </tr>
79 </table>
80
81 It is important to understand that most applications (`vi`, `emacs`, `frame`, `interleaf`, `wingz`, `dogz`, etc.) issue the `close()` system call when the user chooses/issues the "save" command in the application.
82
83 Users are not required to exit the application to save their changes back to the server.
84
85 **Byte-range file locking:** [ Programmer ]
86
87 AFS does not support byte-range locking within a file, although `lockf()` and `fcntl()` calls will return 0 (success). The first time a byte-range lock is attempted, AFS will display
88
89     afs: byte-range lock/unlock ignored; make sure no one else else is running this program.
90
91 There are a couple of platform-specific exceptions to this behavior. Currently (as of 1.6.2), Linux clients will enforce byte-range file locks for processes on the local client only. In addition, Windows clients attempt to simulate byte-range locks for local processes, and acquire full-file locks on the fileserver when a byte-range lock is requested.
92
93 Server-side byte range locking requires a protocol change, which is currently under consideration.
94
95 **Whole-file locking:** [ Programmer ]
96
97 AFS supports advisory locking of an entire file with `flock()`. Processes on the same client workstation that attempt to lock a file obey the proper locking semantics. Processes on different AFS clients requesting a lock on the same file would get `EWOULDBLOCK` returned.
98
99 **Character and block special files:** [ [[SysAdmin]] ]
100
101 AFS does not support character and block special files. The `mknod` command does not create either character or block special files under `/afs`.
102
103 ### 2.02 What is an AFS protection group?
104
105 A named list of users.
106
107 Group names are used in AFS ACLs to identify lists of users with particular access permissions.
108
109 In AFS, users can create and maintain their own protection groups. This is different to unix where only the system administrator can manage `/etc/group`.
110
111 AFS groups are stored in the protection database on fileserver(s) and managed by using the `pts` command.
112
113 An AFS group typically has the format `owner-id:group-name`. By default, only the owner of a group can change its members.
114
115 It is possible to have both users and IP addresses as members of an AFS group. By using an IP address like this you can specify all the users from the host with that IP address. Note that IP address membership is insecure, due to the possibility of packet spoofing and the inability of current AFS protocols to protect server communications that do not involve a user-based security token; the `rxgk` security protocol currently under development will enable token-protected access at the client machine level as well as the user level.
116
117 ### 2.03 What are the AFS-defined protection groups?
118
119 - `system:anyuser`
120   - Everyone who has access to an AFS client in any cell that is on the same network as your cell.
121
122 - `system:authuser`
123   - Everyone who has access to an AFS client in any cell that is on the same network as your cell **and** has valid tokens for your cell (i.e. has been authenticated in your cell).
124
125 - `system:administrators`
126   - Users who have privileges to execute some but not all system administrator commands.
127
128 ### 2.04 What is an AFS access control list (ACL)?
129
130 There is an ACL for every directory in AFS. The ACL specifies protection at the directory level (not file level) by listing permissions of users and/or groups to a directory. There is a maximum of 20 entries on an ACL.
131
132 For example:
133
134 An AFS ACL is displayed by using the `fs` command as shown below:
135
136     tweety@toontown $ fs listacl .
137     Access list for . is
138     Normal rights:
139       fac:coords rlidwka
140       system:anyuser rl
141
142 This ACL shows that members of the AFS protection group `fac:coords` have full access rights to the current directory and `system:anyuser` has only read and lookup rights.
143
144 The members of `fac:coords` can be determined by accessing the protection group database using the `pts` command as shown below:
145
146     tweety@toontown $ pts membership fac:coords
147     Members of fac:coords (id: -1577) are:
148       sylvester
149       roadrunner
150       yosemite.sam
151
152 ### 2.05 What are the AFS access rights?
153
154 In AFS, there are seven access rights that may be set or not set:
155
156 <table border="1">
157   <tr>
158     <th bgcolor="#99CCCC"><strong>lookup</strong></th>
159     <td><code>l</code></td>
160     <td>Permission to examine the ACL and traverse the directory (needed with most other access rights); permission to look up filenames in a directory</td>
161   </tr>
162   <tr>
163     <th bgcolor="#99CCCC"><strong>read</strong></th>
164     <td><code>r</code></td>
165     <td>View the contents of files in the directory</td>
166   </tr>
167   <tr>
168     <th bgcolor="#99CCCC"><strong>insert</strong></th>
169     <td><code>i</code></td>
170     <td>Add new files or sub-directories</td>
171   </tr>
172   <tr>
173     <th bgcolor="#99CCCC"><strong>write</strong></th>
174     <td><code>w</code></td>
175     <td>Modify file contents, use `chmod`</td>
176   </tr>
177   <tr>
178     <th bgcolor="#99CCCC"><strong>delete</strong></th>
179     <td><code>d</code></td>
180     <td>Remove file(s) in the directory</td>
181   </tr>
182   <tr>
183     <th bgcolor="#99CCCC"><strong>lock</strong></th>
184     <td><code>k</code></td>
185     <td>Permission for programs to `flock()` files in the directory</td>
186   </tr>
187   <tr>
188     <th bgcolor="#99CCCC"><strong>administer</strong></th>
189     <td><code>a</code></td>
190     <td>Ability to change the ACL</td>
191   </tr>
192 </table>
193
194 There are shorthand forms for some common permission combinations:
195
196 <table border="1">
197   <tr>
198     <th bgcolor="#99CCCC"><code>read</code></th>
199     <td><code>rl</code></td>
200     <td><em>read</em> and <em>lookup</em></td>
201   </tr>
202   <tr>
203     <th bgcolor="#99CCCC"><code>write</code></th>
204     <td><code>rlidwk</code></td>
205     <td>all rights except <em>administer</em></td>
206   </tr>
207   <tr>
208     <th bgcolor="#99CCCC"><code>all</code></th>
209     <td><code>rlidwka</code></td>
210     <td>all rights</td>
211   </tr>
212   <tr>
213     <th bgcolor="#99CCCC"><code>none</code></th>
214     <td></td>
215     <td>removes all rights</td>
216   </tr>
217 </table>
218
219 ### 2.06 What is `pagsh`?
220
221 A command to get a new shell with a process authentication group (PAG).
222
223 This is normally used if your system does not get AFS tokens on login. It is used to get a PAG prior to running `klog`/`aklog`.
224
225 The PAG uniquely identifies the user to the Cache Manager. Without a PAG, the Cache Manager uses the Unix UID to identify a user and tokens will be shared across all processes owned by that UID.
226
227 ### 2.07 Why use a PAG?
228
229 There are two reasons:
230
231 1. Child processes inherit the PAG and the AFS token so they are AFS authenticated.
232
233 1. For security: if you don't have a PAG, then the Cache Manager identifies you by Unix UID. Another user with `root` access to the client could `su` to you and thereby use your token.
234
235 ### 2.08 How can I tell if I have a PAG?
236
237 Usually you can tell if you have a PAG by typing `id`. (Platforms which are derived directly from AT&T System V Release 4, such as Solaris, will not show the additional group vector by default; if there is no `groups=` section in the output of `id`, try `id -a`.) A PAG is indicated by the appearance of one or two large integers in the list of groups.
238
239 For example:
240
241     sylvester@toontown $ id
242     uid=1000(sylvester) gid=20(staff) groups=33536,32533,20(staff),30(catz)
243
244 On Linux clients, your PAG may not show up as such a group in the group list. An alternative way to check on Linux is to look at your kernel keyring with `keyctl show`:
245
246     $ keyctl show
247     Session Keyring
248            -3 --alswrv   1000  1000  keyring: _ses.32603
249     819041549 ----s--v      0     0   \_ afs_pag: _pag
250
251 If you see an `afs_pag` key in the output, then you are in a PAG.
252
253 ### 2.09 Can I still run `cron` jobs with AFS?
254
255 Yes, but remember that in order to fully access files in AFS you have to be AFS authenticated. If your `cron` job doesn't `aklog` then it only gets `system:anyuser` access.
256
257 The preferred way to make use of Kerberos tickets and AFS tokens from a `cron` job is [[kstart|http://www.eyrie.org/~eagle/software/kstart/]]. If you are using the Heimdal implementation of Kerberos, you can also use its `kinit` with the `-afslog` option and a command.
258
259 Note that you can still run a `cron` job without getting a token, if the task does not need to be AFS authenticated. In this case, you may get `stderr` from the `cron` job if your `.profile` is not accessible because of the ACL protecting your `$HOME`. Simply redirect to `/dev/null`:
260
261     0 7 * * * $sys_anyuser_readable_dir/7AMdaily 2>/dev/null
262
263 ### 2.10 How much disk space does a 1-byte file occupy in AFS?
264
265 This varies depending on the filesystem used by the fileserver containing that file. Some filesystems may only use up 1024 bytes for such a file, and others may use 4096; still others may use more or fewer bytes.
266
267 ### 2.11 Is it possible to specify a user who is external to the current AFS cell on an ACL?
268
269 Yes. This requires setting up a cross-realm relationship with the Kerberos realm on the remote site, but this is possible. Typically you refer to "remote" users like `user@remote.cell`, and you can use them in ACLs, or add them to `pts` groups.
270
271 ### 2.12 Are there any problems printing files in `/afs`?
272
273 There are two common issues that come up with printing from AFS:
274
275 - the print client passes pathnames to the print service, which does not have access to your AFS token;
276
277 - if not using a PAG (UID-based tokens), `setuid` print clients don't have access to your AFS token.
278
279 Both of these may be mitigated by using shell redirection to send the file to the print client:
280
281     lpr < /afs/ny.toontown.com/home/elmer/private/wabbit-hunting
282
283 (The `lp` command generally supports the `-c` option to force a file copy. Note that the `lp` command provided with [[CUPS|http://cups.org]] *always* works this way, and makes a connection to the server to transfer the file instead of copying it to a secure queue area directly, so should not have token issues at all.)
284
285 Very few print services have the ability to manage token access in a way that allows an ACL-protected file to be printed by pathname without enabling access control to be subverted by users by means of the print service. It is **not** recommended to grant the print service general access to AFS by means of [[kstart|http://www.eyrie.org/software/kstart/]] or similar mechanisms.
286
287 ### 2.13 Can I create a FIFO (a/k/a named pipe) in `/afs`?
288
289 No. AFS does not support `mknod fifofile p`. AFS only supports normal files, directories, and symlinks; not Unix- or Windows-specific filesystem node types.
290
291 ### 2.14 If an AFS server crashes, do I have to reboot my AFS client?
292
293 No.
294
295 Typically, if an AFS server becomes unavailable, the AFS Cache Manager on your AFS client will see you through the outage until the server returns. This robustness is dependent on the way your AFS cell has been configured including the following factors:
296
297 - On the client side:
298   - How big is the cache?
299   - Are the files you need already in the cache?
300
301 - On the server side:
302   - How many servers? It's best to have a minimum of three.
303   - Is the data you are accessing replicated? In AFS, replicas are [[ReadOnly]] copies.
304
305 With replicated volumes, the AFS Cache Manager knows about all of the servers on which the replicas are located. Therefore, when the Cache Manager accesses a replicated volume, if the RPC times out, the Cache Manager automatically retrys the RPC, using a different file server.
306
307 If necessary, the Cache Manager will attempt to contact all file servers on which a replica of the volume resides.
308
309 If you are accessing [[ReadWrite]] volumes on a crashed server then you will not be able to save changes back to the server until it returns.
310
311 You don't need to reboot, and the Cache Manager activity is "invisible" to the user. You may want to speed up recovery by issuing the command `fs checkservers`, but even this is unnecessary and will usually only improve recovery by a few seconds.
312
313 ### 2.15 Can I use AFS on my diskless workstation?
314
315 Yes. The AFS Cache Manager can be configured to work with either a disk based cache or a memory (RAM) based cache.
316
317 Note that using a memory cache may not be as fast as you might think. Modern operating systems should cache disk data in memory when accessed, so using a disk cache should mean you are hitting RAM most of the time anyway. Disk caches are also much more common, and thus much more heavily tested, and so are better optimized. If you have a local disk and it's reasonably fast, usually going with a disk cache is preferable to memory cache. Additionally, most operating systems do a better job of optimizing a native RAM disk, so you might consider putting your AFS cache in a RAM disk instead of using [[OpenAFS]]'s own memory cache.
318
319 ### 2.16 Can I test for AFS tokens from within my program?
320
321 Yes. However, the mechanism for doing so varies depending on the platform. To see examples of how to do this, you can look at the source of any program that deals with AFS tokens. One such example is [pam-afs-session](http://www.eyrie.org/~eagle/software/pam-afs-session/)
322
323 ### 2.17 What's the difference between `/afs/cellname` and `/afs/.cellname`?
324
325 AFS has [[ReadOnly]] (RO) and [[ReadWrite]] (RW) volumes.
326
327 The convention in AFS is to mount the RW volume `root.cell` as `/afs/.cellname` and the RO volume `root.cell.readonly` as `/afs/cellname`. This is so that when you travel down the `/afs/.cellname` link, AFS will always use the RW site of any volumes that have RO clones. This allows your administrator to update the RW copy of a volume and `vos release $volname` so that it will appear in `/afs/cellname`.
328
329 ### 2.18 Can I `aklog` as two users on a machine in the same cell?
330
331 Yes, *if* you use two different PAGs. The token store only supports one token per cell per authentication group; with UID-based PAGs, this means one token per cell per user, but with PAGs you can have multiple shell windows/sessions, each with its own PAG and associated AFS tokens.
332
333 Note that most Kerberos implementations (the one on Mac OS X 10.7 and 10.8 being a notable exception) only allow a ticket-granting ticket (TGT) for a single principal (this restriction is even tighter than AFS's, as you cannot have a separate TGT per realm!), so if you plan to use separate PAGs you will also want to use separate credential caches ("ticket files" in older Kerberos parlance).
334
335 An alternative to using multiple users in this way is to use ACLs to grant access on a shared directory to both users.
336
337 ### 2.19 What are the `~/.__afsXXXX` files?
338
339 They are temporary reference files used by the AFS Cache Manager.
340
341 With most Unix filesystems, when you a remove a file that is kept open by a process, the file stays around physically while it is no longer referenced in any directory (which you will see as a mismatch between disk space usage according to `df` and `du`).
342
343 Some applications rely on that feature, e.g. they create a temporary file and remove it immediatley while keeping the file descriptor open. The file then disappears from the filesystem automatically when the process terminates or the file descriptor gets closed otherwise. Such applications could get into trouble with older versions of AFS, where the file could really disappear while it was held open.
344
345 Newer versions of AFS rename such files to `.__afsXXXX`, thus making sure that the data stays around as expected by the application. As soon as the file gets closed, the associated `.__afsXXXX` should disappear.
346
347 ### 2.20 How do you set up IP-based ACLs?
348
349 See [[IPAccessControl]].
350
351 ### 2.21 What meaning do the owner, group, and mode bits have in AFS?
352
353 In order to appear more like a local filesystem, AFS will faithfully store the numeric UID (owner), GID (group), for both files and directories, as well as the permission bits (read, write, and execute for user, group, and other, plus `setuid`, `setgid`, and "sticky" bits) for files. Note that permission bits for directories are not stored.
354
355 For the most part, these values are simply recorded and reported back when requested. However, in some instances the fileserver and/or cache manager will make access control decisions based in part on these values. The following is believed to be a complete list of those circumstances. Below, "owner" refers to the user whose numeric `pts` identity is equal to the owner of the file or directory; this might not bear any relationship to the UNIX UID associated with the client process that created the file.
356
357 - implicit ACLs
358   - the owner of the root directory of a volume has implicit _administer_ (`a`) rights on all directories in the volume
359   - the owner of a file has implicit _read_ (`r`) and _write_ (`w`) rights on a file if that user has _insert_ (`i`) rights on its parent directory
360
361 - to **read** from a file, you must have _read_ (`r`) rights _and_ at least one of the following must be true:
362   - the file's `u+r` (user read, `0400` octal) bit is set
363   - you are the owner of the file
364   - you are a member of `system:administrators`
365
366 - to **write** to a file, you must have _write_ (`w`) rights _and_ at least one of the following must be true:
367   - the file's `u+w` (user write, `0200` octal) bit is set
368   - you are the owner of the file
369   - you are a member of `system:administrators`
370
371 - changing mode bits and owner/group:
372   - the fileserver will only allow the mode bits on a file (`ugo+rwx`) to be changed if the user has _write_ (`w`) and _lookup_ (`l`) rights on the file's parent directory
373   - the fileserver will only allow the mode bits on a directory to be changed if the user has _delete_ (`d`), _insert_ (`i`), and _lookup_ (`l`) rights on the directory
374   - only members of `system:administrators` can change the owner or group of a file
375   - only members of `system:administrators` can change the `setuid` and `setgid` bits on a file
376
377 The "sticky" bit, group of a file, `g+rwx` (octal `0070`), and `o+rwx` (octal `0007`) bits are completely ignored by all AFS components. Additionally, the `u+rwx` (octal `0700`) bits are ignored on directories.
378
379 Newly created files and directories are given an owner numerically equal to the `pts` identity of the user who created the file or directory. Initial mode bits are assigned by the AFS cilent, typically based on the creating user's `umask`.
380
381 ### 2.22 What are "dropboxes"?
382
383 When the ACL on a directory is set to `irl` (_read_, _list_, _insert_), this creates what is called a "dropbox". In theory, users should be able to deposit files in the directory, but not modify them once deposited.
384
385 In practice, the "not modify them once deposited" part is not enforced by the fileserver; only the [[OpenAFS]] client enforces this restriction. Thus, you should not depend on this for security.
386
387 Also, note that a `system:anyuser irl` ACL has an additional problems: because dropbox semantics are based on `pts` identities (see question 2.21), the fileserver cannot distinguish between two unauthenticated users. So, not only can a user come back days later and modify the "dropped" file, but **any** user can modify a file dropped by an unauthenticated user, at any time. 
388
389 ### 2.23 Can I access a RW volume using the RO path?
390
391 Depends. Once you have RO-Volumes released, a mountpoint pointing to the RO will bring you to the RO volume. To change that behavior, you have to change the corresponding mountpoint with `fs rmmount` and `fs mkmount -rw`. However, for some situations, like software installations, it might be useful to reach the RW volume through the RO path.
392
393 You can do that for a single client with a special setup. The trick is to break the convention described in 2.17 for a single client: mount the RW volume `root.cell` (instead of `root.cell.readonly`) as `/afs/cellname`. This can be done by creating an alternative `root.afsrw` volume which is identical to `root.afs` except that it has an RW mount for `root.cell`, then add `-rootvol root.afsrw` to the `afsd` command options on startup (either in `/etc/init.d/afs` or wherever your system stores service configuation; this is often `/usr/vice/etc/config/afsd.options` on most Unixes and `/etc/sysconfig/afs` on many Linux distributions) and ensure that the `-dynroot` option is *not* specified.