summaryrefslogtreecommitdiff
path: root/taint.c
diff options
context:
space:
mode:
authorLarry Wall <larry@netlabs.com>1993-11-10 00:00:00 +0000
committerLarry Wall <larry@netlabs.com>1993-11-10 00:00:00 +0000
commit463ee0b2acbd047c27e8b5393cdd8398881824c5 (patch)
treeae17d9179fc861ae5fc5a86da9139631530cb6fe /taint.c
parent93a17b20b6d176db3f04f51a63b0a781e5ffd11c (diff)
downloadperl-463ee0b2acbd047c27e8b5393cdd8398881824c5.tar.gz
perl 5.0 alpha 4
[editor's note: the sparc executables have not been included, and emacs backup files have been removed. This was reconstructed from a tarball found on the September 1994 InfoMagic CD; the date of this is approximate]
Diffstat (limited to 'taint.c')
-rw-r--r--taint.c62
1 files changed, 44 insertions, 18 deletions
diff --git a/taint.c b/taint.c
index 5178ee2250..66affdde86 100644
--- a/taint.c
+++ b/taint.c
@@ -1,14 +1,38 @@
+#include "EXTERN.h"
+#include "perl.h"
+
+void
+taint_not(s)
+char *s;
+{
+ if (euid != uid)
+ croak("No %s allowed while running setuid", s);
+ if (egid != gid)
+ croak("No %s allowed while running setgid", s);
+}
+
void
taint_proper(f, s)
char *f;
char *s;
{
- DEBUG_u(fprintf(stderr,"%s %d %d %d\n",s,tainted,uid, euid));
- if (tainted && (!euid || euid != uid || egid != gid || taintanyway)) {
- if (!unsafe)
- fatal(f, s);
- else if (dowarn)
- warn(f, s);
+ if (tainting) {
+ DEBUG_u(fprintf(stderr,"%s %d %d %d\n",s,tainted,uid, euid));
+ if (tainted) {
+ char *ug = 0;
+ if (euid != uid)
+ ug = " while running setuid";
+ else if (egid != gid)
+ ug = " while running setgid";
+ else if (tainting)
+ ug = " while running with -T switch";
+ if (ug) {
+ if (!unsafe)
+ croak(f, s, ug);
+ else if (dowarn)
+ warn(f, s, ug);
+ }
+ }
}
}
@@ -17,18 +41,20 @@ taint_env()
{
SV** svp;
- svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE);
- if (!svp || *svp == &sv_undef || (*svp)->sv_tainted) {
- tainted = 1;
- if ((*svp)->sv_tainted == 2)
- taint_proper("Insecure directory in %s", "PATH");
- else
- taint_proper("Insecure %s", "PATH");
- }
- svp = hv_fetch(GvHVn(envgv),"IFS",3,FALSE);
- if (svp && *svp != &sv_undef && (*svp)->sv_tainted) {
- tainted = 1;
- taint_proper("Insecure %s", "IFS");
+ if (tainting) {
+ svp = hv_fetch(GvHVn(envgv),"PATH",4,FALSE);
+ if (!svp || *svp == &sv_undef || mg_find(*svp, 't')) {
+ tainted = 1;
+ if (SvPRIVATE(*svp) & SVp_TAINTEDDIR)
+ taint_proper("Insecure directory in %s%s", "PATH");
+ else
+ taint_proper("Insecure %s%s", "PATH");
+ }
+ svp = hv_fetch(GvHVn(envgv),"IFS",3,FALSE);
+ if (svp && *svp != &sv_undef && mg_find(*svp, 't')) {
+ tainted = 1;
+ taint_proper("Insecure %s%s", "IFS");
+ }
}
}