]> arthur.barton.de Git - ngircd-alex.git/blobdiff - src/ngircd/irc-login.c
Added optional support for IDENT lookups (configure switch "--with-ident").
[ngircd-alex.git] / src / ngircd / irc-login.c
index ab7f190e7765cffa4ef444fcad873330243cabf6..10188c5e0203c8dfb4c2b8179fc51ca4ad6029a0 100644 (file)
@@ -14,7 +14,7 @@
 
 #include "portab.h"
 
-static char UNUSED id[] = "$Id: irc-login.c,v 1.32 2003/01/02 17:55:28 alex Exp $";
+static char UNUSED id[] = "$Id: irc-login.c,v 1.37 2003/12/27 13:01:12 alex Exp $";
 
 #include "imp.h"
 #include <assert.h>
@@ -31,8 +31,10 @@ static char UNUSED id[] = "$Id: irc-login.c,v 1.32 2003/01/02 17:55:28 alex Exp
 #include "log.h"
 #include "messages.h"
 #include "parse.h"
+#include "irc.h"
 #include "irc-info.h"
 #include "irc-write.h"
+#include "cvs-version.h"
 
 #include "exp.h"
 #include "irc-login.h"
@@ -222,6 +224,7 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
                        
                        /* neuen Client-Nick speichern */
                        Client_SetID( target, Req->argv[0] );
+                       IRC_SetPenalty( target, 2 );
                }
 
                return CONNECTED;
@@ -282,6 +285,10 @@ IRC_NICK( CLIENT *Client, REQUEST *Req )
 GLOBAL BOOLEAN
 IRC_USER( CLIENT *Client, REQUEST *Req )
 {
+#ifdef IDENTAUTH
+       CHAR *ptr;
+#endif
+
        assert( Client != NULL );
        assert( Req != NULL );
 
@@ -294,6 +301,10 @@ IRC_USER( CLIENT *Client, REQUEST *Req )
                /* Falsche Anzahl Parameter? */
                if( Req->argc != 4 ) return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command );
 
+#ifdef IDENTAUTH
+               ptr = Client_User( Client );
+               if( ! ptr || ! *ptr || *ptr == '~' )
+#endif
                Client_SetUser( Client, Req->argv[0], FALSE );
                Client_SetInfo( Client, Req->argv[3] );
 
@@ -427,12 +438,16 @@ IRC_PONG( CLIENT *Client, REQUEST *Req )
 LOCAL BOOLEAN
 Hello_User( CLIENT *Client )
 {
+#ifdef CVSDATE
+       CHAR ver[12], vertxt[30];
+#endif
+
        assert( Client != NULL );
 
-       /* Passwort ueberpruefen */
+       /* Check password ... */
        if( strcmp( Client_Password( Client ), Conf_ServerPwd ) != 0 )
        {
-               /* Falsches Passwort */
+               /* Bad password! */
                Log( LOG_ERR, "User \"%s\" rejected (connection %d): Bad password!", Client_Mask( Client ), Client_Conn( Client ));
                Conn_Close( Client_Conn( Client ), NULL, "Bad password", TRUE );
                return DISCONNECTED;
@@ -440,13 +455,29 @@ Hello_User( CLIENT *Client )
 
        Log( LOG_NOTICE, "User \"%s\" registered (connection %d).", Client_Mask( Client ), Client_Conn( Client ));
 
-       /* Andere Server informieren */
+       /* Inform other servers */
        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 ));
 
+       /* Welcome :-) */
        if( ! IRC_WriteStrClient( Client, RPL_WELCOME_MSG, Client_ID( Client ), Client_Mask( Client ))) return FALSE;
-       if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), VERSION, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return FALSE;
+
+       /* Version and system type */
+#ifdef CVSDATE
+        strlcpy( ver, CVSDATE, sizeof( ver ));
+        strncpy( ver + 4, ver + 5, 2 );
+        strncpy( ver + 6, ver + 8, 3 );
+       snprintf( vertxt, sizeof( vertxt ), "%s(%s)", PACKAGE_VERSION, ver );
+       if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return FALSE;
+#else
+       if( ! IRC_WriteStrClient( Client, RPL_YOURHOST_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, TARGET_CPU, TARGET_VENDOR, TARGET_OS )) return FALSE;
+#endif
+
        if( ! IRC_WriteStrClient( Client, RPL_CREATED_MSG, Client_ID( Client ), NGIRCd_StartStr )) return FALSE;
-       if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), VERSION, USERMODES, CHANMODES )) return FALSE;
+#ifdef CVSDATE
+       if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), vertxt, USERMODES, CHANMODES )) return FALSE;  
+#else
+       if( ! IRC_WriteStrClient( Client, RPL_MYINFO_MSG, Client_ID( Client ), Client_ID( Client_ThisServer( )), PACKAGE_VERSION, USERMODES, CHANMODES )) return FALSE;
+#endif
 
        /* Features */
        if( ! IRC_WriteStrClient( Client, RPL_ISUPPORT_MSG, Client_ID( Client ), CLIENT_NICK_LEN - 1, CHANNEL_TOPIC_LEN - 1, CLIENT_AWAY_LEN - 1, Conf_MaxJoins )) return DISCONNECTED;
@@ -456,6 +487,9 @@ Hello_User( CLIENT *Client )
        if( ! IRC_Send_LUSERS( Client )) return DISCONNECTED;
        if( ! IRC_Show_MOTD( Client )) return DISCONNECTED;
 
+       /* Suspend the client for a second ... */
+       IRC_SetPenalty( Client, 1 );
+
        return CONNECTED;
 } /* Hello_User */
 
@@ -463,19 +497,18 @@ Hello_User( CLIENT *Client )
 LOCAL VOID
 Kill_Nick( CHAR *Nick, CHAR *Reason )
 {
-       CLIENT *c;
+       REQUEST r;
 
        assert( Nick != NULL );
        assert( Reason != NULL );
 
-       Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
-
-       /* andere Server benachrichtigen */
-       IRC_WriteStrServers( NULL, "KILL %s :%s", Nick, Reason );
+       r.prefix = Client_ThisServer( );
+       r.argv[0] = Nick;
+       r.argv[1] = Reason;
+       r.argc = 2;
 
-       /* Ggf. einen eigenen Client toeten */
-       c = Client_Search( Nick );
-       if( c && ( Client_Conn( c ) != NONE )) Conn_Close( Client_Conn( c ), NULL, Reason, TRUE );
+       Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
+       IRC_KILL( Client_ThisServer( ), &r );
 } /* Kill_Nick */