blob: 2f64885a5c858bb501c2f05306d985aebcafba38 [file] [log] [blame]
MG Mud User88f12472016-06-24 23:31:02 +02001// MorgenGrauen MUDlib
2//
3// login.c -- Object for players just logging in
4//
5// $Id: login.c 9245 2015-06-04 13:04:39Z Arathorn $
6
7 /*
8 * secure/login.c
9 *
10 * This object is cloned for every user trying to log in
11 * We are still running root.
12 *
13 * login.c looks up the username in the secure/PASSWD file. If it is
14 * found, the password is checked. If the user is already logged in,
15 * he will be reconnected to the running object. If the other object
16 * is still interactive, that will be disconnected before the user is
17 * reconnected to that object.
18 *
19 * If the user is not in PASSWD, a new entry with level 0 is created.
20 * All PASSWD writing is done in secure/master.c.
21 *
22 */
23#pragma strict_types
24#pragma no_shadow
25#pragma no_inherit
26#pragma verbose_errors
27#pragma combine_strings
28//#pragma pedantic
29//#pragma range_check
30#pragma warn_deprecated
31
32#include <config.h>
33#include <properties.h>
34#include <moving.h>
35#include "/secure/wizlevels.h"
36#include <telnet.h>
37#include <defines.h>
38#include <input_to.h>
39
40inherit "/secure/mini_props.c";
41inherit "/secure/telnetneg.c";
42
43#define SSL_GRRETING "REMOTE_HOST="
44#define PROXIES ({"127.0.0.1","87.79.24.60"})
45#define GUESTMASTER "/secure/guestmaster"
46
47#ifndef DEBUG
48#define DEBUG(x) if(find_player("tiamak")) tell_object(find_player("tiamak"),x)
49#define DEBUGM(x) if(find_player("muadib")) tell_object(find_player("muadib"),x)
50#endif
51
52/* Variables of the secure save file */
53int level, loginfails, creation_date;
54string password, name, shell, ep, ek, mq;
55string ektips;
56string fptips;
57string *domains, *guilds, *uidstotakecare;
58
59static int invis, neu;
60static string loginname;
61static string cap_name;
62static string *userentry;
63static string banish;
64static mixed *races;
65static int newbie;
66static string realip;
67
68// Prototypes
69static void SendTelopts();
70public nomask string loginname();
71// the following 4 lfuns deal with real logins
72public nomask int logon();
73static int logon2( string str );
74static int load_player_object( int guestflag );
75static void load_player_ob_2( string obname, int guestflag );
76static int check_illegal( string str );
77static int valid_name( string str );
78static int new_password( string str );
79static int again_password( string str );
80static int check_password( string str );
81static void select_race();
82static void ask_race_question();
83static void get_race_answer( string str );
84
85protected void create();
86public string short();
87public string query_real_name();
88public nomask int query_prevent_shadow();
MG Mud User88f12472016-06-24 23:31:02 +020089public int remove();
90// the following 3 lfuns deal with dummy player creation
91public mixed new_logon( string str);
92static mixed new_load_player_object();
93static mixed new_load_player_ob_2( string obname );
94static void ask_mud_played_question();
95static void get_mud_played_answer(string str);
96
97
98public nomask string loginname()
99{
100 return loginname ? loginname : "";
101}
102
103
104public int remove()
105{
106 destruct( this_object() );
107 return 1;
108}
109
110
111static int check_too_many_logons()
112{
113 object *u;
114 string ip;
115
116 ip = query_ip_number(this_object());
117 // users() nehmen, falls nicht-interaktive Clones von login.c existieren.
118 u = filter( users(), function status (object ob, string addr) {
Zesstra077f3c62016-09-30 21:24:05 +0200119 return load_name(ob) == "/secure/login"
MG Mud User88f12472016-06-24 23:31:02 +0200120 && query_ip_number(ob) == addr;
121 }, ip );
122
Zesstracb45e3d2016-09-30 20:13:31 +0200123 if ( sizeof(u) > 2) {
MG Mud User88f12472016-06-24 23:31:02 +0200124 write( "\nEs laufen schon zu viele Anmeldungen von Deiner Adresse "
125 "aus.\nProbier es bitte in ein bis zwei Minuten noch "
126 "einmal.\n" );
127
Zesstracb45e3d2016-09-30 20:13:31 +0200128 log_file( "LOGIN_DENY", sprintf( "%s: >2 Logons von %-15s (%s)\n",
MG Mud User88f12472016-06-24 23:31:02 +0200129 ctime(time())[4..15],
130 query_ip_number(this_object()),
131 query_ip_name(this_object()) ) );
132 return 1;
133 }
134 else
135 return 0;
136}
137
138
139/*
140 * This is the function that gets called by /secure/master for every user
141 */
142public nomask int logon()
143{
144 loginname = "logon";
145 newbie=0;
146 realip="";
147
148 // als erstes wird ein Lookup gemacht, ob die Quelladresse ein
149 // Tor-Exitnode ist, der erlaubt, zu uns zu kommunizieren. Das Lookup ist
150 // asynchron und braucht eine Weile, wenn das Ergebnis noch nicht gecacht
151 // ist. An dieser Stelle wird das Ergebnis nicht ausgewertet. Achja, wie
152 // machen das natuerlich nicht fuer die IP vom Mudrechner...
153 if (query_ip_number(this_object()) != "87.79.24.60")
154 {
155 "/p/daemon/dnslookup"->check_tor(query_ip_number(this_object()),query_mud_port());
156 "/p/daemon/dnslookup"->check_dnsbl(query_ip_number(this_object()));
157 }
158 printf("HTTP/1.0 302 Found\n"
159 "Location: http://mg.mud.de/\n\n"
160 "NetCologne, Koeln, Germany. Local time: %s\n\n"
161 MUDNAME" LDmud, NATIVE mode, driver version %s\n\n",
162 strftime("%c"), __VERSION__);
163
164 SendTelopts();
165
166 if ( check_too_many_logons() ){
167 destruct(this_object());
168 return 0;
169 }
170
171 // ist die Verbindung schon wieder weg?
172 if (objectp(this_object()) && interactive(this_object())) {
173 cat( "/etc/WELCOME" );
174 }
175
176 input_to( "logon2", INPUT_PROMPT,
177 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
Zesstra28d72e52016-10-27 23:56:19 +0200178 set_next_reset(300);
MG Mud User88f12472016-06-24 23:31:02 +0200179 return 1;
180}
181
182
183static int check_too_many_from_same_ip()
184{
185 object *u;
186 string ip;
187
188 ip = query_ip_number(this_object());
189 u = filter(users(), function status (object ob, string addr, int a) {
190 return query_ip_number(ob) == addr
191 && ob->QueryProp(P_AGE) < a;
192 }, ip, 12*60*60); // 24h in heart_beats
193
194 if ( sizeof(u) > 25 ){
195 write( "\nDa anscheinend gerade jemand von Deiner Adresse aus "
196 "versucht, das \n"MUDNAME" mit neuen Charakteren zu "
197 "ueberschwemmen, werden momentan \nnur aeltere Charaktere "
198 "von dieser Adresse zugelassen.\nWenn Du meinst, dass es "
199 "sich um einen Fehler handelt, logg Dich bitte als \n"
200 "Gast ein und sprich einen Erzmagier oder Gott an.\n" );
201
202 log_file( "LOGIN_DENY", sprintf( "%s: >10 Spieler von %-15s (%s)\n",
203 ctime(time())[4..15],
204 query_ip_number(this_object()),
205 query_ip_name(this_object()) ) );
206
207 destruct(this_object());
208 return 1;
209 }
210 else
211 return 0;
212}
213
214
215static int check_illegal( string str )
216{
217 string res;
218
219 res = (string)master()->QuerySBanished(query_ip_number(this_object()));
220 if (!res)
221 {
222 // check connection from Tor exit node
223 string eff_ip = (realip!="" ? realip : query_ip_number(this_object()));
224 if ("/p/daemon/dnslookup"->check_tor(eff_ip, query_mud_port())
225 || "/p/daemon/dnslookup"->check_dnsbl(eff_ip))
226 res =
227 "\nSorry, von Deiner Adresse kamen ein paar Idioten, die "
228 "ausschliesslich\nAerger machen wollten. Deshalb haben wir "
229 "die Moeglichkeit,\neinfach neue Charaktere "
230 "anzulegen, fuer diese Adresse gesperrt.\n\n"
231 "Falls Du bei uns spielen moechtest, schicke bitte eine Email "
232 "an\n\n mud@mg.mud.de\n\n"
233 "mit der Bitte, einen Charakter fuer Dich anzulegen.\n" ;
234 }
235
236 if ( res )
237 {
238 write( res );
239 log_file( "LOGIN_DENY", sprintf( "%s: %-11s %-15s (%s)\n",
240 ctime(time())[4..15], str,
241 query_ip_number(this_object()),
242 query_ip_name(this_object()) ) );
243 remove();
244 return 1;
245 }
246
247 return 0;
248}
249
250
251/*
252 * Check that a player name is valid. Only allow
253 * lowercase letters.
254 */
255static int valid_name( string str )
256{
257 int i;
258
259 if ( str == "logon" ){
260 write( "Der Name wuerde nur Verwirrung stiften.\n" );
261 return 0;
262 }
263
264 i = sizeof(str);
265
266 if ( i > 11 ){
267 write( "Dein Name ist zu lang, nimm bitte einen anderen.\n" );
268 return 0;
269 }
270
271 for ( ; i--; )
272 if ( str[i] < 'a' || str[i] > 'z' ) {
273 write( "Unerlaubtes Zeichen '" + str[i..i] + "' im Namen: " + str
274 + "\n" );
275 write( "Benutze bitte nur Buchstaben ohne Umlaute.\n" );
276 return 0;
277 }
278
279 return 1;
280}
281
282
283static int logon2( string str )
284{
285 int i, arg;
286 mixed txt;
287
288 if ( !str || str == "" ){
289 write( "Abbruch!\n" );
290 destruct( this_object() );
291 return 0;
292 }
293
294 // Unterstuetzung fuer das Mud Server Status Protocol
295 // (http://tintin.sourceforge.net/mssp/)
296#ifdef MSSP_SUPPORT
297 if (str == "MSSP-REQUEST") {
298 "/secure/misc/mssp"->print_mssp_response();
299 log_file( "MSSP.log", sprintf( "%s: %-15s (%s)\n",
300 strftime("%c"),
301 query_ip_number(this_object()),
302 query_ip_name(this_object())||"N/A" ) );
303 input_to("logon2", INPUT_PROMPT,
304 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
305 return 1;
306 }
307#endif
308
309 if(strstr(str,SSL_GRRETING)==0)
310 {
311 if( member(PROXIES,query_ip_number(this_object()))>-1 )
312 {
313 realip=str[sizeof(SSL_GRRETING)..];
314 } // andere IPs werden einfach ignoriert. -> log/PROXY.REQ ?
315 // ggf. Lookup fuer Torexits anstossen.
316 "/p/daemon/dnslookup"->check_tor(realip,query_mud_port());
317 "/p/daemon/dnslookup"->check_dnsbl(realip);
318
319 input_to( "logon2", INPUT_PROMPT,
320 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
321 return 1;
322 }
323
324 if ( loginname != "logon" ) {
325 log_file( "ILLEGAL", sprintf( "%s Illegal patch of login: "
326 "loginname = %O\n",
327 dtime(time()), loginname ) );
328 destruct( this_object() );
329 return 0;
330 }
331
332 str = lower_case(str);
333 cap_name = capitalize(str);
334
335 if ( str == "neu" && !neu ){
336 cat( "/etc/WELCOME_NEW" );
337 neu = 1;
338 input_to( "logon2", INPUT_PROMPT, "Name: ");
339 return 1;
340 }
341
342 if ( !valid_name(str) ){
343 string pr;
344 if ( !neu )
345 pr= "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ";
346 else
347 pr= "Bitte gib Dir einen anderen Namen: ";
348
349 input_to( "logon2", INPUT_PROMPT, pr );
350 return 1;
351 }
352
353 if ( sscanf( str, "gast%d", arg ) == 1 ){
354 write( "Du meinst wohl 'Gast' ...\n" );
355 str = "gast";
356 }
357
358 loginname = str;
359
360 /* read the secure save file to see if character already exists */
361 if ( loginname != "gast" &&
362 !restore_object( master()->secure_savefile(loginname) ) ){
363 object *user;
364
365 if ( !neu )
366 {
367 write( "Es existiert kein Charakter mit diesem Namen.\n" );
368 write( "Falls Du einen neuen Charakter erschaffen moechtest, "
369 "tippe bitte \"neu\" ein.\n" );
370
371 loginname = "logon";
372 input_to( "logon2", INPUT_PROMPT,
373 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
374 return 1;
375 }
376
377 for ( i = sizeof(user = users() - ({ 0, this_object() })); i--; )
378 if ( object_name(user[i])[0..12] == "/secure/login" &&
379 ((string)user[i]->loginname()) == loginname ){
380 write( "Eine Anmeldung fuer diesen Namen laeuft bereits.\n" );
381 destruct( this_object() );
382 return 1;
383 }
384
385 // Site-Banish checken
386 if ( check_illegal(loginname))
387 return 1;
388
389 if ( check_too_many_from_same_ip() )
390 return 1;
391
392 /* new character */
393 if ( sizeof(loginname) < 3 ){
394 write( "Der Name ist zu kurz.\n" );
395 loginname = "logon";
396 input_to( "logon2", INPUT_PROMPT,
397 "Versuch einen anderen Namen: ");
398 return 1;
399 }
400
401
402 if ( (txt = (string)master()->QueryBanished(loginname)) ){
403 if ( txt != "Dieser Name ist gesperrt." )
404 txt = sprintf("Hoppla - dieser Name ist reserviert oder gesperrt "
405 "(\"gebanisht\")!\nGrund: %s\n",txt);
406 else
407 txt = "Hoppla - dieser Name ist reserviert oder gesperrt "
408 "(\"gebanisht\")!\n";
409 write(txt);
410 loginname = "logon";
411 input_to( "logon2", INPUT_PROMPT,
412 "Bitte gib Dir einen anderen Namen: ");
413 return 1;
414 }
415
416 /* Initialize the new secure savefile */
417 name = loginname;
418 password = "";
419 level = 0;
420 domains = ({ });
421 guilds = ({ });
422 shell = "";
423 ep = "";
424 ek = "";
425 mq = "";
426 ektips="";
427 fptips="";
428 creation_date = time();
429
430 input_to( "new_password", INPUT_NOECHO|INPUT_PROMPT,
431 "Waehle ein Passwort: ");
432 return 1;
433 }
434 else {
435 if ( loginname == "gast" ){
436 if ( check_illegal(loginname) )
437 return 1;
438
439 load_player_object(1);
440 return 1;
441 }
442
443 if ( neu ){
444 write( "Es existiert bereits ein Charakter dieses Namens.\n" );
445 loginname = "logon";
446 input_to( "logon2", INPUT_PROMPT,
447 "Gib Dir einen anderen Namen: ");
448 return 1;
449 }
450
451 if ( (int)master()->check_late_player(loginname) )
452 {
453 write( "Dieser Spieler hat uns leider fuer immer verlassen.\n" );
454 loginname = "logon";
455 input_to( "logon2", INPUT_PROMPT,
456 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
457 return 1;
458 }
459
460 if ( txt = (string)master()->QueryTBanished(loginname) ){
461 write( txt );
462 loginname = "logon";
463 input_to( "logon2", INPUT_PROMPT,
464 "Wie heisst Du denn (\"neu\" fuer neuen Spieler)? ");
465 return 1;
466 }
467
468 if ( creation_date > (time() - 30*24*60*60)
469 && check_too_many_from_same_ip() )
470 return 1;
471
472 write( "Schoen, dass Du wieder da bist, "+capitalize(loginname)+"!\n" );
473
474 if ( !stringp(password) || password == "" ) {
475 write( "Du hast KEIN PASSWORD!\n" );
476 write( "Benutze den \"password\"-Befehl, um das zu aendern !\n" );
477 load_player_object(0);
478 return 1;
479 }
480
481 input_to( "check_password", INPUT_NOECHO|INPUT_PROMPT,
482 "Passwort: ");
483 return 1;
484 }
485}
486
487
488static int new_password( string str )
489{
490 write( "\n" );
491
492 if ( !str || str == "" )
493 return remove();
494
495 password = str;
496
497 if ( !master()->good_password( str, loginname ) ) {
498 input_to( "new_password", INPUT_NOECHO|INPUT_PROMPT,
499 "Bitte gib ein Passwort an: ");
500 return 1;
501 }
502
503 write( "\nZur Erinnerung: Es ist v e r b o t e n, andere Spieler "
504 "anzugreifen!\n" );
505 write( "Das gilt auch fuer Froesche, bei denen \"Ein Frosch namens "
506 "XXXXX\" steht.\n\n" );
507 input_to( "again_password", INPUT_NOECHO|INPUT_PROMPT,
508 "Passwort bitte nochmal eingeben: ");
509 return 1;
510}
511
512static int again_password( string str )
513{
514 write( "\n" );
515
516 if ( str != password ){
517 write( "Die Passwoerter stimmten nicht ueberein!\n" );
518 destruct( this_object() );
519 return 1;
520 }
521
Zesstra28d72e52016-10-27 23:56:19 +0200522 set_next_reset(600);
MG Mud User88f12472016-06-24 23:31:02 +0200523 password = md5_crypt( password, 0 );
524 save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname );
525 master()->RemoveFromCache( loginname );
526
527 load_player_object(0);
528 return 1;
529}
530
531static int check_password( string str )
532{
533 write( "\n" );
534
535 // Invis einloggen?
536 if (sizeof(str) > 1 && str[0] == '-') {
537 invis = 1;
538 str = str[1..];
539 }
540
541 // welcher Hash ists denn?
542 if (sizeof(password) > 13) {
543 // MD5-Hash
544 str = md5_crypt(str, password);
545 }
546 else if (sizeof(password) > 2) {
547 // Crypt-Hash
548 str = crypt(str, password[0..1]);
549 }
550 else {
551 // keiner von beiden Hashes -> ungueltiges PW
552 str = 0;
553 }
554
555 if ( !stringp(str) || str != password ) {
556 // Hashes stimmen nicht ueberein -> und schluss...
557 write( "Falsches Passwort!\n");
558 if ( loginfails > 2 )
559 write(break_string(
560 "Solltest Du weiterhin Probleme mit dem Einloggen haben, kannst "
561 "Du Dein Passwort zuruecksetzen lassen, indem Du Dich als Gast "
562 "anmeldest und einen Erzmagier ansprichst, oder indem Du Dich "
563 "mittels einer E-Mail an mud@md.mud.de mit uns in Verbindung "
564 "setzt.",78));
565
566 log_file( (level < 60 ? "LOGINFAIL" : "ARCH/LOGINFAIL"),
567 sprintf( "PASSWORD: %-11s %s, %-15s (%s)\n",
568 loginname, ctime(time())[4..15],
569 query_ip_number(this_object()),
570 query_ip_name(this_object()) ), 200000 );
571
572 loginfails++;
573 save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname );
574 master()->RemoveFromCache( loginname );
575 destruct( this_object() );
576 return 1;
577 }
578
579 if ( loginfails ) {
580 write( loginfails + " fehlgeschlagene" + (loginfails == 1 ? "r" : "") +
581 " Login-Versuch" + (loginfails == 1 ? "" : "e") +
582 " seit dem letzten erfolgreichen Login.\n" );
583 loginfails = 0;
584 }
585
586 save_object( SECURESAVEPATH + loginname[0..0] + "/" + loginname );
587 master()->RemoveFromCache( loginname );
588
589 load_player_object(0);
590 return 1;
591}
592
593
594static void select_race()
595{
596 int i;
597 string s;
598
599 races = get_dir( "/std/shells/*.c" );
600
601 // Mensch soll immer als erstes in der Auswahlliste stehen.
602 if (member(races,"human.c")!=-1)
603 races=({"human.c"})+(races-({"human.c"}));
604
605 for ( i = sizeof(races); i--; ){
606 races[i] = "/std/shells/" + races[i][0..<3];
607 s = 0;
608
609 if ( catch(s = (string)call_other( races[i], "QueryAllowSelect" ); publish)
610 || !s)
611 s = 0;
612 else if ( catch(s = (string)call_other( races[i], "QueryProp", P_RACE );publish) )
613 s = 0;
614
615 if ( !sizeof(s) )
616 races[i..i] = ({});
617 else
618 races[i] = ({ races[i], s });
619 }
620
621 if ( sizeof(races) == 1 ){
622 write( "Es gibt nur eine Rasse, Du hast also keine Wahl.\n" );
623
624 shell = races[0][0];
625 master()->set_player_object( loginname, shell );
626
627 return load_player_ob_2( shell, 0 );
628 }
629
630 return ask_mud_played_question();
631}
632
633static void ask_mud_played_question()
634{
635 write(break_string(
636 "\nWenn Du ein absoluter Neuling in diesem Spiel bist moechten "
637 "wir Dir mit einigen Tips zu Beginn beiseite stehen.\n\n",78,
638 0,BS_LEAVE_MY_LFS));
639 input_to( "get_mud_played_answer", INPUT_PROMPT,
640 "Hast Du schon einmal in einem MUD gespielt? (ja,nein): ");
641 return;
642}
643
644static void ask_race_question()
645{
646 int i, j;
647
648 write( break_string( "Du musst Dich jetzt entscheiden, welcher Rasse Du "
649 "in dieser Welt angehoeren moechtest. Alle Rassen "
650 "haben verschiedene Vor- und Nachteile, insgesamt "
651 "aber gleich gute Chancen. Auch das Startgebiet "
652 "haengt von der ausgewaehlten Rasse ab. Im "
653 "Normalfall kann die Rasse nicht mehr gewechselt "
654 "werden, nachdem sie einmal ausgewaehlt wurde. "
655 "Ueberlege Dir Deine Entscheidung also gut. Derzeit "
656 "stehen folgende Rassen zur Auswahl:\n\n", 78 ) );
657
658 for ( i = 0, j = sizeof(races); i < j; i++ )
659 printf( "% 2d. %-30s %s", i+1, capitalize(races[i][1]),
660 (i % 2 ? "\n" : "| ") );
661
662 if ( sizeof(races) % 2 )
663 write( "\n" );
664
665 write( break_string( "\nDurch Eingabe einer Ziffer waehlst Du die Rasse "
666 "aus, durch Eingabe eines \"\?\" gefolgt von einer "
667 "Ziffer erhaeltst Du naehere Informationen ueber "
668 "eine Rasse. Ein \"\?\" allein wiederholt diese "
669 "Liste.", 78, 0, 1 ) );
670
671 if (newbie)
672 {
673 write(break_string("\nAls Neuling solltest Du Dich NICHT fuer "
674 "die Dunkelelfen entscheiden. Diese "
675 "Rasse hat einige Probleme im Umgang "
676 "mit den anderen Rassen und mit dem "
677 "Sonnenlicht.",78,0,BS_LEAVE_MY_LFS));
678 }
679
680 input_to( "get_race_answer", INPUT_PROMPT,
681 "\nWas willst Du tun: ");
682 return;
683}
684
685
686static void get_race_answer( string str )
687{
688 int num;
689
690 if ( str == "?" )
691 return ask_race_question();
692
693 if ( sscanf( str, "?%d", num ) ){
694 if ( num < 1 || num > sizeof(races) ){
695 write( "Das geht nicht.\n\n");
696 input_to( "get_race_answer", INPUT_PROMPT,
697 "Was willst Du tun: ");
698 return;
699 }
700
701 write( call_other( races[num - 1][0], "QueryProp", P_RACE_DESCRIPTION ));
702 input_to( "get_race_answer", INPUT_PROMPT,
703 "\nWas willst Du tun: ");
704 return;
705 }
706
707 if ( sscanf( str, "%d", num ) && num >= 1 && num <= sizeof(races) ){
708 write( "Ok, Du bist jetzt ein "
709 + capitalize(races[num-1][1]) + ".\n" );
710
711 shell = races[num-1][0];
712 master()->set_player_object( loginname, shell );
713 return load_player_ob_2( shell, 0 );
714 }
715
716 write("Wie bitte?\n\n" );
717 input_to( "get_race_answer", INPUT_PROMPT,
718 "Was willst Du tun: ");
719}
720
721static void get_mud_played_answer (string str)
722{
723 if ( str == "ja" || str=="j")
724 {
725 newbie=0;
726 return ask_race_question();
727 }
728 if ( str != "nein" && str!="n")
729 {
730 write("\n\nAntworte bitte mit ja oder nein.\n\n");
731
732 return ask_mud_played_question();
733 }
734 newbie=1;
735 write("\n\nEine kleine Einfuehrung in das "MUDNAME" bekommst "
736 "Du auch hier:\n\n"
737 "http://mg.mud.de/newweb/hilfe/tutorial/inhalt.shtml\n\n");
738 return ask_race_question();
739
740}
741
742static int load_player_object( int guestflag )
743{
744 object ob;
745 string fname;
746 int was_interactive;
747
748 if ( sizeof(users()) >= 195 && !IS_WIZARD(loginname) ){
749 write( "Die maximale Spielerzahl wurde bereits erreicht!!!\n"
750 "Aus technischen Gruenden duerfen sich nur noch Magier "
751 "einloggen.\nVersuch es spaeter noch einmal ...\n" );
752 destruct( this_object() );
753 return 1;
754 }
755 else if ( sizeof(users()) >= 198 && !IS_ARCH(loginname) ){
756 write( "Die maximale Spieler- und Magierzahl wurde bereits erreicht!!!"
757 "\nAus technischen Gruenden duerfen sich nur noch Erzmagier "
758 "einloggen.\nVersuch es spaeter noch einmal ...\n" );
759 destruct( this_object() );
760 return 1;
761 }
762
763 if ( file_size("/etc/NOLOGIN")>=0 )
764 {
765 if (file_size("/etc/NOLOGIN.info")>0) {
766 //NOLOGIN.info enthaelt evtl. weitergehende Informationen fuer
767 //Spieler, z.B. vorrauss. Wiederverfuegbarkeit.
768 write(break_string(read_file("/etc/NOLOGIN.info"),78,"",
769 BS_LEAVE_MY_LFS|BS_SINGLE_SPACE));
770 }
771 else {
772 //sonst Standardmeldung ausgeben.
773 write ("\nAufgrund von technischen Problemen ist das Einloggen ins "
774 MUDNAME" zur \nZeit nicht moeglich. Bitte versuch es "
775 "spaeter noch einmal.\n\n");
776 }
777 if ( IS_ARCH(loginname) ||
778 member(explode(read_file("/etc/NOLOGIN")||"","\n"),
779 loginname)!=-1 )
780 {
781 write("Im Moment koennen nur Erzmagier einloggen. Um Spieler "
782 "wieder ins Spiel zu lassen, muss die Datei '/etc/NOLOGIN' "
783 "geloescht werden.\n\n ");
784 } else {
785 destruct( this_object() );
786 return 1;
787 }
788 }
789
790 if ( guestflag ){
791 if ( catch(guestflag = (int)GUESTMASTER->new_guest();publish)
792 || !guestflag ){
793 write( "Derzeit ist kein Gastlogin moeglich!\n" );
794 destruct( this_object() );
795 return 1;
796 }
797
798 loginname = "gast" + guestflag;
799 cap_name = capitalize(loginname);
800 name = cap_name;
801
802 if ( !(ob = find_player(loginname) || find_netdead(loginname)) ){
803 object *user;
804 int i;
805
806 // gegen Horden von Gast1 - wenn ein Gast noch am Prompt fuer
807 // das Geschlecht haengt, ist er ueber find_player() noch nicht
808 // zu finden ...
809 for ( i = sizeof(user = users() - ({ 0, this_object() })); i--; )
810 if ( object_name(user[i])[0..11] == "/std/shells/" &&
811 getuid(user[i]) == loginname ){
812 ob = user[i];
813 break;
814 }
815 }
816
817 if ( ob ){
818 tell_object( ob, "Ein anderer Spieler moechte diesen Gastzugang "
819 "jetzt benutzen. Wenn es Dir hier\ngefallen hat, "
820 "ueberleg Dir doch einen Charakternamen und komm "
821 "unter diesem\nNamen wieder!\n" );
822 destruct(ob);
823 }
824
825 load_player_ob_2( "std/shells/human", guestflag );
826
827 return 1;
828 }
829 else {
830 /* Test if we are already playing */
831 was_interactive = 0;
832 ob = find_player(loginname) || find_netdead(loginname);
833
834 if (ob) {
835 write( "Du nimmst schon am Spiel teil!\n" );
836 write( "Verwende Deine alte sterbliche Huelle ...\n" );
837
838 if ( interactive(ob) )
839 {
840 /* The other object is still interactive; reconnect that "soul"
841 to a dummy object and destruct that, thus disconnecting the
842 other probably linkdead user. The real "body" is still
843 there for reconnecting by login.c */
844 remove_interactive(ob);
845 was_interactive = 1;
846 }
847 // Wenn Invislogin, P_INVIS setzen.
848 if ( invis && IS_WIZARD(ob) )
849 {
850 ob->SetProp( P_INVIS, ob->QueryProp(P_AGE) );
851 tell_object( ob, "DU BIST UNSICHTBAR!\n" );
852 }
853 /* Now reconnect to the old body */
854 exec( ob, this_object() );
855 ob->set_realip(realip);
856 if ( ((int)ob->QueryProp(P_LEVEL)) == -1 )
857 ob->start_player( cap_name );
858 else
859 ob->Reconnect( was_interactive );
860
861 call_out( "remove", 2 );
862 return 1;
863 }
864 }
865
866 /* read player object from passwd file */
867 if ( stringp(shell) && shell != "" )
868 load_player_ob_2 ( shell, 0 );
869 else
870 select_race();
871
872 return 1;
873}
874
875
876static void load_player_ob_2( string obname, int guestflag )
877{
878 object blueprint;
879 string err, ob_name;
880 object ob, old_ob;
881
882 if (!interactive()) {
883 destruct(this_object());
884 return;
885 }
886 /* start player activity */
Zesstrae88826c2016-09-24 20:37:05 +0200887 log_file( "syslog/shell/ENTER", sprintf( "%-11s %s, %-15s (%s).\n",
MG Mud User88f12472016-06-24 23:31:02 +0200888 capitalize(name), ctime(time())[4..15],
889 query_ip_number(this_object()),
890 query_ip_name(this_object()) ), 200000 );
891
892 seteuid(loginname);
893
894 /* load the "real" player object */
895 /* If some asshole has moved the blueprint */
896 if ( objectp(blueprint = find_object(obname)) && environment(blueprint) )
897 destruct(blueprint);
898
899 if ( err = catch(ob = clone_object(obname);publish) ){
900 log_file( "SHELLS", "Failed to load shell " + obname + ", " +
901 dtime(time()) + ", " + loginname + "\n" + err + "\n\n" );
902
903 write( "Konnte das passende Playerobjekt nicht laden. Lade "
904 "stattdessen\ndas Objekt Mensch. BITTE ERZMAGIER "
905 "BENACHRICHTIGEN !\n" );
906 err = catch(ob = clone_object("/std/shells/human");publish);
907 }
908
909 if ( !ob || err ) {
910 write( "Error on loading " + shell + "\nError = " + err + "\n" );
911 destruct( this_object() );
912 return;
913 }
914
915 if ( guestflag )
916 catch( GUESTMASTER->set_guest( guestflag, ob );publish );
917
918 ob_name = explode( object_name(ob), "#" )[0];
919
920 if ( sizeof(ob_name) > 11 && ob_name[0..11] == "/std/shells/" )
921 ob_name = ob_name[11..];
922
923 ob_name = ob_name + ":" + loginname;
924
925 if( !guestflag )
926 {
927 if ( old_ob = find_object(ob_name) )
928 {
929 catch(old_ob->remove();publish);
930
931 if ( old_ob )
932 destruct( old_ob );
933 }
934 rename_object( ob, ob_name );
935 ob->__reload_explore();
936 }
937 exec( ob, this_object() );
938 ob->set_realip(realip);
939 ob->start_player( cap_name );
940 //Hinweis: Das Spielerobjekt holt sich in updates_after_restore() von hier
941 //den Status von invis und setzt ggf. P_INVIS
942
943 // TODO: Prop rauswerfen und in Spielern SAVE entfernen, wenn die folgenden
944 // Verwendungen entsorgt sind:
945 // /d/wueste/hirudo/goldstrand/rooms/gefaengnis.c
946 // /d/inseln/tilly/feuerinsel/obj/formular.c
947 // /d/polar/files.chaos/tilly/obj/dose_obj.c
948 ob->SetProp( "creation_date", creation_date );
949 ob->Set( "creation_date", SAVE|SECURED|PROTECTED, F_MODE_AS );
950 // wenn der Spieler noch nicht im Mud gespielt hat, wird die aktuelle Zeit
951 // in die entsprechende Prop geschrieben. Die Prop ist transient und wird
952 // absichtlich nicht gespeichert.
953 if (newbie)
954 ob->SetProp("_lib_mud_newbie", creation_date);
955
956 destruct( this_object() );
957}
958
959
960/*
961 * With arg = 0 this function should only be entered once!
962 */
963protected void create()
964{
965 loginname = "logon";
966 creation_date = -1;
967 catch( load_object( "/secure/merlin");publish );
968 loginfails = 0;
969 realip="";
970 if (clonep())
971 set_next_reset(900);
972 else
973 set_next_reset(-1);
974}
975
976void reset()
977{
978 if (clonep())
Zesstra28d72e52016-10-27 23:56:19 +0200979 {
980 if (interactive(this_object()))
981 tell_object(this_object(),"Time out!");
MG Mud User88f12472016-06-24 23:31:02 +0200982 remove();
Zesstra28d72e52016-10-27 23:56:19 +0200983 }
MG Mud User88f12472016-06-24 23:31:02 +0200984}
985
986public string short()
987{
988 return "<Einloggender Teilnehmer>.\n";
989}
990
991
992public string query_real_name()
993{
994 return "<logon>";
995}
996
997
998public nomask int query_prevent_shadow()
999{
1000 return 1;
1001}
1002
1003
MG Mud User88f12472016-06-24 23:31:02 +02001004// Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht
1005// im Loginprozess involviert.
1006public mixed new_logon( string str)
1007{
1008 seteuid(getuid()); // sonst funkt ARCH_SECURITY nicht
1009
1010 if ( !ARCH_SECURITY || process_call() ){
1011 write( "Nur fuer Erzmagier erlaubt!\n" );
1012 destruct( this_object() );
1013 return -1;
1014 }
1015
1016 if ( !str || str == "" ){
1017 write( "Kein Name angegeben!\n" );
1018 destruct( this_object() );
1019 return 0;
1020 }
1021
1022 str = lower_case(str);
1023 cap_name = capitalize(str);
1024
1025 loginname = str;
1026 seteuid(ROOTID);
1027
1028 /* read the secure save file to see if character already exists */
1029 if ( !restore_object( master()->secure_savefile(loginname) ) ){
1030 write( "Kein solcher Spieler!\n" );
1031 destruct( this_object() );
1032 return 0;
1033 }
1034 else {
1035 write( "Ok, der Spieler " + capitalize(str) + " existiert!\n" );
1036 return new_load_player_object();
1037 }
1038}
1039
1040// Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht
1041// im Loginprozess involviert.
1042static mixed new_load_player_object()
1043{
1044 if ( find_player(loginname) || find_netdead(loginname) ){
1045 write( "Der Spieler ist bereits online oder netztot!\n" );
1046 destruct( this_object() );
1047 return 2;
1048 }
1049
1050 /* read player object from passwd file */
1051 if ( stringp(shell) && shell != "" )
1052 return new_load_player_ob_2( shell );
1053 else {
1054 write( "Keine Shell angegeben!\n" );
1055 destruct( this_object() );
1056 return 0;
1057 }
1058}
1059
1060// Wird von simul_efuns benutzt, um nen dummy-Spielerobjekt zu erzeugen. Nicht
1061// im Loginprozess involviert.
1062static mixed new_load_player_ob_2( string obname )
1063{
1064 object blueprint;
1065 string err, ob_name;
1066 object ob, old_ob;
1067
1068 seteuid(loginname);
1069
1070 /* load the "real" player object */
1071 /* If some asshole has moved the blueprint */
1072 if ( objectp(blueprint = find_object(obname)) && environment(blueprint) )
1073 destruct( blueprint );
1074
1075 err = catch(ob = clone_object(obname);publish);
1076
1077 if ( err ){
1078 log_file( "SHELLS", "Failed to load shell " + obname + ", " +
1079 dtime(time()) + ", " + loginname + "\n" + err + "\n\n" );
1080
1081 write( "Konnte das passende Playerobjekt nicht laden. "
1082 "Lade stattdessen\ndas Objekt Mensch!\n" );
1083
1084 err = catch(ob = clone_object( "std/shells/human" );publish );
1085 }
1086
1087 if ( !ob || err ){
1088 write( "Error on loading " + shell + "\nError = " + err + "\n" );
1089 destruct( this_object() );
1090 return 0;
1091 }
1092
1093 ob_name = explode( object_name(ob), "#" )[0];
1094
1095 if ( sizeof(ob_name) > 11 && ob_name[0..11] == "/std/shells/" )
1096 ob_name = ob_name[11..];
1097
1098 ob_name = ob_name + ":" + loginname;
1099
1100 if ( old_ob = find_object(ob_name) ){
1101 catch( old_ob->remove(); publish );
1102
1103 if ( old_ob )
1104 destruct( old_ob );
1105 }
1106
1107 rename_object( ob, ob_name );
1108 ob->__reload_explore();
1109 ob->set_realip(realip);
1110 ob->start_player(cap_name);
1111 ob->SetProp( "creation_date", creation_date );
1112 ob->Set( "creation_date", SAVE|SECURED|PROTECTED, F_MODE_AS );
1113
1114 ob->move( "/room/nowhere", M_NOCHECK );
1115 set_object_heart_beat( ob, 0 );
1116 destruct( this_object() );
1117
1118 return ob;
1119}
1120
1121string query_realip()
1122{
1123 return realip ? realip : "";
1124}
1125
1126int query_invis()
1127{
1128 return invis;
1129}
1130