.\" -*-nroff-*- .TH tmpdir 1 "6 April 1999" "Local tools" .SH NAME tmpdir \- choose, or check a choice of, temporary directory .SH SYNOPSIS .B tmpdir .RB [ \-bcv ] .RB [ \-g .IR group ] .RB [ \-C .IR dir ] .SH USAGE The .B tmpdir program creates a secure place for temporary files to be stored, and outputs an assignment to the .B TMPDIR variable suitable for execution by a shell. .PP Many programs aren't sufficiently careful about how they handle temporary files. For example, if a program which creates files in .B /tmp without making careful checks beforehand, a malicious user who can predict the name that the program will use can create a symbolic link with that name: when run, the program will then overwrite some file using your current privileges. Similarly, many programs create temporary files using generous default permissions, which may well be a mistake. .PP The .B tmpdir program finds a secure place for temporary files, creating one if necessary. The criteria it uses to choose a place are as follows: .IP " 1." The temporary directory must be owned by the user, and have mode 700 (i.e., readable, writable and searchable only by the owner). .IP " 2." The path through the filesystem to the temporary directory must be secure against modifications by other malicious users. See the .BR chkpath (1) manual page for a description of how this is done: the two programs work in the same way. .PP First, .B tmpdir checks to see whether the current value of the .B TMPDIR environment variable is a secure place for temporary files. If so, it is accepted immediately. Otherwise, it tries to find or create a directory in .B /tmp (on the assumption that this is a fast disk suitable for temporary files), with the name .BI /tmp/ user \- suffix for some .IR suffix . If that fails, it tries to create a directory in your home directory, with the name .BI ~/tmp\- suffix\fR. If .I that fails too, then .B tmpdir gives up: if your home directory's not secure (or full) than a secure temporary directory is the least of your worries. .SS Options The following options are supported: .TP .B "\-b, \-\-bourne" Output an assignment using Bourne shell syntax. The default is to examine the user's shell and decide which syntax to use based on that. .TP .B "\-c, \-\-cshell" Output an assignment using C shell syntax. .TP .BI "\-g, \-\-group " group Trust (the members of) .IR group : consider directories they can write to be safe. .TP .B "-v, \-\-verbose" Report problems to standard error. Repeat for more verbosity. .TP .BI "\-C, --check " dir Don't try to find a temporary directory; just see whether .I dir is secure, and exit successfully if it is (and unsuccessfully if it isn't). .SH BUGS None known. .SH SEE ALSO .BR chkpath (1), .BR checkpath (3), .BR tmpnam (3), .BR tmpfile (3). .SH AUTHOR Mark Wooding (mdw@nsict.org).