Initial revision
[checkpath] / tmpdir.1
CommitLineData
efa7a97b 1.TH tmpdir 1 "6 April 1999" "Local tools"
2.SH NAME
3tmpdir \- choose, or check a choice of, temporary directory
4.SH SYNOPSIS
5.B tmpdir
6.RB [ \-bc ]
7.RB [ \-v
8.IR dir ]
9.SH USAGE
10The
11.B tmpdir
12program creates a secure place for temporary files to be stored, and
13outputs an assignment to the
14.B TMPDIR
15variable suitable for execution by a shell.
16.PP
17Many programs aren't sufficiently careful about how they handle
18temporary files. For example, if a program which creates files in
19.B /tmp
20without making careful checks beforehand, a malicious user who can
21predict the name that the program will use can create a symbolic link
22with that name: when run, the program will then overwrite some file
23using your current privileges. Similarly, many programs create
24temporary files using generous default permissions, which may well be a
25mistake.
26.PP
27The
28.B tmpdir
29program finds a secure place for temporary files, creating one if
30necessary. The criteria it uses to choose a place are as follows:
31.IP 1.
32The temporary directory must be owned by the user, and have mode 700
33(i.e., readable, writable and searchable only by the owner).
34.IP 2.
35The path through the filesystem to the temporary directory must be
36secure against modifications by other malicious users. See the
37.BR chkpath (1)
38manual page for a description of how this is done: the two programs work
39in the same way.
40.PP
41First,
42.B tmpdir
43checks to see whether the current value of the
44.B TMPDIR
45environment variable is a secure place for temporary files. If so, it
46is accepted immediately. Otherwise, it tries to find or create a
47directory in
48.B /tmp
49(on the assumption that this is a fast disk suitable for temporary
50files), with the name
51.BI /tmp/ user \- suffix
52for some
53.IR suffix .
54If that fails, it tries to create a directory in your home directory,
55with the name
56.BI ~/tmp\- suffix\fR.
57If
58.I that
59fails too, then
60.B tmpdir
61gives up: if your home directory's not secure (or full) than a secure
62temporary directory is the least of your worries.
63.SS OPTIONS
64The following options are supported:
65.TP
66.B "\-b, \-\-bourne"
67Output an assignment using Bourne shell syntax. The default is to
68examine the user's shell and decide which syntax to use based on that.
69.TP
70.B "\-c, \-\-cshell"
71Output an assignment using C shell syntax.
72.TP
73.BI "\-v, --verify=" dir
74Don't try to find a temporary directory; just see whether
75.I dir
76is secure, and exit successfully if it is (and unsuccessfully if it
77isn't).
78.SH BUGS
79None known.
80.SH SEE ALSO
81.BR chkpath (1),
82.BR tmpnam (3),
83.BR tmpfile (3).
84.SH AUTHOR
85Mark Wooding (mdw@nsict.org).