]> arthur.barton.de Git - ngircd-alex.git/blob - src/ngircd/irc-login.c
dd436192caa888c395572b91ea47d2aa10e30921
[ngircd-alex.git] / src / ngircd / irc-login.c
1 /*
2  * ngIRCd -- The Next Generation IRC Daemon
3  * Copyright (c)2001-2008 Alexander Barton (alex@barton.de)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * Please read the file COPYING, README and AUTHORS for more information.
10  *
11  * Login and logout
12  */
13
14
15 #include "portab.h"
16
17 #include "imp.h"
18 #include <assert.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <strings.h>
23
24 #include "ngircd.h"
25 #include "resolve.h"
26 #include "conn-func.h"
27 #include "conf.h"
28 #include "client.h"
29 #include "channel.h"
30 #include "log.h"
31 #include "messages.h"
32 #include "parse.h"
33 #include "irc.h"
34 #include "irc-info.h"
35 #include "irc-write.h"
36
37 #include "exp.h"
38 #include "irc-login.h"
39
40
41 static bool Hello_User PARAMS(( CLIENT *Client ));
42 static void Kill_Nick PARAMS(( char *Nick, char *Reason ));
43
44
45 /**
46  * Handler for the IRC command "PASS".
47  * See RFC 2813 section 4.1.1, and RFC 2812 section 3.1.1.
48  */
49 GLOBAL bool
50 IRC_PASS( CLIENT *Client, REQUEST *Req )
51 {
52         char *type, *orig_flags;
53         int protohigh, protolow;
54
55         assert( Client != NULL );
56         assert( Req != NULL );
57
58         /* Return an error if this is not a local client */
59         if (Client_Conn(Client) <= NONE)
60                 return IRC_WriteStrClient(Client, ERR_UNKNOWNCOMMAND_MSG,
61                                           Client_ID(Client), Req->command);
62         
63         if (Client_Type(Client) == CLIENT_UNKNOWN && Req->argc == 1) {
64                 /* Not yet registered "unknown" connection, PASS with one
65                  * argument: either a regular client, service, or server
66                  * using the old RFC 1459 section 4.1.1 syntax. */
67                 LogDebug("Connection %d: got PASS command ...",
68                          Client_Conn(Client));
69         } else if ((Client_Type(Client) == CLIENT_UNKNOWN ||
70                     Client_Type(Client) == CLIENT_UNKNOWNSERVER) &&
71                    (Req->argc == 3 || Req->argc == 4)) {
72                 /* Not yet registered "unknown" connection or outgoing server
73                  * link, PASS with three or four argument: server using the
74                  * RFC 2813 section 4.1.1 syntax. */
75                 LogDebug("Connection %d: got PASS command (new server link) ...",
76                          Client_Conn(Client));
77         } else if (Client_Type(Client) == CLIENT_UNKNOWN ||
78                    Client_Type(Client) == CLIENT_UNKNOWNSERVER) {
79                 /* Unregistered connection, but wrong number of arguments: */
80                 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
81                                           Client_ID(Client), Req->command);
82         } else {
83                 /* Registered connection, PASS command is not allowed! */
84                 return IRC_WriteStrClient(Client, ERR_ALREADYREGISTRED_MSG,
85                                           Client_ID(Client));
86         }
87
88         Client_SetPassword(Client, Req->argv[0]);
89         Client_SetType(Client, CLIENT_GOTPASS);
90
91         /* Protocol version */
92         if (Req->argc >= 2 && strlen(Req->argv[1]) >= 4) {
93                 int c2, c4;
94
95                 c2 = Req->argv[1][2];
96                 c4 = Req->argv[1][4];
97
98                 Req->argv[1][4] = '\0';
99                 protolow = atoi(&Req->argv[1][2]);
100                 Req->argv[1][2] = '\0';
101                 protohigh = atoi(Req->argv[1]);
102                         
103                 Req->argv[1][2] = c2;
104                 Req->argv[1][4] = c4;
105         } else
106                 protohigh = protolow = 0;
107
108         /* Protocol type, see doc/Protocol.txt */
109         if (Req->argc >= 2 && strlen(Req->argv[1]) > 4)
110                 type = &Req->argv[1][4];
111         else
112                 type = NULL;
113         
114         /* Protocol flags/options */
115         if (Req->argc >= 4)
116                 orig_flags = Req->argv[3];
117         else
118                 orig_flags = "";
119
120         /* Implementation, version and IRC+ flags */
121         if (Req->argc >= 3) {
122                 char *impl, *ptr, *serverver, *flags;
123
124                 impl = Req->argv[2];
125                 ptr = strchr(impl, '|');
126                 if (ptr)
127                         *ptr = '\0';
128
129                 if (type && strcmp(type, PROTOIRCPLUS) == 0) {
130                         /* The peer seems to be a server which supports the
131                          * IRC+ protocol (see doc/Protocol.txt). */
132                         serverver = ptr + 1;
133                         flags = strchr(serverver, ':');
134                         if (flags) {
135                                 *flags = '\0';
136                                 flags++;
137                         } else
138                                 flags = "";
139                         Log(LOG_INFO,
140                             "Peer announces itself as %s-%s using protocol %d.%d/IRC+ (flags: \"%s\").",
141                             impl, serverver, protohigh, protolow, flags);
142                 } else {
143                         /* The peer seems to be a server supporting the
144                          * "original" IRC protocol (RFC 2813). */
145                         serverver = "";
146                         if (strchr(orig_flags, 'Z'))
147                                 flags = "Z";
148                         else
149                                 flags = "";
150                         Log(LOG_INFO,
151                             "Peer announces itself as \"%s\" using protocol %d.%d (flags: \"%s\").",
152                             impl, protohigh, protolow, flags);
153                 }
154                 Client_SetFlags(Client, flags);
155         }
156
157         return CONNECTED;
158 } /* IRC_PASS */
159
160
161 /**
162  * IRC "NICK" command.
163  * This function implements the IRC command "NICK" which is used to register
164  * with the server, to change already registered nicknames and to introduce
165  * new users which are connected to other servers.
166  */
167 GLOBAL bool
168 IRC_NICK( CLIENT *Client, REQUEST *Req )
169 {
170         CLIENT *intr_c, *target, *c;
171         char *modes;
172
173         assert( Client != NULL );
174         assert( Req != NULL );
175
176 #ifndef STRICT_RFC
177         /* Some IRC clients, for example BitchX, send the NICK and USER
178          * commands in the wrong order ... */
179         if( Client_Type( Client ) == CLIENT_UNKNOWN
180             || Client_Type( Client ) == CLIENT_GOTPASS
181             || Client_Type( Client ) == CLIENT_GOTNICK
182             || Client_Type( Client ) == CLIENT_GOTUSER
183             || Client_Type( Client ) == CLIENT_USER
184             || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
185 #else
186         if( Client_Type( Client ) == CLIENT_UNKNOWN
187             || Client_Type( Client ) == CLIENT_GOTPASS
188             || Client_Type( Client ) == CLIENT_GOTNICK
189             || Client_Type( Client ) == CLIENT_USER
190             || ( Client_Type( Client ) == CLIENT_SERVER && Req->argc == 1 ))
191 #endif
192         {
193                 /* User registration or change of nickname */
194
195                 /* Wrong number of arguments? */
196                 if( Req->argc != 1 )
197                         return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG,
198                                                    Client_ID( Client ),
199                                                    Req->command );
200
201                 /* Search "target" client */
202                 if( Client_Type( Client ) == CLIENT_SERVER )
203                 {
204                         target = Client_Search( Req->prefix );
205                         if( ! target )
206                                 return IRC_WriteStrClient( Client,
207                                                            ERR_NOSUCHNICK_MSG,
208                                                            Client_ID( Client ),
209                                                            Req->argv[0] );
210                 }
211                 else
212                 {
213                         /* Is this a restricted client? */
214                         if( Client_HasMode( Client, 'r' ))
215                                 return IRC_WriteStrClient( Client,
216                                                            ERR_RESTRICTED_MSG,
217                                                            Client_ID( Client ));
218
219                         target = Client;
220                 }
221
222 #ifndef STRICT_RFC
223                 /* If the clients tries to change to its own nickname we won't
224                  * do anything. This is how the original ircd behaves and some
225                  * clients (for example Snak) expect it to be like this.
226                  * But I doubt that this is "really the right thing" ... */
227                 if( strcmp( Client_ID( target ), Req->argv[0] ) == 0 )
228                         return CONNECTED;
229 #endif
230
231                 /* Check that the new nickname is available. Special case:
232                  * the client only changes from/to upper to lower case. */
233                 if( strcasecmp( Client_ID( target ), Req->argv[0] ) != 0 )
234                 {
235                         if( ! Client_CheckNick( target, Req->argv[0] ))
236                                 return CONNECTED;
237                 }
238
239                 if(( Client_Type( target ) != CLIENT_USER )
240                    && ( Client_Type( target ) != CLIENT_SERVER ))
241                 {
242                         /* New client */
243                         Log( LOG_DEBUG, "Connection %d: got valid NICK command ...", 
244                              Client_Conn( Client ));
245
246                         /* Register new nickname of this client */
247                         Client_SetID( target, Req->argv[0] );
248
249                         /* If we received a valid USER command already then
250                          * register the new client! */
251                         if( Client_Type( Client ) == CLIENT_GOTUSER )
252                                 return Hello_User( Client );
253                         else
254                                 Client_SetType( Client, CLIENT_GOTNICK );
255                 }
256                 else
257                 {
258                         /* Nickname change */
259                         if( Client_Conn( target ) > NONE )
260                         {
261                                 /* Local client */
262                                 Log( LOG_INFO,
263                                      "User \"%s\" changed nick (connection %d): \"%s\" -> \"%s\".",
264                                      Client_Mask( target ), Client_Conn( target ),
265                                      Client_ID( target ), Req->argv[0] );
266                         }
267                         else
268                         {
269                                 /* Remote client */
270                                 Log( LOG_DEBUG,
271                                      "User \"%s\" changed nick: \"%s\" -> \"%s\".",
272                                      Client_Mask( target ), Client_ID( target ),
273                                      Req->argv[0] );
274                         }
275
276                         /* Inform all users and servers (which have to know)
277                          * of this nickname change */
278                         if( Client_Type( Client ) == CLIENT_USER )
279                                 IRC_WriteStrClientPrefix( Client, Client,
280                                                           "NICK :%s",
281                                                           Req->argv[0] );
282                         IRC_WriteStrServersPrefix( Client, target,
283                                                    "NICK :%s", Req->argv[0] );
284                         IRC_WriteStrRelatedPrefix( target, target, false,
285                                                    "NICK :%s", Req->argv[0] );
286
287                         /* Register old nickname for WHOWAS queries */
288                         Client_RegisterWhowas( target );
289
290                         /* Save new nickname */
291                         Client_SetID( target, Req->argv[0] );
292
293                         IRC_SetPenalty( target, 2 );
294                 }
295
296                 return CONNECTED;
297         }
298         else if( Client_Type( Client ) == CLIENT_SERVER )
299         {
300                 /* Server introduces new client */
301
302                 /* Falsche Anzahl Parameter? */
303                 if( Req->argc != 7 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
304
305                 /* Nick ueberpruefen */
306                 c = Client_Search( Req->argv[0] );
307                 if( c )
308                 {
309                         /* Der neue Nick ist auf diesem Server bereits registriert:
310                          * sowohl der neue, als auch der alte Client muessen nun
311                          * disconnectiert werden. */
312                         Log( LOG_ERR, "Server %s introduces already registered nick \"%s\"!", Client_ID( Client ), Req->argv[0] );
313                         Kill_Nick( Req->argv[0], "Nick collision" );
314                         return CONNECTED;
315                 }
316
317                 /* Server, zu dem der Client connectiert ist, suchen */
318                 intr_c = Client_GetFromToken( Client, atoi( Req->argv[4] ));
319                 if( ! intr_c )
320                 {
321                         Log( LOG_ERR, "Server %s introduces nick \"%s\" on unknown server!?", Client_ID( Client ), Req->argv[0] );
322                         Kill_Nick( Req->argv[0], "Unknown server" );
323                         return CONNECTED;
324                 }
325
326                 /* Neue Client-Struktur anlegen */
327                 c = Client_NewRemoteUser( intr_c, Req->argv[0], atoi( Req->argv[1] ), Req->argv[2], Req->argv[3], atoi( Req->argv[4] ), Req->argv[5] + 1, Req->argv[6], true);
328                 if( ! c )
329                 {
330                         /* Eine neue Client-Struktur konnte nicht angelegt werden.
331                          * Der Client muss disconnectiert werden, damit der Netz-
332                          * status konsistent bleibt. */
333                         Log( LOG_ALERT, "Can't create client structure! (on connection %d)", Client_Conn( Client ));
334                         Kill_Nick( Req->argv[0], "Server error" );
335                         return CONNECTED;
336                 }
337
338                 modes = Client_Modes( c );
339                 if( *modes ) Log( LOG_DEBUG, "User \"%s\" (+%s) registered (via %s, on %s, %d hop%s).", Client_Mask( c ), modes, Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
340                 else Log( LOG_DEBUG, "User \"%s\" registered (via %s, on %s, %d hop%s).", Client_Mask( c ), Client_ID( Client ), Client_ID( intr_c ), Client_Hops( c ), Client_Hops( c ) > 1 ? "s": "" );
341
342                 /* Andere Server, ausser dem Introducer, informieren */
343                 IRC_WriteStrServersPrefix( Client, Client, "NICK %s %d %s %s %d %s :%s", Req->argv[0], atoi( Req->argv[1] ) + 1, Req->argv[2], Req->argv[3], Client_MyToken( intr_c ), Req->argv[5], Req->argv[6] );
344
345                 return CONNECTED;
346         }
347         else return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
348 } /* IRC_NICK */
349
350
351 GLOBAL bool
352 IRC_USER( CLIENT *Client, REQUEST *Req )
353 {
354 #ifdef IDENTAUTH
355         char *ptr;
356 #endif
357
358         assert( Client != NULL );
359         assert( Req != NULL );
360
361 #ifndef STRICT_RFC
362         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS || Client_Type( Client ) == CLIENT_UNKNOWN )
363 #else
364         if( Client_Type( Client ) == CLIENT_GOTNICK || Client_Type( Client ) == CLIENT_GOTPASS )
365 #endif
366         {
367                 /* Wrong number of parameters? */
368                 if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
369
370                 /* User name */
371 #ifdef IDENTAUTH
372                 ptr = Client_User( Client );
373                 if( ! ptr || ! *ptr || *ptr == '~' ) Client_SetUser( Client, Req->argv[0], false );
374 #else
375                 Client_SetUser( Client, Req->argv[0], false );
376 #endif
377
378                 /* "Real name" or user info text: Don't set it to the empty string, the original ircd
379                  * can't deal with such "real names" (e. g. "USER user * * :") ... */
380                 if( *Req->argv[3] ) Client_SetInfo( Client, Req->argv[3] );
381                 else Client_SetInfo( Client, "-" );
382
383                 Log( LOG_DEBUG, "Connection %d: got valid USER command ...", Client_Conn( Client ));
384                 if( Client_Type( Client ) == CLIENT_GOTNICK ) return Hello_User( Client );
385                 else Client_SetType( Client, CLIENT_GOTUSER );
386                 return CONNECTED;
387         }
388         else if( Client_Type( Client ) == CLIENT_USER || Client_Type( Client ) == CLIENT_SERVER || Client_Type( Client ) == CLIENT_SERVICE )
389         {
390                 return IRC_WriteStrClient( Client, ERR_ALREADYREGISTRED_MSG, Client_ID( Client ));
391         }
392         else return IRC_WriteStrClient( Client, ERR_NOTREGISTERED_MSG, Client_ID( Client ));
393 } /* IRC_USER */
394
395
396 GLOBAL bool
397 IRC_QUIT( CLIENT *Client, REQUEST *Req )
398 {
399         CLIENT *target;
400         char quitmsg[LINE_LEN];
401         
402         assert( Client != NULL );
403         assert( Req != NULL );
404                 
405         /* Wrong number of arguments? */
406         if( Req->argc > 1 )
407                 return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
408
409         if (Req->argc == 1)
410                 strlcpy(quitmsg, Req->argv[0], sizeof quitmsg);
411
412         if ( Client_Type( Client ) == CLIENT_SERVER )
413         {
414                 /* Server */
415                 target = Client_Search( Req->prefix );
416                 if( ! target )
417                 {
418                         /* Den Client kennen wir nicht (mehr), also nichts zu tun. */
419                         Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client ));
420                         return CONNECTED;
421                 }
422
423                 Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
424
425                 return CONNECTED;
426         }
427         else
428         {
429                 if (Req->argc == 1 && quitmsg[0] != '\"') {
430                         /* " " to avoid confusion */
431                         strlcpy(quitmsg, "\"", sizeof quitmsg);
432                         strlcat(quitmsg, Req->argv[0], sizeof quitmsg-1);
433                         strlcat(quitmsg, "\"", sizeof quitmsg );
434                 }
435
436                 /* User, Service, oder noch nicht registriert */
437                 Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true);
438                 
439                 return DISCONNECTED;
440         }
441 } /* IRC_QUIT */
442
443
444 GLOBAL bool
445 IRC_PING(CLIENT *Client, REQUEST *Req)
446 {
447         CLIENT *target, *from;
448
449         assert(Client != NULL);
450         assert(Req != NULL);
451
452         /* Wrong number of arguments? */
453         if (Req->argc < 1)
454                 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
455                                           Client_ID(Client));
456 #ifdef STRICT_RFC
457         /* Don't ignore additional arguments when in "strict" mode */
458         if (Req->argc > 2)
459                  return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
460                                            Client_ID(Client), Req->command);
461 #endif
462
463         if (Req->argc > 1) {
464                 /* A target has been specified ... */
465                 target = Client_Search(Req->argv[1]);
466
467                 if (!target || Client_Type(target) != CLIENT_SERVER)
468                         return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
469                                         Client_ID(Client), Req->argv[1]);
470
471                 if (target != Client_ThisServer()) {
472                         /* Ok, we have to forward the PING */
473                         if (Client_Type(Client) == CLIENT_SERVER)
474                                 from = Client_Search(Req->prefix);
475                         else
476                                 from = Client;
477                         if (!from)
478                                 return IRC_WriteStrClient(Client,
479                                                 ERR_NOSUCHSERVER_MSG,
480                                                 Client_ID(Client), Req->prefix);
481
482                         return IRC_WriteStrClientPrefix(target, from,
483                                         "PING %s :%s", Req->argv[0],
484                                         Req->argv[1] );
485                 }
486         }
487
488         if (Client_Type(Client) == CLIENT_SERVER) {
489                 if (Req->prefix)
490                         from = Client_Search(Req->prefix);
491                 else
492                         from = Client;
493         } else
494                 from = Client_ThisServer();
495         if (!from)
496                 return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
497                                         Client_ID(Client), Req->prefix);
498
499         Log(LOG_DEBUG, "Connection %d: got PING, sending PONG ...",
500             Client_Conn(Client));
501
502 #ifdef STRICT_RFC
503         return IRC_WriteStrClient(Client, "PONG %s :%s",
504                 Client_ID(from), Client_ID(Client));
505 #else
506         /* Some clients depend on the argument being returned in the PONG
507          * reply (not mentioned in any RFC, though) */
508         return IRC_WriteStrClient(Client, "PONG %s :%s",
509                 Client_ID(from), Req->argv[0]);
510 #endif
511 } /* IRC_PING */
512
513
514 GLOBAL bool
515 IRC_PONG(CLIENT *Client, REQUEST *Req)
516 {
517         CLIENT *target, *from;
518         char *s;
519
520         assert(Client != NULL);
521         assert(Req != NULL);
522
523         /* Wrong number of arguments? */
524         if (Req->argc < 1)
525                 return IRC_WriteStrClient(Client, ERR_NOORIGIN_MSG,
526                                           Client_ID(Client));
527         if (Req->argc > 2)
528                 return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG,
529                                           Client_ID(Client), Req->command);
530
531         /* Forward? */
532         if (Req->argc == 2 && Client_Type(Client) == CLIENT_SERVER) {
533                 target = Client_Search(Req->argv[0]);
534                 if (!target)
535                         return IRC_WriteStrClient(Client, ERR_NOSUCHSERVER_MSG,
536                                         Client_ID(Client), Req->argv[0]);
537
538                 from = Client_Search(Req->prefix);
539
540                 if (target != Client_ThisServer() && target != from) {
541                         /* Ok, we have to forward the message. */
542                         if (!from)
543                                 return IRC_WriteStrClient(Client,
544                                                 ERR_NOSUCHSERVER_MSG,
545                                                 Client_ID(Client), Req->prefix);
546
547                         if (Client_Type(Client_NextHop(target)) != CLIENT_SERVER)
548                                 s = Client_ID(from);
549                         else
550                                 s = Req->argv[0];
551                         return IRC_WriteStrClientPrefix(target, from,
552                                  "PONG %s :%s", s, Req->argv[1]);
553                 }
554         }
555
556         /* The connection timestamp has already been updated when the data has
557          * been read from so socket, so we don't need to update it here. */
558
559         if (Client_Conn(Client) > NONE)
560                 Log(LOG_DEBUG,
561                         "Connection %d: received PONG. Lag: %ld seconds.",
562                         Client_Conn(Client),
563                         time(NULL) - Conn_LastPing(Client_Conn(Client)));
564         else
565                  Log(LOG_DEBUG,
566                         "Connection %d: received PONG.", Client_Conn(Client));
567
568         return CONNECTED;
569 } /* IRC_PONG */
570
571
572 static bool
573 Hello_User(CLIENT * Client)
574 {
575         assert(Client != NULL);
576
577         /* Check password ... */
578         if (strcmp(Client_Password(Client), Conf_ServerPwd) != 0) {
579                 /* Bad password! */
580                 Log(LOG_ERR,
581                     "User \"%s\" rejected (connection %d): Bad password!",
582                     Client_Mask(Client), Client_Conn(Client));
583                 Conn_Close(Client_Conn(Client), NULL, "Bad password", true);
584                 return DISCONNECTED;
585         }
586
587         Log(LOG_NOTICE, "User \"%s\" registered (connection %d).",
588             Client_Mask(Client), Client_Conn(Client));
589
590         /* Inform other servers */
591         IRC_WriteStrServers(NULL, "NICK %s 1 %s %s 1 +%s :%s",
592                             Client_ID(Client), Client_User(Client),
593                             Client_Hostname(Client), Client_Modes(Client),
594                             Client_Info(Client));
595
596         if (!IRC_WriteStrClient
597             (Client, RPL_WELCOME_MSG, Client_ID(Client), Client_Mask(Client)))
598                 return false;
599         if (!IRC_WriteStrClient
600             (Client, RPL_YOURHOST_MSG, Client_ID(Client),
601              Client_ID(Client_ThisServer()), PACKAGE_VERSION, TARGET_CPU,
602              TARGET_VENDOR, TARGET_OS))
603                 return false;
604         if (!IRC_WriteStrClient
605             (Client, RPL_CREATED_MSG, Client_ID(Client), NGIRCd_StartStr))
606                 return false;
607         if (!IRC_WriteStrClient
608             (Client, RPL_MYINFO_MSG, Client_ID(Client),
609              Client_ID(Client_ThisServer()), PACKAGE_VERSION, USERMODES,
610              CHANMODES))
611                 return false;
612
613         /* Features supported by this server (005 numeric, ISUPPORT),
614          * see <http://www.irc.org/tech_docs/005.html> for details. */
615         if (!IRC_Send_ISUPPORT(Client))
616                 return DISCONNECTED;
617
618         Client_SetType(Client, CLIENT_USER);
619
620         if (!IRC_Send_LUSERS(Client))
621                 return DISCONNECTED;
622         if (!IRC_Show_MOTD(Client))
623                 return DISCONNECTED;
624
625         /* Suspend the client for a second ... */
626         IRC_SetPenalty(Client, 1);
627
628         return CONNECTED;
629 } /* Hello_User */
630
631
632 static void
633 Kill_Nick( char *Nick, char *Reason )
634 {
635         REQUEST r;
636
637         assert( Nick != NULL );
638         assert( Reason != NULL );
639
640         r.prefix = (char *)Client_ThisServer( );
641         r.argv[0] = Nick;
642         r.argv[1] = Reason;
643         r.argc = 2;
644
645         Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
646         IRC_KILL( Client_ThisServer( ), &r );
647 } /* Kill_Nick */
648
649
650 /* -eof- */