X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=ngircd-alex.git;a=blobdiff_plain;f=src%2Fngircd%2Firc-login.c;h=140d68e0dcbaf96013b7878572e749e1dfccdfcd;hp=c90a7c1c835db59727c9f2081c48d44f9063a147;hb=e86e193e010b44bc567c0fb2dfbebd81b9735358;hpb=456e55921dddb4ae24bfc887b668c0e6407caace diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index c90a7c1c..140d68e0 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -1,6 +1,6 @@ /* * ngIRCd -- The Next Generation IRC Daemon - * Copyright (c)2001-2010 Alexander Barton (alex@barton.de) + * Copyright (c)2001-2011 Alexander Barton (alex@barton.de) and Contributors. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include "ngircd.h" #include "conn-func.h" +#include "class.h" #include "conf.h" #include "channel.h" #include "io.h" @@ -653,32 +654,37 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req ) CLIENT *target; char quitmsg[LINE_LEN]; - assert( Client != NULL ); - assert( Req != NULL ); + assert(Client != NULL); + assert(Req != NULL); /* Wrong number of arguments? */ - if( Req->argc > 1 ) - return IRC_WriteStrClient( Client, ERR_NEEDMOREPARAMS_MSG, Client_ID( Client ), Req->command ); + if (Req->argc > 1) + return IRC_WriteStrClient(Client, ERR_NEEDMOREPARAMS_MSG, + Client_ID(Client), Req->command); if (Req->argc == 1) strlcpy(quitmsg, Req->argv[0], sizeof quitmsg); - if ( Client_Type( Client ) == CLIENT_SERVER ) - { + if (Client_Type(Client) == CLIENT_SERVER) { /* Server */ - target = Client_Search( Req->prefix ); - if( ! target ) - { - Log( LOG_WARNING, "Got QUIT from %s for unknown client!?", Client_ID( Client )); + target = Client_Search(Req->prefix); + if (!target) { + Log(LOG_WARNING, + "Got QUIT from %s for unknown client!?", + Client_ID(Client)); return CONNECTED; } - Client_Destroy( target, "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true); - - return CONNECTED; - } - else - { + if (target != Client) { + Client_Destroy(target, "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); + return CONNECTED; + } else { + Conn_Close(Client_Conn(Client), "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); + return DISCONNECTED; + } + } else { if (Req->argc == 1 && quitmsg[0] != '\"') { /* " " to avoid confusion */ strlcpy(quitmsg, "\"", sizeof quitmsg); @@ -687,7 +693,8 @@ IRC_QUIT( CLIENT *Client, REQUEST *Req ) } /* User, Service, or not yet registered */ - Conn_Close( Client_Conn( Client ), "Got QUIT command.", Req->argc == 1 ? quitmsg : NULL, true); + Conn_Close(Client_Conn(Client), "Got QUIT command.", + Req->argc == 1 ? quitmsg : NULL, true); return DISCONNECTED; } @@ -953,6 +960,7 @@ Hello_User(CLIENT * Client) } else { /* Sub process */ Log_Init_Subprocess("Auth"); + Conn_CloseAllSockets(NONE); result = PAM_Authenticate(Client); if (write(pipefd[1], &result, sizeof(result)) != sizeof(result)) Log_Subprocess(LOG_ERR, @@ -1003,6 +1011,7 @@ cb_Read_Auth_Result(int r_fd, UNUSED short events) /* Read result from pipe */ len = Proc_Read(proc, &result, sizeof(result)); + Proc_Close(proc); if (len == 0) return; @@ -1053,6 +1062,12 @@ Reject_Client(CLIENT *Client) static bool Hello_User_PostAuth(CLIENT *Client) { + if (Class_IsMember(CLASS_GLINE, Client) || + Class_IsMember(CLASS_KLINE, Client)) { + Reject_Client(Client); + return DISCONNECTED; + } + Introduce_Client(NULL, Client, CLIENT_USER); if (!IRC_WriteStrClient