From: Nicholas Clark Date: Fri, 3 Feb 2006 22:41:55 +0000 (+0000) Subject: And as we've now got to the point where all calls to Perl_moreswitches X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=97bd566409a94bf7961734af3ac8131276ce086b;p=p5sagit%2Fp5-mst-13.2.git And as we've now got to the point where all calls to Perl_moreswitches have -1 as the second argument, we can remove the second argument, which gets us back to where we started, only with the elimination of a per-thread variable. p4raw-id: //depot/perl@27075 --- diff --git a/embed.fnc b/embed.fnc index 16d1d02..de210b0 100644 --- a/embed.fnc +++ b/embed.fnc @@ -469,7 +469,7 @@ Ap |I32 |mg_size |NN SV* sv Ap |void |mini_mktime |NN struct tm *pm p |OP* |mod |NULLOK OP* o|I32 type p |int |mode_from_discipline|NULLOK SV* discp -Ap |char* |moreswitches |NN char* s|int suidscript +Ap |char* |moreswitches |NN char* s p |OP* |my |NN OP* o Ap |NV |my_atof |NN const char *s #if (!defined(HAS_MEMCPY) && !defined(HAS_BCOPY)) || (!defined(HAS_MEMMOVE) && !defined(HAS_SAFE_MEMCPY) && !defined(HAS_SAFE_BCOPY)) diff --git a/embed.h b/embed.h index 674f8a1..8918b0d 100644 --- a/embed.h +++ b/embed.h @@ -2530,7 +2530,7 @@ #define mod(a,b) Perl_mod(aTHX_ a,b) #define mode_from_discipline(a) Perl_mode_from_discipline(aTHX_ a) #endif -#define moreswitches(a,b) Perl_moreswitches(aTHX_ a,b) +#define moreswitches(a) Perl_moreswitches(aTHX_ a) #ifdef PERL_CORE #define my(a) Perl_my(aTHX_ a) #endif diff --git a/perl.c b/perl.c index 09e49c6..cf84f86 100644 --- a/perl.c +++ b/perl.c @@ -1643,7 +1643,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) case 'X': case 'w': case 'A': - if ((s = moreswitches(s, -1))) + if ((s = moreswitches(s))) goto reswitch; break; @@ -1981,7 +1981,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) PL_tainting = TRUE; } } else { - moreswitches(d, -1); + moreswitches(d); } } } @@ -2009,7 +2009,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit) else if (scriptname == NULL) { #ifdef MSDOS if ( PerlLIO_isatty(PerlIO_fileno(PerlIO_stdin())) ) - moreswitches("h", -1); + moreswitches("h"); #endif scriptname = "-"; } @@ -2935,7 +2935,7 @@ Perl_get_debug_opts(pTHX_ const char **s, bool givehelp) /* This routine handles any switches that can be given during run */ char * -Perl_moreswitches(pTHX_ char *s, const int suidscript) +Perl_moreswitches(pTHX_ char *s) { dVAR; UV rschar; @@ -3003,7 +3003,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) s++; return s; case 'd': - forbid_setid('d', suidscript); + forbid_setid('d', -1); s++; /* -dt indicates to the debugger that threads will be used */ @@ -3037,7 +3037,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) case 'D': { #ifdef DEBUGGING - forbid_setid('D', suidscript); + forbid_setid('D', -1); s++; PL_debug = get_debug_opts( (const char **)&s, 1) | DEBUG_TOP_FLAG; #else /* !DEBUGGING */ @@ -3069,7 +3069,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) } return s; case 'I': /* -I handled both here and in parse_body() */ - forbid_setid('I', suidscript); + forbid_setid('I', -1); ++s; while (*s && isSPACE(*s)) ++s; @@ -3118,7 +3118,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) } return s; case 'A': - forbid_setid('A', suidscript); + forbid_setid('A', -1); if (!PL_preambleav) PL_preambleav = newAV(); s++; @@ -3141,10 +3141,10 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) return s; } case 'M': - forbid_setid('M', suidscript); /* XXX ? */ + forbid_setid('M', -1); /* XXX ? */ /* FALL THROUGH */ case 'm': - forbid_setid('m', suidscript); /* XXX ? */ + forbid_setid('m', -1); /* XXX ? */ if (*++s) { char *start; SV *sv; @@ -3191,7 +3191,7 @@ Perl_moreswitches(pTHX_ char *s, const int suidscript) s++; return s; case 's': - forbid_setid('s', suidscript); + forbid_setid('s', -1); PL_doswitches = TRUE; s++; return s; @@ -4229,7 +4229,11 @@ S_find_beginning(pTHX_ const int suidscript) /* skip forward in input to the real script? */ + /* This will croak if suidscript is >= 0, as -x cannot be used with + setuid scripts. */ forbid_setid('x', suidscript); + /* Hence you can't get here if suidscript >= 0 */ + #ifdef MACOS_TRADITIONAL /* Since the Mac OS does not honor #! arguments for us, we do it ourselves */ @@ -4265,7 +4269,7 @@ S_find_beginning(pTHX_ const int suidscript) while (isDIGIT(s2[-1]) || s2[-1] == '-' || s2[-1] == '.' || s2[-1] == '_') s2--; if (strnEQ(s2-4,"perl",4)) - while ((s = moreswitches(s, -1))) + while ((s = moreswitches(s))) ; } #ifdef MACOS_TRADITIONAL diff --git a/proto.h b/proto.h index be01dc4..f445055 100644 --- a/proto.h +++ b/proto.h @@ -1306,7 +1306,7 @@ PERL_CALLCONV void Perl_mini_mktime(pTHX_ struct tm *pm) PERL_CALLCONV OP* Perl_mod(pTHX_ OP* o, I32 type); PERL_CALLCONV int Perl_mode_from_discipline(pTHX_ SV* discp); -PERL_CALLCONV char* Perl_moreswitches(pTHX_ char* s, int suidscript) +PERL_CALLCONV char* Perl_moreswitches(pTHX_ char* s) __attribute__nonnull__(pTHX_1); PERL_CALLCONV OP* Perl_my(pTHX_ OP* o) diff --git a/toke.c b/toke.c index df89130..8f01720 100644 --- a/toke.c +++ b/toke.c @@ -3008,12 +3008,7 @@ Perl_yylex(pTHX) Perl_croak(aTHX_ "Too late for \"-%.*s\" option", (int)(d - m), m); } - /* Given that these switches are within the script, - then it is not unsafe to allow them even within - a suidperl fd script. Hence pass in the - suidscript flag as -1, irrespective of what we - really are. */ - d = moreswitches(d, -1); + d = moreswitches(d); } while (d); if (PL_doswitches && !switches_done) { int argc = PL_origargc;