/*
* 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
#include "ngircd.h"
#include "conn-func.h"
+#include "class.h"
#include "conf.h"
#include "channel.h"
#include "io.h"
#ifndef STRICT_RFC
if (Conf_AuthPing) {
- Conn_SetAuthPing(Client_Conn(Client), random());
+ Conn_SetAuthPing(Client_Conn(Client), rand());
IRC_WriteStrClient(Client, "PING :%ld",
Conn_GetAuthPing(Client_Conn(Client)));
LogDebug("Connection %d: sent AUTH PING %ld ...",
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);
}
/* 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;
}
} 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,
/* Read result from pipe */
len = Proc_Read(proc, &result, sizeof(result));
+ Proc_Close(proc);
if (len == 0)
return;
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
* @param Reason Reason for the KILL.
*/
static void
-Kill_Nick( char *Nick, char *Reason )
+Kill_Nick(char *Nick, char *Reason)
{
REQUEST r;
- assert( Nick != NULL );
- assert( Reason != NULL );
+ assert (Nick != NULL);
+ assert (Reason != NULL);
- r.prefix = (char *)Client_ThisServer( );
+ r.prefix = NULL;
r.argv[0] = Nick;
r.argv[1] = Reason;
r.argc = 2;
- Log( LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s", Nick, Reason );
- IRC_KILL( Client_ThisServer( ), &r );
+ Log(LOG_ERR, "User(s) with nick \"%s\" will be disconnected: %s",
+ Nick, Reason);
+
+ IRC_KILL(Client_ThisServer(), &r);
} /* Kill_Nick */