#!/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;