Change 33000 by [EMAIL PROTECTED] on 2008/01/18 14:27:36
Eliminate all PERL_UNUSED_ARG()s in S_validate_suid() by changing its
prototype depending on the compile time options. In turn, this finds
things that are unused in its callers.
Affected files ...
... //depot/perl/embed.fnc#559 edit
... //depot/perl/embed.h#743 edit
... //depot/perl/perl.c#853 edit
... //depot/perl/perl.h#822 edit
... //depot/perl/proto.h#893 edit
Differences ...
==== //depot/perl/embed.fnc#559 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#558~32958~ 2008-01-11 08:42:11.000000000 -0800
+++ perl/embed.fnc 2008-01-18 06:27:36.000000000 -0800
@@ -1277,10 +1277,23 @@
s |int |open_script |NN const char *scriptname|bool dosearch \
|NN int *suidscript|NN PerlIO **rsfpp
s |void |usage |NN const char *name
-s |void |validate_suid |NN const char *validarg \
- |NN const char *scriptname|int fdscript \
+#ifdef DOSUID
+# ifdef IAMSUID
+so |void |validate_suid |NN const char *validarg \
+ |int fdscript \
|int suidscript|NN SV* linestr_sv \
|NN PerlIO *rsfp
+# else
+so |void |validate_suid |NN const char *validarg \
+ |NN const char *scriptname|int fdscript \
+ |NN SV* linestr_sv \
+ |NN PerlIO *rsfp
+# endif
+#else
+# ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
+so |void |validate_suid |NN PerlIO *rsfp
+# endif
+#endif
# if defined(IAMSUID)
s |int |fd_on_nosuid_fs|int fd
==== //depot/perl/embed.h#743 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#742~32958~ 2008-01-11 08:42:11.000000000 -0800
+++ perl/embed.h 2008-01-18 06:27:36.000000000 -0800
@@ -1259,7 +1259,14 @@
#define nuke_stacks S_nuke_stacks
#define open_script S_open_script
#define usage S_usage
-#define validate_suid S_validate_suid
+#endif
+#ifdef DOSUID
+# ifdef IAMSUID
+# else
+# endif
+#else
+# ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
+# endif
#endif
# if defined(IAMSUID)
#ifdef PERL_CORE
@@ -3552,7 +3559,20 @@
#define nuke_stacks() S_nuke_stacks(aTHX)
#define open_script(a,b,c,d) S_open_script(aTHX_ a,b,c,d)
#define usage(a) S_usage(aTHX_ a)
-#define validate_suid(a,b,c,d,e,f) S_validate_suid(aTHX_ a,b,c,d,e,f)
+#endif
+#ifdef DOSUID
+# ifdef IAMSUID
+#ifdef PERL_CORE
+#endif
+# else
+#ifdef PERL_CORE
+#endif
+# endif
+#else
+# ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
+#ifdef PERL_CORE
+#endif
+# endif
#endif
# if defined(IAMSUID)
#ifdef PERL_CORE
==== //depot/perl/perl.c#853 (text) ====
Index: perl/perl.c
--- perl/perl.c#852~32998~ 2008-01-18 03:01:15.000000000 -0800
+++ perl/perl.c 2008-01-18 06:27:36.000000000 -0800
@@ -125,16 +125,22 @@
static I32 read_e_script(pTHX_ int idx, SV *buf_sv, int maxlen);
-#ifdef IAMSUID
-#ifndef DOSUID
-#define DOSUID
-#endif
-#endif /* IAMSUID */
-
-#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
#ifdef DOSUID
-#undef DOSUID
-#endif
+# ifdef IAMSUID
+/* Drop scriptname */
+# define validate_suid(validarg, scriptname, fdscript, suidscript,
linestr_sv, rsfp) S_validate_suid(aTHX_ validarg, fdscript, suidscript,
linestr_sv, rsfp)
+# else
+/* Drop suidscript */
+# define validate_suid(validarg, scriptname, fdscript, suidscript,
linestr_sv, rsfp) S_validate_suid(aTHX_ validarg, scriptname, fdscript,
linestr_sv, rsfp)
+# endif
+#else
+# ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
+/* Drop everything. Heck, don't even try to call it */
+# define validate_suid(validarg, scriptname, fdscript, suidscript,
linestr_sv, rsfp) NOOP
+# else
+/* Drop almost everything */
+# define validate_suid(validarg, scriptname, fdscript, suidscript,
linestr_sv, rsfp) S_validate_suid(aTHX_ rsfp)
+# endif
#endif
#define CALL_BODY_EVAL(myop) \
@@ -1486,12 +1492,9 @@
PERL_UNUSED_ARG(my_perl);
-#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
-#ifdef IAMSUID
-#undef IAMSUID
- Perl_croak(aTHX_ "suidperl is no longer needed since the kernel can now
execute\n\
-setuid perl scripts securely.\n");
-#endif /* IAMSUID */
+#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW_AND_IAMSUID
+ Perl_croak(aTHX_ "suidperl is no longer needed since the kernel can now "
+ "execute\nsetuid perl scripts securely.\n");
#endif
#if defined(USE_HASH_SEED) || defined(USE_HASH_SEED_EXPLICIT)
@@ -3762,31 +3765,20 @@
}
#endif /* IAMSUID */
+#ifdef DOSUID
STATIC void
-S_validate_suid(pTHX_ const char *validarg, const char *scriptname,
- int fdscript, int suidscript, SV *linestr_sv, PerlIO *rsfp)
+S_validate_suid(pTHX_ const char *validarg,
+# ifndef IAMSUID
+ const char *scriptname,
+# endif
+ int fdscript,
+# ifdef IAMSUID
+ int suidscript,
+# endif
+ SV *linestr_sv, PerlIO *rsfp)
{
dVAR;
-#ifdef DOSUID
const char *s, *s2;
-#endif
-
-#ifdef DOSUID
-# ifdef IAMSUID
- PERL_UNUSED_ARG(scriptname);
-# else
- PERL_UNUSED_ARG(suidscript);
-# endif
-#else
- PERL_UNUSED_ARG(validarg);
- PERL_UNUSED_ARG(scriptname);
- PERL_UNUSED_ARG(linestr_sv);
- PERL_UNUSED_ARG(fdscript);
- PERL_UNUSED_ARG(suidscript);
-# ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
- PERL_UNUSED_ARG(rsfp);
-# endif
-#endif
/* do we need to emulate setuid on scripts? */
@@ -3815,8 +3807,6 @@
* Configure script will set this up for you if you want it.
*/
-#ifdef DOSUID
-
if (PerlLIO_fstat(PerlIO_fileno(rsfp),&PL_statbuf) < 0) /* normal stat
is insecure */
Perl_croak(aTHX_ "Can't stat script \"%s\"",PL_origfilename);
if (PL_statbuf.st_mode & (S_ISUID|S_ISGID)) {
@@ -4158,7 +4148,16 @@
PERL_FPU_POST_EXEC
Perl_croak(aTHX_ "Can't do setuid (suidperl cannot exec perl)\n");
# endif /* IAMSUID */
+}
+
#else /* !DOSUID */
+
+# ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
+/* Don't even need this function. */
+# else
+STATIC void
+S_validate_suid(pTHX_ PerlIO *rsfp)
+{
if (PL_euid != PL_uid || PL_egid != PL_gid) { /* (suidperl doesn't
exist, in fact) */
# ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
PerlLIO_fstat(PerlIO_fileno(rsfp),&PL_statbuf); /* may be either
wrapped or real suid */
@@ -4172,8 +4171,9 @@
# endif /* SETUID_SCRIPTS_ARE_SECURE_NOW */
/* not set-id, must be wrapped */
}
-#endif /* DOSUID */
}
+# endif /* SETUID_SCRIPTS_ARE_SECURE_NOW */
+#endif /* DOSUID */
STATIC void
S_find_beginning(pTHX_ SV* linestr_sv, PerlIO *rsfp)
==== //depot/perl/perl.h#822 (text) ====
Index: perl/perl.h
--- perl/perl.h#821~32955~ 2008-01-11 05:59:32.000000000 -0800
+++ perl/perl.h 2008-01-18 06:27:36.000000000 -0800
@@ -41,6 +41,24 @@
# endif
#endif
+/* This logic needs to come after reading config.h, but before including
+ proto.h */
+#ifdef IAMSUID
+# ifndef DOSUID
+# define DOSUID
+# endif
+#endif
+
+#ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
+# ifdef DOSUID
+# undef DOSUID
+# endif
+# ifdef IAMSUID
+# undef IAMSUID
+# define SETUID_SCRIPTS_ARE_SECURE_NOW_AND_IAMSUID
+# endif
+#endif
+
/* See L<perlguts/"The Perl API"> for detailed notes on
* PERL_IMPLICIT_CONTEXT and PERL_IMPLICIT_SYS */
==== //depot/perl/proto.h#893 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#892~32958~ 2008-01-11 08:42:11.000000000 -0800
+++ perl/proto.h 2008-01-18 06:27:36.000000000 -0800
@@ -3410,12 +3410,28 @@
STATIC void S_usage(pTHX_ const char *name)
__attribute__nonnull__(pTHX_1);
-STATIC void S_validate_suid(pTHX_ const char *validarg, const char
*scriptname, int fdscript, int suidscript, SV* linestr_sv, PerlIO *rsfp)
+#ifdef DOSUID
+# ifdef IAMSUID
+STATIC void S_validate_suid(pTHX_ const char *validarg, int fdscript, int
suidscript, SV* linestr_sv, PerlIO *rsfp)
+ __attribute__nonnull__(pTHX_1)
+ __attribute__nonnull__(pTHX_4)
+ __attribute__nonnull__(pTHX_5);
+
+# else
+STATIC void S_validate_suid(pTHX_ const char *validarg, const char
*scriptname, int fdscript, SV* linestr_sv, PerlIO *rsfp)
__attribute__nonnull__(pTHX_1)
__attribute__nonnull__(pTHX_2)
- __attribute__nonnull__(pTHX_5)
- __attribute__nonnull__(pTHX_6);
+ __attribute__nonnull__(pTHX_4)
+ __attribute__nonnull__(pTHX_5);
+# endif
+#else
+# ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
+STATIC void S_validate_suid(pTHX_ PerlIO *rsfp)
+ __attribute__nonnull__(pTHX_1);
+
+# endif
+#endif
# if defined(IAMSUID)
STATIC int S_fd_on_nosuid_fs(pTHX_ int fd);
End of Patch.