]>
Commit | Line | Data |
---|---|---|
ac1cfefa MT |
1 | #!/usr/bin/perl |
2 | # | |
3 | # SmoothWall CGIs | |
4 | # | |
5 | # This code is distributed under the terms of the GPL | |
6 | # | |
7 | # (c) The SmoothWall Team | |
8 | # | |
9 | # $Id: changepw.cgi,v 1.4.2.6 2005/03/07 21:28:03 eoberlander Exp $ | |
10 | # | |
11 | ||
12 | use strict; | |
13 | ||
14 | # enable only the following on debugging purpose | |
15 | #use warnings; | |
16 | #use CGI::Carp 'fatalsToBrowser'; | |
17 | ||
986e08d9 | 18 | require '/var/ipfire/general-functions.pl'; |
ac1cfefa MT |
19 | require "${General::swroot}/lang.pl"; |
20 | require "${General::swroot}/header.pl"; | |
21 | ||
22 | my %cgiparams=(); | |
23 | my $errormessage=''; | |
24 | ||
25 | &Header::showhttpheaders(); | |
26 | ||
27 | $cgiparams{'ACTION_ADMIN'} = ''; | |
28 | $cgiparams{'ACTION_DIAL'} = ''; | |
29 | ||
30 | &Header::getcgihash(\%cgiparams); | |
31 | ||
32 | if ($cgiparams{'ACTION_ADMIN'} eq $Lang::tr{'save'}) | |
33 | { | |
34 | my $password1 = $cgiparams{'ADMIN_PASSWORD1'}; | |
35 | my $password2 = $cgiparams{'ADMIN_PASSWORD2'}; | |
36 | if ($password1 eq $password2) | |
37 | { | |
38 | if ($password1 =~ m/\s|\"/) { | |
39 | $errormessage = $Lang::tr{'password contains illegal characters'}; | |
40 | } | |
41 | elsif (length($password1) >= 6) | |
42 | { | |
43 | system('/usr/bin/htpasswd', '-m', '-b', "${General::swroot}/auth/users", 'admin', "${password1}"); | |
44 | &General::log($Lang::tr{'admin user password has been changed'}); | |
45 | } | |
46 | else { | |
47 | $errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; } | |
48 | } | |
49 | else { | |
50 | $errormessage = $Lang::tr{'passwords do not match'}; } | |
51 | } | |
52 | ||
53 | if ($cgiparams{'ACTION_DIAL'} eq $Lang::tr{'save'}) | |
54 | { | |
55 | my $password1 = $cgiparams{'DIAL_PASSWORD1'}; | |
56 | my $password2 = $cgiparams{'DIAL_PASSWORD2'}; | |
57 | if ($password1 eq $password2) | |
58 | { | |
59 | if($password1 =~ m/\s|\"/) { | |
60 | $errormessage = $Lang::tr{'password contains illegal characters'}; | |
61 | } | |
62 | elsif (length($password1) >= 6) | |
63 | { | |
64 | system('/usr/bin/htpasswd', '-b', "${General::swroot}/auth/users", 'dial', "${password1}"); | |
65 | &General::log($Lang::tr{'dial user password has been changed'}); | |
66 | } | |
67 | else { | |
68 | $errormessage = $Lang::tr{'passwords must be at least 6 characters in length'}; } | |
69 | } | |
70 | else { | |
71 | $errormessage = $Lang::tr{'passwords do not match'}; } | |
72 | } | |
73 | ||
74 | &Header::openpage($Lang::tr{'change passwords'}, 1, ''); | |
75 | ||
76 | &Header::openbigbox('100%', 'left', '', $errormessage); | |
77 | ||
78 | if ($errormessage) { | |
79 | &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); | |
80 | print "<class name='base'>$errormessage\n"; | |
81 | print " </class>\n"; | |
82 | &Header::closebox(); | |
83 | } | |
84 | ||
85 | print "<form method='post' action='$ENV{'SCRIPT_NAME'}'>\n"; | |
86 | ||
87 | &Header::openbox('100%', 'left', $Lang::tr{'administrator user password'}); | |
88 | print <<END | |
89 | <table width='100%'> | |
90 | <tr> | |
91 | <td width='20%' class='base'>$Lang::tr{'username'} 'admin'</td> | |
92 | <td width='15%' class='base' align='right'>$Lang::tr{'password'} </td> | |
93 | <td width='15%'><input type='password' name='ADMIN_PASSWORD1' size='10' /></td> | |
94 | <td width='15%' class='base' align='right'>$Lang::tr{'again'} </td> | |
95 | <td width='15%'><input type='password' name='ADMIN_PASSWORD2' size='10' /></td> | |
96 | <td width='20%' align='center'><input type='submit' name='ACTION_ADMIN' value='$Lang::tr{'save'}' /></td> | |
97 | </tr> | |
98 | </table> | |
99 | END | |
100 | ; | |
101 | &Header::closebox(); | |
102 | ||
103 | &Header::openbox('100%', 'left', $Lang::tr{'dial user password'}); | |
104 | print <<END | |
105 | <table width='100%'> | |
106 | <tr> | |
107 | <td width='20%' class='base'>$Lang::tr{'username'} 'dial'</td> | |
108 | <td width='15%' class='base' align='right'>$Lang::tr{'password'} </td> | |
109 | <td width='15%'><input type='password' name='DIAL_PASSWORD1' size='10'/></td> | |
110 | <td width='15%' class='base' align='right'>$Lang::tr{'again'} </td> | |
111 | <td width='15%'><input type='password' name='DIAL_PASSWORD2' size='10' /></td> | |
112 | <td width='20%' align='center'><input type='submit' name='ACTION_DIAL' value='$Lang::tr{'save'}' /></td> | |
113 | </tr> | |
114 | </table> | |
115 | END | |
116 | ; | |
117 | &Header::closebox(); | |
118 | ||
119 | print "</form>\n"; | |
120 | ||
121 | &Header::closebigbox(); | |
122 | ||
123 | &Header::closepage(); |