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