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

clone.c File Reference

Services clone detection. More...

#include "services.h"
#include "nickserv.h"
#include "hash.h"

Go to the source code of this file.

Classes

struct  pending_alert

Functions

pending_alertfind_palert (HostClone *hc)
 Find a pending clone alert.

pending_alertmake_palert ()
 Create a new clone alert.

void free_palert (struct pending_alert *pArg)
void add_palert (struct pending_alert *pArg)
 Add a clone alert to the list.

void remove_palert (struct pending_alert *pZap)
 A clone alert is removed from the list.

void listCloneAlerts (UserList *nick)
 Send the list of clone alerts to a user /OS TRIGGER LIST.

time_t updateCloneAlerts (time_t aval)
 Update clone alerts.

CloneRuleGetCrule (char *mask)
 Retrieve a clone rule by mask or number for oper edit purposes.

CloneRuleGetCruleMatch (char *host)
 Find any matching rules.

CloneRuleNewCrule ()
 Creates a new clone rule object.

void AddCrule (CloneRule *rule, int n)
 Add an alocated rule rule to the linked list at point 'n'.

char * MakeUserHost (char *user, char *host)
 Build a user mask for the purpose of crule checking.

void UpdateCrule (CloneRule orig, CloneRule *rule)
void RemoveCrule (CloneRule *zap)
 Remove a clone rule from the linked list.

void initCloneData (HostClone *hc)
 Initializes a clone host detection structure.

int addClone (char *nick, char *user, char *host)
 Registers an online user with the clone detection system.

UserCloneaddUserClone (HostClone *hc, char *user)
 Adds a user's username information to the user clone database for their hostname.

void delClone (char *user, char *host)
 Remove a client from the clone database.

void delUserClone (HostClone *hc, UserClone *uc)
 Delete information on a user@ from a cloneinfo machine item.

HostClonegetCloneData (char *host)
 Retrieves the clone information for a machine.

UserClonegetUserCloneData (HostClone *hc, char *user)
 Get clone-detection-related information on a user from a host clone record and knowledge of a username.


Variables

HostClonefirstClone = NULL
HostClonelastClone = NULL
CloneRulefirst_crule = NULL
pending_alertpendingAlerts
 List of pending clone alerts.


Detailed Description

Services clone detection.

Procedures found in this module are used for tracking and alerting the network to the presence of possible clonebots.

Author:
Chip Norkus

Max Byrd

Greg Poma

James Hess

Date:
1996-1997, 1999, 2001
Id
clone.c,v 1.1.1.1 2003/07/04 02:51:58 Mysid Exp

Definition in file clone.c.


Function Documentation

void add_palert struct pending_alert pArg  ) 
 

Add a clone alert to the list.

Parameters:
pArg Record to list
Precondition:
pArg is a pointer to a new clone alert record.
Postcondition:
The clone alert record referenced by pArg is listed and ready for use if otherwise valid.

Definition at line 130 of file clone.c.

References pending_alert::next, and pendingAlerts.

Referenced by addClone().

int addClone char *  nick,
char *  user,
char *  host
 

Registers an online user with the clone detection system.

Parameters:
nick Nickname of client signing on
user Username of client signing on
host Hostname of client signing on
Returns:
Normally returns 0, returns 1 if clones are killed and should not be registered with the online users database.
Warning:
If 1 is returned then no online user structure has been affected, only a KILL message has been dispatched, and the user has not been registered with the clone database but instead been rejected.

Definition at line 486 of file clone.c.

References add_palert(), addUserClone(), clonehashent::clone, CLONE_ALERT, CLONE_IGNOREFLAG, CLONE_KILLFLAG, CLONE_OK, CloneHash, CloneRule, hostclonestruct::clones, userclonestruct::clones, delClone(), find_palert(), firstClone, hostclonestruct::flags, trigger_rule::flags, getCloneData(), GetCruleMatch(), getHashKey(), hostclonestruct::hashnext, hostclonestruct::hashprev, hostclonestruct::host, HostClone, initCloneData(), trigger_rule::kill_msg, lastClone, clonehashent::lastclone, make_palert(), MakeUserHost(), hostclonestruct::next, NickServ, oalloc(), OperServ, hostclonestruct::previous, sSend(), trigger_rule::trigger, hostclonestruct::trigger, userclonestruct::trigger, userclonestruct::uflags, updateCloneAlerts(), UserClone, and trigger_rule::warn_msg.

Referenced by addNewUser().

void AddCrule CloneRule rule,
int  n
 

Add an alocated rule rule to the linked list at point 'n'.

Parameters:
rule Item to add to rule linklist
n Point to insert item into list at

Definition at line 344 of file clone.c.

References CloneRule, first_crule, and trigger_rule::next.

Referenced by readTriggerData().

UserClone* addUserClone HostClone hc,
char *  user
 

Adds a user's username information to the user clone database for their hostname.

Parameters:
hc Host-wide clone information
user Userid of the person being added
Returns:
The user clone object created or found is returned.
Bug:
There may be a problem in the logic handling of user@ rules verses rules maybe mask should be changed to simply 'host' instead of [<user>]host

Definition at line 614 of file clone.c.

References CloneRule, userclonestruct::clones, hostclonestruct::firstUser, hostclonestruct::flags, trigger_rule::flags, GetCruleMatch(), getUserCloneData(), hostclonestruct::host, HostClone, hostclonestruct::lastUser, MakeUserHost(), userclonestruct::next, oalloc(), userclonestruct::previous, userclonestruct::trigger, hostclonestruct::trigger, trigger_rule::trigger, userclonestruct::user, UserClone, and trigger_rule::utrigger.

Referenced by addClone().

void delClone char *  user,
char *  host
 

Remove a client from the clone database.

Parameters:
user Username of client logging off
host Hostname of client logging off

Definition at line 663 of file clone.c.

References clonehashent::clone, CLONE_ALERT, CloneHash, hostclonestruct::clones, userclonestruct::clones, CTime, delUserClone(), find_palert(), firstClone, hostclonestruct::flags, free_palert(), getCloneData(), getHashKey(), getUserCloneData(), hostclonestruct::hashnext, hostclonestruct::hashprev, hostclonestruct::host, HostClone, lastClone, clonehashent::lastclone, hostclonestruct::next, hostclonestruct::previous, remove_palert(), hostclonestruct::trigger, userclonestruct::trigger, userclonestruct::uflags, and UserClone.

Referenced by addClone(), and remUser().

struct pending_alert* find_palert HostClone hc  ) 
 

Find a pending clone alert.

Parameters:
hc Host object find a pending alert for
Precondition:
Hc is a pointer to a valid, listed hostclone object.
Returns:
A null pointer is returned if no clone alert could be found to match the given object. Else a pointer to the proper alert object.

Definition at line 86 of file clone.c.

References HostClone, pending_alert::next, and pendingAlerts.

Referenced by addClone(), and delClone().

void free_palert struct pending_alert pArg  ) 
 

Parameters:
pArg Clone alert to free out
Precondition:
pArg is a pointer to an otherwise valid, clone alert record that has been removed from the alert list.
Postcondition:
The area pointed to by pArg is freed.

Definition at line 118 of file clone.c.

Referenced by delClone().

HostClone* getCloneData char *  host  ) 
 

Retrieves the clone information for a machine.

Parameters:
host Hostname to retrieve information on

Definition at line 752 of file clone.c.

References clonehashent::clone, CloneHash, getHashKey(), hostclonestruct::hashnext, hostclonestruct::host, and HostClone.

Referenced by addClone(), and delClone().

CloneRule* GetCrule char *  mask  ) 
 

Retrieve a clone rule by mask or number for oper edit purposes.

Parameters:
mask Name of mask or index number to search for
Returns:
A clone rule object or a NULL pointer indicating that the sought item could not be found.

Definition at line 289 of file clone.c.

References CloneRule, first_crule, mask(), trigger_rule::mask, and trigger_rule::next.

CloneRule* GetCruleMatch char *  host  ) 
 

Find any matching rules.

Parameters:
host Address of user
Returns:
A matching clone rule object or a null pointer for no match conditions

Definition at line 315 of file clone.c.

References CloneRule, first_crule, trigger_rule::mask, match(), and trigger_rule::next.

Referenced by addClone(), and addUserClone().

void initCloneData HostClone hc  ) 
 

Initializes a clone host detection structure.

Parameters:
hc Pointer to clone host object to initialize

Definition at line 463 of file clone.c.

References hostclonestruct::clones, hostclonestruct::firstUser, hostclonestruct::flags, hostclonestruct::hashnext, hostclonestruct::hashprev, hostclonestruct::host, HostClone, hostclonestruct::lastUser, hostclonestruct::next, hostclonestruct::previous, and hostclonestruct::trigger.

Referenced by addClone().

void listCloneAlerts UserList nick  ) 
 

Send the list of clone alerts to a user /OS TRIGGER LIST.

Precondition:
Nick is a pointer to a valid, listed online user.
Postcondition:
An IRC message that no clone alerts are present or a list of clone alerts has been sent for nick.

Definition at line 170 of file clone.c.

References CLONE_ALERT, CLONE_OK, hostclonestruct::clones, userclonestruct::clones, CTime, hostclonestruct::firstUser, hostclonestruct::host, HostClone, pending_alert::next, userclonestruct::next, _userlist::nick, OperServ, pendingAlerts, sSend(), hostclonestruct::trigger, userclonestruct::trigger, userclonestruct::uflags, userclonestruct::user, and UserClone.

struct pending_alert* make_palert  ) 
 

Create a new clone alert.

Returns:
A pointer to a freshly-allocated, initialized clone alert object

Definition at line 100 of file clone.c.

References trigger_rule::next, and oalloc().

Referenced by addClone().

char* MakeUserHost char *  user,
char *  host
[static]
 

Build a user mask for the purpose of crule checking.

Returns:
Returns a pattern to a user mask, returns a blank string "" on error. Never returns NULL.

Definition at line 379 of file clone.c.

Referenced by addClone(), addUserClone(), and UpdateCrule().

CloneRule* NewCrule  ) 
 

Creates a new clone rule object.

Returns:
A pointer to a newly created clone rule item, any failure is fatal.

Definition at line 334 of file clone.c.

References CloneRule, and oalloc().

Referenced by readTriggerData().

void remove_palert struct pending_alert pZap  ) 
 

A clone alert is removed from the list.

Parameters:
pZap Clone alert to remove
Precondition:
pZap is a pointer to a valid, listed clone alert record.
Postcondition:
The alert referenced by pZap is otherwise valid but is no longer listed.

Definition at line 146 of file clone.c.

References trigger_rule::next, pending_alert::next, and pendingAlerts.

Referenced by delClone().

void RemoveCrule CloneRule zap  ) 
 

Remove a clone rule from the linked list.

Parameters:
zap Rule to remove

Definition at line 444 of file clone.c.

References CloneRule, first_crule, and trigger_rule::next.

time_t updateCloneAlerts time_t  aval  ) 
 

Update clone alerts.

Precondition:
Aval is the UTC calendar time at which the updateCloneAlert procedure began.
Returns:
The time at which the next regular updateCloneAlert procedure should occur.

Definition at line 219 of file clone.c.

References CLONE_ALERT, CLONE_OK, hostclonestruct::clones, userclonestruct::clones, CTime, hostclonestruct::firstUser, hostclonestruct::flags, hostclonestruct::host, HostClone, pending_alert::next, userclonestruct::next, OperServ, pendingAlerts, sSend(), hostclonestruct::trigger, userclonestruct::trigger, userclonestruct::uflags, userclonestruct::user, and UserClone.

Referenced by addClone(), and main().

void UpdateCrule CloneRule  orig,
CloneRule rule
 

Apply a crule to a trigger if they are in sync

'orig' is what the rule looked like before the update and is used for the 'sync' determination

A rule that is in sync with a trigger either completely matches the trigger or if the trigger completely matches the defaults.

Definition at line 399 of file clone.c.

References CloneRule, firstClone, hostclonestruct::firstUser, hostclonestruct::flags, trigger_rule::flags, hostclonestruct::host, HostClone, MakeUserHost(), trigger_rule::mask, match(), hostclonestruct::next, userclonestruct::next, hostclonestruct::trigger, trigger_rule::trigger, userclonestruct::trigger, userclonestruct::user, UserClone, and trigger_rule::utrigger.


Variable Documentation

CloneRule* first_crule = NULL
 

First clone rule item

Definition at line 52 of file clone.c.

Referenced by AddCrule(), GetCrule(), GetCruleMatch(), RemoveCrule(), and saveTriggerData().

HostClone* firstClone = NULL
 

List of clone info items

Definition at line 50 of file clone.c.

Referenced by addClone(), delClone(), and UpdateCrule().

HostClone* lastClone = NULL
 

Last entry in clone info items

Definition at line 51 of file clone.c.

Referenced by addClone(), and delClone().

struct pending_alert * pendingAlerts
 

List of pending clone alerts.

A pending clone alert item

To be valid 'hc' must point to a valid hostclone record and next must be a null pointer or point to a valid pending_alert record.

Referenced by add_palert(), find_palert(), listCloneAlerts(), remove_palert(), and updateCloneAlerts().


Generated at Sat Oct 25 20:56:11 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.