0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-07-06 10:38:37 +02:00

Merge branch 'master' into authd-framework-2

This commit is contained in:
Elizabeth Myers 2016-03-25 20:09:23 -05:00
commit 460032e61f
14 changed files with 122 additions and 97 deletions

View file

@ -1,8 +1,9 @@
set -v
export MSYSTEM=MINGW64
export PATH=/mingw64/bin:/usr/local/bin:/usr/bin:/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
sh ./autogen.sh
./configure --prefix=c:/projects/charybdis/build --enable-openssl=/mingw64 --build=x86_64-pc-mingw64 --host=x86_64-pc-mingw64
./configure --prefix=c:/projects/charybdis/build --enable-openssl=/mingw64
make -j2
make install

1
.gitignore vendored
View file

@ -34,6 +34,7 @@ librb/aclocal.m4
librb/include/librb_config.h
librb/include/librb_config.h.in
librb/include/librb-config.h
librb/include/serno.h
librb/librb.pc
librb/ltmain.sh
librb/missing

View file

@ -52,7 +52,7 @@ static int _modinit(void);
static void _moddeinit(void);
static int eb_or(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
static int eb_and(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type);
static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, int is_and);
static int eb_combi(const char *data, struct Client *client_p, struct Channel *chptr, long mode_type, bool is_and);
static int recursion_depth = 0;
DECLARE_MODULE_AV2(extb_extended, _modinit, _moddeinit, NULL, NULL, NULL, NULL, NULL, extb_desc);
@ -76,20 +76,20 @@ _moddeinit(void)
static int eb_or(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{
return eb_combi(data, client_p, chptr, mode_type, FALSE);
return eb_combi(data, client_p, chptr, mode_type, false);
}
static int eb_and(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type)
{
return eb_combi(data, client_p, chptr, mode_type, TRUE);
return eb_combi(data, client_p, chptr, mode_type, true);
}
static int eb_combi(const char *data, struct Client *client_p,
struct Channel *chptr, long mode_type, int is_and)
struct Channel *chptr, long mode_type, bool is_and)
{
const char *p, *banend;
int have_result = FALSE;
bool have_result = false;
int allowed_nodes = 11;
size_t datalen;
@ -143,12 +143,12 @@ static int eb_combi(const char *data, struct Client *client_p,
recursion_depth++;
while (--allowed_nodes) {
int invert = FALSE;
bool invert = false;
char *child_data, child_data_buf[BANLEN];
ExtbanFunc f;
if (*p == '~') {
invert = TRUE;
invert = true;
p++;
if (p == banend) {
MOD_DEBUG("combo invalid: no data after ~");
@ -164,7 +164,7 @@ static int eb_combi(const char *data, struct Client *client_p,
if (*p == ':') {
unsigned int parencount = 0;
int escaped = FALSE, done = FALSE;
bool escaped = false, done = false;
char *o;
p++;
@ -173,7 +173,7 @@ static int eb_combi(const char *data, struct Client *client_p,
* we already have_result.
*/
o = child_data = child_data_buf;
while (TRUE) {
while (true) {
if (p == banend) {
if (parencount) {
MOD_DEBUG("combo invalid: EOD while in parens");
@ -186,11 +186,11 @@ static int eb_combi(const char *data, struct Client *client_p,
if (*p != '(' && *p != ')' && *p != '\\' && *p != ',')
*o++ = '\\';
*o++ = *p++;
escaped = FALSE;
escaped = false;
} else {
switch (*p) {
case '\\':
escaped = TRUE;
escaped = true;
break;
case '(':
parencount++;
@ -208,7 +208,7 @@ static int eb_combi(const char *data, struct Client *client_p,
if (parencount)
*o++ = *p;
else
done = TRUE;
done = true;
break;
default:
*o++ = *p;
@ -239,7 +239,7 @@ static int eb_combi(const char *data, struct Client *client_p,
child_result = child_result == EXTBAN_MATCH;
if (is_and ? !child_result : child_result)
have_result = TRUE;
have_result = true;
}
if (p == banend)

View file

@ -166,7 +166,9 @@ struct Client
struct LocalUser
{
rb_dlink_node tnode; /* This is the node for the local list type the client is on*/
rb_dlink_node tnode; /* This is the node for the local list type the client is on */
rb_dlink_list connids; /* This is the list of connids to free */
/*
* The following fields are allocated only for local clients
* (directly connected to *this* server with a socket.
@ -233,7 +235,6 @@ struct LocalUser
time_t next_away; /* Don't allow next away before... */
time_t last;
uint32_t connid;
/* clients allowed to talk through +g */
rb_dlink_list allow_list;
@ -272,7 +273,6 @@ struct LocalUser
struct _ssl_ctl *ssl_ctl; /* which ssl daemon we're associate with */
struct _ssl_ctl *z_ctl; /* second ctl for ssl+zlib */
uint32_t zconnid;
uint32_t localflags;
struct ZipStats *zipstats; /* zipstats */
uint16_t cork_count; /* used for corking/uncorking connections */
@ -605,4 +605,8 @@ extern char *generate_uid(void);
void allocate_away(struct Client *);
void free_away(struct Client *);
uint32_t connid_get(struct Client *client_p);
void connid_put(uint32_t id);
void client_release_connids(struct Client *client_p);
#endif /* INCLUDED_client_h */

View file

@ -95,11 +95,8 @@ extern void del_from_resv_hash(const char *name, struct ConfItem *aconf);
extern struct ConfItem *hash_find_resv(const char *name);
extern void clear_resv_hash(void);
void add_to_cli_connid_hash(struct Client *client_p);
void del_from_cli_connid_hash(struct Client *client_p);
void add_to_cli_connid_hash(struct Client *client_p, uint32_t id);
void del_from_cli_connid_hash(uint32_t id);
struct Client *find_cli_connid_hash(uint32_t connid);
void add_to_zconnid_hash(struct Client *client_p);
void del_from_zconnid_hash(struct Client *client_p);
#endif /* INCLUDED_hash_h */

View file

@ -76,7 +76,7 @@ static rb_bh *pclient_heap = NULL;
static rb_bh *user_heap = NULL;
static rb_bh *away_heap = NULL;
static char current_uid[IDLEN];
static int32_t current_connid = 0;
static uint32_t current_connid = 0;
rb_dictionary *nd_dict = NULL;
@ -129,6 +129,78 @@ init_client(void)
nd_dict = rb_dictionary_create("nickdelay", irccmp);
}
/*
* connid_get - allocate a connid
*
* inputs - none
* outputs - a connid token which is used to represent a logical circuit
* side effects - current_connid is incremented, possibly multiple times.
* the association of the connid to it's client is committed.
*/
uint32_t
connid_get(struct Client *client_p)
{
s_assert(MyClient(client_p));
if (!MyClient(client_p))
return 0;
/* find a connid that is available */
while (find_cli_connid_hash(++current_connid) != NULL)
{
/* handle wraparound, current_connid must NEVER be 0 */
if (current_connid == 0)
++current_connid;
}
add_to_cli_connid_hash(client_p, current_connid);
rb_dlinkAddAlloc(RB_UINT_TO_POINTER(current_connid), &client_p->localClient->connids);
return current_connid;
}
/*
* connid_put - free a connid
*
* inputs - connid to free
* outputs - nothing
* side effects - connid bookkeeping structures are freed
*/
void
connid_put(uint32_t id)
{
struct Client *client_p;
s_assert(id != 0);
if (id == 0)
return;
client_p = find_cli_connid_hash(id);
if (client_p == NULL)
return;
del_from_cli_connid_hash(id);
rb_dlinkFindDestroy(RB_UINT_TO_POINTER(id), &client_p->localClient->connids);
}
/*
* client_release_connids - release any connids still attached to a client
*
* inputs - client to garbage collect
* outputs - none
* side effects - client's connids are garbage collected
*/
void
client_release_connids(struct Client *client_p)
{
rb_dlink_node *ptr, *ptr2;
s_assert(MyClient(client_p));
if (!MyClient(client_p))
return;
RB_DLINK_FOREACH_SAFE(ptr, ptr2, client_p->localClient->connids.head)
connid_put(RB_POINTER_TO_UINT(ptr->data));
}
/*
* make_client - create a new Client struct and set it to initial state.
@ -160,17 +232,6 @@ make_client(struct Client *from)
client_p->localClient->F = NULL;
if(current_connid+1 == 0)
current_connid++;
client_p->localClient->connid = ++current_connid;
if(current_connid+1 == 0)
current_connid++;
client_p->localClient->zconnid = ++current_connid;
add_to_cli_connid_hash(client_p);
client_p->preClient = rb_bh_alloc(pclient_heap);
/* as good a place as any... */
@ -229,7 +290,7 @@ free_local_client(struct Client *client_p)
client_p->localClient->listener = 0;
}
del_from_cli_connid_hash(client_p);
client_release_connids(client_p);
if(client_p->localClient->F != NULL)
{
rb_close(client_p->localClient->F);
@ -1949,7 +2010,7 @@ close_connection(struct Client *client_p)
else
ServerStats.is_ni++;
del_from_cli_connid_hash(client_p);
client_release_connids(client_p);
if(client_p->localClient->F != NULL)
{

View file

@ -40,7 +40,6 @@
#include "rb_radixtree.h"
rb_dictionary *client_connid_tree = NULL;
rb_dictionary *client_zconnid_tree = NULL;
rb_radixtree *client_id_tree = NULL;
rb_radixtree *client_name_tree = NULL;
@ -60,7 +59,6 @@ void
init_hash(void)
{
client_connid_tree = rb_dictionary_create("client connid", rb_uint32cmp);
client_zconnid_tree = rb_dictionary_create("client zconnid", rb_uint32cmp);
client_id_tree = rb_radixtree_create("client id", NULL);
client_name_tree = rb_radixtree_create("client name", irccasecanon);
@ -493,41 +491,19 @@ clear_resv_hash(void)
}
void
add_to_zconnid_hash(struct Client *client_p)
add_to_cli_connid_hash(struct Client *client_p, uint32_t id)
{
rb_dictionary_add(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid), client_p);
rb_dictionary_add(client_connid_tree, RB_UINT_TO_POINTER(id), client_p);
}
void
del_from_zconnid_hash(struct Client *client_p)
del_from_cli_connid_hash(uint32_t id)
{
rb_dictionary_delete(client_zconnid_tree, RB_UINT_TO_POINTER(client_p->localClient->zconnid));
}
void
add_to_cli_connid_hash(struct Client *client_p)
{
rb_dictionary_add(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid), client_p);
}
void
del_from_cli_connid_hash(struct Client *client_p)
{
rb_dictionary_delete(client_connid_tree, RB_UINT_TO_POINTER(client_p->localClient->connid));
rb_dictionary_delete(client_connid_tree, RB_UINT_TO_POINTER(id));
}
struct Client *
find_cli_connid_hash(uint32_t connid)
{
struct Client *target_p;
target_p = rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid));
if (target_p != NULL)
return target_p;
target_p = rb_dictionary_retrieve(client_zconnid_tree, RB_UINT_TO_POINTER(connid));
if (target_p != NULL)
return target_p;
return NULL;
return rb_dictionary_retrieve(client_connid_tree, RB_UINT_TO_POINTER(connid));
}

View file

@ -396,6 +396,7 @@ initialize_server_capabs(void)
* output - none
* side effects - items in ircd_paths[] array are relocated
*/
#ifdef _WIN32
static void
relocate_paths(void)
{
@ -466,6 +467,7 @@ relocate_paths(void)
ircd_paths[IRCD_PATH_BIN] = rb_strdup(workbuf);
ircd_paths[IRCD_PATH_LIBEXEC] = rb_strdup(workbuf);
}
#endif
/*
* write_pidfile
@ -656,7 +658,7 @@ charybdis_main(int argc, char *argv[])
}
#endif
#ifndef ENABLE_FHS_PATHS
#ifdef _WIN32
relocate_paths();
#endif

View file

@ -66,7 +66,7 @@ char linebuf[512];
#define YY_INPUT(buf,result,max_size) \
if (!(result = conf_fgets(buf, max_size, conf_fbfile_in))) \
YY_FATAL_ERROR("input in flex scanner failed");
YY_FATAL_ERROR("input in flex scanner failed");
%}
ws [ \t]*
@ -101,9 +101,9 @@ include \.include{ws}(\<.*\>|\".*\")
{
int i,j;
yylval.string[yyleng-2] = '\0'; /* remove close
* quote
* quote
*/
for (j=i=0 ;yylval.string[i] != '\0'; i++,j++)
{
if (yylval.string[i] != '\\')
@ -113,7 +113,7 @@ include \.include{ws}(\<.*\>|\".*\")
else
{
i++;
if (yylval.string[i] == '\0') /* XXX
if (yylval.string[i] == '\0') /* XXX
* should not
* happen
*/
@ -133,7 +133,7 @@ include \.include{ws}(\<.*\>|\".*\")
loadmodule { return LOADMODULE; }
{string} {
{string} {
strcpy(yylval.string, yytext);
yylval.string[yyleng] = '\0';
return STRING;
@ -148,7 +148,7 @@ loadmodule { return LOADMODULE; }
void ccomment()
{
int c;
/* log(L_NOTICE, "got comment"); */
while (1)
{
@ -157,7 +157,7 @@ void ccomment()
if (c == '*')
{
while ((c = input()) == '*');
if (c == '/')
if (c == '/')
break;
if (c == '\n') ++lineno;
}
@ -182,15 +182,15 @@ void cinclude(void)
else
*strchr(++c, '>') = 0;
/* do stacking and co. */
/* do stacking and co. */
if (include_stack_ptr >= MAX_INCLUDE_DEPTH)
conf_report_error("Includes nested too deep (max is %d)", MAX_INCLUDE_DEPTH);
else
{
FILE *tmp_fbfile_in;
tmp_fbfile_in = fopen(c, "r");
if (tmp_fbfile_in == NULL)
{
/* if its not found in PREFIX, look in IRCD_PATH_ETC */

View file

@ -481,7 +481,7 @@ add_connection(struct Listener *listener, rb_fde_t *F, struct sockaddr *sai, str
free_client(new_client);
return;
}
new_client->localClient->ssl_ctl = start_ssld_accept(F, xF[1], new_client->localClient->connid); /* this will close F for us */
new_client->localClient->ssl_ctl = start_ssld_accept(F, xF[1], connid_get(new_client)); /* this will close F for us */
if(new_client->localClient->ssl_ctl == NULL)
{
free_client(new_client);

View file

@ -1157,7 +1157,7 @@ serv_connect_ssl_callback(rb_fde_t *F, int status, void *data)
}
client_p->localClient->F = xF[0];
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], rb_get_fd(xF[0]));
client_p->localClient->ssl_ctl = start_ssld_connect(F, xF[1], connid_get(client_p));
if(!client_p->localClient->ssl_ctl)
{
serv_connect_callback(client_p->localClient->F, RB_ERROR, data);

View file

@ -863,23 +863,11 @@ start_zlib_session(void *data)
return;
}
if(IsSSL(server))
{
/* tell ssld the new connid for the ssl part*/
buf2[0] = 'Y';
uint32_to_buf(&buf2[1], rb_get_fd(server->localClient->F));
uint32_to_buf(&buf2[5], rb_get_fd(xF2));
ssl_cmd_write_queue(server->localClient->ssl_ctl, NULL, 0, buf2, sizeof(buf2));
}
F[0] = server->localClient->F;
F[1] = xF1;
del_from_zconnid_hash(server);
server->localClient->F = xF2;
/* need to redo as what we did before isn't valid now */
uint32_to_buf(&buf[1], server->localClient->zconnid);
add_to_zconnid_hash(server);
uint32_to_buf(&buf[1], connid_get(server));
server->localClient->z_ctl = which_ssld();
if(!server->localClient->z_ctl)

View file

@ -95,7 +95,7 @@ mr_starttls(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sou
sendto_one_numeric(client_p, RPL_STARTTLS, form_str(RPL_STARTTLS));
send_queued(client_p);
ctl = start_ssld_accept(client_p->localClient->F, F[1], client_p->localClient->connid);
ctl = start_ssld_accept(client_p->localClient->F, F[1], connid_get(client_p));
if (ctl != NULL)
{
client_p->localClient->F = F[0];

View file

@ -1067,11 +1067,6 @@ mod_process_cmd_recv(mod_ctl_t * ctl)
process_stats(ctl, ctl_buf);
break;
}
case 'Y':
{
change_connid(ctl, ctl_buf);
break;
}
#ifdef HAVE_LIBZ
case 'Z':