char *getenv _((char *)); /* Usually in <stdlib.h> */
#endif
+#ifdef I_FCNTL
+#include <fcntl.h>
+#endif
+#ifdef I_SYS_FILE
+#include <sys/file.h>
+#endif
+
dEXTCONST char rcsid[] = "perl.c\nPatch level: ###\n";
#ifdef IAMSUID
if (euid != uid || egid != gid)
croak("No -e allowed in setuid scripts");
if (!e_fp) {
+#ifdef HAS_UMASK
+ int oldumask = PerlLIO_umask(0177);
+#endif
e_tmpname = savepv(TMPPATH);
#ifdef HAS_MKSTEMP
e_tmpfd = PerlLIO_mkstemp(e_tmpname);
-
- if (e_tmpfd < 0)
- croak("Can't mkstemp() temporary file \"%s\"", e_tmpname);
- e_fp = PerlIO_fdopen(e_tmpfd,"w");
#else /* use mktemp() */
(void)PerlLIO_mktemp(e_tmpname);
if (!*e_tmpname)
- croak("Can't mktemp() temporary file \"%s\"", e_tmpname);
+ croak("Cannot generate temporary filename");
+# if defined(HAS_OPEN3) && defined(O_EXCL)
+ e_tmpfd = open(e_tmpname,
+ O_WRONLY | O_CREAT | O_EXCL,
+ 0600);
+# else
+ (void)UNLINK(e_tmpname);
+ /* Yes, potential race. But at least we can say we tried. */
e_fp = PerlIO_open(e_tmpname,"w");
-#endif /* HAS_MKSTEMP */
+# endif
+#endif /* ifdef HAS_MKSTEMP */
+#if defined(HAS_MKSTEMP) || (defined(HAS_OPEN3) && defined(O_EXCL))
+ if (e_tmpfd < 0)
+ croak("Cannot create temporary file \"%s\"", e_tmpname);
+ e_fp = PerlIO_fdopen(e_tmpfd,"w");
+#endif
if (!e_fp)
- croak("Cannot open temporary file \"%s\"", e_tmpname);
+ croak("Cannot create temporary file \"%s\"", e_tmpname);
+#ifdef HAS_UMASK
+ (void)PerlLIO_umask(oldumask);
+#endif
}
if (*++s)
PerlIO_puts(e_fp,s);
(F) List assignment to %ENV is not supported on some systems, notably VMS.
-=item Can't mkstemp() temporary file %s
-
-(F) The mkstemp() routine failed for some reason while trying to
-process a B<-e> switch. Maybe your temporary file partition
-is full, or over-protected, or clobbered.
-
-=item Can't mktemp() temporary file %s
-
-(F) The mktemp() routine failed for some reason while trying to
-process a B<-e> switch. Maybe your temporary file partition
-is full, or over-protected, or clobbered.
-
=item Can't modify %s in %s
(F) You aren't allowed to assign to the item indicated, or otherwise try to
an assignment operator, which implies modifying the value itself.
Perhaps you need to copy the value to a temporary, and repeat that.
+=item Cannot create temporary file "%s"
+
+(F) A temporary file could not created for some reason while trying to
+process a B<-e> switch. Maybe your temporary file partition is full,
+or over-protected, or clobbered.
+
=item Cannot find an opnumber for "%s"
(F) A string of a form C<CORE::word> was given to prototype(), but
there is no builtin with the name C<word>.
-=item Cannot open temporary file %s
+=item Cannot generate temporary filename
-(F) A temporary file could not created for some reason while trying to
-process a B<-e> switch. Maybe your temporary file partition is full,
-or over-protected, or clobbered.
+(F) While trying to process a B<-e> switch, a filename for a temporary
+file could not be generated. Maybe your temporary file partition is
+full, or over-protected, or clobbered.
=item Cannot resolve method `%s' overloading `%s' in package `%s'