… | |
… | |
87 | if ($time && $m) { |
87 | if ($time && $m) { |
88 | if ($time < $m->{instantiate_time}) { |
88 | if ($time < $m->{instantiate_time}) { |
89 | # the map was reset in the meantime |
89 | # the map was reset in the meantime |
90 | my $age = $cf::RUNTIME - $time; |
90 | my $age = $cf::RUNTIME - $time; |
91 | |
91 | |
92 | warn $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
92 | cf::info $ob->name, " map reset after logout, logout age $age (>= $MAX_DISCONNECT_TIME)\n";#d# |
93 | |
93 | |
94 | if ($age >= $MAX_DISCONNECT_TIME) { |
94 | if ($age >= $MAX_DISCONNECT_TIME) { |
95 | $ob->message ( |
95 | $ob->message ( |
96 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
96 | "You didn't use a bed to reality to leave this realm, leaving your body in great danger. " |
97 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
97 | . "Unfortunately, nobody was near to help you when the monsters arrived to eat you. " |
… | |
… | |
126 | } |
126 | } |
127 | |
127 | |
128 | $ob->goto ($map, $x, $y); |
128 | $ob->goto ($map, $x, $y); |
129 | } |
129 | } |
130 | |
130 | |
131 | sub encode_password { |
131 | sub 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 | |
|
|
138 | sub 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). |
139 | sub nuke_playerdir { |
150 | sub 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; |
… | |
… | |
440 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
452 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
441 | } |
453 | } |
442 | }; |
454 | }; |
443 | } else { |
455 | } else { |
444 | my $change = delete $pl->{password_change}; |
456 | my $change = delete $pl->{password_change}; |
445 | warn "CHECK: @$change | $pl->{password_change} <<<<<\n"; |
|
|
446 | |
457 | |
447 | if ($change && (time - $change->[0]) < 60) { |
458 | if ($change && (time - $change->[0]) < 60) { |
448 | $pl->message ( |
459 | $pl->message ( |
449 | "Ok, changed your password!", |
460 | "Ok, changed your password!", |
450 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
461 | cf::NDI_UNIQUE | cf::NDI_RED | cf::NDI_REPLY); |
… | |
… | |
537 | unless safe_spot $pl; |
548 | unless safe_spot $pl; |
538 | } |
549 | } |
539 | }, |
550 | }, |
540 | ); |
551 | ); |
541 | |
552 | |
542 | |
|
|