Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

akill.c File Reference

OperServ (services) banlist routines. More...

#include "services.h"
#include "operserv.h"
#include "hash.h"
#include "email.h"
#include "log.h"
#include "sipc.h"

Go to the source code of this file.

Functions

void saveKlineQueue ()
 Keep the kline queue stored to disk before it's mailed.

void loadKlineQueue ()
 Loads the queued e-mail pieces to be sent to the AKILLMAILTO address.

void listAkills (char *from, char type)
 Handles an AutoKill/AutoHurt/Ignore/... list request.

int isAKilled (char *nick, char *user, char *host)
 Returns TRUE if a user is akilled.

akillgetAkill (char *nick, char *user, char *host)
long getAkillId (struct akill *ak)
akillgetAhurt (char *nick, char *user, char *host)
char * getAkReason (struct akill *ak)
char * applyAkill (char *nick, char *user, char *host, struct akill *ak)
int isAHurt (char *nick, char *user, char *host)
 Returns TRUE if a user is autohurt.

int isIgnored (char *nick, char *user, char *host)
 Returns TRUE if a user is ignored.

void checkAkillAllUsers (struct akill *ak)
 Apply a new autokill/ban to online users.

int addakill (long length, char *mask, char *by, char type, char *reason)
 Addakill adds an item to an OperServ autokill/ignore/autohurt/other list.

void queueakill (char *mask, char *setby, char *length, char *reason, time_t time, int type, int id, int added)
 Adds information about an autokill to the body of the kline queue that is periodically mailed to the AKILLMAILTO address.

const char * aktype_str (int type, int which)
 Returns a string indicating which type of OperServ banlist item we have.

void timed_akill_queue (char *)
 Sends out services kline queue e-mail messages when the time arrives for them to be sent.

int removeAkill (char *from, char *mask)
 Handles a user attempting to remove an akill.

int removeAkillType (char *from, char *mask, int type, int restrict)
 Handles a user attempting to remove an OperServ banlist item.

void autoremoveakill (char *mask)
 Handles automatic removal of expired akills by OperServ.

void saveakills ()
 Saves the akill database.

void parseFprint (FILE *fp, char pre, const char *str)
 Splits a string across
and prints each line starting with a prefix character.

void loadakills ()
 Load the akill/kline databases.


Variables

unsigned long top_akill_stamp = 0
 Highest akill stamp in use.

akillfirstBanItem = NULL
 First Item in the autokill list.

EmailMessage kline_email
 E-mail to be sent to kline@.

EmailString kline_enforce_buf
 Buffer of akill enforcement logs.

EmailMessage ops_email
 E-mail to be sent to ops@.

EmailString ops_enforce_buf
 Enforce buffer to be mailed to ops.

int kline_email_nitems = 0
 Number of items in the kline queue for kline@.

int ops_email_nitems = 0
 Number of items in the kline queue for ops@.

time_t kline_e_last_time
 Time of last kline@ kline queue message.

time_t ops_e_last_time
 Time of last ops@ kline queue message.


Detailed Description

OperServ (services) banlist routines.

Procedures in this file are used by OperServ and services timers to manage the autokill lists - this module also contains the implementation of those lists.

Author:
Chip Norkus

Max Byrd

Greg Poma

James Hess

Date:
1996-2001
Id
akill.c,v 1.1.1.1 2003/07/04 02:50:53 Mysid Exp

Definition in file akill.c.


Function Documentation

int addakill long  length,
char *  mask,
char *  by,
char  type,
char *  reason
 

Addakill adds an item to an OperServ autokill/ignore/autohurt/other list.

Returns:
0 if successful, -1 if failed
Parameters:
length Duration (in seconds) to leave item in the list, 0 for permanent
mask This is the mask to be affected by the entry
by This is the nickname of the user that was responsible for creating the entry (OperServ for automatic)
type This is the entry type (A_AKILL, A_AHURT, A_IGNORE)
reason This is the reason the entry needs to be set
Precondition:
Length is an integer between 0 and INT_MAX. Mask is a pointer to a valid NUL-terminated character array. By is a pointer to a valid, NUL-terminated character array that holds a valid IRC nickname. Type is one of the A_xx constants for autokills as defined in operserv.h (ex: A_AKILL). Reason is a pointer to a valid, non-zero, NUL-terminated character array.
Postcondition:
An autokill record is added. One or more users might have been killed or autohurt. One or more nickname structures may have been removed from the online users list and their memory freed.

Definition at line 449 of file akill.c.

References A_AHURT, A_AKILL, aktype_str(), autoremoveakill(), checkAkillAllUsers(), firstBanItem, mask(), myname, akill::next, oalloc(), OperServ, akill::prev, queueakill(), sSend(), strncpyzt, timer(), and top_akill_stamp.

const char* aktype_str int  type,
int  which
 

Returns a string indicating which type of OperServ banlist item we have.

Parameters:
type Represents the type of list item (such as A_AKILL)
which Indicates which string to print, '0' is the standard form such as 'autokill', '1' is the capitalized form such as 'Autokill', and '2' is the past-tense verb form such as 'autokilled'. No other value for which is allowed.
Returns a string representing the type of list item

Definition at line 577 of file akill.c.

References A_AHURT, A_AKILL, and A_IGNORE.

Referenced by addakill(), queueakill(), removeAkill(), and removeAkillType().

char* applyAkill char *  nick,
char *  user,
char *  host,
struct akill ak
 

Returns:
A reason string if the user described is akilled, otherwise a null pointer.
Parameters:
nick The user's nickname
user The users's username
host The user's hostname
Precondition:
Nick, user, and host each point to separate, valid NUL-terminated character arrays. Nick is a valid IRC nickname, user is a valid IRC username, and host is a valid IRC hostname.
Postcondition:
If the user is found, then if appropriate an AKILL or AHURT message is sent.

Definition at line 238 of file akill.c.

References A_AHURT, A_AKILL, CTime, akill::host, akill::id, kline_email_nitems, kline_enforce_buf, myname, akill::nick, ops_email_nitems, ops_enforce_buf, akill::reason, akill::set, sSend(), akill::type, akill::unset, and akill::user.

Referenced by addNewUser().

void autoremoveakill char *  mask  ) 
 

Handles automatic removal of expired akills by OperServ.

Parameters:
mask Mask to be removed
Warning: this function calls free() on the mask passed

Definition at line 857 of file akill.c.

References mask(), OperServ, and removeAkill().

Referenced by addakill(), and loadakills().

void checkAkillAllUsers struct akill ak  ) 
 

Apply a new autokill/ban to online users.

Parameters:
Pointer to an akill item (struct akill) to be applied
Precondition:
Ak is a valid, listed autokill object.
Postcondition:
IRC kill messages have been sent for all users that are effected by this autokill. Similarly HURTSETS for all new ahurt users. A remUser call is made for each user killed, so one or more online user structures may no longer be valid.

Definition at line 349 of file akill.c.

References A_AHURT, A_AKILL, addGhost(), _userlist::caccess, CTime, delTimedGhost(), service_struct::host, _userlist::host, akill::host, kline_email_nitems, kline_enforce_buf, LIST_FIRST, LIST_NEXT, match(), service_struct::name, NBYPASS, _userlist::nick, akill::nick, NISOPER, _userlist::oflags, ops_email_nitems, ops_enforce_buf, akill::reason, _userlist::reg, remUser(), sSend(), strncpyzt, timer(), akill::type, _userlist::user, akill::user, and UserHash.

Referenced by addakill().

int isAHurt char *  nick,
char *  user,
char *  host
 

Returns TRUE if a user is autohurt.

Parameters:
nick The user's nickname
user The users's username
host The user's hostname
Precondition:
Nick, user, and host each point to separate NUL-terminated character arrays. Respectively, a valid nickname, a valid username, and a valid IRC hostname.

Definition at line 303 of file akill.c.

References A_AHURT, firstBanItem, match(), and akill::next.

Referenced by parseLine().

int isAKilled char *  nick,
char *  user,
char *  host
 

Returns TRUE if a user is akilled.

Parameters:
nick The user's nickname
user The users's username
host The user's hostname
Precondition:
Nick, user, and host each point to separate, valid NUL-terminated character arrays. Nick is a valid IRC nickname, user is a valid IRC username, and host is a valid IRC hostname.

Definition at line 179 of file akill.c.

References A_AKILL, firstBanItem, match(), and akill::next.

Referenced by changeNick().

int isIgnored char *  nick,
char *  user,
char *  host
 

Returns TRUE if a user is ignored.

Parameters:
nick The user's nickname
user The users's username
host The user's hostname
Precondition:
Nick, user, and host each point to separate NUL-terminated character arrays. Respectively, a valid nickname, a valid username, and a valid IRC hostname.

Definition at line 327 of file akill.c.

References A_IGNORE, firstBanItem, match(), and akill::next.

Referenced by parseLine().

void listAkills char *  from,
char  type
 

Handles an AutoKill/AutoHurt/Ignore/... list request.

Parameters:
from Oper requesting list
type Type of list requested (ie: A_AKILL)
Precondition:
From points to a valid NUL-terminated character array bearing the nickname of an online IRC oper. Type is one of the akill type constants (ex: A_AKILL, A_IGNORE, A_AHURT);

Definition at line 129 of file akill.c.

References firstBanItem, mask(), akill::next, OperServ, and sSend().

void loadKlineQueue  ) 
 

Loads the queued e-mail pieces to be sent to the AKILLMAILTO address.

Bug:
FIXME: Blank lines that were supposed to be in the message are not getting through services restarts!!

Definition at line 902 of file akill.c.

References EmailString::add(), kline_e_last_time, kline_email, kline_email_nitems, kline_enforce_buf, ops_e_last_time, ops_email, ops_email_nitems, and ops_enforce_buf.

Referenced by loadakills().

void parseFprint FILE *  fp,
char  pre,
const char *  str
 

Splits a string across
and prints each line starting with a prefix character.

Parameters:
fp File to print to
pre Prefix character
str String to print

Definition at line 976 of file akill.c.

References strncpyzt.

Referenced by saveKlineQueue().

void queueakill char *  mask,
char *  setby,
char *  length,
char *  reason,
time_t  time,
int  type,
int  id,
int  added
 

Adds information about an autokill to the body of the kline queue that is periodically mailed to the AKILLMAILTO address.

Parameters:
mask This is the mask of the item to be queued
length This is a string representing the duration
setby This is a string representing the nickname who created the item
reason This is a string representing the reason the entry was created
time This is the time at which the list entry was added (UTC)
type This is the type of entry (A_AKILL, for example)
added If TRUE, then an entry has been added. If FALSE, then an entry has been removed.

Definition at line 536 of file akill.c.

References EmailString::add(), aktype_str(), EmailMessage::body, kline_email, kline_email_nitems, mask(), ops_email, and ops_email_nitems.

Referenced by addakill(), removeAkill(), and removeAkillType().

int removeAkill char *  from,
char *  mask
 

Handles a user attempting to remove an akill.

Returns:
0 if successful, -1 if failed
Parameters:
from Nicname attempting to remove akill
mask Mask that removal of is attempted
Bug:
This looks ugly

Definition at line 682 of file akill.c.

References A_AHURT, A_AKILL, aktype_str(), cancel_timer(), firstBanItem, getNickData(), mask(), myname, akill::next, OAKILL, OperServ, opFlagged(), queueakill(), and sSend().

Referenced by autoremoveakill().

int removeAkillType char *  from,
char *  mask,
int  type,
int  restrict
 

Handles a user attempting to remove an OperServ banlist item.

Returns:
0 if successful, -1 if failed
Parameters:
from Nicname attempting to remove akill
mask Mask that removal of is attempted
type Type of entry removal is being attempted of (such as A_AKILL)
restrict [UNUSED]
Bug:
You say "If OperServ is removing the kill", but you just strcmp() != 0'ed against OperServ... what's the deal? Oh yeah.. you cancel too, bad comment?

Definition at line 771 of file akill.c.

References A_AHURT, A_AKILL, aktype_str(), cancel_timer(), firstBanItem, getNickData(), mask(), myname, akill::next, OAKILL, OperServ, opFlagged(), queueakill(), and sSend().

void saveakills void   ) 
 

Saves the akill database.

Note that ignores, autohurts, ... are saved as well

Definition at line 867 of file akill.c.

References firstBanItem, akill::next, and saveKlineQueue().

Referenced by sshutdown().


Variable Documentation

unsigned long top_akill_stamp = 0
 

Highest akill stamp in use.

Todo:
Highest stamp should save to services.totals

Definition at line 69 of file akill.c.

Referenced by addakill(), loadakills(), main(), and writeServicesTotals().


Generated at Sat Oct 25 20:56:10 2003 for Services using Doxygen.
Services Copyr. 1996-2001 Chip Norkus, Max Byrd, Greg Poma, Michael Graff, James Hess, Dafydd James. All rights reserved See LICENSE for licensing information.