Check for TMPDIR and if set use it
This commit is contained in:
parent
a7b8eee6c0
commit
91a643411d
5
mktemp.c
5
mktemp.c
|
@ -19,7 +19,7 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *template = "tmp.XXXXXXXXXX";
|
char *template = "tmp.XXXXXXXXXX";
|
||||||
char *tmpdir = "/tmp";
|
char *tmpdir = "/tmp", *p;
|
||||||
char tmppath[PATH_MAX];
|
char tmppath[PATH_MAX];
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@ main(int argc, char *argv[])
|
||||||
else if (argc == 1)
|
else if (argc == 1)
|
||||||
template = argv[0];
|
template = argv[0];
|
||||||
|
|
||||||
|
if ((p = getenv("TMPDIR")))
|
||||||
|
tmpdir = p;
|
||||||
|
|
||||||
snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template);
|
snprintf(tmppath, sizeof(tmppath), "%s/%s", tmpdir, template);
|
||||||
if (dflag) {
|
if (dflag) {
|
||||||
if (!mkdtemp(tmppath)) {
|
if (!mkdtemp(tmppath)) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user