tru64-unix-managers (formerly alpha-osf-managers) (1994-2012)
 help / color / mirror / Atom feed
From: Ralf Borowski <rborowski () tembec ! ca>
To: tru64-unix-managers
Subject: SUMMARY: Changing Passwords
Date: Thu, 18 Apr 2002 19:48:04 +0000	[thread overview]
Message-ID: <102653755322454.tru64-unix-managers.marc@archive.invalid> (raw)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: multipart/mixed; boundary="------=_NextPart_000_0001_01C1E6F0.6E7586A0", Size: 26219 bytes --]

This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C1E6F0.6E7586A0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0002_01C1E6F0.6E7893E0"


------=_NextPart_001_0002_01C1E6F0.6E7893E0
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

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_0002_01C1E6F0.6E7893E0
Content-Type: text/html;
	charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:st1=3D"urn:schemas-microsoft-com:office:smarttags" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dus-ascii">


<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:filelist.xml@01C1E6F0.6D68AA80">
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"PersonName"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"time"/>
<o:SmartTagType =
namespaceuri=3D"urn:schemas-microsoft-com:office:smarttags"
 name=3D"date"/>
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:SpellingState>Clean</w:SpellingState>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:EnvelopeVis/>
  <w:Compatibility>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]--><!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:553679495 -2147483648 8 0 66047 0;}
@font-face
	{font-family:Verdana;
	panose-1:2 11 6 4 3 5 4 4 2 4;
	mso-font-charset:0;
	mso-generic-font-family:swiss;
	mso-font-pitch:variable;
	mso-font-signature:536871559 0 0 0 415 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
p.MsoAutoSig, li.MsoAutoSig, div.MsoAutoSig
	{margin:0in;
	margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:12.0pt;
	font-family:"Times New Roman";
	mso-fareast-font-family:"Times New Roman";}
span.EmailStyle17
	{mso-style-type:personal-compose;
	mso-style-noshow:yes;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:Arial;
	mso-ascii-font-family:Arial;
	mso-hansi-font-family:Arial;
	mso-bidi-font-family:Arial;
	color:windowtext;}
span.SpellE
	{mso-style-name:"";
	mso-spl-e:yes;}
span.GramE
	{mso-style-name:"";
	mso-gram-e:yes;}
@page Section1
	{size:8.5in 11.0in;
	margin:1.0in 1.25in 1.0in 1.25in;
	mso-header-margin:.5in;
	mso-footer-margin:.5in;
	mso-paper-source:0;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */=20
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=3DEN-US link=3Dblue vlink=3Dpurple =
style=3D'tab-interval:.5in'>

<div class=3DSection1>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Thanks to everyone who responded, particularly =
</span></font><st1:PersonName><font
 size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;font-family:Arial'>Ryan
 McConigley</span></font></st1:PersonName><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'> and Michael R. Mehall =
whose
suggestions and samples proved invaluable.<span =
style=3D'mso-spacerun:yes'>&nbsp;
</span>What I finally did was add a simple web form to the Apache server =
on our
Tru64 box.<span style=3D'mso-spacerun:yes'>&nbsp; </span>This form calls =
a <span
class=3DSpellE>cgi</span> script in <span class=3DSpellE>perl</span>, =
which in turn
executes an &#8216;expect&#8217; script that actually does the password
change.<span style=3D'mso-spacerun:yes'>&nbsp; </span>Now my users can =
easily
change their <span class=3DGramE>Unix</span> passwords without actually =
logging
in to a telnet session. Expect is a tool I downloaded from <a
href=3D"http://expect.nist.gov/expect.tar.Z">http://expect.nist.gov/expec=
t.tar.Z</a>
and requires <span class=3DSpellE>Tcl</span> which can be downloaded =
from <a
href=3D"http://dev.scriptics.com/registration/8.3.2.html">http://dev.scri=
ptics.com/registration/8.3.2.html</a><o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Both tools compile on Tru64 5.1A without too much =
trouble
and work well. <span style=3D'mso-spacerun:yes'>&nbsp;</span>Expect =
includes
examples, one of which helped me a great deal as =
well.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>For simplicity, the ChangePassword.html file goes =
into the <span
class=3DSpellE>htdocs</span> directory, and the .<span =
class=3DSpellE>cgi</span>
and .exp scripts go into the <span class=3DSpellE>cgi</span>-bin =
directory. <span
style=3D'mso-spacerun:yes'>&nbsp;</span>Permissions in <span =
class=3DSpellE>cgi</span>-bin
are 544 <span class=3DGramE>( r</span>-<span =
class=3DSpellE>xr</span>&#8212;r--) which
should be safe enough as this web page is only available =
internally.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Please send any suggestions for improvements you may
have.<span style=3D'mso-spacerun:yes'>&nbsp; </span>Be kind &#8211; =
these are my
first html, <span class=3DSpellE>perl</span>, and expect =
scripts.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Regards, <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'>Ralf<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3DArial><span =
style=3D'font-size:10.0pt;
font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoAutoSig><i style=3D'mso-bidi-font-style:normal'><font =
size=3D3
face=3DVerdana><span =
style=3D'font-size:12.0pt;font-family:Verdana;font-style:italic;
mso-bidi-font-style:normal;mso-no-proof:yes'>Ralf =
Borowski<o:p></o:p></span></font></i></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'>Senior Systems =
Specialist<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'>Tembec Inc. - Pulp =
Group<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'>Tel. (819) =
627-4103<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'>Fax. (819) =
627-9908<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'><a =
href=3D"mailto:rborowski@tembec.ca">rborowski@tembec.ca</a><o:p></o:p></s=
pan></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal =
style=3D'mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
font-family:Tahoma'>-----Original Message-----<br>
<b><span style=3D'font-weight:bold'>From:</span></b> Ralf Borowski
[mailto:rborowski@tembec.ca]<br>
<b><span style=3D'font-weight:bold'>Sent:</span></b> =
</span></font><st1:date
Month=3D"4" Day=3D"10" Year=3D"2002"><font size=3D2 face=3DTahoma><span =
style=3D'font-size:
 10.0pt;font-family:Tahoma'>Wednesday, April 10, =
2002</span></font></st1:date><font
size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;font-family:Tahoma'> </span></font><st1:time
Hour=3D"8" Minute=3D"43"><font size=3D2 face=3DTahoma><span =
style=3D'font-size:10.0pt;
 font-family:Tahoma'>8:43 AM</span></font></st1:time><font size=3D2 =
face=3DTahoma><span
style=3D'font-size:10.0pt;font-family:Tahoma'><br>
<b><span style=3D'font-weight:bold'>To:</span></b> =
tru64-unix-managers@ornl.gov<br>
<b><span style=3D'font-weight:bold'>Subject:</span></b> Changing =
Passwords</span></font><o:p></o:p></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Good =
Morning!<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo=
nt></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>All &#8220;regular =
users&#8221; on
my Tru64 5.1A servers use thin clients that connect to applications and
databases residing on our servers.<span =
style=3D'mso-spacerun:yes'>&nbsp;
</span>They only need accounts to make connections with their thin =
client
applications and never actually log on to the servers to do =
anything.<span
style=3D'mso-spacerun:yes'>&nbsp; </span>I have disabled telnet on the =
servers
and replaced it with SSH and have purchased clients for my =
System&#8217;s <span
class=3DSpellE>Admins</span> to use for their day to day =
administration.<span
style=3D'mso-spacerun:yes'>&nbsp; </span>My problem is that the regular =
users
have no easy way of changing their <span class=3DGramE>Unix</span> =
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&#8217;t
have to distribute SSH clients to everyone?<span
style=3D'mso-spacerun:yes'>&nbsp; </span>Would it be difficult to write =
an applet
in Java or c to handle this?<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo=
nt></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>TIA for any suggestions you =
may
have.<o:p></o:p></span></font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo=
nt></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Regards,<o:p></o:p></span></=
font></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo=
nt></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'>Ralf<o:p></o:p></span></font=
></p>

<p class=3DMsoNormal style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:10.0pt;font-family:Arial'><o:p>&nbsp;</o:p></span></fo=
nt></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><i =
style=3D'mso-bidi-font-style:
normal'><font size=3D3 face=3DVerdana><span =
style=3D'font-size:12.0pt;font-family:
Verdana;font-style:italic;mso-bidi-font-style:normal;mso-no-proof:yes'>Ra=
lf
Borowski<o:p></o:p></span></font></i></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:11.0pt;font-family:Arial;mso-no-proof:yes'>Senior =
Systems
Specialist<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:11.0pt;font-family:Arial;mso-no-proof:yes'>Tembec =
Inc. - Pulp
Group<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:11.0pt;font-family:Arial;mso-no-proof:yes'>Tel. (819) =
627-4103<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:11.0pt;font-family:Arial;mso-no-proof:yes'>Fax. (819) =
627-9908<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig style=3D'margin-left:.5in'><font size=3D2 =
face=3DArial><span
style=3D'font-size:11.0pt;font-family:Arial;mso-no-proof:yes'>rborowski@t=
embec.ca<o:p></o:p></span></font></p>

<p class=3DMsoAutoSig><font size=3D2 face=3DArial><span =
style=3D'font-size:11.0pt;
font-family:Arial;mso-no-proof:yes'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D3 face=3D"Times New Roman"><span =
style=3D'font-size:
12.0pt'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>

------=_NextPart_001_0002_01C1E6F0.6E7893E0--

------=_NextPart_000_0001_01C1E6F0.6E7586A0
Content-Type: text/html;
	name="PasswordChange.html"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="PasswordChange.html"

<HTML>
<HEAD>
<meta HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dwindows-1252">
<meta http-equiv=3D"Content-Language" content=3D"en-us">
<TITLE>New Page 3</TITLE>
</HEAD>
<BODY bgcolor=3D"#C0C0C0">
<H1>Change UNIX Password</H1>
<HR>
<FORM METHOD=3D"POST" =
ACTION=3D"http://10.3.8.8/cgi-bin/ChangePassword.cgi">
<P>
Enter your =
username:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT NAME=3D"Username" SIZE=3D8 MAXLENGTH=3D8></P>
<P>
Enter your =
password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=3Dpassword NAME=3D"Password" SIZE=3D16 MAXLENGTH=3D16></P>
<P>
Enter your new password:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<INPUT TYPE=3Dpassword NAME=3D"NewPassword" SIZE=3D16 =
MAXLENGTH=3D16></P>
<P>
Re-enter your new password:&nbsp;&nbsp;
<INPUT TYPE=3Dpassword NAME=3D"VerifyNewPassword" SIZE=3D16 =
MAXLENGTH=3D16></P>
<INPUT TYPE=3Dsubmit VALUE=3D"Change Now">
<INPUT TYPE=3DRESET VALUE=3D"Reset Form">
</FORM>
<HR>
<H5>
Ralf Borowski.<br>Copyright =A9 2002 Tembec Inc. All rights reserved. =
<BR>
Revised:=20
<!--WEBBOT BOT=3DTimeStamp
    S-Type=3D"EDITED"
    S-Format=3D"%m/%d/%y"
--></H5>
</BODY>
</HTML>
------=_NextPart_000_0001_01C1E6F0.6E7586A0
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 <<End_of_Error;
<title>CGI Program - Unexpected Error</title>
<h1>$keyword</h1>
<hr>$message</hr>
Please contact $webmaster for more information.

End_of_Error

    exit(1);
}

sub password_bad
{
print "Content-type: text/html\n\n";
print "<HTML>\n\n";
print "<HEAD><TITLE>Identity Crisis</TITLE></HEAD>\n";
print "<BODY>\n";
print "<CENTER><H1>Identity Crisis</H1>\n";
print "</CENTER>\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 <A href=3D\"/ChangePassword\.html\">here</a> to try =
again\n";

print "<A HREF=3D\"/Welcome\.html\">Return to support Home Page</A>\n";
print "</PRE>\n";
print "</BODY></HTML>\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 "<HTML>\n\n";
        print "<HEAD><TITLE>Password Change</TITLE></HEAD>\n";
        print "<BODY>\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 "<CENTER><H1>Password Changed</H1>\n";
        }
        else
        {
                print "<CENTER><H1>Password Change Failed</H1>\n";
        }

        print "</CENTER>\n";
        print "<PRE>\n";
        print "Unix Password for user: $l_user ($realname)";
        print "\n";

        if ( $exit_value eq 1 )
        {
                print "Error: Unknown login ID. \n";
        }
        elseif ( $exit_value eq 2 )
        {
                print "Error: Timeout while attempting to change =
password. \n";
        }
        elseif ( $exit_value eq 3 )
        {
                print "Error: Unknown user. \n";
        }
        elseif ( $exit_value eq 4 )
        {
                print "Error: Insufficient priviledge. \n";
        }
        elseif ( $exit_value eq 5 )
        {
                print "Error: Password too short. \n";
        }
        elseif ( $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 "<BR>\n";
        print "Revision A\n";


        print "<A HREF=3D\"/Welcome\.html\">Return to support Home =
Page</A>\n";
        print "</PRE>\n";
        print "</BODY></HTML>\n";

exit(0);
}
------=_NextPart_000_0001_01C1E6F0.6E7586A0
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_0001_01C1E6F0.6E7586A0--

                 reply	other threads:[~2002-04-18 19:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox