File:  [LON-CAPA] / loncom / pwchange
Revision 1.1: download - view: text, annotated - select for diffs
Tue Oct 23 03:43:02 2001 UTC (22 years, 5 months ago) by harris41
Branches: MAIN
CVS tags: HEAD
setuid wrapper around passwd command

#!/usr/bin/perl

use strict;

$ENV{'PATH'}='/bin:/usr/bin'; # Nullify path information.
$ENV{'BASH_ENV'}=''; # Nullify shell environment information.

if ($>!=0) {
    exit 1;
}

my $user=shift @ARGV;
$user=~/^(\w+)$/;
my $safe=$1;
my $pword=<>;
chomp $pword;
unless (length($safe) and ($user eq $safe) and ($safe=~/^[A-Za-z]/)) {
    exit 2;
}

my $pbad=0;
map {if (($_<32)&&($_>126)){$pbad=1;}} (split(//,$pword));
exit 3 if $pbad;

open OUT,"|passwd --stdin $safe >/dev/null";
print OUT $pword;
print OUT "\n";
close OUT;

exit $?/256;

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>