Commit | Line | Data |
---|---|---|
3c389526 KM |
1 | .\" Copyright (c) 1980 Regents of the University of California. |
2 | .\" All rights reserved. The Berkeley software License Agreement | |
3 | .\" specifies the terms and conditions for redistribution. | |
4 | .\" | |
87150da0 | 5 | .\" @(#)sticky.8 6.2 (Berkeley) %G% |
3c389526 | 6 | .\" |
7db7c2c4 | 7 | .TH STICKY 8 "" |
3c389526 KM |
8 | .UC 4 |
9 | .SH NAME | |
87150da0 | 10 | sticky \- persistent text and append-only directories |
3c389526 | 11 | .SH DESCRIPTION |
87150da0 DS |
12 | The |
13 | .I "sticky bit" | |
14 | (file mode bit 01000, see | |
15 | .IR chmod (2)) | |
16 | is used to indicate special treatment | |
17 | for certain executable files and directories. | |
18 | .SH "STICKY TEXT EXECUTABLE FILES" | |
19 | While the `sticky bit' | |
3c389526 KM |
20 | is set on a sharable executable file, |
21 | the text of that file will not be removed from the system swap area. | |
22 | Thus the file does not have to be fetched from the file system | |
23 | upon each execution. | |
24 | As long as a copy remains in the swap area, the | |
25 | original text cannot be overwritten in the file system, | |
26 | nor can the file be deleted. | |
27 | (Directory entries can be removed so long as one link remains.) | |
28 | .PP | |
87150da0 | 29 | Sharable executable files are made by the |
3c389526 KM |
30 | .B \-n |
31 | and | |
32 | .B \-z | |
33 | options of | |
34 | .IR ld (1). | |
35 | .PP | |
87150da0 DS |
36 | To replace a sticky text executable file that has been used, |
37 | perform the following steps: | |
3c389526 KM |
38 | (1) Clear the sticky bit with |
39 | .IR chmod (1). | |
40 | (2) Execute the old program to flush the swapped copy. | |
41 | This can be done safely even if others are using it. | |
42 | (3) Overwrite the sticky file. | |
43 | If the file is being executed by any process, | |
44 | writing will be prevented; it suffices to simply remove the file | |
45 | and then rewrite it, being careful to reset the owner and mode with | |
46 | .I chmod | |
47 | and | |
48 | .IR chown (2). | |
49 | (4) Set the sticky bit again. | |
50 | .PP | |
87150da0 DS |
51 | Only the super-user can set the sticky bit |
52 | on a sharable executable file. | |
53 | .SH "STICKY DIRECTORIES" | |
54 | A directory whose `sticky bit' is set | |
55 | becomes an append-only directory, or, more accurately, | |
56 | a directory in which the deletion of files is restricted. | |
57 | A file in a sticky directory may only be removed or renamed | |
58 | by a user if the user has write permission for the directory and | |
59 | the user is the owner of the file, the owner of the directory, | |
60 | or the super-user. | |
61 | This feature is usefully applied to directories such as /tmp | |
62 | which must be publicly writable but | |
63 | should deny users the license to arbitrarily | |
64 | delete or rename each others' files. | |
3c389526 | 65 | .PP |
87150da0 DS |
66 | Any user may create a sticky directory. |
67 | See | |
68 | .IR chmod (1) | |
69 | for details about modifying file modes. | |
70 | .SH BUGS | |
71 | Sticky text executable files are | |
72 | largely unnecessary on the VAX. | |
73 | The sticky attribute is useful only for large programs that | |
74 | will page heavily to start, since text pages are normally cached in core | |
3c389526 | 75 | as long as possible after all instances of a text image exit. |
87150da0 DS |
76 | .PP |
77 | Since the text areas of sticky text executables are stashed in the swap area, | |
78 | abuse of the feature can cause a system to run out of swap. | |
79 | .PP | |
80 | Neither | |
81 | .IR open (2) | |
82 | nor | |
83 | .IR mkdir (2) | |
84 | will create a file with the sticky bit set. |