[3856] in bugtraq
Re: mktemp() and friends
daemon@ATHENA.MIT.EDU (Steve \"Stevers!\" Coile)
Tue Dec 24 14:04:02 1996
Date: Tue, 24 Dec 1996 10:42:43 -0500
Reply-To: "Steve \"Stevers!\" Coile" <scoile@patriot.net>
From: "Steve \"Stevers!\" Coile" <scoile@patriot.net>
X-To: Theo de Raadt <deraadt@cvs.openbsd.org>
To: Multiple recipients of list BUGTRAQ <BUGTRAQ@netspace.org>
In-Reply-To: <199612232253.PAA06999@cvs.openbsd.org>
Here's what I'd like to see in a routine that creates and opens temporary
files:
+ Atomic operation, like mkstemp, where one routine names, creates,
and opens the file.
+ Something that accepts the new file's modes, unlike mkstemp, so that
we don't have to go through the following three step process to ensure
that the file is empty before we use a file created with 0666:
mkstemp
chmod
ftruncate
+ Something that relocates relative file specifications to another
location. For instance, why not have the function use the TMP or
TEMP environment variables to determine what directory to place the
temporary file in if the file is given as a relative path (default to
/tmp if TMP and TEMP are undefined)? Or, why not have the function
use a system-provided directory template. This would give system
management the ability to relocate temporary files without having to
inform the users or update programs.
For instance, if a system manager prefers that all temporary files
be located in directories under /tmp named after the user (or euid)
creating them, such a guideline would be built into this routine.
What would be really cool is if it could be a modifiable parameter,
perhaps specified at boot-time.
So, suppose we call the new routine nmkstmp:
int *nmkstmp(char *template,int modes);
if (template[0] == '/')
tmpname = template;
else
{
/* We might have things in here that do the following:
/*
/* + If TMP or TEMP environment variables are defined, use one
/* of them as the directory.
/*
/* + If the effective user ID is less than 100 (i.e. a system
/* account), we look to see whether the user has a directory
/* named "tmp" (or, if TMP or TEMP was relative in the above,
/* we might use that as the name of the directory to look for)
/* in their home directory and use it if it exists. We might
/* also do this for all users.
/*
/* + If there exists a directory in the system temporary directory
/* (e.g. /tmp) named after and owned by the user specified
/* by the effective user ID, use that directory.
/*
/* + If all else fails, simply use /tmp as the directory.
*/
/* Combine the directory and name template giving a new template. */
}
/* Continue as normal. */
--
Steve Coile P a t r i o t N e t Systems Engineering
scoile@patriot.net Patriot Computer Group (703) 277-7737