1 ## <a name="2 Using AFS"></a> 2 Using AFS
3 The Usage Section of the [[AFSFrequentlyAskedQuestions]].
10 <li><a href="#2 Using AFS"> 2 Using AFS</a><ul>
11 <li><a href="#2.01 What are the differences b"> 2.01 What are the differences between AFS and a unix filesystem?</a></li>
12 <li><a href="#2.02 What is an AFS protection"> 2.02 What is an AFS protection group?</a></li>
13 <li><a href="#2.03 What are the AFS defined p"> 2.03 What are the AFS defined protection groups?</a></li>
14 <li><a href="#2.04 What is an AFS access cont"> 2.04 What is an AFS access control list (ACL)?</a></li>
15 <li><a href="#2.05 What are the AFS access ri"> 2.05 What are the AFS access rights?</a></li>
16 <li><a href="#2.06 What is pagsh?"> 2.06 What is pagsh?</a></li>
17 <li><a href="#2.07 Why use a PAG?"> 2.07 Why use a PAG?</a></li>
18 <li><a href="#2.08 How can I tell if I have a"> 2.08 How can I tell if I have a PAG?</a></li>
19 <li><a href="#2.09 Can I still run cron jobs"> 2.09 Can I still run cron jobs with AFS?</a></li>
20 <li><a href="#2.10 How much disk space does a"> 2.10 How much disk space does a 1 byte file occupy in AFS?</a></li>
21 <li><a href="#2.11 Is it possible to specify"> 2.11 Is it possible to specify a user who is external to the current AFS cell on an ACL?</a></li>
22 <li><a href="#2.12 Are there any problems pri"> 2.12 Are there any problems printing files in /afs?</a></li>
23 <li><a href="#2.13 Can I create a fifo (aka n"> 2.13 Can I create a fifo (aka named pipe) in /afs?</a></li>
24 <li><a href="#2.14 If an AFS server crashes,"> 2.14 If an AFS server crashes, do I have to reboot my AFS client?</a></li>
25 <li><a href="#2.15 Can I use AFS on my diskle"> 2.15 Can I use AFS on my diskless workstation?</a></li>
26 <li><a href="#2.16 Can I test for AFS tokens"> 2.16 Can I test for AFS tokens from within my program?</a></li>
27 <li><a href="#2.17 What's the difference betw"> 2.17 What's the difference between /afs/cellname and /afs/.cellname?</a></li>
28 <li><a href="#2.18 Can I klog as two users on"> 2.18 Can I klog as two users on a machine in the same cell?</a></li>
29 <li><a href="#2.19 What are the ~/._afsXXXX f"> 2.19 What are the ~/.__afsXXXX files?</a></li>
30 <li><a href="#2.20 How do you set up IP-based"> 2.20 How do you set up IP-based ACLs?</a></li>
31 <li><a href="#2.21 What meaning do the owner,"> 2.21 What meaning do the owner, group, and mode bits have in AFS?</a></li>
32 <li><a href="#2.22 What are "dropboxes"?"> 2.22 What are "dropboxes"?</a></li>
33 <li><a href="#2.23 Can I access a RW-Volume">2.23 Can I access a RW-Volume using the RO-Path ?</a></li>
44 ### <a name="2.01 What are the differences b"></a> 2.01 What are the differences between AFS and a unix filesystem?
46 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.
48 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]].
50 Here is a summary of the differences:
52 **Authentication:** [ User ]
54 Before a user can access protected AFS files (s)he needs to become
55 authenticated to AFS using the klog command (Kerberos login) to get an AFS
56 token. Or, a user can run "aklog" to convert existing krb5 tickets into an AFS
59 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.
61 Many systems have the klog/aklog functionality done automatically when the user
62 logs in via PAM or some other login process. If you use a system where you have
63 to issue the klog/aklog command after login, then you may want to run the pagsh
64 command first (see below).
66 AFS provides access control lists to give more precise control to users wishing to protect their files (see AFS ACL below).
68 **File permissions:** [ User ]
70 Unix mode bits on files are usually ignored. The exception to this are the
71 "owner" bits, which can be used to remove access for almost everyone accessing
72 the file (that is, if you remove the "w" bit from the owner permissions, almost
73 nobody can write to the file).
75 Instead of Unix mode bits, you should generally use AFS ACLs to protect your
78 **Data protection with AFS ACLs:** [ User ]
80 Some versions of unix (eg 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.)
82 **Protection groups:** [ User ]
84 Users can create and maintain their own protection groups in AFS - as opposed to unix where only sys admins can manage protection groups.
86 **Hard links:** [ User ]
88 In AFS, hard links (eg: 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.
90 Symbolic links work in AFS because they reference a pathname and not an i-node directly. (Hard links reference an i-node directly.)
92 **Changing file protection by moving a file:** [ User ]
94 Moving a file to a different directory will change the protection of a file if the ACL on the new directory if different to the ACL on the original directory.
96 **chown and chgrp:** [ User ]
98 Only members of the AFS group "system:administrators" can use these commands on files in /afs.
100 **Save on close:** [ Programmer ]
102 AFS Cache Manager does not send file modifications to a file server until the close() or fsync() system call.
104 write() system calls only update the local cache copy on the client.
106 Note the difference in semantic of writing a file:
108 <table border="1" cellpadding="0" cellspacing="0">
110 <th bgcolor="#99CCCC"><strong> local unix file: </strong></th>
111 <td> writes update the file "immediately" </td>
114 <th align="center" bgcolor="#99CCCC"><strong> AFS file: </strong></th>
115 <td> local cached copy updated "immediately" but the server copy is only updated when the file is closed or fsync'ed. </td>
119 It is important to understand that most applications (eg: vi, emacs, frame, interleaf, wingz, dogz, etc) issue the close() system call when the user chooses/issues the "save" command in the application.
121 Users are not required to exit the application to "save" their changes back to the server.
123 **byte-range file locking:** [ Programmer ]
125 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:
127 "afs: byte-range lock/unlock ignored; make sure no one else else is running this program."
129 There are a couple of platform-specific exceptions to this behavior. Currently
130 (as of 1.6.2), Linux clients will enforce byte-range file locks for processes
131 on the local client only. In addition, Windows clients attempt to simulate
132 byte-range locks for local processes, and acquire full-file locks on the
133 fileserver when a byte-range lock is requested.
135 **whole file locking:** [ Programmer ]
137 AFS does support advisory locking an entire file with flock(). Processes on the same client workstation that attempt to lock a file obey the proper locking semantics.
139 Processes on different AFS clients requesting a lock on the same file would get EWOULDBLOCK returned.
141 **character and block special files:** [ [[SysAdmin]] ]
143 AFS does not support character and block special files. The mknod command does not create either character or block special files in /afs.
145 ### <a name="2.02 What is an AFS protection"></a><a name="2.02 What is an AFS protection "></a> 2.02 What is an AFS protection group?
147 A named list of users.
149 Group names are used in AFS ACLs to identify lists of users with particular access permissions.
151 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.
153 AFS groups are stored in the protection database on fileserver(s) and managed by using the "pts" command.
155 An AFS group typically has the format:
157 - owner-id:group-name
159 By default, only the owner of a group can change its members.
161 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.
163 ### <a name="2.03 What are the AFS defined p"></a> 2.03 What are the AFS defined protection groups?
166 - Everyone who has access to an AFS client in any cell that is on the same network as your cell.
169 - 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 (ie has been authenticated in your cell).
171 - system:administrators
172 - Users who have privileges to execute some but not all system administrator commands.
174 ### <a name="2.04 What is an AFS access cont"></a> 2.04 What is an AFS access control list (ACL)?
176 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.
180 An AFS ACL is displayed by using the "fs" command as shown below:
182 tweety@toontown $ fs listacl .
188 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.
190 The members of "fac:coords" can be determined by accessing the protection group database using the "pts" command as shown below:
192 tweety@toontown $ pts membership fac:coords
193 Members of fac:coords (id: -1577) are:
198 ### <a name="2.05 What are the AFS access ri"></a> 2.05 What are the AFS access rights?
200 In AFS, there are seven access rights that may be set or not set:
202 <table border="1" cellpadding="0" cellspacing="0">
204 <th bgcolor="#99CCCC"><strong> lookup </strong></th>
205 <td><code>l</code></td>
206 <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>
209 <th bgcolor="#99CCCC"><strong> read </strong></th>
210 <td><code>r</code></td>
211 <td> View the contents of files in the directory </td>
214 <th bgcolor="#99CCCC"><strong> insert </strong></th>
215 <td><code>i</code></td>
216 <td> Add new files or sub-directories </td>
219 <th bgcolor="#99CCCC"><strong> write </strong></th>
220 <td><code>w</code></td>
221 <td> Modify file contents, use "chmod" </td>
224 <th bgcolor="#99CCCC"><strong> delete </strong></th>
225 <td><code>d</code></td>
226 <td> Remove file(s) in directory </td>
229 <th bgcolor="#99CCCC"><strong> lock </strong></th>
230 <td><code>k</code></td>
231 <td> Permission for programs to "flock" files in the directory </td>
234 <th bgcolor="#99CCCC"><strong> administer </strong></th>
235 <td><code>a</code></td>
236 <td> Ability to change the ACL </td>
240 There are short-hand forms:
242 <table border="1" cellpadding="0" cellspacing="0">
244 <th bgcolor="#99CCCC"><strong> read </strong></th>
245 <td><code>rl</code></td>
246 <td> read and lookup </td>
249 <th bgcolor="#99CCCC"><strong> write </strong></th>
250 <td><code>rlidwk</code></td>
251 <td> all rights except administer </td>
254 <th bgcolor="#99CCCC"><strong> all </strong></th>
255 <td><code>rlidwka</code></td>
256 <td> all rights </td>
259 <th bgcolor="#99CCCC"><strong> none </strong></th>
261 <td> removes all rights </td>
265 ### <a name="2.06 What is pagsh?"></a> 2.06 What is pagsh?
267 A command to get a new shell with a process authentication group (PAG).
269 This is normally used if your system does not get AFS tokens on login. It is
270 used to get a PAG prior to running klog/aklog.
272 The PAG uniquely identifies the user to the Cache Manager. Without a PAG the Cache Manager uses the unix UID to identify a user.
274 ### <a name="2.07 Why use a PAG?"></a> 2.07 Why use a PAG?
276 There are two reasons:
278 1. Child processes inherit the PAG and the AFS token so they are AFS authenticated.
280 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 therefore use your token.
282 ### <a name="2.08 How can I tell if I have a"></a> 2.08 How can I tell if I have a PAG?
284 Usually you can tell if you have a PAG by typing "groups". A PAG is indicated
285 by the appearance of one or two large integers in the list of groups.
289 sylvester@toontown $ groups
290 33536 32533 staff catz
292 On Linux clients, your PAG may not show up as such a group in the group list.
293 An alternative way to check on Linux is to look at your kernel keyring with
298 -3 --alswrv 1000 1000 keyring: _ses.32603
299 819041549 ----s--v 0 0 \_ afs_pag: _pag
301 If you see an afs_pag key in the output, then you are in a PAG.
303 ### <a name="2.09 Can I still run cron jobs"></a><a name="2.09 Can I still run cron jobs "></a> 2.09 Can I still run cron jobs with AFS?
305 Yes, but remember that in order to fully access files in AFS you have to be AFS authenticated. If your cron job doesn't klog then it only gets system:anyuser access.
307 The klog command has a "-pipe" option which will read a password from stdin. IF (yes, that's a big if) you are prepared to store your password in a local (non-AFS) file then you might use the following:
309 (a) create a "wrapper" script to get a PAG, get your AFS token and execute a command:
311 #!/usr/afsws/bin/pagsh
314 # AUTHOR Paul Blackburn <mpb@acm.org>
315 # PURPOSE Run an AFS authenticated cron job.
316 # Get a PAG, get the user's token,
317 # then exec user's command
322 echo "Usage: ${CMD} [ -principal AFSID ] passwordfile command" >&2
325 if [ ${1} = "-principal" ]; then
326 PRINCIPAL="${1} ${2}"
330 if [ -z "${1}" ]; then
331 echo "${CMD} error: need name of password file" >&2
339 /usr/afsws/bin/klog ${PRINCIPAL} -pipe < ${passwordfile}
341 if [ -z "${1}" ]; then
342 echo "${CMD} error: need name of command to run" >&2
347 command=`echo ${command_line} | awk '{print $1}'`
349 # Check if we can run the command.
350 # If we got this far, it is likely that the command name is correct
351 # but there may be a problem in accessing the command file.
352 # If there is an error, log it via syslog (logger) rather than ">&2"
354 if [ ! -x "${command}" ]; then
355 M="error: unable to execute command ${command}"
356 logger -i -t "${CMD}" "${M}"
362 (b) Store your password in a local (non-AFS) file that only you have access to (perhaps: /home/$USER/.p).
364 Make sure that this file is mode 600 and also be sure that you trust whoever has root access on this system and whoever has access to backup tapes! Also, don't forget to change this file if you change your AFS password.
366 (c) In your crontab file, run afs\_wrap\_cron followed by unlog:
368 0 6 * * * /usr/local/bin/afs_wrap_cron /home/$USER/.p \
369 $HOME/bin/6AMdaily; /usr/afsws/bin/unlog
371 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:
373 0 7 * * * $sys_anyuser_readable_dir/7AMdaily 2>/dev/null
375 ### <a name="2.10 How much disk space does a"></a> 2.10 How much disk space does a 1 byte file occupy in AFS?
377 This varies depending on the filesystem used by the fileserver containing that
378 file. Some filesystems may only use up 1024 bytes for such a file, and others
379 may use 4096; still others may use more or fewer bytes.
381 ### <a name="2.11 Is it possible to specify"></a><a name="2.11 Is it possible to specify "></a> 2.11 Is it possible to specify a user who is external to the current AFS cell on an ACL?
383 Yes. This requires setting up a cross-realm relationship with the Kerberos
384 realm on the remote site, but this is possible. Typically you refer to "remote"
385 users like "user@remote.cell", and you can use them in ACLs, or add them to pts
388 ### <a name="2.12 Are there any problems pri"></a> 2.12 Are there any problems printing files in /afs?
390 The issue of printing in AFS is almost always the same: what do you send to the printing daemon? Do you send it the bytes you want to print or do you just send the file name containing those bytes? If you send it a file name, you have to be sure that the printing daemon can read it. Most daemons run with no AFS tokens, so can't access directories unless they are open for system:anyuser read access. Often, printing commands (lpr, lp, enq) have an option that allows for both modes of operation, though the default behavior varies from system to system. If you're interested in making your daemons authenticate to AFS, check out Russ Allbery's kstart package:
392 - <http://www.eyrie.org/~eagle/software/kstart/>
394 Another common problem is setuid printing commands. For instance, the "enq" command runs as root, daemon, or some such user. If you aren't using the AFS login and simply issue "klog" to get tokens, those tokens are associated with your uid. When setuid programs run, they lose access to your token and often can't read the file name given as an argument. The solution in this case is to use "pagsh" before "klog" so that your tokens are transferred to subprocesses automatically by group membership. This works even if the uid changes, as for setuid programs.
396 ### <a name="2.13 Can I create a fifo (aka n"></a> 2.13 Can I create a fifo (aka named pipe) in /afs?
398 No. AFS does not support "mknod fifofile p".
400 ### <a name="2.14 If an AFS server crashes,"></a><a name="2.14 If an AFS server crashes, "></a> 2.14 If an AFS server crashes, do I have to reboot my AFS client?
404 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:
406 - On the client side:
407 - How big is the cache?
408 - Are the files you need already in the cache?
410 - On the server side:
411 - How many servers? It's best to have a minimum of three.
412 - Is the data you are accessing replicated? In AFS, replicas are [[ReadOnly]] copies.
414 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.
416 If necessary, the Cache Manager will attempt to contact all file servers on which a replica of the volume resides.
418 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.
420 You don't need to reboot, and the Cache Manager activity is "invisible" to the user.
422 ### <a name="2.15 Can I use AFS on my diskle"></a> 2.15 Can I use AFS on my diskless workstation?
424 Yes. The AFS Cache Manager can be configured to work with either a disk based
425 cache or a memory (RAM) based cache.
427 Note that using a memory cache may not be as fast as you might think. Modern
428 operating systems should cache disk data in memory when accessed, so using a
429 disk cache should mean you are hitting RAM most of the time anyway. Disk caches
430 are also much more common, and thus much more heavily tested, and so is more
431 optimized. If you have the local disk and it's reasonably fast, usually going
432 with a disk cache is the better way to go.
434 ### <a name="2.16 Can I test for AFS tokens"></a><a name="2.16 Can I test for AFS tokens "></a> 2.16 Can I test for AFS tokens from within my program?
436 Yes. However, the mechanism for doing so varies depending on the platform. To
437 see examples of how to do this, you can look at the source of any program that
438 deals with AFS tokens. One such example is [pam-afs-session](http://www.eyrie.org/~eagle/software/pam-afs-session/)
440 ### <a name="2.17 What's the difference betw"></a> 2.17 What's the difference between /afs/cellname and /afs/.cellname?
442 AFS has [[ReadOnly]] (RO) and [[ReadWrite]] (RW) volumes.
444 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.
446 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.
448 This allows your administrator to update the RW copy of a volume and "vos release $volname" so that it will appear in /afs/cellname.
450 ### <a name="2.18 Can I klog as two users on"></a> 2.18 Can I klog as two users on a machine in the same cell?
452 Yes, if you use two different PAGs.
454 It's: "One token per PAG per client system."
456 From one shell you can only authenticate as a single user of a cell. If you open another shell (with another PAG) you can klog as a different user of the same cell from the same client.
458 You can authenticate into many cells from one client shell.
460 ### <a name="2.19 What are the ~/._afsXXXX f"></a> 2.19 What are the ~/.\_\_afsXXXX files?
462 They are temporary reference files used by the AFS Cache Manager.
464 In 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).
466 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 automagically 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.
468 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.
470 ### <a name="2.20 How do you set up IP-based"></a> 2.20 How do you set up IP-based ACLs?
472 See [[IPAccessControl]].
474 ### <a name="2.21 What meaning do the owner,"></a><a name="2.21 What meaning do the owner, "></a> 2.21 What meaning do the owner, group, and mode bits have in AFS?
476 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.
478 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.
481 - the owner of the root directory of a volume has implicit administer (a) rights on all directories in the volume
482 - 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
483 - to **read** from a file you must have read (r) rights _and_ at least one of the following must be true:
484 - the file's u+r (user read) bit is set
485 - you are the owner of the file
486 - you are a member of system:administrators
487 - to **write** to a file you must have write (w) rights _and_ at least one of the following must be true:
488 - the file's u+w (user write) bit is set
489 - you are the owner of the file
490 - you are a member of system:administrators
492 - changing mode bits and owner/group:
493 - 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 file's parent directory.
494 - 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.
495 - only members of system:administrators can change the owner or group of a file.
496 - only members of system:administrators can change the setuid and setgid bits on a file.
498 The sticky bit, group of a file, g+rwx, and o+rwx bits are completely ignored by all AFS components. Additionally, the u+rwx bits are ignored on directories.
500 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.
502 ### <a name="2.22 What are "dropboxes"?"></a> 2.22 What are "dropboxes"?
504 When the ACL on a directory is set to "irl", 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.
506 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.
508 Also, note that system:anyuser=irl has 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.
510 ### <a name="2.23 Can I access a RW-Volume"></a>2.23 Can I access a RW-Volume using the RO-Path ?
512 Depends. Once, you have RO-Volumes released, a mountpoint pointing to the RO, will bring you to the RO-Volume.<br/>
513 To change that behaviour, you have to change the corresponding mountpoint.<br/>
514 However, for some situations, like software installations, it might be useful to
515 reach the RW-Volume through the RO-path.<br/>
517 You can do that for a single client with a special setup. <br/>
519 The trick is to break the convention described in 2.17 for a single client : <br/>
520 You mount the RW volume "root.cell" as /afs/cellname. <br/>
522 This can be done by creating an alternative "root.afsrw" - Volume ( in contrast to root.afs),
523 where you do the RW-mount.<br/>
524 Then you must not use on this special client the "dynroot" -option and use this alternative root.afsrw
525 as root volume, by adding "-rootvol root.afsrw" to the afsd commandline-options on startup.