ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/login.ext
(Generate patch)

Comparing deliantra/server/ext/login.ext (file contents):
Revision 1.109 by root, Tue May 4 21:45:42 2010 UTC vs.
Revision 1.110 by root, Sat May 8 10:49:44 2010 UTC

126 } 126 }
127 127
128 $ob->goto ($map, $x, $y); 128 $ob->goto ($map, $x, $y);
129} 129}
130 130
131sub encode_password { 131sub encode_password($) {
132 crypt $_[0], 132# crypt $_[0],
133 join '', 133# join '',
134 ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[(cf::rndm 64), (cf::rndm 64)] 134# ('.', '/', 0..9, 'A'..'Z', 'a'..'z')[(cf::rndm 64), (cf::rndm 64)]
135 "!" . unpack "H*", $_[0]
136}
137
138sub compare_password($$) {
139 my ($pass, $token) = @_;
140
141 if ($token =~ /\!(.*)/) {
142 return $pass eq pack "H*", $1;
143 } else {
144 return $token eq crypt $pass, $token;
145 }
135} 146}
136 147
137# delete a player directory, be non-blocking AND synchronous... 148# delete a player directory, be non-blocking AND synchronous...
138# (that's hard, so we crap out and fork). 149# (that's hard, so we crap out and fork).
139sub nuke_playerdir { 150sub nuke_playerdir {
230 241
231 # try to read the user file and check the password 242 # try to read the user file and check the password
232 if (my $pl = cf::player::find $user) { 243 if (my $pl = cf::player::find $user) {
233 aio_stat $pl->path and next; 244 aio_stat $pl->path and next;
234 my $mtime = (stat _)[9]; 245 my $mtime = (stat _)[9];
235 my $hash = $pl->password; 246 my $token = $pl->password;
236 247
237 if ($cf::CFG{ext_login_nocheck} or $hash eq crypt $pass, $hash) { 248 if ($cf::CFG{ext_login_nocheck} or compare_password $pass, $token) {
249 $pl->password (encode_password $pass); # make sure we store the new encoding #d#
238 nuke_str $pass; 250 nuke_str $pass;
239 # password matches, wonderful 251 # password matches, wonderful
240 my $pl = cf::player::find $user or next; 252 my $pl = cf::player::find $user or next;
241 $pl->connect ($ns); 253 $pl->connect ($ns);
242 enter_map $pl; 254 enter_map $pl;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines