--- loncom/pwchange 2001/11/15 18:22:04 1.4 +++ loncom/pwchange 2003/02/03 18:03:52 1.9 @@ -5,24 +5,33 @@ # pwchange - setuid script to change unix passwords # # YEAR=2001 -# 10/23,11/13,11/15 Scott Harrison # -# $Id: pwchange,v 1.4 2001/11/15 18:22:04 harris41 Exp $ +# YEAR=2002 +# 02/19 Matthew Hall +# +# $Id: pwchange,v 1.9 2003/02/03 18:03:52 harris41 Exp $ ### use strict; +my $noprint = 1; + + +print "In pwchange\n" unless $noprint; +print "Real uid = $< effective uid = $> \n" unless $noprint; # ------------------------------------------------------------------ Untainting $ENV{'PATH'}='/bin:/usr/bin'; # Nullify path information. delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; # nullify potential taints -# ----------------------------- Make sure this process is running from user=www -my $wwwid=getpwnam('www'); -if ($wwwid!=$<) { +# ---------------------------- Make sure this process is running from user=root + +if (0 != $<) { + print "Username not root" unless $noprint; exit 1; } # ----------------------------------------------- If not running setuid as root if ($>!=0) { + print "Not setuid to root" unless $noprint; exit 1; } @@ -30,14 +39,16 @@ if ($>!=0) { my $user=shift @ARGV; $user=~/^(\w+)$/; my $safe=$1; +print "Save user = $safe" unless $noprint; + my $pword=<>; chomp $pword; unless (length($safe) and ($user eq $safe) and ($safe=~/^[A-Za-z]/)) { exit 2; } - +print "Password = $pword" unless $noprint; my $pbad=0; -map {if (($_<32)&&($_>126)){$pbad=1;}} (split(//,$pword)); +foreach (split(//,$pword)) {if ((ord($_)<32)||(ord($_)>126)){$pbad=1;}} exit 3 if $pbad; # --------------------------------------------------------- Call system command 500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.