summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--perl.c6
-rw-r--r--perlio.c16
-rw-r--r--util.h5
3 files changed, 10 insertions, 17 deletions
diff --git a/perl.c b/perl.c
index 0c05c9a41e..e6932b5d33 100644
--- a/perl.c
+++ b/perl.c
@@ -4032,16 +4032,12 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch, bool *suidscript)
};
const char * const err = "Failed to create a fake bit bucket";
if (strEQ(scriptname, BIT_BUCKET)) {
-#ifdef HAS_MKSTEMP /* Hopefully mkstemp() is safe here. */
- int old_umask = umask(0177);
- int tmpfd = mkstemp(tmpname);
- umask(old_umask);
+ int tmpfd = Perl_my_mkstemp(tmpname);
if (tmpfd > -1) {
scriptname = tmpname;
close(tmpfd);
} else
Perl_croak(aTHX_ err);
-#endif
}
#endif
rsfp = PerlIO_open(scriptname,PERL_SCRIPT_MODE);
diff --git a/perlio.c b/perlio.c
index 2a57772c46..d9fdac3f90 100644
--- a/perlio.c
+++ b/perlio.c
@@ -49,11 +49,6 @@
#include "XSUB.h"
-#ifdef __Lynx__
-/* Missing proto on LynxOS */
-int mkstemp(char*);
-#endif
-
#ifdef VMS
#include <rms.h>
#endif
@@ -5034,32 +5029,29 @@ PerlIO_tmpfile(void)
const int fd = win32_tmpfd();
if (fd >= 0)
f = PerlIO_fdopen(fd, "w+b");
-#elif defined(HAS_MKSTEMP) && ! defined(VMS) && ! defined(OS2)
+#elif ! defined(VMS) && ! defined(OS2)
int fd = -1;
char tempname[] = "/tmp/PerlIO_XXXXXX";
const char * const tmpdir = TAINTING_get ? NULL : PerlEnv_getenv("TMPDIR");
SV * sv = NULL;
int old_umask = umask(0177);
- /*
- * I have no idea how portable mkstemp() is ... NI-S
- */
if (tmpdir && *tmpdir) {
/* if TMPDIR is set and not empty, we try that first */
sv = newSVpv(tmpdir, 0);
sv_catpv(sv, tempname + 4);
- fd = mkstemp(SvPVX(sv));
+ fd = Perl_my_mkstemp(SvPVX(sv));
}
if (fd < 0) {
SvREFCNT_dec(sv);
sv = NULL;
/* else we try /tmp */
- fd = mkstemp(tempname);
+ fd = Perl_my_mkstemp(tempname);
}
if (fd < 0) {
/* Try cwd */
sv = newSVpvs(".");
sv_catpv(sv, tempname + 4);
- fd = mkstemp(SvPVX(sv));
+ fd = Perl_my_mkstemp(SvPVX(sv));
}
umask(old_umask);
if (fd >= 0) {
diff --git a/util.h b/util.h
index 7bec0fcde3..71531c7e85 100644
--- a/util.h
+++ b/util.h
@@ -241,6 +241,11 @@ means arg not present, 1 is empty string/null byte */
(little), (lend) - (little)))
#endif
+#ifdef __Lynx__
+/* Missing proto on LynxOS */
+int mkstemp(char*);
+#endif
+
#if defined(HAS_MKOSTEMP) && defined(PERL_CORE)
# define Perl_my_mkostemp(templte, flags) mkostemp(templte, flags)
#endif