summaryrefslogtreecommitdiff
path: root/perl.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-18 15:28:09 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-18 15:28:09 +0000
commitf20b29985da982221016a5e2fdf979d5ba37b5cf (patch)
tree090ccdf72dfee40ca0c4e8b6227002787e896c9b /perl.c
parentec2019add1c7fdb16a67372a1ed14c16660c3cea (diff)
downloadperl-f20b29985da982221016a5e2fdf979d5ba37b5cf.tar.gz
The suidscript argument to S_forbid_setid(), S_open_script() and
S_validate_suid() is actually just a boolean. So make it so. p4raw-id: //depot/perl@33001
Diffstat (limited to 'perl.c')
-rw-r--r--perl.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/perl.c b/perl.c
index a8f53039a0..214d666dc6 100644
--- a/perl.c
+++ b/perl.c
@@ -1767,7 +1767,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
if (argv[1] && !strcmp(argv[1], "Dev:Pseudo"))
break;
#endif
- forbid_setid('e', -1);
+ forbid_setid('e', FALSE);
if (!PL_e_script) {
PL_e_script = newSVpvs("");
add_read_e_script = TRUE;
@@ -1791,7 +1791,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
goto reswitch;
case 'I': /* -I handled both here and in moreswitches() */
- forbid_setid('I', -1);
+ forbid_setid('I', FALSE);
if (!*++s && (s=argv[1]) != NULL) {
argc--,argv++;
}
@@ -1808,7 +1808,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
Perl_croak(aTHX_ "No directory specified for -I");
break;
case 'S':
- forbid_setid('S', -1);
+ forbid_setid('S', FALSE);
dosearch = TRUE;
s++;
goto reswitch;
@@ -2030,7 +2030,7 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
init_perllib();
{
- int suidscript;
+ bool suidscript = FALSE;
const int fdscript
= open_script(scriptname, dosearch, &suidscript, &rsfp);
@@ -2060,10 +2060,10 @@ S_parse_body(pTHX_ char **env, XSINIT_t xsinit)
#endif
) {
- /* This will croak if suidscript is >= 0, as -x cannot be used with
+ /* This will croak if suidscript is true, as -x cannot be used with
setuid scripts. */
forbid_setid('x', suidscript);
- /* Hence you can't get here if suidscript >= 0 */
+ /* Hence you can't get here if suidscript is true */
find_beginning(linestr_sv, rsfp);
if (cddir && PerlDir_chdir( (char *)cddir ) < 0)
@@ -3017,7 +3017,7 @@ Perl_moreswitches(pTHX_ const char *s)
s++;
return s;
case 'd':
- forbid_setid('d', -1);
+ forbid_setid('d', FALSE);
s++;
/* -dt indicates to the debugger that threads will be used */
@@ -3055,7 +3055,7 @@ Perl_moreswitches(pTHX_ const char *s)
case 'D':
{
#ifdef DEBUGGING
- forbid_setid('D', -1);
+ forbid_setid('D', FALSE);
s++;
PL_debug = get_debug_opts( (const char **)&s, 1) | DEBUG_TOP_FLAG;
#else /* !DEBUGGING */
@@ -3091,7 +3091,7 @@ Perl_moreswitches(pTHX_ const char *s)
}
return s;
case 'I': /* -I handled both here and in parse_body() */
- forbid_setid('I', -1);
+ forbid_setid('I', FALSE);
++s;
while (*s && isSPACE(*s))
++s;
@@ -3140,10 +3140,10 @@ Perl_moreswitches(pTHX_ const char *s)
}
return s;
case 'M':
- forbid_setid('M', -1); /* XXX ? */
+ forbid_setid('M', FALSE); /* XXX ? */
/* FALL THROUGH */
case 'm':
- forbid_setid('m', -1); /* XXX ? */
+ forbid_setid('m', FALSE); /* XXX ? */
if (*++s) {
const char *start;
const char *end;
@@ -3191,7 +3191,7 @@ Perl_moreswitches(pTHX_ const char *s)
s++;
return s;
case 's':
- forbid_setid('s', -1);
+ forbid_setid('s', FALSE);
PL_doswitches = TRUE;
s++;
return s;
@@ -3491,13 +3491,11 @@ S_init_main_stash(pTHX)
STATIC int
S_open_script(pTHX_ const char *scriptname, bool dosearch,
- int *suidscript, PerlIO **rsfpp)
+ bool *suidscript, PerlIO **rsfpp)
{
int fdscript = -1;
dVAR;
- *suidscript = -1;
-
if (PL_e_script) {
PL_origfilename = savepvs("-e");
}
@@ -3520,7 +3518,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch,
* Is it a mistake to use a similar /dev/fd/ construct for
* suidperl?
*/
- *suidscript = 1;
+ *suidscript = TRUE;
/* PSz 20 Feb 04
* Be supersafe and do some sanity-checks.
* Still, can we be sure we got the right thing?
@@ -3563,7 +3561,7 @@ S_open_script(pTHX_ const char *scriptname, bool dosearch,
* perl with that fd as it has always done.
*/
}
- if (*suidscript != 1) {
+ if (*suidscript) {
Perl_croak(aTHX_ "suidperl needs (suid) fd script\n");
}
#else /* IAMSUID */
@@ -3773,7 +3771,7 @@ S_validate_suid(pTHX_ const char *validarg,
# endif
int fdscript,
# ifdef IAMSUID
- int suidscript,
+ bool suidscript,
# endif
SV *linestr_sv, PerlIO *rsfp)
{
@@ -3815,7 +3813,7 @@ S_validate_suid(pTHX_ const char *validarg,
const char *s_end;
# ifdef IAMSUID
- if (fdscript < 0 || suidscript != 1)
+ if (fdscript < 0 || !suidscript)
Perl_croak(aTHX_ "Need (suid) fdscript in suidperl\n"); /* We already checked this */
/* PSz 11 Nov 03
* Since the script is opened by perl, not suidperl, some of these
@@ -4092,7 +4090,7 @@ FIX YOUR KERNEL, OR PUT A C WRAPPER AROUND THIS SCRIPT!\n");
Perl_croak(aTHX_ "Effective UID cannot exec script\n"); /* they can't do this */
}
# ifdef IAMSUID
- else if (fdscript < 0 || suidscript != 1)
+ else if (fdscript < 0 || !suidscript)
/* PSz 13 Nov 03 Caught elsewhere, useless(?!) here */
Perl_croak(aTHX_ "(suid) fdscript needed in suidperl\n");
else {
@@ -4312,7 +4310,7 @@ Perl_doing_taint(int argc, char *argv[], char *envp[])
"program input from stdin", which is substituted in place of '\0', which
could never be a command line flag. */
STATIC void
-S_forbid_setid(pTHX_ const char flag, const int suidscript)
+S_forbid_setid(pTHX_ const char flag, const bool suidscript) /* g */
{
dVAR;
char string[3] = "-x";
@@ -4351,7 +4349,7 @@ S_forbid_setid(pTHX_ const char flag, const int suidscript)
*
* Also see comments about root running a setuid script, elsewhere.
*/
- if (suidscript >= 0)
+ if (suidscript)
Perl_croak(aTHX_ "No %s allowed with (suid) fdscript", message);
#ifdef IAMSUID
/* PSz 11 Nov 03 Catch it in suidperl, always! */