xref: /openbsd-src/share/man/man8/sticky.8 (revision b2ea75c1b17e1a9a339660e7ed45cd24946b230e)
1.\"	$OpenBSD: sticky.8,v 1.5 2000/12/22 16:54:38 avsm Exp $
2.\"	$NetBSD: sticky.8,v 1.3 1994/11/30 19:36:27 jtc Exp $
3.\"
4.\" Copyright (c) 1980, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\"    must display the following acknowledgement:
17.\"	This product includes software developed by the University of
18.\"	California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\"    may be used to endorse or promote products derived from this software
21.\"    without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\"     @(#)sticky.8	8.1 (Berkeley) 6/5/93
36.\"
37.Dd June 5, 1993
38.Dt STICKY 8
39.Os
40.Sh NAME
41.Nm sticky
42.Nd sticky text and append-only directories
43.Sh DESCRIPTION
44A special file mode, called the
45.Em sticky bit
46(mode S_ISVTX),
47is used to indicate special treatment
48for shareable executable files and directories.
49See
50.Xr chmod 2
51or
52the file
53.Pa /usr/include/sys/stat.h
54for an explanation of file modes.
55.Sh STICKY TEXT EXECUTABLE FILES
56An executable shareable file whose sticky bit is set
57will not be immediately discarded from swap space after execution.
58The kernel will hoard the text segment of the file for future
59reuse and avoid having to reload the program.
60Shareable text segments are normally placed
61in a least-frequently used cache after use,
62and thus the `sticky bit' has little effect on commonly used text images.
63.Pp
64Sharable executable files are created with the
65.Fl n
66and
67.Fl z
68options of
69the loader
70.Xr ld 1 .
71.Pp
72Only the superuser can set the sticky bit
73on a sharable executable file.
74.Sh STICKY DIRECTORIES
75A directory whose `sticky bit' is set
76becomes an append-only directory, or, more accurately,
77a directory in which the deletion of files is restricted.
78A file in a sticky directory may only be removed or renamed
79by a user if the user has write permission for the directory and
80the user is the owner of the file, the owner of the directory,
81or the superuser.
82This feature is usefully applied to directories such as
83.Pa /tmp
84which must be publicly writable but
85should deny users the license to arbitrarily
86delete or rename each others' files.
87.Pp
88Any user may create a sticky directory.
89See
90.Xr chmod 1
91for details about modifying file modes.
92.Sh BUGS
93Since the text areas of sticky text executables are stashed in the swap area,
94abuse of the feature can cause a system to run out of swap.
95.Pp
96Neither
97.Xr open 2
98nor
99.Xr mkdir 2
100will create a file with the sticky bit set.
101.Sh HISTORY
102A
103.Nm
104command appeared in Version 32V AT&T UNIX.
105