X-Git-Url: https://jfr.im/git/irc/rqf/shadowircd.git/blobdiff_plain/5366977b4f3c7a50d170bf7a1e29b14c74944db7..6e9b4415cce8808ad39f90612f0218274f3cb1c1:/src/s_auth.c diff --git a/src/s_auth.c b/src/s_auth.c index 6224aa6..dc3aecd 100644 --- a/src/s_auth.c +++ b/src/s_auth.c @@ -21,7 +21,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * USA * - * $Id: s_auth.c 3161 2007-01-25 07:23:01Z nenolod $ */ + * $Id: s_auth.c 3354 2007-04-03 09:21:31Z nenolod $ */ /* * Changes: @@ -35,23 +35,19 @@ */ #include "stdinc.h" #include "config.h" -#include "tools.h" #include "s_auth.h" #include "s_conf.h" #include "client.h" #include "common.h" -#include "event.h" #include "irc_string.h" #include "sprintf_irc.h" #include "ircd.h" #include "numeric.h" #include "packet.h" #include "res.h" -#include "commio.h" #include "s_log.h" #include "s_stats.h" #include "send.h" -#include "memory.h" #include "hook.h" #include "blacklist.h" @@ -89,8 +85,8 @@ ReportType; #define sendheader(c, r) sendto_one_notice(c, HeaderMessages[(r)]) -static dlink_list auth_poll_list; -static BlockHeap *auth_heap; +static rb_dlink_list auth_poll_list; +static rb_bh *auth_heap; static EVH timeout_auth_queries_event; static PF read_auth_reply; @@ -107,7 +103,7 @@ init_auth(void) /* This hook takes a struct Client for its argument */ memset(&auth_poll_list, 0, sizeof(auth_poll_list)); eventAddIsh("timeout_auth_queries_event", timeout_auth_queries_event, NULL, 1); - auth_heap = BlockHeapCreate(sizeof(struct AuthRequest), LCLIENT_HEAP_SIZE); + auth_heap = rb_bh_create(sizeof(struct AuthRequest), LCLIENT_HEAP_SIZE); } /* @@ -116,11 +112,11 @@ init_auth(void) static struct AuthRequest * make_auth_request(struct Client *client) { - struct AuthRequest *request = BlockHeapAlloc(auth_heap); + struct AuthRequest *request = rb_bh_alloc(auth_heap); client->localClient->auth_request = request; request->fd = -1; request->client = client; - request->timeout = CurrentTime + ConfigFileEntry.connect_timeout; + request->timeout = rb_current_time() + ConfigFileEntry.connect_timeout; return request; } @@ -130,7 +126,7 @@ make_auth_request(struct Client *client) static void free_auth_request(struct AuthRequest *request) { - BlockHeapFree(auth_heap, request); + rb_bh_free(auth_heap, request); } /* @@ -147,10 +143,10 @@ release_auth_client(struct AuthRequest *auth) return; client->localClient->auth_request = NULL; - dlinkDelete(&auth->node, &auth_poll_list); + rb_dlinkDelete(&auth->node, &auth_poll_list); free_auth_request(auth); - if(client->localClient->fd > highest_fd) - highest_fd = client->localClient->fd; + if(client->localClient->F->fd > highest_fd) + highest_fd = client->localClient->F->fd; /* * When a client has auth'ed, we want to start reading what it sends @@ -158,9 +154,9 @@ release_auth_client(struct AuthRequest *auth) * -- adrian */ client->localClient->allow_read = MAX_FLOOD; - comm_setflush(client->localClient->fd, 1000, flood_recalc, client); - dlinkAddTail(client, &client->node, &global_client_list); - read_packet(client->localClient->fd, client); + rb_setflush(client->localClient->F->fd, 1000, flood_recalc, client); + rb_dlinkAddTail(client, &client->node, &global_client_list); + read_packet(client->localClient->F->fd, client); } /* @@ -182,7 +178,7 @@ auth_dns_callback(void *vptr, struct DNSReply *reply) sendto_realops_snomask(SNO_GENERAL, L_ALL, "auth_dns_callback(): auth->client->localClient (%s) is NULL", get_client_name(auth->client, HIDE_IP)); - dlinkDelete(&auth->node, &auth_poll_list); + rb_dlinkDelete(&auth->node, &auth_poll_list); free_auth_request(auth); /* and they will silently drop through and all will hopefully be ok... -nenolod */ @@ -249,7 +245,7 @@ auth_error(struct AuthRequest *auth) { ++ServerStats->is_abad; - comm_close(auth->fd); + rb_close(auth->fd); auth->fd = -1; ClearAuth(auth); @@ -278,7 +274,7 @@ start_auth_query(struct AuthRequest *auth) return 0; family = auth->client->localClient->ip.ss_family; - if((fd = comm_socket(family, SOCK_STREAM, 0, "ident")) == -1) + if((fd = rb_socket(family, SOCK_STREAM, 0, "ident")) == -1) { report_error("creating auth stream socket %s:%s", get_client_name(auth->client, SHOW_IP), @@ -286,12 +282,16 @@ start_auth_query(struct AuthRequest *auth) ++ServerStats->is_abad; return 0; } - if((MAXCONNECTIONS - 10) < fd) + + /* + * TBD: this is a pointless arbitrary limit .. we either have a socket or not. -nenolod + */ + if((rb_get_maxconnections() - 10) < fd) { sendto_realops_snomask(SNO_GENERAL, L_ALL, "Can't allocate fd for auth on %s", get_client_name(auth->client, SHOW_IP)); - comm_close(fd); + rb_close(fd); return 0; } @@ -305,7 +305,7 @@ start_auth_query(struct AuthRequest *auth) * and machines with multiple IP addresses are common now */ memset(&localaddr, 0, locallen); - getsockname(auth->client->localClient->fd, + getsockname(auth->client->localClient->F->fd, (struct sockaddr *) &localaddr, &locallen); mangle_mapped_sockaddr((struct sockaddr *)&localaddr); @@ -320,7 +320,7 @@ start_auth_query(struct AuthRequest *auth) auth->fd = fd; SetAuthConnect(auth); - comm_connect_tcp(fd, auth->client->sockhost, 113, + rb_connect_tcp(fd, auth->client->sockhost, 113, (struct sockaddr *) &localaddr, GET_SS_LEN(localaddr), auth_connect_callback, auth, localaddr.ss_family, GlobalSetOptions.ident_timeout); @@ -415,7 +415,7 @@ start_auth(struct Client *client) if(ConfigFileEntry.disable_auth == 0) start_auth_query(auth); - dlinkAdd(auth, &auth->node, &auth_poll_list); + rb_dlinkAdd(auth, &auth->node, &auth_poll_list); } /* @@ -425,18 +425,18 @@ start_auth(struct Client *client) static void timeout_auth_queries_event(void *notused) { - dlink_node *ptr; - dlink_node *next_ptr; + rb_dlink_node *ptr; + rb_dlink_node *next_ptr; struct AuthRequest *auth; - DLINK_FOREACH_SAFE(ptr, next_ptr, auth_poll_list.head) + RB_DLINK_FOREACH_SAFE(ptr, next_ptr, auth_poll_list.head) { auth = ptr->data; - if(auth->timeout < CurrentTime) + if(auth->timeout < rb_current_time()) { if(auth->fd >= 0) - comm_close(auth->fd); + rb_close(auth->fd); if(IsDoingAuth(auth)) { @@ -452,14 +452,14 @@ timeout_auth_queries_event(void *notused) sendheader(auth->client, REPORT_FAIL_DNS); } - auth->client->localClient->lasttime = CurrentTime; + auth->client->localClient->lasttime = rb_current_time(); release_auth_client(auth); } } } /* - * auth_connect_callback() - deal with the result of comm_connect_tcp() + * auth_connect_callback() - deal with the result of rb_connect_tcp() * * If the connection failed, we simply close the auth fd and report * a failure. If the connection suceeded send the ident server a query @@ -488,9 +488,9 @@ auth_connect_callback(int fd, int error, void *data) } if(getsockname - (auth->client->localClient->fd, (struct sockaddr *) &us, + (auth->client->localClient->F->fd, (struct sockaddr *) &us, (socklen_t *) & ulen) - || getpeername(auth->client->localClient->fd, + || getpeername(auth->client->localClient->F->fd, (struct sockaddr *) &them, (socklen_t *) & tlen)) { ilog(L_IOERROR, "auth get{sock,peer}name error for %s:%m", @@ -498,7 +498,7 @@ auth_connect_callback(int fd, int error, void *data) auth_error(auth); return; } - ircsnprintf(authbuf, sizeof(authbuf), "%u , %u\r\n", + rb_snprintf(authbuf, sizeof(authbuf), "%u , %u\r\n", (unsigned int) ntohs(them.sin_port), (unsigned int) ntohs(us.sin_port)); if(write(auth->fd, authbuf, strlen(authbuf)) == -1) @@ -534,7 +534,7 @@ read_auth_reply(int fd, void *data) if(len < 0 && ignoreErrno(errno)) { - comm_setselect(fd, FDLIST_IDLECLIENT, COMM_SELECT_READ, read_auth_reply, auth, 0); + rb_setselect(fd, FDLIST_IDLECLIENT, COMM_SELECT_READ, read_auth_reply, auth, 0); return; } @@ -565,7 +565,7 @@ read_auth_reply(int fd, void *data) } } - comm_close(auth->fd); + rb_close(auth->fd); auth->fd = -1; ClearAuth(auth); @@ -607,8 +607,8 @@ delete_auth_queries(struct Client *target_p) delete_resolver_queries(&auth->dns_query); if(auth->fd >= 0) - comm_close(auth->fd); + rb_close(auth->fd); - dlinkDelete(&auth->node, &auth_poll_list); + rb_dlinkDelete(&auth->node, &auth_poll_list); free_auth_request(auth); }