home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.perl
- Path: sparky!uunet!rayssd!ras
- From: ras@rayssd.ssd.ray.com (Shaw)
- Subject: Bad label: _EVAL_, inconsistent behavior
- Message-ID: <1992Aug14.184402.25912@rayssd.ssd.ray.com>
- Summary: eval works nonsetuid, fails when setuid
- Keywords: eval, setuidness, etc.
- Sender: Ralph Shaw (ras@ssd.ray.com)
- Organization: Raytheon Submarine Signal Division, Portsmouth, RI
- Distribution: usa
- Date: Fri, 14 Aug 1992 18:44:02 GMT
- Lines: 78
-
- Got a problem maybe somebody can help shed light on. I've been
- working on a program that will run (with a wrapper) setuid to root,
- (as it's "chfn" - working on the password file), which behaves
- differently when running from a C wrapper, setuid, then when it isn't.
- (I'm running PERL 4.19, I know I should update, but haven't yet.)
-
- I've done similar things before, (setuid wrapper running perl that
- eval's something), and have beaten my way thru the gauntlet of
- "taintperl", and it does not seem to object to anything I've done.
- basically, I've got an array of field names and constraint-patterns,
- and am passing them down to a subroutine that queries the user for
- the new value, or accepts the old one (if it's valid), etc. See below:
-
- $ chfn ras
- Warning: Employee Nbr. (UNIX Support) is not numeric (5-digit)
-
- Cannot change Last Name: Shaw
- Change First Name: (Ralph A.)
- Change Mail Stop: (130) 131
- Change Employee Nbr.: (UNIX Support) 00000
- Bad label: _EVAL_ at passutils.pl line 375, <STDIN> line 3.
-
- $ pik 345 385 passutils.pl
- 345 sub chfn { # change what they gave you, or return it
- 346 local($N) = $_[0]; # index into @FN array
- 347 local($old) = $_[1]; # what it was set to
- 348
- 349 die "$PROGNAME: chfn: invalid index $N\n"
- 350 if(($N % 4) > $#FN);
- 351
- 352 local($prompt) = $FN[$N]; # what to ask them
- 353 local($test) = $FN[$N+1]; # what to check it against
- 354 local($warn) = $FN[$N+2]; # what to tell them for failures
- 355 local($allow) = $FN[$N+3]; # can this be changed by a user?
- 356 local($answer, $tries);
- 357
- 358
- 359 #
- 360 # Some fields only the Superuser can change
- 361 #
- 362 if($RUID && $allow == 0) {
- 363 print "Cannot change $FN[$N]: $A[$C]\n";
- 364 return $old;
- 365 }
- 366
- 367 $warn = "Alphabetic" if(length($warn) == 0);
- 368
- 369 while($tries++ < 10) {
- 370 print "Change $prompt: ($old) ";
- 371 $answer = <STDIN>;
- 372 chop($answer);
- 373 $answer = $old if($answer eq '');
- 374
- 375 if(length($test)) {
- 376 print "if($answer =~ $test)\n" if $DEBUG;
- 377 eval qq:return "$answer" if "$answer" =~ $test:;
- 378 print "$prompt must be $warn\n\n";
- 379 } else {
- 380 return($answer);
- 381 }
- 382 }
- 383 print STDERR "Too many tries, I give up!\n";
- 384 exit(1);
- 385 }
-
- I've also tried:
- eval "return \$answer if (\$answer =~ $test)";
- and
- eval qq:return $answer if (\$answer =~ $test):;
- as well as a few other combnations. The "Bad label:" message
- comes out on the next call to the subroutine after I've changed
- something, and refers to <STDIN> line N, where N is the number of
- times it's run the sub and gotten an answer.
-
- Any clues? I find no reference to _EVAL_ in the Book, and mysterious
- references to the "qq" mechanism didn't seem to help either.
- Thanks,
- Ralph Shaw ras@ssd.ray.com
-