#include "config.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/wait.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <sys/resource.h>
#include <errno.h>
#include <signal.h>
#include <stdio.h>
#include <netdb.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <stdarg.h>
#include <ctype.h>
#include <time.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "options.h"
#include "parse.h"
#include "struct.h"
Go to the source code of this file.
Defines | |
#define | FREE(x) do { free(x) ; (x) = NULL; } while (0) |
#define | assert(x) (!(x) ? fatalSvsError(__FILE__, __LINE__, #x) : 0) |
DEBUG: Terminate if x is false with a fatal error. | |
#define | MAX(x, y) (((x) > (y)) ? (x) : (y)) |
Macro that returns the highest value provided. | |
#define | MIN(x, y) ( ( (x) < (y) ) ? (x) : (y) ) |
Macro that returns the lower value provided. | |
#define | strncpyzt(s_dest, s_src, s_size) |
Copy N bytes from source to target string but ensure (NUL) termination. | |
#define | FATAL_ERROR 66 |
#define | FALSE 0 |
Not true. | |
#define | TRUE !(FALSE) |
Not false. | |
#define | net_read(a, b, c) read((a), (b), (c)) |
Temporary hack. | |
#define | net_write(a, b, c) write((a), (b), (c)) |
Temporary hack. | |
#define | NUMSERVS 7 |
#define | MAXEVENTS 4096 |
#define | GLOBOPS_ON_RAW |
#define | VERSION_NUM VERSION |
Version number string for services. | |
#define | VERSION_QUOTE ("When you wake up you're all weak, throwing your life away") |
Version quote string. | |
#define | VERSION_STRING (PACKAGE "-" VERSION_NUM "") |
Complete version string. | |
#define | LOGCHAN "#services" |
Channel for log output. | |
#define | DEBUGCHAN "#services-debug" |
Channel for debug output. | |
#define | NETWORK_CHANNELS "#sorcery:" LOGCHAN ":" DEBUGCHAN ":" |
List of network channels. | |
#define | A_AKILL 0x01 |
Autokill typeflag. | |
#define | A_IGNORE 0x02 |
Services ignore typeflag. | |
#define | A_AHURT 0x04 |
Autohurt typeflag. | |
#define | CLONE_KILLFLAG 0x01 |
Clone trigger kill flag. | |
#define | CLONE_IGNOREFLAG 0x02 |
Clone trigger ignore flag. | |
#define | CLONE_PERMTRIGGER 0x04 |
Clone trigger perm flag. | |
#define | CLONE_OK 0x08 |
Clone alert has been cleared. | |
#define | CLONE_ALERT 0x10 |
Has set off a clone alert. | |
#define | str_cmp strcasecmp |
Functions | |
void | flushLogs (char *) |
Flush services logs. | |
void | expireChans (char *) |
void | expireNicks (char *) |
This function handles timed NickServ expiration runs, deletes non-held nicknames that have not been used for their maximum inactivity period before expiration. | |
void | sshutdown (int) |
Shuts down services. | |
void | checkTusers (char *) |
Check total number of users. | |
void | readConf (void) |
Reads the services configuration file. | |
void | addUser (char *, char *, char *, char *, char *) |
int | ConnectToServer (char *, int) |
Used at services startup to connect to its uplink. | |
void | sSend (char *,...) __attribute__((format(printf |
void | logDump (FILE *, char *,...) __attribute__((format(printf |
void | breakLine (char *) |
void | handler (int) |
Signal handler. | |
char * | xorit (char *) |
Encrypt a password string. | |
void | sendInfoReply (UserList *) |
int | cancel_timer (int) |
Cancels a timer event. | |
int | timer (long, void(*func)(char *), void *) |
Schedules a timer. | |
void | timeralarm (void) |
Check for expired timers. | |
void | dumptimer (char *from) |
Reports the list of timers. | |
void | sync_cfg (char *) |
Periodic synchronizations (saves) of various databases. | |
void | AppendBuffer (char **, const char *) |
void | SetDynBuffer (char **, const char *) |
void | breakString (int, char *, char *args[256], char) |
int | match (const char *, const char *) |
Matches a string against the specified pattern for wildcards \ as allowed done by IRC clients/servers. | |
void | strtolower (char *) |
Lowercases a NUL-terminated string in place. | |
void | doTfunc (char *) |
char * | sfgets (char *, int, FILE *) |
int | check_match (char *) |
int | exp_match (char *, char *) |
void | parse_str (char **, int, int, char *, size_t) |
Merge a vector of strings into one string across delimeters. | |
void | mask (char *, char *, int, char *) |
This function is used by the NickServ ADDMASK command. | |
void | tzapply (char *) |
int | split_userhost (const char *input_host, MaskData *data) |
Splits a string into a supplied mask structure. | |
void | free_mask (MaskData *) |
Frees a mask structure. | |
MaskData * | make_mask (void) |
Allocates a mask structure. | |
void * | oalloc (size_t) |
Clean and allocate a memory area. | |
char * | genHostMask (char *) |
Returns the masked version of a host. | |
char * | flagstring (int flags, const char *bits[]) |
Report the names of bits set. | |
int | flagbit (char *, const char *bits[]) |
char * | str_dup (const char *) |
Allocates and returns a copy of the supplied string. | |
unsigned char * | toBase64 (const unsigned char *stream, size_t left) |
unsigned char * | fromBase64 (const char *cStr, int *len) |
void | listAkills (char *from, char type) |
Handles an AutoKill/AutoHurt/Ignore/... list request. | |
int | addakill (long length, char *mask, char *by, char type, char *reason) |
Addakill adds an item to an OperServ autokill/ignore/autohurt/other list. | |
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 | saveakills (void) |
Saves the akill database. | |
void | loadakills (void) |
Load the akill/kline databases. | |
int | isAKilled (char *, char *, char *) |
Returns TRUE if a user is akilled. | |
char * | checkAndSetAKill (char *nick, char *user, char *host) |
int | isAHurt (char *, char *, char *) |
Returns TRUE if a user is autohurt. | |
int | isIgnored (char *, char *, char *) |
Returns TRUE if a user is ignored. | |
void | timed_akill_queue (char *) |
Sends out services kline queue e-mail messages when the time arrives for them to be sent. | |
void | autoremoveakill (char *mask) |
Handles automatic removal of expired akills by OperServ. | |
void | queueakill (char *, char *, char *, char *, time_t, int, int, int) |
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 | dlogInit (void) |
Initialize debug logging at bootup. | |
void | dlogEntry (char *,...) |
Store a log entry in the debug-log stack. | |
void | dlogDump (FILE *) |
Services crash or request, dump debug log entries to file. | |
void | motd (char *) |
Print the services message of the day. | |
void | help (char *, char *, char **, int) |
Handle a user's help request. | |
void | flush_help_cache (void) |
Flush out the help cache. | |
help_cache * | check_help_cache (char *) |
Check if a help item is in the cache if so return it, else return NULL. | |
int | fatalSvsError (const char *fName, int lineNo, const char *cErr) |
int | isPasswordAcceptable (const char *password, char *reason) |
Is a password acceptable? | |
Variables | |
char | myname [255] |
Name of services. | |
char | mypass [33] |
Password of services' N-line. | |
char | hostname [255] |
Hostname of services' uplink. | |
int | port |
IRC Port of services' uplink. | |
int | server |
File descriptor of services' connection with the uplink. | |
Service | services [NUMSERVS] |
Array of services and their data... see above for Service struct. | |
database | db |
Database files. | |
u_long | totalusers |
Total online users. | |
u_long | mostusers |
Maximum concurrent users. | |
u_long | mostnicks |
Number of registered nicknames. | |
u_long | mostchans |
Number of registered channels. | |
u_long | mostmemos |
Number of memos ?? | |
u_long | counterOldCSFmt |
Counter of number of ChanServ commands interpreted by the old hack. | |
long | startup |
Time services started (now or first time). | |
long | firstup |
Time services started (now or first time). | |
char * | OperServ |
Services nickname constants. | |
char * | NickServ |
Services nickname constants. | |
char * | ChanServ |
Services nickname constants. | |
char * | MemoServ |
Services nickname constants. | |
char * | InfoServ |
Services nickname constants. | |
char * | GameServ |
Services nickname constants. | |
char | coreBuffer [IRCBUF] |
Used for printing core messages. | |
u_int | AccessLimit |
Limits set in services.conf. | |
u_int | OpLimit |
Limits set in services.conf. | |
u_int | AkickLimit |
Limits set in services.conf. | |
u_int | ChanLimit |
Limits set in services.conf. | |
u_int | NickLimit |
Limits set in services.conf. | |
time_t | CTime |
Current time (UTC), keep this in mind... | |
time_t | nextNsync |
Times (UTC) of next syncs. | |
time_t | nextCsync |
Times (UTC) of next syncs. | |
time_t | nextMsync |
Times (UTC) of next syncs. |
This header includes indirectly some system-related files and declares global constants and other entities used throughout all of services.
Max Byrd
Greg Poma
James Hess
Definition in file services.h.
|
Autokill typeflag. Send copyright notices.. define or undef Definition at line 205 of file services.h. Referenced by addakill(), aktype_str(), applyAkill(), checkAkillAllUsers(), isAKilled(), loadakills(), os_akill(), IpcType::queryObjMessage(), removeAkill(), and removeAkillType(). |
|
Clone trigger perm flag.
Definition at line 221 of file services.h. |
|
This is for the benefit of bigbrother, so it will know when to not attempt to restart services. What is 'bigbrother'??? Definition at line 127 of file services.h. |
|
Send a globops when SRAs use /os raw Definition at line 179 of file services.h. |
|
Macro that returns the highest value provided.
Definition at line 97 of file services.h. Referenced by main(), and setIdentify(). |
|
maximum events running in timer system at once... Definition at line 174 of file services.h. |
|
Macro that returns the lower value provided.
Definition at line 106 of file services.h. Referenced by ranstring(). |
|
Temporary hack.
Definition at line 143 of file services.h. Referenced by main(). |
|
The number of services entries present -- this MUST be right or services WILL have lots of problems Definition at line 152 of file services.h. Referenced by parseLine(). |
|
Shortcut for case-insensitive comparison Definition at line 431 of file services.h. Referenced by IpcType::alterObjMessage(), IpcType::alterRegNickMessage(), and IpcType::authObjMessage(). |
|
Value: do { \ strncpy((s_dest), (s_src), (s_size)); \ (s_dest)[(s_size) - 1] = '\0'; \ } while(0)
Definition at line 116 of file services.h. Referenced by addakill(), addGhost(), addUserToChan(), banKick(), breakLine(), checkAkillAllUsers(), cs_set_mlock(), getMiscChanOp(), is_postnews(), loadakills(), IpcType::makeMessage(), NickSeeUser(), parseFprint(), parseLine(), readChanData(), readInfoData(), readMemoData(), readNickData(), IpcType::ReadPackets(), readTriggerData(), regnick_ugethost(), sendToChanServ(), setChanMode(), setChanTopic(), SetUserNickHostReal(), and xorit(). |
|
Addakill adds an item to an OperServ autokill/ignore/autohurt/other list.
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. |
|
Add a new user, be that ChanServ or a nick in holding. in the 'mode' variable you can specify +iogsw or any other ircd compatible modes.
Definition at line 153 of file server.c. References myname, and sSend(). Referenced by addGhost(), main(), make_clone(), and parseLine(). |
|
Returns a string indicating which type of OperServ banlist item we have.
Definition at line 577 of file akill.c. References A_AHURT, A_AKILL, and A_IGNORE. Referenced by addakill(), queueakill(), removeAkill(), and removeAkillType(). |
|
Definition at line 744 of file stuff.c. References oalloc(). Referenced by dbReadString(). |
|
Handles automatic removal of expired akills by OperServ.
|
|
Break up a string of data into seperate pieces and parse those. (parseLine())
Definition at line 182 of file server.c. References FALSE, MAX_IRC_LINE_LEN, oldData, OperServ, parseLine(), sSend(), sshutdown(), strncpyzt, and TRUE. Referenced by main(). |
|
Cancels a timer event.
Definition at line 200 of file timer.c. References firstTimerItem, and t_chain::next. Referenced by removeAkill(), and removeAkillType(). |
|
Check if a help item is in the cache if so return it, else return NULL.
Definition at line 237 of file help.c. References firsthelpcache, helpcache_t::name, and helpcache_t::next. Referenced by help(). |
|
Check total number of users. Checks the total number of users to see if a change to the network PLUS-L-CHANNEL mode is necessary to take into account a new maximum number of concurrent connections. Definition at line 122 of file signal.c. References checkTusers(), mostusers, OperServ, sSend(), and timer(). Referenced by checkTusers(), and parseLine(). |
|
Used at services startup to connect to its uplink.
Definition at line 60 of file server.c. References corelog, flushLogs(), logDump(), and sshutdown(). Referenced by main(). |
|
Reports the list of timers.
This is part of the debug command /OPERSERV TIMERS Definition at line 268 of file timer.c. References firstTimerItem, t_table::func, t_chain::next, OperServ, and sSend(). |
|
Channel Expirations Definition at line 2503 of file chanserv.c. References CBANISH, ChanServ, CHOLD, delRegChan(), expireChans(), firstRegChan, getChanData(), SLogfile::log(), mostchans, chanlist_struct::reg, saveChanData(), sSend(), and timer(). Referenced by expireChans(), and parseLine(). |
|
This function handles timed NickServ expiration runs, deletes non-held nicknames that have not been used for their maximum inactivity period before expiration. <
Definition at line 2122 of file nickserv.c. References CTime, mostnicks, NBANISH, and NHOLD. Referenced by parseLine(). |
|
|
|
Report the names of bits set.
|
|
Flush services logs. Performs a 'flush' on the log files resulting in any new services log messages being written to disk Definition at line 103 of file signal.c. Referenced by flushLogs(). |
|
Frees a mask structure.
Definition at line 646 of file stuff.c. References mask(). |
|
Decode from base64 - whole lot easier to decode than to encode
Definition at line 144 of file passwd.c. References assert, and oalloc(). Referenced by readChanData(), and readNickData(). |
|
Returns the masked version of a host.
Definition at line 521 of file stuff.c. References FALSE, tokenEncode(), and TRUE. Referenced by addUserToChan(), getMiscChanOp(), IpcType::queryRegNickMessage(), and regnick_ugethost(). |
|
Signal handler.
Definition at line 216 of file signal.c. References coreBuffer, corelog, dlogDump(), logDump(), sSend(), sshutdown(), and timed_akill_queue(). Referenced by main(). |
|
Handle a user's help request.
Definition at line 101 of file help.c. References check_help_cache(), helpcache_t::first, firsthelpcache, lasthelpcache, helpline_t::line, helpcache_t::name, helpcache_t::next, helpline_t::next, oalloc(), parse_str(), and sSend(). |
|
Returns TRUE if a user is autohurt.
Definition at line 303 of file akill.c. References A_AHURT, firstBanItem, match(), and akill::next. Referenced by parseLine(). |
|
Returns TRUE if a user is akilled.
Definition at line 179 of file akill.c. References A_AKILL, firstBanItem, match(), and akill::next. Referenced by changeNick(). |
|
Returns TRUE if a user is ignored.
Definition at line 327 of file akill.c. References A_IGNORE, firstBanItem, match(), and akill::next. Referenced by parseLine(). |
|
Is a password acceptable? This procedure tests whether a password is acceptable or not in terms of technical devices that _need_ to have the password fit into certain ranges. |
|
Handles an AutoKill/AutoHurt/Ignore/... list request.
Definition at line 129 of file akill.c. References firstBanItem, mask(), akill::next, OperServ, and sSend(). |
|
This function is used by the NickServ ADDMASK command.
Definition at line 355 of file stuff.c. Referenced by addAccessMask(), addakill(), autoremoveakill(), banKick(), delAccessMask(), free_mask(), GetCrule(), listAkills(), loadakills(), make_mask(), match(), ns_addmask(), queueakill(), removeAkill(), and removeAkillType(). |
|
Matches a string against the specified pattern for wildcards \ as allowed done by IRC clients/servers.
Compare if a given string (name) matches the given mask. A wildcard match can be made, '*' matches any number of characters and '?' matches any single character. Additionally, wildcards can be escaped with a preceding \. return 0, if match 1, if no match
Definition at line 129 of file stuff.c. References mask(). Referenced by addUserToChan(), checkAccess(), checkAkillAllUsers(), do_chanop_list(), GetCruleMatch(), getMiscChanOp(), isAHurt(), isAKilled(), isIgnored(), isQlined(), and UpdateCrule(). |
|
Print the services message of the day.
Definition at line 61 of file help.c. References mostchans, mostnicks, mostusers, myname, and sSend(). Referenced by parseLine(). |
|
Clean and allocate a memory area.
Definition at line 404 of file stuff.c. References sshutdown(). Referenced by addakill(), addClone(), addGhost(), addNewUser(), addOpData(), addRegNick(), addUserClone(), addUserToChan(), AppendBuffer(), banKick(), changeNick(), changeNickOnAllChans(), detect_mass(), dlogInit(), fromBase64(), help(), is_postnews(), loadakills(), make_mask(), make_palert(), MakeChannelTrigger(), IpcType::makeMessage(), NewCrule(), IpcType::pollAndHandle(), readChanData(), readInfoData(), readMemoData(), readNickData(), setChanMode(), SetDynBuffer(), setIdentify(), str_dup(), strn_dup(), timer(), and toBase64(). |
|
Merge a vector of strings into one string across delimeters.
this function is the reverse of the original breakString Definition at line 318 of file stuff.c. Referenced by adCheck(), addNewUser(), help(), is_postnews(), and setChanTopic(). |
|
Adds information about an autokill to the body of the kline queue that is periodically mailed to the AKILLMAILTO address.
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(). |
|
Reads the services configuration file. void loadAKills(void); void saveAKills(void); Definition at line 72 of file conf.c. References AccessLimit, addOpData(), AkickLimit, ChanLimit, delOpData(), getRegNickData(), ipcPort, myname, mypass, NHOLD, NickLimit, OAKILL, OCBANDEL, OCLONE, OIGNORE, OLIST, ONBANDEL, OPFLAG_DEFAULT, OpLimit, ORAKILL, OREMROOT, OROOT, OSERVOP, OSETFLAG, and sshutdown(). Referenced by main(). |
|
Handles a user attempting to remove an akill.
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(). |
|
Handles a user attempting to remove an OperServ banlist item.
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(). |
|
Saves the akill database.
Definition at line 867 of file akill.c. References firstBanItem, akill::next, and saveKlineQueue(). Referenced by sshutdown(). |
|
Respond to an /INFO message
Definition at line 605 of file server.c. References myname, _userlist::nick, services_info, and sSend(). Referenced by parseLine(). |
|
Definition at line 774 of file stuff.c. References oalloc(). Referenced by IpcType::authObjMessage(), IpcType::authSysMessage(), freeRegNickListRec(), freeUserListRec(), IpcType::makeMessage(), NickSeeUser(), ns_addmask(), readNickData(), and SetUserNickHostReal(). |
|
Splits a string into a supplied mask structure.
Definition at line 664 of file stuff.c. References corelog, mask_structure::host, logDump(), mask_structure::nick, str_dup(), strn_dup(), and mask_structure::user. |
|
Shuts down services.
Definition at line 165 of file signal.c. References saveakills(), saveInfoData(), saveMemoData(), saveNickData(), sSend(), syncChanData(), timed_akill_queue(), VERSION_NUM, and writeServicesTotals(). Referenced by breakLine(), ConnectToServer(), handler(), main(), oalloc(), parseLine(), readChanData(), readConf(), readInfoData(), readMemoData(), readNickData(), sSend(), and unexpected_eof(). |
|
Allocates and returns a copy of the supplied string.
Definition at line 597 of file stuff.c. References oalloc(). Referenced by IpcType::authObjMessage(), IpcType::authSysMessage(), dbWriteString(), is_sendinfo(), MakeChannelTrigger(), and split_userhost(). |
|
Schedules a timer.
Definition at line 125 of file timer.c. References firstTimerItem, myname, t_chain::next, oalloc(), t_chain::prev, t_chain::run, sSend(), and t_chain::tid. Referenced by addakill(), addNewUser(), addUserToChan(), annoyNickThief(), changeNick(), checkAkillAllUsers(), checkTusers(), expireChans(), flushLogs(), killide(), loadakills(), main(), parseLine(), sync_cfg(), timed_advert_maint(), and timed_akill_queue(). |
|
Check for expired timers. Checks for timers that are expired, runs the specified function on those timers and removes them from the timer list.
Definition at line 236 of file timer.c. References t_chain::args, firstTimerItem, t_chain::func, t_chain::next, t_chain::prev, and t_chain::run. Referenced by main(). |
|
Encode in base64 - finally got this working, I hope. -Mysid
Definition at line 42 of file passwd.c. References assert, and oalloc(). Referenced by PrintPass(), saveChanData(), and saveNickData(). |
|
Encrypt a password string.
Definition at line 286 of file stuff.c. References strncpyzt. Referenced by readChanData(), readNickData(), saveChanData(), and saveNickData(). |