1 char rcsid[] = "$Header: perly.c,v 3.0.1.8 90/10/16 10:14:20 lwall Locked $\nPatch level: ###\n";
3 * Copyright (c) 1989, Larry Wall
5 * You may distribute under the terms of the GNU General Public License
6 * as specified in the README file that comes with the perl 3.0 kit.
9 * Revision 3.0.1.8 90/10/16 10:14:20 lwall
10 * patch29: *foo now prints as *package'foo
11 * patch29: added waitpid
12 * patch29: the debugger now understands packages and evals
13 * patch29: added -M, -A and -C
14 * patch29: -w sometimes printed spurious warnings about ARGV and ENV
15 * patch29: require "./foo" didn't work right
16 * patch29: require error messages referred to wrong file
18 * Revision 3.0.1.7 90/08/13 22:22:22 lwall
19 * patch28: defined(@array) and defined(%array) didn't work right
21 * Revision 3.0.1.6 90/08/09 04:55:50 lwall
22 * patch19: added -x switch to extract script from input trash
23 * patch19: Added -c switch to do compilation only
24 * patch19: added numeric interpretation of $]
25 * patch19: added require operator
26 * patch19: $0, %ENV, @ARGV were wrong in dumped script
27 * patch19: . is now explicitly in @INC (and last)
29 * Revision 3.0.1.5 90/03/27 16:20:57 lwall
30 * patch16: MSDOS support
31 * patch16: do FILE inside eval blows up
33 * Revision 3.0.1.4 90/02/28 18:06:41 lwall
34 * patch9: perl can now start up other interpreters scripts
35 * patch9: nested evals clobbered their longjmp environment
36 * patch9: eval could mistakenly return undef in array context
38 * Revision 3.0.1.3 89/12/21 20:15:41 lwall
39 * patch7: ANSI strerror() is now supported
40 * patch7: errno may now be a macro with an lvalue
41 * patch7: allowed setuid scripts to have a space after #!
43 * Revision 3.0.1.2 89/11/17 15:34:42 lwall
44 * patch5: fixed possible confusion about current effective gid
46 * Revision 3.0.1.1 89/11/11 04:50:04 lwall
47 * patch2: moved yydebug to where its type didn't matter
49 * Revision 3.0 89/10/18 15:22:21 lwall
60 #include "patchlevel.h"
69 #ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
75 static char* moreswitches();
77 extern char **environ;
87 char *index(), *strcpy(), *getenv();
88 bool dosearch = FALSE;
93 #ifdef SETUID_SCRIPTS_ARE_SECURE_NOW
96 fatal("suidperl is no longer needed since the kernel can now execute\n\
97 setuid perl scripts securely.\n");
104 euid = (int)geteuid();
106 egid = (int)getegid();
109 * There is no way we can refer to them from Perl so close them to save
110 * space. The other alternative would be to provide STDAUX and STDPRN
113 (void)fclose(stdaux);
114 (void)fclose(stdprn);
117 origfilename = savestr(argv[0]);
119 loop_ptr = -1; /* start label stack again */
122 (void)sprintf(index(rcsid,'#'), "%d\n", PATCHLEVEL);
123 linestr = Str_new(65,80);
124 str_nset(linestr,"",0);
125 str = str_make("",0); /* first used for -I flags */
126 curstash = defstash = hnew(0);
127 curstname = str_make("main",4);
128 stab_xhash(stabent("_main",TRUE)) = defstash;
129 defstash->tbl_name = "main";
130 incstab = hadd(aadd(stabent("INC",TRUE)));
131 incstab->str_pok |= SP_MULTI;
132 for (argc--,argv++; argc > 0; argc--,argv++) {
133 if (argv[0][0] != '-' || !argv[0][1])
137 validarg = " PHOOEY ";
155 if (s = moreswitches(s))
161 if (euid != uid || egid != gid)
162 fatal("No -e allowed in setuid scripts");
165 e_tmpname = savestr(TMPPATH);
166 (void)mktemp(e_tmpname);
167 e_fp = fopen(e_tmpname,"w");
169 fatal("Cannot open temporary file");
175 (void)putc('\n', e_fp);
179 if (euid != uid || egid != gid)
180 fatal("No -I allowed in setuid scripts");
186 (void)apush(stab_array(incstab),str_make(s,0));
189 (void)apush(stab_array(incstab),str_make(argv[1],0));
190 str_cat(str,argv[1]);
197 if (euid != uid || egid != gid)
198 fatal("No -P allowed in setuid scripts");
205 if (euid != uid || egid != gid)
206 fatal("No -s allowed in setuid scripts");
227 fatal("Unrecognized switch: -%s",s);
237 #define PRIVLIB "/usr/local/lib/perl"
239 (void)apush(stab_array(incstab),str_make(PRIVLIB,0));
240 (void)apush(stab_array(incstab),str_make(".",1));
243 str_set(&str_yes,Yes);
247 if (argv[0] == Nullch)
249 if (dosearch && !index(argv[0], '/') && (s = getenv("PATH"))) {
250 char *xfound = Nullch, *xfailed = Nullch;
253 bufend = s + strlen(s);
256 s = cpytill(tokenbuf,s,bufend,':',&len);
258 for (len = 0; *s && *s != ';'; tokenbuf[len++] = *s++);
259 tokenbuf[len] = '\0';
264 if (len && tokenbuf[len-1] != '/')
266 if (len && tokenbuf[len-1] != '\\')
268 (void)strcat(tokenbuf+len,"/");
269 (void)strcat(tokenbuf+len,argv[0]);
272 fprintf(stderr,"Looking for %s\n",tokenbuf);
274 if (stat(tokenbuf,&statbuf) < 0) /* not there? */
276 if ((statbuf.st_mode & S_IFMT) == S_IFREG
277 && cando(S_IREAD,TRUE,&statbuf) && cando(S_IEXEC,TRUE,&statbuf)) {
278 xfound = tokenbuf; /* bingo! */
282 xfailed = savestr(tokenbuf);
285 fatal("Can't execute %s", xfailed ? xfailed : argv[0] );
288 argv[0] = savestr(xfound);
291 fdpid = anew(Nullstab); /* for remembering popen pids by fd */
292 pidstatus = hnew(Nullstab); /* for remembering status of dead pids */
294 origfilename = savestr(argv[0]);
295 curcmd->c_filestab = fstab(origfilename);
296 if (strEQ(origfilename,"-"))
300 str_cat(str,PRIVLIB);
301 (void)sprintf(buf, "\
302 %ssed %s -e '/^[^#]/b' \
303 -e '/^#[ ]*include[ ]/b' \
304 -e '/^#[ ]*define[ ]/b' \
305 -e '/^#[ ]*if[ ]/b' \
306 -e '/^#[ ]*ifdef[ ]/b' \
307 -e '/^#[ ]*ifndef[ ]/b' \
309 -e '/^#[ ]*endif/b' \
317 (doextract ? "-e '1,/^#/d\n'" : ""),
318 argv[0], CPPSTDIN, str_get(str), CPPMINUS);
320 #ifdef IAMSUID /* actually, this is caught earlier */
321 if (euid != uid && !euid) /* if running suidperl */
323 (void)seteuid(uid); /* musn't stay setuid root */
326 (void)setreuid(-1, uid);
332 rsfp = mypopen(buf,"r");
337 rsfp = fopen(argv[0],"r");
338 if (rsfp == Nullfp) {
340 #ifndef IAMSUID /* in case script is not readable before setuid */
341 if (euid && stat(stab_val(curcmd->c_filestab)->str_ptr,&statbuf) >= 0 &&
342 statbuf.st_mode & (S_ISUID|S_ISGID)) {
343 (void)sprintf(buf, "%s/%s", BIN, "suidperl");
344 execv(buf, origargv); /* try again */
345 fatal("Can't do setuid\n");
349 fatal("Can't open perl script \"%s\": %s\n",
350 stab_val(curcmd->c_filestab)->str_ptr, strerror(errno));
352 str_free(str); /* free -I directories */
354 /* do we need to emulate setuid on scripts? */
356 /* This code is for those BSD systems that have setuid #! scripts disabled
357 * in the kernel because of a security problem. Merely defining DOSUID
358 * in perl will not fix that problem, but if you have disabled setuid
359 * scripts in the kernel, this will attempt to emulate setuid and setgid
360 * on scripts that have those now-otherwise-useless bits set. The setuid
361 * root version must be called suidperl. If regular perl discovers that
362 * it has opened a setuid script, it calls suidperl with the same argv
363 * that it had. If suidperl finds that the script it has just opened
364 * is NOT setuid root, it sets the effective uid back to the uid. We
365 * don't just make perl setuid root because that loses the effective
366 * uid we had before invoking perl, if it was different from the uid.
368 * DOSUID must be defined in both perl and suidperl, and IAMSUID must
369 * be defined in suidperl only. suidperl must be setuid root. The
370 * Configure script will set this up for you if you want it.
372 * There is also the possibility of have a script which is running
373 * set-id due to a C wrapper. We want to do the TAINT checks
374 * on these set-id scripts, but don't want to have the overhead of
375 * them in normal perl, and can't use suidperl because it will lose
376 * the effective uid info, so we have an additional non-setuid root
377 * version called taintperl that just does the TAINT checks.
381 if (fstat(fileno(rsfp),&statbuf) < 0) /* normal stat is insecure */
382 fatal("Can't stat script \"%s\"",origfilename);
383 if (statbuf.st_mode & (S_ISUID|S_ISGID)) {
388 /* On this access check to make sure the directories are readable,
389 * there is actually a small window that the user could use to make
390 * filename point to an accessible directory. So there is a faint
391 * chance that someone could execute a setuid script down in a
392 * non-accessible directory. I don't know what to do about that.
393 * But I don't think it's too important. The manual lies when
394 * it says access() is useful in setuid programs.
396 if (access(stab_val(curcmd->c_filestab)->str_ptr,1)) /*double check*/
397 fatal("Permission denied");
399 /* If we can swap euid and uid, then we can determine access rights
400 * with a simple stat of the file, and then compare device and
401 * inode to make sure we did stat() on the same file we opened.
402 * Then we just have to make sure he or she can execute it.
405 struct stat tmpstatbuf;
407 if (setreuid(euid,uid) < 0 || getuid() != euid || geteuid() != uid)
408 fatal("Can't swap uid and euid"); /* really paranoid */
409 if (stat(stab_val(curcmd->c_filestab)->str_ptr,&tmpstatbuf) < 0)
410 fatal("Permission denied"); /* testing full pathname here */
411 if (tmpstatbuf.st_dev != statbuf.st_dev ||
412 tmpstatbuf.st_ino != statbuf.st_ino) {
414 if (rsfp = mypopen("/bin/mail root","w")) { /* heh, heh */
416 "User %d tried to run dev %d ino %d in place of dev %d ino %d!\n\
417 (Filename of set-id script was %s, uid %d gid %d.)\n\nSincerely,\nperl\n",
418 uid,tmpstatbuf.st_dev, tmpstatbuf.st_ino,
419 statbuf.st_dev, statbuf.st_ino,
420 stab_val(curcmd->c_filestab)->str_ptr,
421 statbuf.st_uid, statbuf.st_gid);
422 (void)mypclose(rsfp);
424 fatal("Permission denied\n");
426 if (setreuid(uid,euid) < 0 || getuid() != uid || geteuid() != euid)
427 fatal("Can't reswap uid and euid");
428 if (!cando(S_IEXEC,FALSE,&statbuf)) /* can real uid exec? */
429 fatal("Permission denied\n");
431 #endif /* SETREUID */
434 if ((statbuf.st_mode & S_IFMT) != S_IFREG)
435 fatal("Permission denied");
436 if ((statbuf.st_mode >> 6) & S_IWRITE)
437 fatal("Setuid/gid script is writable by world");
438 doswitches = FALSE; /* -s is insecure in suid */
440 if (fgets(tokenbuf,sizeof tokenbuf, rsfp) == Nullch ||
441 strnNE(tokenbuf,"#!",2) ) /* required even on Sys V */
445 while (!isspace(*s)) s++;
446 if (strnNE(s-4,"perl",4)) /* sanity check */
447 fatal("Not a perl script");
448 while (*s == ' ' || *s == '\t') s++;
450 * #! arg must be what we saw above. They can invoke it by
451 * mentioning suidperl explicitly, but they may not add any strange
452 * arguments beyond what #! says if they do invoke suidperl that way.
454 len = strlen(validarg);
455 if (strEQ(validarg," PHOOEY ") ||
456 strnNE(s,validarg,len) || !isspace(s[len]))
457 fatal("Args must match #! line");
460 if (euid != uid && (statbuf.st_mode & S_ISUID) &&
461 euid == statbuf.st_uid)
463 fatal("YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!\n\
464 FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
467 if (euid) { /* oops, we're not the setuid root perl */
470 (void)sprintf(buf, "%s/%s", BIN, "suidperl");
471 execv(buf, origargv); /* try again */
473 fatal("Can't do setuid\n");
476 if (statbuf.st_mode & S_ISGID && statbuf.st_gid != egid)
478 (void)setegid(statbuf.st_gid);
481 (void)setregid((GIDTYPE)-1,statbuf.st_gid);
483 setgid(statbuf.st_gid);
486 if (statbuf.st_mode & S_ISUID) {
487 if (statbuf.st_uid != euid)
489 (void)seteuid(statbuf.st_uid); /* all that for this */
492 (void)setreuid((UIDTYPE)-1,statbuf.st_uid);
494 setuid(statbuf.st_uid);
498 else if (uid) /* oops, mustn't run as root */
500 (void)seteuid((UIDTYPE)uid);
503 (void)setreuid((UIDTYPE)-1,(UIDTYPE)uid);
505 setuid((UIDTYPE)uid);
509 euid = (int)geteuid();
511 egid = (int)getegid();
512 if (!cando(S_IEXEC,TRUE,&statbuf))
513 fatal("Permission denied\n"); /* they can't do this */
517 fatal("-P not allowed for setuid/setgid script\n");
519 fatal("Script is not setuid/setgid in suidperl\n");
521 #ifndef TAINT /* we aren't taintperl or suidperl */
522 /* script has a wrapper--can't run suidperl or we lose euid */
523 else if (euid != uid || egid != gid) {
525 (void)sprintf(buf, "%s/%s", BIN, "taintperl");
526 execv(buf, origargv); /* try again */
527 fatal("Can't run setuid script with taint checks");
532 #ifndef TAINT /* we aren't taintperl or suidperl */
533 if (euid != uid || egid != gid) { /* (suidperl doesn't exist, in fact) */
534 #ifndef SETUID_SCRIPTS_ARE_SECURE_NOW
535 fstat(fileno(rsfp),&statbuf); /* may be either wrapped or real suid */
536 if ((euid != uid && euid == statbuf.st_uid && statbuf.st_mode & S_ISUID)
538 (egid != gid && egid == statbuf.st_gid && statbuf.st_mode & S_ISGID)
541 fatal("YOU HAVEN'T DISABLED SET-ID SCRIPTS IN THE KERNEL YET!\n\
542 FIX YOUR KERNEL, PUT A C WRAPPER AROUND THIS SCRIPT, OR USE -u AND UNDUMP!\n");
543 #endif /* SETUID_SCRIPTS_ARE_SECURE_NOW */
544 /* not set-id, must be wrapped */
546 (void)sprintf(buf, "%s/%s", BIN, "taintperl");
547 execv(buf, origargv); /* try again */
548 fatal("Can't run setuid script with taint checks");
553 #if !defined(IAMSUID) && !defined(TAINT)
555 /* skip forward in input to the real script? */
558 if ((s = str_gets(linestr, rsfp, 0)) == Nullch)
559 fatal("No Perl script found in input\n");
560 if (*s == '#' && s[1] == '!' && instr(s,"perl")) {
561 ungetc('\n',rsfp); /* to keep line count right */
563 if (s = instr(s,"perl -")) {
565 while (s = moreswitches(s)) ;
567 if (cddir && chdir(cddir) < 0)
568 fatal("Can't chdir to %s",cddir);
571 #endif /* !defined(IAMSUID) && !defined(TAINT) */
573 defstab = stabent("_",TRUE);
577 stab_xhash(stabent("_DB",TRUE)) = debstash;
579 dbargs = stab_xarray(aadd((tmpstab = stabent("args",TRUE))));
580 tmpstab->str_pok |= SP_MULTI;
581 dbargs->ary_flags = 0;
582 subname = str_make("main",4);
583 DBstab = stabent("DB",TRUE);
584 DBstab->str_pok |= SP_MULTI;
585 DBline = stabent("dbline",TRUE);
586 DBline->str_pok |= SP_MULTI;
587 DBsub = hadd(tmpstab = stabent("sub",TRUE));
588 tmpstab->str_pok |= SP_MULTI;
589 DBsingle = stab_val((tmpstab = stabent("single",TRUE)));
590 tmpstab->str_pok |= SP_MULTI;
591 DBtrace = stab_val((tmpstab = stabent("trace",TRUE)));
592 tmpstab->str_pok |= SP_MULTI;
593 DBsignal = stab_val((tmpstab = stabent("signal",TRUE)));
594 tmpstab->str_pok |= SP_MULTI;
600 bufend = bufptr = str_get(linestr);
602 savestack = anew(Nullstab); /* for saving non-local values */
603 stack = anew(Nullstab); /* for saving non-local values */
604 stack->ary_flags = 0; /* not a real array */
605 afill(stack,63); afill(stack,-1); /* preextend stack */
606 afill(savestack,63); afill(savestack,-1);
608 /* now parse the script */
611 if (yyparse() || error_count) {
613 fatal("%s had compilation errors.\n", origfilename);
615 fatal("Execution of %s aborted due to compilation errors.\n",
620 New(50,loop_stack,128,struct loop);
623 New(51,debname,128,char);
624 New(52,debdelim,128,char);
632 (void)UNLINK(e_tmpname);
635 /* initialize everything that won't change if we undump */
637 if (sigstab = stabent("SIG",allstabs)) {
638 sigstab->str_pok |= SP_MULTI;
642 magicalize("!#?^~=-%0123456789.+&*()<>,\\/[|`':\024");
643 userinit(); /* in case linked C routines want magical variables */
645 amperstab = stabent("&",allstabs);
646 leftstab = stabent("`",allstabs);
647 rightstab = stabent("'",allstabs);
648 sawampersand = (amperstab || leftstab || rightstab);
649 if (tmpstab = stabent(":",allstabs))
650 str_set(STAB_STR(tmpstab),chopset);
651 if (tmpstab = stabent("\024",allstabs))
654 /* these aren't necessarily magical */
655 if (tmpstab = stabent(";",allstabs))
656 str_set(STAB_STR(tmpstab),"\034");
657 if (tmpstab = stabent("]",allstabs)) {
658 str = STAB_STR(tmpstab);
660 strncpy(tokenbuf,rcsid+19,3);
661 sprintf(tokenbuf+3,"%2.2d",PATCHLEVEL);
662 str->str_u.str_nval = atof(tokenbuf);
665 str_nset(stab_val(stabent("\"", TRUE)), " ", 1);
667 stdinstab = stabent("STDIN",TRUE);
668 stdinstab->str_pok |= SP_MULTI;
669 stab_io(stdinstab) = stio_new();
670 stab_io(stdinstab)->ifp = stdin;
671 tmpstab = stabent("stdin",TRUE);
672 stab_io(tmpstab) = stab_io(stdinstab);
673 tmpstab->str_pok |= SP_MULTI;
675 tmpstab = stabent("STDOUT",TRUE);
676 tmpstab->str_pok |= SP_MULTI;
677 stab_io(tmpstab) = stio_new();
678 stab_io(tmpstab)->ofp = stab_io(tmpstab)->ifp = stdout;
679 defoutstab = tmpstab;
680 tmpstab = stabent("stdout",TRUE);
681 stab_io(tmpstab) = stab_io(defoutstab);
682 tmpstab->str_pok |= SP_MULTI;
684 curoutstab = stabent("STDERR",TRUE);
685 curoutstab->str_pok |= SP_MULTI;
686 stab_io(curoutstab) = stio_new();
687 stab_io(curoutstab)->ofp = stab_io(curoutstab)->ifp = stderr;
688 tmpstab = stabent("stderr",TRUE);
689 stab_io(tmpstab) = stab_io(curoutstab);
690 tmpstab->str_pok |= SP_MULTI;
691 curoutstab = defoutstab; /* switch back to STDOUT */
693 statname = Str_new(66,0); /* last filename we did stat on */
698 just_doit: /* come here if running an undumped a.out */
699 argc--,argv++; /* skip name of script */
701 for (; argc > 0 && **argv == '-'; argc--,argv++) {
702 if (argv[0][1] == '-') {
706 str_numset(stab_val(stabent(argv[0]+1,TRUE)),(double)1.0);
712 if (tmpstab = stabent("0",allstabs))
713 str_set(STAB_STR(tmpstab),origfilename);
714 if (argvstab = stabent("ARGV",allstabs)) {
715 argvstab->str_pok |= SP_MULTI;
716 (void)aadd(argvstab);
717 aclear(stab_array(argvstab));
718 for (; argc > 0; argc--,argv++) {
719 (void)apush(stab_array(argvstab),str_make(argv[0],0));
723 (void) stabent("ENV",TRUE); /* must test PATH and IFS */
725 if (envstab = stabent("ENV",allstabs)) {
726 envstab->str_pok |= SP_MULTI;
728 hclear(stab_hash(envstab), FALSE);
731 for (; *env; env++) {
732 if (!(s = index(*env,'=')))
735 str = str_make(s--,0);
736 str_magic(str, envstab, 'E', *env, s - *env);
737 (void)hstore(stab_hash(envstab), *env, s - *env, str, 0);
744 if (tmpstab = stabent("$",allstabs))
745 str_numset(STAB_STR(tmpstab),(double)getpid());
752 if (setjmp(top_env)) /* sets goto_targ on longjump */
753 loop_ptr = -1; /* start label stack again */
759 fprintf(stderr,"\nEXECUTING...\n\n");
763 fprintf(stderr,"%s syntax OK\n", origfilename);
769 (void) cmd_exec(main_root,G_SCALAR,-1);
772 fatal("Can't find label \"%s\"--aborting",goto_targ);
783 while (*sym = *list++)
784 magicname(sym, Nullch, 0);
788 magicname(sym,name,namlen)
795 if (stab = stabent(sym,allstabs)) {
796 stab_flags(stab) = SF_VMAGIC;
797 str_magic(stab_val(stab), stab, 0, name, namlen);
801 /* this routine is in perly.c by virtue of being sort of an alternate main() */
804 do_eval(str,optype,stash,gimme,arglast)
811 STR **st = stack->ary_array;
816 CMD * VOLATILE oldcurcmd = curcmd;
817 VOLATILE int oldtmps_base = tmps_base;
818 VOLATILE int oldsave = savestack->ary_fill;
819 VOLATILE int oldperldb = perldb;
820 SPAT * VOLATILE oldspat = curspat;
821 static char *last_eval = Nullch;
822 static CMD *last_root = Nullcmd;
823 VOLATILE int sp = arglast[0];
827 tmps_base = tmps_max;
828 if (curstash != stash) {
829 (void)savehptr(&curstash);
832 str_set(stab_val(stabent("@",TRUE)),"");
833 if (curcmd->c_line == 0) /* don't debug debugger... */
836 if (optype == O_EVAL) { /* normal eval */
837 curcmd->c_filestab = fstab("(eval)");
839 str_sset(linestr,str);
840 str_cat(linestr,";"); /* be kind to them */
843 if (last_root && !in_eval) {
848 specfilename = str_get(str);
850 if (optype == O_REQUIRE && &str_undef !=
851 hfetch(stab_hash(incstab), specfilename, strlen(specfilename), 0)) {
853 tmps_base = oldtmps_base;
858 tmpfilename = savestr(specfilename);
859 if (index("/.", *tmpfilename))
860 rsfp = fopen(tmpfilename,"r");
862 ar = stab_array(incstab);
863 for (i = 0; i <= ar->ary_fill; i++) {
864 (void)sprintf(buf, "%s/%s",
865 str_get(afetch(ar,i,TRUE)), specfilename);
866 rsfp = fopen(buf,"r");
870 if (*s == '.' && s[1] == '/')
872 Safefree(tmpfilename);
873 tmpfilename = savestr(s);
878 curcmd->c_filestab = fstab(tmpfilename);
879 Safefree(tmpfilename);
882 tmps_base = oldtmps_base;
883 if (optype == O_REQUIRE) {
884 sprintf(tokenbuf,"Can't locate %s in @INC", specfilename);
885 if (instr(tokenbuf,".h "))
886 strcat(tokenbuf," (change .h to .ph maybe?)");
887 if (instr(tokenbuf,".ph "))
888 strcat(tokenbuf," (did you run h2ph?)");
889 fatal("%s",tokenbuf);
891 if (gimme != G_ARRAY)
892 st[++sp] = &str_undef;
899 oldoldbufptr = oldbufptr = bufptr = str_get(linestr);
900 bufend = bufptr + linestr->str_cur;
901 if (++loop_ptr >= loop_max) {
903 Renew(loop_stack, loop_max, struct loop);
905 loop_stack[loop_ptr].loop_label = "_EVAL_";
906 loop_stack[loop_ptr].loop_sp = sp;
909 deb("(Pushing label #%d _EVAL_)\n", loop_ptr);
912 if (setjmp(loop_stack[loop_ptr].loop_env)) {
920 retval |= error_count;
922 else if (last_root && *bufptr == *last_eval && strEQ(bufptr,last_eval)){
924 eval_root = last_root; /* no point in reparsing */
926 else if (in_eval == 1) {
931 last_eval = savestr(bufptr);
934 retval |= error_count;
936 last_root = eval_root;
941 myroot = eval_root; /* in case cmd_exec does another eval! */
944 st = stack->ary_array;
946 if (gimme != G_ARRAY)
947 st[++sp] = &str_undef;
948 last_root = Nullcmd; /* can't free on error, for some reason */
955 sp = cmd_exec(eval_root,gimme,sp);
956 st = stack->ary_array;
957 for (i = arglast[0] + 1; i <= sp; i++)
958 st[i] = str_static(st[i]);
959 /* if we don't save result, free zaps it */
960 if (in_eval != 1 && myroot != last_root)
968 char *tmps = loop_stack[loop_ptr].loop_label;
969 deb("(Popping label #%d %s)\n",loop_ptr,
974 tmps_base = oldtmps_base;
976 if (savestack->ary_fill > oldsave) /* let them use local() */
977 restorelist(oldsave);
979 if (optype != O_EVAL) {
981 if (optype == O_REQUIRE)
982 fatal("%s", str_get(stab_val(stabent("@",TRUE))));
986 if (gimme == G_SCALAR ? str_true(st[sp]) : sp > arglast[0]) {
987 (void)hstore(stab_hash(incstab), specfilename,
988 strlen(specfilename), str_smake(stab_val(curcmd->c_filestab)),
991 else if (optype == O_REQUIRE)
992 fatal("%s did not return a true value", specfilename);
999 /* This routine handles any switches that can be given during run */
1017 if (euid != uid || egid != gid)
1018 fatal("No -d allowed in setuid scripts");
1026 if (euid != uid || egid != gid)
1027 fatal("No -D allowed in setuid scripts");
1031 warn("Recompile perl with -DDEBUGGING to use -D switch\n");
1035 inplace = savestr(s+1);
1036 for (s = inplace; *s && !isspace(*s); s++) ;
1038 argvoutstab = stabent("ARGVOUT",TRUE);
1042 if (euid != uid || egid != gid)
1043 fatal("No -I allowed in setuid scripts");
1046 (void)apush(stab_array(incstab),str_make(s,0));
1049 fatal("No space allowed after -I");
1068 fputs("\nThis is perl, version 3.0\n\n",stdout);
1069 fputs(rcsid,stdout);
1070 fputs("\nCopyright (c) 1989, 1990, Larry Wall\n",stdout);
1072 fputs("MS-DOS port Copyright (c) 1989, 1990, Diomidis Spinellis\n",
1075 fputs("OS/2 port Copyright (c) 1990, Raymond Chen, Kai Uwe Rommel\n",
1080 Perl may be copied only under the terms of the GNU General Public License,\n\
1081 a copy of which can be found with the Perl 3.0 distribution kit.\n",stdout);
1095 fatal("Switch meaningless after -x: -%s",s);