#!/usr/local/bin/perl # # Developed by Allen Hubble to provide a single file solution to changing # Apache user passwords with the look and feel of the Lawson Portal. The # script is designed to be run as a bookmark from within the Lawson Portal. # Do not have it open a new window. I recommend setting it up as a link in # the menus through the role files - just as the online manuals are made # available. # # The script will authenticate the user using the existing password and # that the two occurences of the new password match. It will then display # a success message and REQUIRE THE USER TO LOGIN TO THE PORTAL AGAIN! # # The core logistics of the CGI were taken from one provided to me by # (I believe) Fred Chung. I've enhanced it to add functionality and the # integration with the Portal. # # Allen Hubble - Hubble Technology Consulting Inc. # Web Site: http://www.hubtech.ca # Email and IM: ahubble@hubtech.ca # Telephone: 416-802-5713 # ############################################################################ # This CGI program must be tailored for each Environment: # # 1. Edit the first line to reference the correct location of the perl # binary (use: 'which perl' to determine the correct value) and # # 2. Edit the PasswordFile variable to reference the correct location # of the password file for this host. ############################################################################ ################################################ # Customize this variable for your Environment # ################################################ $PasswordFile = '/usr/local/apache/userdb/LawsonUsers'; # End of Customizations $JSCRIPT=<remote_user(); $PasswordForm = join "\n", $c->br, $c->br, $c->start_form, $c->table({-border => '0', -background => '/lawson/portal/images/login2.gif', -width => '338', -height => '330', -align => 'center'}, $c->Tr( $c->td({-class=>'xTLabel', -colspan=>'2', -align=>'center'}, '









' ) ), $c->Tr( $c->td({-class=>'xTLabel', -align=>'right'}, 'User ID:'), $c->td({-class=>'xTLabel', -align=>'left'}, $who), ), $c->Tr( $c->td( {-class=>'xTLabel', -align=>'right'}, 'Current Password:' ), $c->td( {-class=>'xTLabel', -align=>'left'}, $c->password_field({-default=>'',-name=>'pswd'}) ) ), $c->Tr( $c->td( {-class=>'xTLabel', -align=>'right'}, 'New Password:' ), $c->td( {-class=>'xTLabel', -align=>'left'}, $c->password_field({-default=>'',-value=>$chkpw,-name=>'newp'}) ) ), $c->Tr( $c->td( {-class=>'xTLabel', -align=>'right'}, 'Re-enter New Password:' ), $c->td( {-class=>'xTLabel', -align=>'left'}, $c->password_field({-default=>'',-name=>'rnwp'}) ), ), $c->Tr( $c->td({-colspan=>'2', -align=>'center'}, $c->submit( { -class=>'xTToolbarButton', -style=>'background-color:buttonface;color:black', -value=>'Update' } ), $c->defaults( { -class=>'xTToolbarButton', -style=>'background-color:buttonface;color:black', -value=>'Clear Form' } ), $c->button( { -class=>'xTToolbarButton', -style=>'background-color:buttonface;color:black', -name =>'cancel', -value=>'Cancel', -onClick=>'top.switchContents("home.htm")' } ), $c->br, $c->br ), ) ), $c->end_form; unless ( $chkpw = $c->param('newp') ) { print $c->header, $c->start_html( -title => 'Lawson Password Change', -style => {'src' => '/lawson/portal/triscuit.css'}, -onLoad => 'top.lawsonPortal.setTitle("Password Change");', ), $PasswordForm, $c->end_html; exit 0; } $password = $c->param('pswd'); $new_password = $c->param('newp'); open PW, "< $PasswordFile" or bail("System Error 2. Please notify the webmaster."); while () { chomp; ($user, $pass) = split /:/; $passwords{$user} = $pass; } close PW; bail("Authorization failed. You need to supply the correct current password.") unless ($p = $passwords{$who}) && $p eq crypt($password, $p); bail("The passwords you entered don't match. Please try again.") unless $new_password eq $c->param('rnwp'); $passwords{$who} = crypt($new_password, $p); open PW, "> $PasswordFile" or bail("System Error 3. Please notify the webmaster."); while (@pw = each %passwords) { print PW join(':', @pw), "\n"; } close PW; print $c->header, $c->start_html( -title => 'Successful Lawson Portal Password Change', -style => {'src'=>'/lawson/portal/triscuit.css'}, -script=>$JSCRIPT, -onLoad=>'pwreset()' ), $c->h1('Success'), $c->p("Password has successfully been changed for $who"), $c->end_html; exit 0; ############################################################################# # Subroutines ############################################################################# sub bail { my($msg) = @_; chomp($msg); # just in case the nl is already there print $c->header, $c->start_html( -title => 'Lawson Password Change', -style => {'src' => '/lawson/portal/triscuit.css'}, -onLoad => 'top.lawsonPortal.setTitle("Password Change");alert ("' . $msg . '");', ), $PasswordForm, $c->end_html; exit 0; }