From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <102653755322476.tru64-unix-managers.marc@archive.invalid> From: Ralf Borowski Date: Fri, 19 Apr 2002 14:59:23 +0000 To: tru64-unix-managers Subject: SUMMARY2: Changing Passwords X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=102653755322476 MIME-Version: 1 Content-Type: multipart/mixed; boundary="------=_NextPart_000_0014_01C1E791.441BC7B0" This is a multi-part message in MIME format. ------=_NextPart_000_0014_01C1E791.441BC7B0 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0015_01C1E791.441ED4F0" ------=_NextPart_001_0015_01C1E791.441ED4F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Oops - sent the wrong perl script. The one I sent contained a syntax error which I corrected on the server, but hadn't copied back to my development system. Attached are the correct scripts. Thanks to everyone who responded, particularly Ryan McConigley and Michael R. Mehall whose suggestions and samples proved invaluable. What I finally did was add a simple web form to the Apache server on our Tru64 box. This form calls a cgi script in perl, which in turn executes an 'expect' script that actually does the password change. Now my users can easily change their Unix passwords without actually logging in to a telnet session. Expect is a tool I downloaded from http://expect.nist.gov/expect.tar.Z and requires Tcl which can be downloaded from http://dev.scriptics.com/registration/8.3.2.html Both tools compile on Tru64 5.1A without too much trouble and work well. Expect includes examples, one of which helped me a great deal as well. For simplicity, the ChangePassword.html file goes into the htdocs directory, and the .cgi and .exp scripts go into the cgi-bin directory. Permissions in cgi-bin are 544 ( r-xr-r--) which should be safe enough as this web page is only available internally. Please send any suggestions for improvements you may have. Be kind - these are my first html, perl, and expect scripts. Regards, Ralf Ralf Borowski Senior Systems Specialist Tembec Inc. - Pulp Group Tel. (819) 627-4103 Fax. (819) 627-9908 rborowski@tembec.ca -----Original Message----- From: Ralf Borowski [mailto:rborowski@tembec.ca] Sent: Wednesday, April 10, 2002 8:43 AM To: tru64-unix-managers@ornl.gov Subject: Changing Passwords Good Morning! All "regular users" on my Tru64 5.1A servers use thin clients that connect to applications and databases residing on our servers. They only need accounts to make connections with their thin client applications and never actually log on to the servers to do anything. I have disabled telnet on the servers and replaced it with SSH and have purchased clients for my System's Admins to use for their day to day administration. My problem is that the regular users have no easy way of changing their Unix account passwords. Is there any utility available that will allow my users to change their passwords through a (preferably secure) web interface so I don't have to distribute SSH clients to everyone? Would it be difficult to write an applet in Java or c to handle this? TIA for any suggestions you may have. Regards, Ralf Ralf Borowski Senior Systems Specialist Tembec Inc. - Pulp Group Tel. (819) 627-4103 Fax. (819) 627-9908 rborowski@tembec.ca ------=_NextPart_001_0015_01C1E791.441ED4F0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Oops – sent the wrong perl script.  The one I sent = contained a syntax error which I corrected on the server, but hadn’t copied = back to my development system.  = Attached are the correct scripts.

 

Thanks to everyone who responded, particularly = Ryan McConigley and Michael R. Mehall = whose suggestions and samples proved invaluable.  What I finally did was add a simple web form to the Apache server = on our Tru64 box.  This form calls = a cgi script in perl, = which in turn executes an ‘expect’ script that actually does the password change.  Now my users can = easily change their Unix passwords without actually = logging in to a telnet session. Expect is a tool I downloaded from http://expect.nist.gov/expec= t.tar.Z and requires Tcl which can be downloaded = from http://dev.scri= ptics.com/registration/8.3.2.html

 

Both tools compile on Tru64 5.1A without too much = trouble and work well.  Expect = includes examples, one of which helped me a great deal as = well.

 

For simplicity, the ChangePassword.html file goes = into the htdocs directory, and the .cgi and .exp scripts go into the cgi-bin = directory.  Permissions in cgi-bin are 544 ( r-xr—r--) which should be safe enough as this web page is only available = internally.

 

Please send any suggestions for improvements you may have.  Be kind – = these are my first html, perl, and expect = scripts.

 

Regards,

 

Ralf

 

Ralf = Borowski

Senior Systems = Specialist

Tembec Inc. - Pulp = Group

Tel. (819) = 627-4103

Fax. (819) = 627-9908

rborowski@tembec.ca

 

-----Original Message-----
From: Ralf Borowski [mailto:rborowski@tembec.ca]
Sent: =
Wednesday, April 10, = 2002 8:43 AM
To: =
tru64-unix-managers@ornl.go= v
Subject: Changing = Passwords

Good = Morning!

 

All “regular = users” on my Tru64 5.1A servers use thin clients that connect to applications and databases residing on our servers.  They only need accounts to make connections with their thin = client applications and never actually log on to the servers to do = anything.  I have disabled telnet on the = servers and replaced it with SSH and have purchased clients for my = System’s Admins to use for their day to day = administration.  My problem is that the regular = users have no easy way of changing their Unix = account passwords. Is there any utility available that will allow my users to = change their passwords through a (preferably secure) web interface so I = don’t have to distribute SSH clients to everyone?  Would it be difficult to write = an applet in Java or c to handle this?

 

TIA for any suggestions you = may have.

 

Regards,

 

Ralf

 

Ra= lf Borowski

Senior = Systems Specialist

Tembec = Inc. - Pulp Group

Tel. (819) = 627-4103

Fax. (819) = 627-9908

rborowski@t= embec.ca

 

 

 

------=_NextPart_001_0015_01C1E791.441ED4F0-- ------=_NextPart_000_0014_01C1E791.441BC7B0 Content-Type: text/html; name="PasswordChange.html" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="PasswordChange.html" New Page 3

Change UNIX Password


Enter your = username:          &nbs= p;    

Enter your = password:          &nbs= p;    

Enter your new password:       

Re-enter your new password:  


Ralf Borowski.
Copyright =A9 2002 Tembec Inc. All rights reserved. =
Revised:=20
------=_NextPart_000_0014_01C1E791.441BC7B0 Content-Type: application/octet-stream; name="ChangePassword.exp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="ChangePassword.exp" #!/usr/bin/expect -f # # passwd sometimes doesn't respond fast enough and you can # actually type in the first couple characters of your # password before "passwd" is actually ready to receive! # so I 'sleep .1' at various times in the script to help # this along. set timeout 20 spawn /bin/su [lindex $argv 0] -c "/bin/passwd [lindex $argv 0]" exp_internal 1 match_max 100000 expect { "Unknown login:" { exit 1 } timeout { exit 2 } "Password:" } sleep .1 send "[lindex $argv 1]\r" sleep .1 expect { "unknown user" { exit 3 } "Sorry" { exit 4 } timeout { exit 2 } "Old password:" } sleep .1 send "[lindex $argv 1]\r" sleep .1 expect "New password:" sleep .1 send "[lindex $argv 2]\r" sleep .1 expect { "Please enter a longer password." { exit 5 } "all-lower case password." { exit 6 } timeout { exit 2 } "ew password:" } sleep .1 send "[lindex $argv 2]\r" sleep .1 expect eof ------=_NextPart_000_0014_01C1E791.441BC7B0 Content-Type: application/octet-stream; name="ChangePassword.cgi" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ChangePassword.cgi" #!/usr/bin/perl # --=3D=3D this file has been hacked by Ryan =3D=3D-- # After being stolen from a web requision form $webmaster =3D "rborowski\@tembec\.ca"; $machine_name =3D "localhost"; ### Run it = locally (security) &parse_form_data (*webreq); $username =3D $webreq{'Username'}; $password =3D $webreq{'Password'}; $newpassword =3D $webreq{'NewPassword'}; $newpassword2 =3D $webreq{'VerifyNewPassword'}; $now_string =3D localtime; ($yp_name,$yp_passwd,$yp_uid,$yp_gid,$yp_quota,$yp_gcos,$yp_comment,$yp_d= ir,$yp_shell)=3Dgetpwnam $username; if ($yp_command =3D~ /,/) { @temp_real =3D split(/,/,$yp_comment); $realname =3D $temp_real[0]; } else {$realname =3D $yp_comment; } $hash =3D crypt($password, $yp_passwd); if (crypt ($password, $yp_passwd) eq $yp_passwd)=20 { # Password matches $passwd_match =3D "TRUE"; } else=20 { ### Someone hacking - shouldn't be able to get this far = elsewise $passwd_match =3D "FALSE"; } if ( $newpassword eq $newpassword2 ) { $new_passwd_match =3D "TRUE"; } else { ### New Password Mismatch $new_passwd_match =3D "FALSE"; } if ( $passwd_match eq "TRUE" && $new_passwd_match eq "TRUE" ) { &password_ok ($yp_name, $password, $newpassword); } else { &password_bad; } #########################################################################= #### ### Print out web page here = ################################################ #########################################################################= #### sub parse_form_data { local (*FORM_DATA) =3D @_; local ( $request_method, $query_string, @key_value_pairs, $key_value, $key, $value); $request_method =3D $ENV{'REQUEST_METHOD'}; if ($request_method eq "GET") { $query_string =3D $ENV{'QUERY_STRING'}; } elsif ($request_method eq "POST") { read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'}); } else { &return_error (500, "Server Error", "Server uses unsupported method"); } @key_value_pairs =3D split (/&/, $query_string); foreach $key_value (@key_value_pairs) { ($key, $value) =3D split (/=3D/, $key_value); $value =3D~ tr/+/ /; $value =3D~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg; if (defined($FORM_DATA{$key})) { $FORM_DATA{$key} =3D join ("\0", $FORM_DATA{$key}, $value); } else { $FORM_DATA{$key} =3D $value; } } } sub return_error { local ($status, $keyword, $message) =3D @_; print "Content-type: text/html", "\n"; print "Status: ", $status, " ", $keyword, "\n\n"; print <CGI Program - Unexpected Error

$keyword


$message Please contact $webmaster for more information. End_of_Error exit(1); } sub password_bad { print "Content-type: text/html\n\n"; print "\n\n"; print "Identity Crisis\n"; print "\n"; print "

Identity Crisis

\n"; print "
\n"; if ( $passwd_match eq "FALSE" ) { print "Sorry, either that user doesn't exist, or has\n"; print "a different password\n"; } else { print "Sorry, your new password failed verification\n"; } print "click here to try = again\n"; print "Return to support Home Page\n"; print "\n"; print "\n"; } sub password_ok { local ($user, $pass, $newpass) =3D @_; &display_web_page ($username, $password, $newpassword); } sub display_web_page { local ($l_user, $l_pass, $l_newpass) =3D @_; = ############################################## ### This code block handles the = .vacation file ### Now write out web page print "Content-type: text/html\n\n"; print "\n\n"; print "Password Change\n"; print "\n"; $vac_command =3D sprintf ("./ChangePassword.exp %s %s %s", = $username, $password, $newpassword ); =20 system("$vac_command"); $exit_value =3D $? >> 8; =20 if ( $exit_value eq 0 ) { print "

Password Changed

\n"; } else { print "

Password Change Failed

\n"; } print "
\n"; print "
\n";
        print "Unix Password for user: $l_user ($realname)";
        print "\n";

        if ( $exit_value eq 1 )
        {
                print "Error: Unknown login ID. \n";
        }
        elsif ( $exit_value eq 2 )
        {
                print "Error: Timeout while attempting to change =
password. \n";
        }
        elsif ( $exit_value eq 3 )
        {
                print "Error: Unknown user. \n";
        }
        elsif ( $exit_value eq 4 )
        {
                print "Error: Insufficient priviledge. \n";
        }
        elsif ( $exit_value eq 5 )
        {
                print "Error: Password too short. \n";
        }
        elsif ( $exit_value eq 6 )
        {
                print "Error: Password is all lower-case. \n";
        }
        else
        {
                print "Successfully Changed. \n";
        }
      =20
        if ( $exit_value !=3D 0 )
        {
                print "Passwords must be at least 5 characters in =
length. \n";
                print "At least one of the first 8 characters must be =
\n";
                print "upper-case or a number. \n";
                print "For example asdf1 is valid, but asdfi is not. =
\n";
                print "\nPlease go back and try again. \n";
        }

        print "
\n"; print "Revision A\n"; print "Return to support Home = Page\n"; print "
\n"; print "\n"; exit(0); } ------=_NextPart_000_0014_01C1E791.441BC7B0--