Add new class.{c|h} to project
Implement Class_{AddMask|DeleteMask|IsMember}() functions.
This commit is contained in:
parent
fea2194fc0
commit
06a20b87c4
|
@ -18,20 +18,21 @@ LINTARGS = -weak -warnunixlib +unixlib -booltype BOOLEAN \
|
|||
|
||||
sbin_PROGRAMS = ngircd
|
||||
|
||||
ngircd_SOURCES = ngircd.c array.c channel.c client.c conf.c conn.c conn-func.c \
|
||||
conn-ssl.c conn-zip.c hash.c io.c irc.c irc-channel.c irc-info.c irc-login.c \
|
||||
irc-mode.c irc-op.c irc-oper.c irc-server.c irc-write.c lists.c log.c \
|
||||
match.c op.c numeric.c pam.c parse.c proc.c resolve.c sighandlers.c
|
||||
ngircd_SOURCES = ngircd.c array.c channel.c class.c client.c conf.c conn.c \
|
||||
conn-func.c conn-ssl.c conn-zip.c hash.c io.c irc.c irc-channel.c \
|
||||
irc-info.c irc-login.c irc-mode.c irc-op.c irc-oper.c irc-server.c \
|
||||
irc-write.c lists.c log.c match.c op.c numeric.c pam.c parse.c \
|
||||
proc.c resolve.c sighandlers.c
|
||||
|
||||
ngircd_LDFLAGS = -L../portab -L../tool -L../ipaddr
|
||||
|
||||
ngircd_LDADD = -lngportab -lngtool -lngipaddr
|
||||
|
||||
noinst_HEADERS = ngircd.h array.h channel.h client.h conf.h conf-ssl.h conn.h \
|
||||
conn-func.h conn-ssl.h conn-zip.h hash.h io.h irc.h irc-channel.h \
|
||||
irc-info.h irc-login.h irc-mode.h irc-op.h irc-oper.h irc-server.h \
|
||||
irc-write.h lists.h log.h match.h numeric.h op.h pam.h parse.h proc.h \
|
||||
resolve.h sighandlers.h defines.h messages.h
|
||||
noinst_HEADERS = ngircd.h array.h channel.h class.h client.h conf.h \
|
||||
conf-ssl.h conn.h conn-func.h conn-ssl.h conn-zip.h hash.h io.h \
|
||||
irc.h irc-channel.h irc-info.h irc-login.h irc-mode.h irc-op.h \
|
||||
irc-oper.h irc-server.h irc-write.h lists.h log.h match.h numeric.h \
|
||||
op.h pam.h parse.h proc.h resolve.h sighandlers.h defines.h messages.h
|
||||
|
||||
clean-local:
|
||||
rm -f check-version check-help lint.out
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* ngIRCd -- The Next Generation IRC Daemon
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Please read the file COPYING, README and AUTHORS for more information.
|
||||
*/
|
||||
|
||||
#include "portab.h"
|
||||
|
||||
/**
|
||||
* @file
|
||||
* User class management.
|
||||
*/
|
||||
|
||||
#include "imp.h"
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "defines.h"
|
||||
#include "array.h"
|
||||
#include "conn.h"
|
||||
#include "client.h"
|
||||
#include "lists.h"
|
||||
#include "match.h"
|
||||
|
||||
#include "exp.h"
|
||||
#include "class.h"
|
||||
|
||||
struct list_head My_Classes[CLASS_COUNT];
|
||||
|
||||
GLOBAL void
|
||||
Class_Init(void)
|
||||
{
|
||||
memset(My_Classes, 0, sizeof(My_Classes));
|
||||
}
|
||||
|
||||
GLOBAL void
|
||||
Class_Exit(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < CLASS_COUNT; Lists_Free(&My_Classes[i++]));
|
||||
}
|
||||
|
||||
GLOBAL bool
|
||||
Class_IsMember(const int Class, CLIENT *Client)
|
||||
{
|
||||
assert(Class < CLASS_COUNT);
|
||||
assert(Client != NULL);
|
||||
|
||||
return Lists_Check(&My_Classes[Class], Client);
|
||||
}
|
||||
|
||||
GLOBAL bool
|
||||
Class_AddMask(const int Class, const char *Mask, time_t ValidUntil)
|
||||
{
|
||||
assert(Class < CLASS_COUNT);
|
||||
assert(Mask != NULL);
|
||||
|
||||
return Lists_Add(&My_Classes[Class], Mask, ValidUntil);
|
||||
}
|
||||
|
||||
GLOBAL void
|
||||
Class_DeleteMask(const int Class, const char *Mask)
|
||||
{
|
||||
assert(Class < CLASS_COUNT);
|
||||
assert(Mask != NULL);
|
||||
|
||||
Lists_Del(&My_Classes[Class], Mask);
|
||||
}
|
||||
|
||||
/* -eof- */
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* ngIRCd -- The Next Generation IRC Daemon
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
* Please read the file COPYING, README and AUTHORS for more information.
|
||||
*/
|
||||
|
||||
#ifndef __class_h__
|
||||
#define __class_h__
|
||||
|
||||
/**
|
||||
* @file
|
||||
* User class management.
|
||||
*/
|
||||
|
||||
#define CLASS_KLINE 0
|
||||
#define CLASS_GLINE 1
|
||||
|
||||
#define CLASS_COUNT 2
|
||||
|
||||
GLOBAL void Class_Init PARAMS((void));
|
||||
GLOBAL void Class_Exit PARAMS((void));
|
||||
|
||||
GLOBAL bool Class_AddMask PARAMS((const int Class, const char *Mask,
|
||||
const time_t ValidUntil));
|
||||
GLOBAL void Class_DeleteMask PARAMS((const int Class, const char *Mask));
|
||||
|
||||
GLOBAL bool Class_IsMember PARAMS((const int Class, CLIENT *Client));
|
||||
|
||||
#endif /* __class_h__ */
|
||||
|
||||
/* -eof- */
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include "ngircd.h"
|
||||
#include "conn-func.h"
|
||||
#include "class.h"
|
||||
#include "conf.h"
|
||||
#include "channel.h"
|
||||
#include "io.h"
|
||||
|
@ -936,6 +937,12 @@ Hello_User(CLIENT * Client)
|
|||
}
|
||||
#endif
|
||||
|
||||
if (Class_IsMember(CLASS_GLINE, Client) ||
|
||||
Class_IsMember(CLASS_KLINE, Client)) {
|
||||
Reject_Client(Client);
|
||||
return DISCONNECTED;
|
||||
}
|
||||
|
||||
#ifdef PAM
|
||||
if (!Conf_PAM) {
|
||||
/* Don't do any PAM authentication at all, instead emulate
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
|
||||
#include "defines.h"
|
||||
#include "conn.h"
|
||||
#include "class.h"
|
||||
#include "conf-ssl.h"
|
||||
#include "channel.h"
|
||||
#include "conf.h"
|
||||
|
@ -282,6 +283,7 @@ main( int argc, const char *argv[] )
|
|||
Channel_Init( );
|
||||
Client_Init( );
|
||||
Conn_Init( );
|
||||
Class_Init( );
|
||||
|
||||
if (!io_library_init(CONNECTION_POOL)) {
|
||||
Log(LOG_ALERT, "Fatal: Cannot initialize IO routines: %s", strerror(errno));
|
||||
|
@ -327,6 +329,7 @@ main( int argc, const char *argv[] )
|
|||
Conn_Exit( );
|
||||
Client_Exit( );
|
||||
Channel_Exit( );
|
||||
Class_Exit( );
|
||||
Log_Exit( );
|
||||
}
|
||||
Pidfile_Delete( );
|
||||
|
|
Loading…
Reference in New Issue