#!/usr/bin/perl -w ## CGI to allow people to change their SVN password ## $Id: passwd.pl 913 2005-02-20 05:54:02Z tvd $ use strict; use CGI qw/:standard/; $|++; my $user_auth = '/apps/repository/SVN/svn-auth-credentials'; my $svn_repo = '/apps/repository/SVN/svn-repo-access'; my $admin_group = 'sysadmins'; my $sudo = '/usr/bin/sudo'; my $htpasswd = '/usr/bin/htpasswd'; my $curuser = $ENV{'REMOTE_USER'}; print header, start_html(-title => 'Subversion Passphrase Changing'); unless (defined $curuser) { print h1("Who are you !?!"),"\n"; print end_html; exit 255; } if (param()) { my $pw = param('passphrase') || ''; my $vpw = param('verify') || ''; my $user = param('user') || ''; if ($user ne $curuser) { print h1("Stop trying to crack me!"),"\n"; } elsif (length($pw) < 6) { print "Sorry, the passphrase needs to be at least 6 characters long\n"; } elsif (length($pw) > 80) { print "Sorry, the passphrase can only be 80 characters maximum\n"; } elsif ($pw ne $vpw) { print "The passphrase and the verification don't match, please go back and try again.\n"; } else { # ok, things are good, do the htpasswd call print "The passphrase should be changed at this point, but any errors will be displayed below.",br, "If you only see 'Updating password for user $user', there weren't any errors.",p,"\n", "
\n";
# errors from htpasswd goto stderr, so shunt it to stdout before running htpasswd
open STDERR, ">&STDOUT";
# the braces get around a perl warning
{ exec $sudo, $htpasswd, '-b', '-m', $user_auth, $user, $pw; }
# execution should never get here unless the exec fails horribly
print "\n