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