summaryrefslogtreecommitdiff
path: root/doio.c
Commit message (Collapse)AuthorAgeFilesLines
* Remove gete?[ug]id cachingÆvar Arnfjörð Bjarmason2012-02-181-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently we cache the UID/GID and effective UID/GID similarly to how we used to cache getpid() before v5.14.0-251-g0e21945. Remove this magical behavior in favor of always calling getpid(), getgid() etc. This resolves RT #96208. A minimal testcase for this is the following by Leon Timmermans attached to RT #96208: eval { require 'syscall.ph'; 1 } or eval { require 'sys/syscall.ph'; 1 } or die $@; if (syscall(&SYS_setuid, $ARGV[0] + 0 || 1000) >= 0 or die "$!") { printf "\$< = %d, getuid = %d\n", $<, syscall(&SYS_getuid); } I.e. if we call the sete?[ug]id() functions unbeknownst to perl the $<, $>, $( and $) variables won't be updated. This results in the same sort of issues we had with $$ before v5.14.0-251-g0e21945, and getppid() before my v5.15.7-407-gd7c042c patch. I'm completely eliminating the PL_egid, PL_euid, PL_gid and PL_uid variables as part of this patch, this will break some CPAN modules, but it'll be really easy before the v5.16.0 final to reinstate them. I'd like to remove them to see what breaks, and how easy it is to fix it. These variables are not part of the public API, and the modules using them could either use the Perl_gete?[ug]id() functions or are working around the bug I'm fixing with this commit. The new PL_delaymagic_(egid|euid|gid|uid) variables I'm adding are *only* intended to be used internally in the interpreter to facilitate the delaymagic in Perl_pp_sassign. There's probably some way not to export these to programs that embed perl, but I haven't found out how to do that.
* [perl #77388] Make stacked -t workFather Chrysostomos2012-01-231-8/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Up till now, -t was popping too much off the stack when stacked with other filetest operators. Since the special use of _ doesn’t apply to -t, we cannot simply have it use _ when stacked, but instead we pass the argument down from the previous op. To facilitate this, the whole stacked mechanism has to change. As before, in an expression like -r -w -x, -x and -w are flagged as ‘stacking’ ops (followed by another filetest), and -w and -r are flagged as stacked (preceded by another filetest). Stacking filetest ops no longer return a false value to the next op when a test fails, and stacked ops no longer check the truth of the value on the stack to determine whether to return early (if it’s false). The argument to the first filetest is now passed from one op to another. This is similar to the mechanism that overloaded objects were already using. Now it applies to any argument. Since it could be false, we cannot rely on the boolean value of the stack item. So, stacking ops, when they return false, now traverse the ->op_next pointers and find the op after the last stacked op. That op is returned to the runloop. This short-circuiting is proba- bly faster than calling every subsequent op (a separate function call for each). Filetest ops other than -t continue to use the last stat buffer when stacked, so the argument on the stack is ignored. But if the op is preceded by nothing other than -t (where preceded means on the right, since the ops are evaluated right-to-left), it *does* use the argument on the stack, since -t has not set the last stat buffer. The new OPpFT_AFTER_t flag indicates that a stacked op is preceded by nothing other than -t. In ‘-e -t foo’, the -e gets the flag, but not in ‘-e -t -r foo’, because -r will have saved the stat buffer, so -e can just use that.
* Provide as much diagnostic information as possible in "panic: ..." messages.Nicholas Clark2012-01-161-1/+2
| | | | | | | | | | | | | | | The convention is that when the interpreter dies with an internal error, the message starts "panic: ". Historically, many panic messages had been terse fixed strings, which means that the out-of-range values that triggered the panic are lost. Now we try to report these values, as such panics may not be repeatable, and the original error message may be the only diagnostic we get when we try to find the cause. We can't report diagnostics when the panic message is generated by something other than croak(), as we don't have *printf-style format strings. Don't attempt to report values in panics related to *printf buffer overflows, as attempting to format the values to strings may repeat or compound the original error.
* Make -l HANDLE set PL_laststatval with fatal warningsFather Chrysostomos2012-01-141-1/+2
| | | | | | | Fatal warnings were preventing it from being set, because the warning came first. (PL_laststatval records the success status of the previous stat.)
* Squash repetitititive code in doio.c:my_stat_flagsFather Chrysostomos2012-01-131-8/+3
|
* Make failed filetests consistent with & w/out fatal warningsFather Chrysostomos2012-01-131-2/+4
| | | | | | The result of stat(_) after a failed -r HANDLE would differ depending on whether fatal warnings are on. This corrects that, by setting the internal status before warning about an unopened filehandle.
* stat $ioref should record the handle for -T _Father Chrysostomos2012-01-131-1/+1
| | | | | | | stat $gv records the handle so that -T _ can use it. But stat $ioref hasn’t been doing that, until this commit. PL_statgv can now hold an SVt_PVIO instead of a SVt_PVGV.
* Make <~> work again under miniperlFather Chrysostomos2011-10-241-1/+7
| | | | | | | | | | | | Commit a3342be368 localised %ENV before calling csh for glob. But that causes <~> to stop working. So this commit clears out %ENV *except* for $ENV{HOME}. It relies on the way magic works: Before localising the %ENV hash, it retrieves its $ENV{HOME} element, which is a magical scalar. It calls get-magic to store the value in the scalar itself, localises %ENV, and then calls set-magic on the element, to signal (deceitfully) that an assignment has just happened. So the cached value in the magical sca- lar is used and assigned to the env var.
* Use HEKfFather Chrysostomos2011-10-071-8/+12
| | | | This avoids creating a lot of temporary SVs.
* whichsig nul-cleanup.Brian Fraser2011-10-061-4/+7
| | | | | This adds _pv, _pvn, and _pv versions of whichsig() in mg.c, which get both kill "NAME" and %SIG lookup nul-clean.
* doio.c: Make warnings UTF8- and nul-cleanBrian Fraser2011-10-061-8/+8
|
* Only upgrade when necessaryLeon Timmermans2011-09-181-1/+1
|
* Make -l always treat non-bareword arguments as file namesFather Chrysostomos2011-09-171-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Here is some suspicious code in Perl_my_lstat_flags: if (SvROK(sv) && isGV_with_GP(SvRV(sv)) && ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", GvENAME((const GV *)SvRV(sv))); return (PL_laststatval = -1); } The behaviour differs depending on whether warnings are enabled. That -1 turns into undef in pp_ftlink. So we get an undef return value with warnings on, but a file test on a file name otherwise. In 5.6.2, -l $foo always treated $foo as a file name. In 5.8+, if it is a reference (ignoring magic) and the reference points to a typeglob (ignoring magic) and io warnings are on, it warns and returns undef. So the only time that undef return is reached is when a warning has been emitted, so it’s code that will likely be corrected before it goes into production. Hence I think it unlikely that anyone could be relying on the behaviour of -l \*foo (under warnings). So this commit restores the 5.6 behaviour for that case.
* Make stacked -l workFather Chrysostomos2011-09-171-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Perl 5.10.0 introduced stacked filetest operators, -x -r $foo being equivalent to -r $foo && -x _ That does not work with -l. It was these suspicious lines in Perl_my_lstat_flags that drew my attention to it: > else if (PL_laststype != OP_LSTAT > && (PL_op->op_private & OPpFT_STACKED) && ckWARN(WARN_IO)) > Perl_croak(aTHX_ no_prev_lstat); That croak only happens when warnings are on. Warnings are just supposed to be warnings, unless the ‘user’ explicitly requests fatal warnings. $ perl -le 'print "foo", -l -e "miniperl"' foo $ perl -lwe 'print "foo", -l -e "miniperl"' The stat preceding -l _ wasn't an lstat at -e line 1. That it doesn’t die in the first example is a bug. In fact, it’s using the return value of -e as a file name: $ ln -s miniperl 1 $ ./miniperl -le 'print -l -e "miniperl"' 1 And, with warnings on, if the preceding stat *was* an lstat, it falls back to the pre-stacked behaviour, just as it does when warn- ings are off. It’s meant to be equivalent to -e "miniperl" && -l _ (which is why the error message above says ‘The stat preceding -l _’).
* [perl #93638] $ENV{LS_COLORS} causes miniperl glob failureFather Chrysostomos2011-09-161-0/+1
| | | | | | | | | On some systems, csh croaks if the LS_COLORS envvar contains something it considers invalid. The easiest and least intrusive fix for now is to localize %ENV before running csh, though eventually it might be nice to use File::Glob in miniperl, either by linking it statically or by inlining it.
* Fix #98480 math when reading shared memoryLeon Timmermans2011-09-141-1/+2
| | | | | shmread didn't unset SvIOK properly, causing a read into a SVIV to have an incorrect numeric value. This patch fixes that and adds tests.
* Make utime handle get-magic correctly for glob(ref)sFather Chrysostomos2011-09-101-8/+2
| | | | It used to ignore get-magic for globs and globrefs.
* Make filetest ops handle get-magic correctly for glob(ref)sFather Chrysostomos2011-09-101-6/+1
| | | | | | This patch uses the recently-added MAYBE_DEREF_GV macro which puts the glob deref logic in one spot. It also adds _nomg and _flags varia- tions of it. _flags understands the SV_GMAGIC flag.
* -l followed by bareword should leave the stack aloneFather Chrysostomos2011-09-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | $ ln -s /usr/bin/perl bar $ perl -le' print "bar", -l foo' 1 The -l ate my bar. It’s this naughty piece of code in doio.c:Perl_my_lstat_flags that is the culprit: if (ckWARN(WARN_IO)) { Perl_warner(aTHX_ packWARN(WARN_IO), "Use of -l on filehandle %s", GvENAME(cGVOP_gv)); return (PL_laststatval = -1); } When -l is followed by a bareward, it has no argument on the stack, but the filetest op itself is a gvop. That snippet is from the bare- word-handling code. So, if warnings are off, it falls through to the argument-on-the-stack code and pops off something does not belong to it (that belong to the print, in the example above).
* The Borland Chainsaw MassacreSteve Hay2011-09-101-3/+0
| | | | | Remove support for the Borland C++ compiler on Win32, as agreed here: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2011-09/msg00034.html
* ch(dir|mod|own) should also call FETCH on refs to tied globsFather Chrysostomos2011-09-101-16/+2
| | | | | | | | Following on from commit 935647290357b277, which corrected the beha- viour for tied globs, this commit corrects the behaviour for refer- ences to tied globs. (With tests by Nicholas Clark.)
* ch(dir|mod|own) should not ignore get-magic on glob(ref)sFather Chrysostomos2011-09-081-2/+4
| | | | | | | | When the chdir(*handle) feature was added in 5.8.8, the fact that globs and refs could be magical was not taken into account. They can easily be magical if a typeglob or reference is returned from or assigned to a tied variable.
* Add check_utf8_print()Karl Williamson2011-01-091-0/+6
| | | | | | | This new function looks for problematic code points on output, and warns if any are found, returning FALSE as well. What it warns about may change, so is marked as experimental.
* Fix typos (spelling errors) in Perl sources.Peter J. Acklam) (via RT2011-01-071-1/+1
| | | | | | | | | # New Ticket Created by (Peter J. Acklam) # Please include the string: [perl #81904] # in the subject line of all future correspondence about this issue. # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81904 > Signed-off-by: Abigail <abigail@abigail.be>
* GvIO(gv) returns NULL for a NULL gv, so refactor to take advantage of this.Nicholas Clark2011-01-021-6/+6
| | | | | | Simplify tests of !gv || !io to just !io, avoid calling GvIO(gv) more than once, and where possible initialise io at declaration time, to allow it to be const.
* As report_evil_fh() checks WARN_{CLOSED,UNOPENED}, don't duplicate this.Nicholas Clark2010-12-281-12/+6
| | | | | | | | | | This trades reduced code size for an extra function call in the error path with warnings disabled. (And removes a duplicated check for the case of taking the error path *with* warnings enabled.) Removing the check from Perl_do_close() does not change behaviour, as io is NULL there, hence Perl_report_evil_fh() will always be checking WARN_UNOPENED and setting vile to "unopened".
* As report_wrongway_fh() checks ckWARN(WARN_IO) internally, don't duplicate this.Nicholas Clark2010-12-281-1/+1
| | | | | | This trades reduced code size for an extra function call in the error path with warnings disabled. (And removes a duplicated check for the case of taking the error path *with* warnings enabled.)
* Argument op to report_evil_fh() is always PL_op->op_type, so need not be passedNicholas Clark2010-12-281-6/+6
|
* The io argument to report_evil_fh() is always GvIO(gv), so need not be passed.Nicholas Clark2010-12-281-6/+6
|
* Extract the OP_phoney_* code from report_evil_fh() into report_wrongway_fh()Nicholas Clark2010-12-281-1/+1
| | | | | Previously Perl_report_evil_fh()'s body was just an if/else at the top level - a good sign that it is actually implementing two disjoint functions.
* Don’t use PL_op without checking it first.Father Chrysostomos2010-09-201-1/+3
|
* Fix "Wide character in warn" warningFather Chrysostomos2010-09-161-1/+1
|
* add my_[l]stat_flags(); make my_[l]stat() mathomsDavid Mitchell2010-07-031-4/+4
| | | | | | | my_stat() and my_lstat() call get magic on the stack arg, so create _flags() variants that allow us to control this. (I can't just change the signature or the mg_get() behaviour since my_[l]stat() are listed as being in the public API, even though they're undocumented.)
* RT #75812: apply get magic before checking flags, PVXTony Cook2010-06-251-3/+6
| | | | | | The code was checking flags with applying any get magic, so when a match was doing putting a numeric string into $1, none of the flags checked were set, so producing the "non-numeric process ID" error.
* Move PERL_ASYNC_CHECK() from POPBLOCK() to the kill case of Perl_apply().Nicholas Clark2010-04-181-0/+2
| | | | | | This ensures that (safe) signals sent to the same process are still dispatched within the same statement (as before), without overloading the semantics of block popping.
* [perl #73626] get magic wasn't called on 3rd arg of openDavid Mitchell2010-03-211-1/+2
| | | | | | | Change f6c77cf1bf4d7cb2c7a64dd7608120b471f84062 introduced open($fh,"+<",undef) but in the process stopped calling mg_get() on the third arg, so tied values etc weren't getting processed
* CYG23-544-statReini Urban2010-01-141-0/+4
| | | | | | | | | Stable cygwin patch for root filetests (gid 0 root <= gid 544 Administrators). On cygwin check for the Administrators group (544) which has root rights regarding -r filetests. Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
* [perl #70802] -i'*' refuses to workTony Cook2009-12-031-1/+1
|
* Add Perl_ck_warner_d(), which combines Perl_ckwarn_d() and Perl_warner().Nicholas Clark2009-10-121-27/+19
| | | | | Replace ckWARN_d{,2,3,4}() && Perl_warner() with it, which trades reduced code size for 1 more function call if warnings are not enabled.
* Fix compiler warning in doio.cJerry D. Hedden2009-07-091-4/+7
|
* Make kill() fatal for non-numeric pidsDavid Golden2009-07-091-0/+6
| | | | | | | | | | | | | | | | | | As the debate over the best way to deal with floating point pids stalled, this is just for non-numeric, which at least squashes the bug even if it's not the Platonic ideal for everyone. It also doesn't address overloaded objects that might not have IV, NV or PV appropriately set, but the approach mirrors what is done elsewhere in doio.c so I recommend applying this patch now and fixing the problem of overloaded objects at some other time when it can be done more globally, either through an improvement or replacement of looks_like_number Also updated POD for kill when process is 0 or negative and fixed Test-Harness tests that used kill with a string pid. (Test-Harness test fix also submitted upstream)
* Add test to make sure everything that outputs an exception or warning has a ↵James Mastros2009-06-271-0/+11
| | | | matching entry in perldiag (and fix it so that more of the existing ones do).
* Remove all the 5005threads specific mutex macros, which are now vestigial.Nicholas Clark2009-05-211-2/+0
|
* Remove all #ifdef MACOS_TRADITIONAL code in core and non-dual-life XS code.Nicholas Clark2009-04-271-12/+1
| | | | | | | | (MacOS support was removed from MakeMaker in 6.22, and merged to blead on 15th December 2004 with 5dca256ec738057dc331fb644a93eca44ad5fa14. After this point MacOS wouldn't even have been able to build the perl binary, because it would not have been able to build DynaLoader. If anyone wishes to resurrect MacOS, start by reversing this commit and the relevant part of that commit.)
* Fix perl #63924: shmget limited to 32 bit segment size on 64 bit OSMarcus Holland-Moritz2009-03-241-3/+3
| | | | | | Make sure the size argument to shmget() is not limited by the width of an int. Instead of storing the argument in an int, just store a pointer to the SV and use different conversions for semget() and shmget().
* Fix change 35082 by manually expanding do_open() to Perl_do_openn().Nicholas Clark2008-12-141-5/+5
| | | p4raw-id: //depot/perl@35088
* Re: [perl #60904] Race condition with perl -i.bkChip Salzenberg2008-12-131-9/+6
| | | | | | | Message-ID: <20081201230112.GH31089@tytlal.topaz.cx> Use mode 0600 (minus umask) for creation of the new file with -i p4raw-id: //depot/perl@35082
* standardize save/restore of errno & vaxc$errnoChip Salzenberg2008-12-051-5/+5
| | | | | Message-ID: <20081127070141.GD17663@tytlal.topaz.cx> p4raw-id: //depot/perl@35018
* Just s/Perl_/S_/ isn't good enough - you also need to add the C<static>Nicholas Clark2008-11-261-1/+1
| | | p4raw-id: //depot/perl@34934
* ingroup() is only used in doio.c.Nicholas Clark2008-11-261-1/+1
| | | | | Wrap gen_constant_list in #if defined(PERL_IN_OP_C) p4raw-id: //depot/perl@34925