From: Jarkko Hietaniemi Date: Wed, 18 Mar 1998 23:21:08 +0000 (+0200) Subject: 5.004_63: further -e patching X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=51fa4eeaa214f639610700d3b2aea14f2933be35;p=p5sagit%2Fp5-mst-13.2.git 5.004_63: further -e patching p4raw-id: //depot/perl@846 --- diff --git a/perl.c b/perl.c index f8217ff..0536829 100644 --- a/perl.c +++ b/perl.c @@ -24,6 +24,13 @@ char *getenv _((char *)); /* Usually in */ #endif +#ifdef I_FCNTL +#include +#endif +#ifdef I_SYS_FILE +#include +#endif + dEXTCONST char rcsid[] = "perl.c\nPatch level: ###\n"; #ifdef IAMSUID @@ -679,21 +686,36 @@ setuid perl scripts securely.\n"); 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); diff --git a/pod/perldiag.pod b/pod/perldiag.pod index 25f3b68..77b714c 100644 --- a/pod/perldiag.pod +++ b/pod/perldiag.pod @@ -693,18 +693,6 @@ to exist. (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 @@ -901,16 +889,22 @@ a B<-e> switch. Maybe your /tmp partition is full, or clobbered. 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 was given to prototype(), but there is no builtin with the name C. -=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'