1
0
mirror of https://github.com/anope/anope.git synced 2026-07-02 23:03:12 +02:00

BUILD : 1.7.5 (342) BUGS : #00 NOTES : Certus: Replaced current rand-implementation with arc4random and replaced C++ comments with C-style comments (gcc 2.95 might complain).

git-svn-id: svn://svn.anope.org/anope/trunk@342 31f1291d-b8d6-0310-a050-a5561fc1590b


git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@218 5417fbe8-f217-4b02-8779-1006273d7864
This commit is contained in:
keeper keeper@31f1291d-b8d6-0310-a050-a5561fc1590b
2004-09-09 15:51:33 +00:00
parent 6c2674da5a
commit e41e4cd69e
22 changed files with 266 additions and 26 deletions
+2
View File
@@ -2,6 +2,8 @@ Anope Version S V N
-------------------
Provided by Anope Dev. <dev@anope.org> - 2004
08/24 A New -l option for am script to list possible selectors. [ #00]
09/08 A Removed rand() and ported bsd's arc4random() to fit our needs. [ #00]
09/08 F Fixed gcc2 support with multiple C++ style comments. [ #00]
08/26 F Fixed spelling stuff in the german langfile. [#159]
08/24 F Compile error with gcc2. [ #00]
+11
View File
@@ -1,6 +1,17 @@
Anope Version S V N
-------------------
** ADDED CONFIGURATION DIRECTIVES **
# UserKey1|2|3 <value> [REQUIRED]
#
# These keys are required to initiate the random number generator. These
# numbers MUST be random as you want your passcodes to be random. Don't
# give these keys to no anyone! Keep them private!
#UserKey1 9866235
#UserKey2 5216332
#UserKey3 9651291
** MODIFIED CONFIGURATION DIRECTIVES **
** DELETED CONFIGURATION DIRECTIVES **
+10
View File
@@ -259,6 +259,16 @@ NetworkName "LocalNet"
#
###########################################################################
# UserKey1|2|3 <value> [REQUIRED]
#
# These keys are required to initiate the random number generator. These
# numbers MUST be random as you want your passcodes to be random. Don't
# give these keys to no anyone! Keep them private!
#UserKey1 9866235
#UserKey2 5216332
#UserKey3 9651291
# NoBackupOkay [DISCOURAGED]
# Allows Services to continue file write operations (i.e. database
# saving) even if the original file cannot be backed up. Enabling this
+10
View File
@@ -493,6 +493,9 @@ E char *DefconMessage;
E char *DefConAkillReason;
E char *DefConOffMessage;
E unsigned int UserKey1;
E unsigned int UserKey2;
E unsigned int UserKey3;
/**** converter.c ****/
E int convert_ircservices_44(void);
@@ -642,6 +645,12 @@ E void doCleanBuffer(char *str);
E void EnforceQlinedNick(char *nick, char *killer);
E int nickIsServices(char *nick);
E void add_entropy_userkeys(void);
E void rand_init(void);
E u_char getrandom8(void);
E u_int16_t getrandom16(void);
E u_int32_t getrandom32(void);
/**** modules.c ****/
E void moduleCallBackRun(void);
E void moduleCleanStruct(ModuleData * moduleData[]);
@@ -899,6 +908,7 @@ E void db_mysql_load_cs_dbase(void);
E void db_mysql_load_os_dbase(void);
E void db_mysql_load_exceptions(void);
E void db_mysql_load_news(void);
E unsigned int mysql_rand(void);
#endif
#ifdef USE_ENCRYPTION
+1 -1
View File
@@ -90,7 +90,7 @@ struct Module_ {
void (*hostHelp)(User *u); /* 6 */
void (*helpHelp)(User *u); /* 7 */
// CommandHash *cmdList[MAX_CMD_HASH];
/* CommandHash *cmdList[MAX_CMD_HASH]; */
MessageHash *msgList[MAX_CMD_HASH];
};
+1 -1
View File
@@ -1399,7 +1399,7 @@ void anope_cmd_nc_change(User * u)
/* SVSMODE +d */
void anope_cmd_svid_umode2(User * u, char *ts)
{
// not used by bahamut ircds
/* not used by bahamut ircds */
}
+64 -5
View File
@@ -316,6 +316,10 @@ char *DefConOffMessage;
char *DefconMessage;
char *DefConAkillReason;
unsigned int UserKey1;
unsigned int UserKey2;
unsigned int UserKey3;
/*************************************************************************/
/* Deprecated directive (dep_) and value checking (chk_) functions: */
@@ -332,15 +336,22 @@ static void dep_ListOpersOnly(void)
/* Configuration directives */
typedef struct {
int type;
int flags;
void *ptr;
} ConfParam;
typedef struct {
char *name;
struct {
int type; /* PARAM_* below */
int flags; /* Same */
void *ptr; /* Pointer to where to store the value */
} params[MAXPARAMS];
ConfParam params[MAXPARAMS];
} Directive;
typedef struct {
char *name;
int (*func) (int line, int argc, char **argv);
} ConfCB;
#define PARAM_NONE 0
#define PARAM_INT 1
#define PARAM_POSINT 2 /* Positive integer only */
@@ -358,6 +369,11 @@ typedef struct {
#define PARAM_FULLONLY 0x02 /* Directive only allowed if !STREAMLINED */
#define PARAM_RELOAD 0x04 /* Directive is reloadable */
int doAddOper(int line, int argc, char **argv);
ConfCB confroutines[] = {
{"Oper", &doAddOper}
};
Directive directives[] = {
{"AkillOnAdd", {{PARAM_SET, PARAM_RELOAD, &AkillOnAdd}}},
{"AutokillDB", {{PARAM_STRING, PARAM_RELOAD, &AutokillDBName}}},
@@ -612,6 +628,9 @@ Directive directives[] = {
{"UpdateTimeout", {{PARAM_TIME, PARAM_RELOAD, &UpdateTimeout}}},
{"UseMail", {{PARAM_SET, PARAM_RELOAD, &UseMail}}},
{"UsePrivmsg", {{PARAM_SET, PARAM_RELOAD, &UsePrivmsg}}},
{"UserKey1", {{PARAM_POSINT, PARAM_RELOAD, &UserKey1}}},
{"UserKey2", {{PARAM_POSINT, PARAM_RELOAD, &UserKey2}}},
{"UserKey3", {{PARAM_POSINT, PARAM_RELOAD, &UserKey3}}},
{"UseSVSHOLD", {{PARAM_SET, PARAM_RELOAD, &UseSVSHOLD}}},
{"WallAkillExpire", {{PARAM_SET, PARAM_RELOAD, &WallAkillExpire}}},
{"WallBadOS", {{PARAM_SET, PARAM_RELOAD, &WallBadOS}}},
@@ -675,6 +694,22 @@ void error(int linenum, char *message, ...)
/*************************************************************************/
int doAddOper(int line, int argc, char **argv)
{
char *name;
int i, operflags;
if (argc < 2) {
error(line, "Oper: Missing Arguments");
return 0;
}
name = argv[0];
operflags = atoi(argv[1]);
error(line, "Added Oper %s with flags %d", name, operflags);
return 1;
}
/* Parse a configuration line. Return 1 on success; otherwise, print an
* appropriate error message and return 0. Destroys the buffer by side
* effect.
@@ -727,6 +762,13 @@ int parse(char *buf, int linenum, int reload)
if (!dir)
return 1;
for (n = 0; n < lenof(confroutines); n++) {
ConfCB *cb = &confroutines[n];
if (stricmp(dir, cb->name) != 0)
continue;
return cb->func(linenum, ac, av);
}
for (n = 0; n < lenof(directives); n++) {
Directive *d = &directives[n];
if (stricmp(dir, d->name) != 0)
@@ -1261,6 +1303,23 @@ int read_config(int reload)
}
}
/* Check the user keys */
CHECK(UserKey1);
CHECK(UserKey2);
CHECK(UserKey3);
if ((UserKey1 == UserKey2) || (UserKey1 == UserKey3)
|| (UserKey3 == UserKey2)) {
error(0,
"Every UserKey must be different. It's for YOUR safety! Remember that!");
retval = 0;
}
if ((UserKey1 == 9866235) || (UserKey2 == 5216332)
|| (UserKey3 == 9651291)) {
error(0,
"You don't want your network secure? You are supposed to set NEW UserKey values!!!");
retval = 0;
}
/**
* Check all DEFCON dependiencies...
**/
+1 -1
View File
@@ -1232,7 +1232,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
void anope_cmd_svid_umode3(User * u, char *ts)
{
// not used
/* not used */
}
/* NICK <newnick> */
+3 -3
View File
@@ -1272,19 +1272,19 @@ void anope_cmd_svid_umode(char *nick, time_t ts)
/* nc_change was = 1, and there is no na->status */
void anope_cmd_nc_change(User * u)
{
// not used
/* not used */
}
/* SVSMODE +d */
void anope_cmd_svid_umode2(User * u, char *ts)
{
// not used
/* not used */
}
void anope_cmd_svid_umode3(User * u, char *ts)
{
// not used
/* not used */
}
/* NICK <newnick> */
+4
View File
@@ -589,6 +589,10 @@ int init(int ac, char **av)
/* load any custom modules */
modules_init();
/* Initialize random number generator */
rand_init();
add_entropy_userkeys();
#ifdef USE_CONVERTER
/* Convert the databases NOW! */
# ifdef IS44_CONVERTER
+118 -1
View File
@@ -19,6 +19,12 @@
/* Cheaper than isspace() or isblank() */
#define issp(c) ((c) == 32)
struct arc4_stream {
u_int8_t i;
u_int8_t j;
u_int8_t s[256];
} rs;
/*************************************************************************/
/* toupper/tolower: Like the ANSI functions, but make sure we return an
@@ -642,7 +648,7 @@ void doCleanBuffer(char *str)
break;
*out++ = ' ';
}
*out = ch; // == '\0'
*out = ch; /* == '\0' */
}
void EnforceQlinedNick(char *nick, char *killer)
@@ -714,4 +720,115 @@ int nickIsServices(char *nick)
return found;
}
static void arc4_init(void)
{
int n;
for (n = 0; n < 256; n++)
rs.s[n] = n;
rs.i = 0;
rs.j = 0;
}
static inline void arc4_addrandom(void *dat, int datlen)
{
int n;
u_int8_t si;
rs.i--;
for (n = 0; n < 256; n++) {
rs.i = (rs.i + 1);
si = rs.s[rs.i];
rs.j = (rs.j + si + ((unsigned char *) dat)[n % datlen]);
rs.s[rs.i] = rs.s[rs.j];
rs.s[rs.j] = si;
}
}
void rand_init(void)
{
int n;
#ifndef _WIN32
int fd;
#endif
struct {
#ifdef USE_MYSQL
int sqlrand;
#endif
#ifndef _WIN32
struct timeval nowt; /* time */
char rnd[32]; /* /dev/urandom */
#else
MEMORYSTATUS mstat; /* memory status */
struct _timeb nowt; /* time */
#endif
} rdat;
arc4_init();
/* Grab "random" MYSQL data */
#ifdef USE_MYSQL
rdat.sqlrand = mysql_rand();
#endif
/* Grab OS specific "random" data */
#ifndef _WIN32
/* unix/bsd: time */
gettimeofday(&rdat.nowt, NULL);
/* unix/bsd: /dev/urandom */
fd = open("/dev/urandom", "r");
if (fd) {
n = read(fd, &rdat.rnd, sizeof(rdat.rnd));
close(fd);
}
#else
/* win32: time */
_ftime(&rdat.nowt);
/* win32: memory status */
GlobalMemoryStatus (&rdat.mstat);
#endif
arc4_addrandom(&rdat, sizeof(rdat));
}
void add_entropy_userkeys(void)
{
arc4_addrandom(&UserKey1, sizeof(UserKey1));
arc4_addrandom(&UserKey2, sizeof(UserKey2));
arc4_addrandom(&UserKey3, sizeof(UserKey3));
/* UserKey3 is also used in mysql_rand() */
}
u_char getrandom8(void)
{
u_char si, sj;
rs.i = (rs.i + 1);
si = rs.s[rs.i];
rs.j = (rs.j + si);
sj = rs.s[rs.j];
rs.s[rs.i] = sj;
rs.s[rs.j] = si;
return (rs.s[(si + sj) & 0xff]);
}
u_int16_t getrandom16(void)
{
u_int16_t val;
val = getrandom8() << 8;
val |= getrandom8();
return val;
}
u_int32_t getrandom32(void)
{
u_int32_t val;
val = getrandom8() << 24;
val |= getrandom8() << 16;
val |= getrandom8() << 8;
val |= getrandom8();
return val;
}
+23
View File
@@ -1611,4 +1611,27 @@ void db_mysql_load_ns_dbase(void)
}
}
/* get random mysql number for the generator */
unsigned int mysql_rand(void)
{
char sqlcmd[MAX_SQL_BUF];
unsigned int num = 0;
if (!do_mysql)
return 0;
snprintf(sqlcmd, MAX_SQL_BUF, "SELECT RAND()");
if (db_mysql_query(sqlcmd)) {
log_perror("Can't create sql query: %s", sqlcmd);
db_mysql_error(MYSQL_WARNING, "query");
}
mysql_res = mysql_store_result(mysql);
if (mysql_num_rows(mysql_res) == 0) {
mysql_free_result(mysql_res);
return 0;
}
mysql_row = mysql_fetch_row(mysql_res);
num = (atoi(mysql_row[0]) * UserKey3);
mysql_free_result(mysql_res);
return num;
}
+2 -3
View File
@@ -2010,12 +2010,11 @@ static int do_register(User * u)
notice_lang(s_NickServ, u, PASSWORD_TRUNCATED, PASSMAX - 1);
}
#endif
srand((unsigned) time(NULL));
for (idx = 0; idx < 9; idx++) {
passcode[idx] =
chars[(1 +
(int) (((float) (max - min)) * rand() /
(RAND_MAX + 1.0)) + min)];
(int) (((float) (max - min)) * getrandom16() /
(65535 + 1.0)) + min)];
} passcode[idx] = '\0';
nr = makerequest(u->nick);
nr->passcode = sstrdup(passcode);
+2 -2
View File
@@ -75,8 +75,8 @@ IgnoreData *get_ignore(const char *nick)
IgnoreData **whichlist = &ignore[tolower(nick[0])];
User *u = finduser(nick);
IgnoreData **whichlist2 = NULL;
// Bleah, this doesn't work. I need a way to get the first char of u->username.
//if (u) whichlist2 = &ignore[tolower(u->username[0])];
/* Bleah, this doesn't work. I need a way to get the first char of u->username.
/if (u) whichlist2 = &ignore[tolower(u->username[0])]; */
IgnoreData **whichlistast = &ignore[42]; /* * */
IgnoreData **whichlistqst = &ignore[63]; /* ? */
int finished = 0;
+1 -1
View File
@@ -1369,7 +1369,7 @@ void anope_cmd_nc_change(User * u)
/* SVSMODE +d */
void anope_cmd_svid_umode2(User * u, char *ts)
{
// not used by bahamut ircds
/* not used by bahamut ircds */
}
void anope_cmd_svid_umode3(User * u, char *ts)
+2 -2
View File
@@ -30,7 +30,7 @@ int rdb_open()
{
#ifdef USE_MYSQL
return do_mysql; // db_mysql_open();
return do_mysql; /* db_mysql_open(); */
#endif
}
@@ -41,7 +41,7 @@ int rdb_close()
{
#ifdef USE_MYSQL
return 1; // db_mysql_close();
return 1; /* db_mysql_close(); */
#endif
}
+1 -1
View File
@@ -1424,7 +1424,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
void anope_cmd_svid_umode3(User * u, char *ts)
{
// not used
/* not used */
}
int anope_event_notice(char *source, int ac, char **av)
+1 -1
View File
@@ -1530,7 +1530,7 @@ void anope_cmd_nc_change(User * u)
/* SVSMODE +d */
void anope_cmd_svid_umode2(User * u, char *ts)
{
// not used by bahamut ircds
/* not used by bahamut ircds */
}
void anope_cmd_svid_umode3(User * u, char *ts)
+1 -1
View File
@@ -1452,7 +1452,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
void anope_cmd_svid_umode3(User * u, char *ts)
{
// not used
/* not used */
}
#endif
+1 -1
View File
@@ -1545,7 +1545,7 @@ void anope_cmd_svid_umode2(User * u, char *ts)
void anope_cmd_svid_umode3(User * u, char *ts)
{
// not used
/* not used */
}
int anope_event_error(char *source, int ac, char **av)
+1 -1
View File
@@ -1452,7 +1452,7 @@ void anope_cmd_nc_change(User * u)
/* SVSMODE +d */
void anope_cmd_svid_umode2(User * u, char *ts)
{
// not used by bahamut ircds
/* not used by bahamut ircds */
}
void anope_cmd_svid_umode3(User * u, char *ts)
+6 -1
View File
@@ -8,10 +8,15 @@
VERSION_MAJOR="1"
VERSION_MINOR="7"
VERSION_PATCH="5"
VERSION_BUILD="341"
VERSION_BUILD="342"
# $Log$
#
# BUILD : 1.7.5 (342)
# BUGS : #00
# NOTES : Certus: Replaced current rand-implementation with arc4random and replaced C++ comments with C-style comments (gcc 2.95 might
# complain).
#
# BUILD : 1.7.5 (341)
# BUGS : none
# NOTES : Fixed minor bug in /CS LOGOUT