Committer : entrope
CVSROOT : /cvsroot/undernet-ircu
Module : ircu2.10
Commit time: 2005-05-01 16:11:11 UTC
Modified files:
ChangeLog doc/readme.log include/ircd_log.h ircd/engine_epoll.c
ircd/ircd_auth.c ircd/ircd_log.c ircd/s_misc.c
Log message:
Fix more IAuth bugs and add IAUTH log target.
---------------------- diff included ----------------------
Index: ircu2.10/ChangeLog
diff -u ircu2.10/ChangeLog:1.618 ircu2.10/ChangeLog:1.619
--- ircu2.10/ChangeLog:1.618 Sat Apr 30 18:48:11 2005
+++ ircu2.10/ChangeLog Sun May 1 09:10:40 2005
@@ -1,3 +1,31 @@
+2005-05-01 Michael Poole <[EMAIL PROTECTED]>
+
+ * doc/readme.log: Document IAUTH log target, remove docs for
+ OLDLOG log target.
+
+ * include/ircd_log.h: Add LS_IAUTH target, remove LS_OLDLOG.
+
+ * ircd/ircd_log.c (logDesc): Likewise.
+
+ * ircd/engine_epoll.c (engine_loop): Handle EPOLLHUP for all
+ sockets (e.g. when connecting) and do not generate read/write
+ events in the same pass as error or EOF events.
+
+ * ircd/ircd_auth.c: Convert old sendto and debug messages to use
+ the LS_IAUTH log target. Consistently use IAUTH_CONNECTED flag
+ instead of comparing fd to -1.
+ (iauth_reconnect): If already connected, disconnect and schedule a
+ reconnect later, since an immediate reconnect can cause assertion
+ failure in the event engine. Also schedule a reconnect when the
+ connection attempt fails.
+ (iauth_read): Reconnect on IO_FAILURE.
+ (iauth_sock_callback): Disconnect and schedule a reconnect on both
+ error (after reporting the error) and EOF.
+ (iauth_start_client): Record the IAuth request in the client.
+ (iauth_exit_client): Report the client exit.
+
+ * ircd/s_misc.c (exit_one_client): Fix formatting.
+
2005-04-30 Michael Poole <[EMAIL PROTECTED]>
* ircd/ircd_auth.c (iauth_connect): Initialize (but do not add)
Index: ircu2.10/doc/readme.log
diff -u ircu2.10/doc/readme.log:1.2 ircu2.10/doc/readme.log:1.3
--- ircu2.10/doc/readme.log:1.2 Tue Jan 7 19:17:18 2003
+++ ircu2.10/doc/readme.log Sun May 1 09:11:00 2005
@@ -107,15 +107,15 @@
* SOCKET - Used to report problems with sockets. By default, log
messages to this subsystem go nowhere.
+ * IAUTH - Used to report connects, disconnects and errors for the
+ IAuth authorization mechanism. By default, log messages to this
+ subsystem go to the "NETWORK" server notice mask.
+
* DEBUG - Used only when debugging is enabled. All log messages to
this subsystem go either to the console or to the debug log file
compiled into the server, as well as to the "DEBUG" server notice
mask. This is the only subsystem with a default log file.
- * OLDLOG - Not used anywhere. This is a left-over from when the
- logging subsystem was first created. Log messages to this
- subsystem go nowhere.
-
Configuration
The true power of the logging subsystem comes from its extremely
Index: ircu2.10/include/ircd_log.h
diff -u ircu2.10/include/ircd_log.h:1.10 ircu2.10/include/ircd_log.h:1.11
--- ircu2.10/include/ircd_log.h:1.10 Fri Dec 10 21:13:42 2004
+++ ircu2.10/include/ircd_log.h Sun May 1 09:11:00 2005
@@ -17,7 +17,7 @@
*/
/** @file
* @brief IRC logging interface.
- * @version $Id: ircd_log.h,v 1.10 2004/12/11 05:13:42 klmitch Exp $
+ * @version $Id: ircd_log.h,v 1.11 2005/05/01 16:11:00 entrope Exp $
*/
#ifndef INCLUDED_ircd_log_h
#define INCLUDED_ircd_log_h
@@ -63,8 +63,8 @@
LS_OPER, /**< Users becoming operators. */
LS_RESOLVER, /**< DNS resolver errors. */
LS_SOCKET, /**< Unexpected socket operation errors. */
+ LS_IAUTH, /**< IAuth status. */
LS_DEBUG, /**< Debug messages. */
- LS_OLDLOG, /**< Old logging messages (no longer used). */
LS_LAST_SYSTEM /**< Count of valid LogSys values. */
};
Index: ircu2.10/ircd/engine_epoll.c
diff -u ircu2.10/ircd/engine_epoll.c:1.10 ircu2.10/ircd/engine_epoll.c:1.11
--- ircu2.10/ircd/engine_epoll.c:1.10 Sun Mar 20 08:06:17 2005
+++ ircu2.10/ircd/engine_epoll.c Sun May 1 09:11:01 2005
@@ -18,7 +18,7 @@
*/
/** @file
* @brief Linux epoll_*() event engine.
- * @version $Id: engine_epoll.c,v 1.10 2005/03/20 16:06:17 entrope Exp $
+ * @version $Id: engine_epoll.c,v 1.11 2005/05/01 16:11:01 entrope Exp $
*/
#include "config.h"
@@ -276,9 +276,9 @@
gen_ref_dec(sock);
continue;
}
- }
-
- switch (s_state(sock)) {
+ } else if (events[i].events & EPOLLHUP) {
+ event_generate(ET_EOF, sock, 0);
+ } else switch (s_state(sock)) {
case SS_CONNECTING:
if (events[i].events & EPOLLOUT) /* connection completed */
event_generate(ET_CONNECT, sock, 0);
@@ -291,12 +291,6 @@
case SS_NOTSOCK:
case SS_CONNECTED:
- if (events[i].events & EPOLLIN)
- event_generate((events[i].events & EPOLLHUP) ? ET_EOF : ET_READ,
sock, 0);
- if (events[i].events & EPOLLOUT)
- event_generate(ET_WRITE, sock, 0);
- break;
-
case SS_DATAGRAM:
case SS_CONNECTDG:
if (events[i].events & EPOLLIN)
Index: ircu2.10/ircd/ircd_auth.c
diff -u ircu2.10/ircd/ircd_auth.c:1.14 ircu2.10/ircd/ircd_auth.c:1.15
--- ircu2.10/ircd/ircd_auth.c:1.14 Sat Apr 30 18:48:12 2005
+++ ircu2.10/ircd/ircd_auth.c Sun May 1 09:11:01 2005
@@ -19,7 +19,7 @@
*/
/** @file
* @brief IAuth client implementation for an IRC server.
- * @version $Id: ircd_auth.c,v 1.14 2005/05/01 01:48:12 entrope Exp $
+ * @version $Id: ircd_auth.c,v 1.15 2005/05/01 16:11:01 entrope Exp $
*/
#include "config.h"
@@ -245,7 +245,6 @@
iauth_active = iauth;
timer_init(&i_reconn_timer(iauth));
i_reconnect(iauth) = reconnect;
- s_fd(&i_socket(iauth)) = -1;
iauth_reconnect(iauth);
}
if (passwd)
@@ -313,7 +312,7 @@
if (t_active(&i_request_timer(iauth)))
timer_del(&i_request_timer(iauth));
/* Disconnect from the server. */
- if (s_fd(&i_socket(iauth)) != -1)
+ if (i_GetConnected(iauth))
iauth_disconnect(iauth);
/* Free memory. */
MyFree(iauth);
@@ -400,7 +399,7 @@
{
close(s_fd(&i_socket(iauth)));
socket_del(&i_socket(iauth));
- s_fd(&i_socket(iauth)) = -1;
+ i_ClrConnected(iauth);
}
/** DNS completion callback for an %IAuth connection.
@@ -411,11 +410,11 @@
{
struct IAuth *iauth = vptr;
if (!he) {
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth connection to %s failed: host
lookup failed", i_host(iauth));
+ log_write(LS_IAUTH, L_NOTICE, 0, "IAuth connection to %s failed: host
lookup failed", i_host(iauth));
} else {
memcpy(&i_addr(iauth).addr, &he->addr, sizeof(i_addr(iauth).addr));
if (!irc_in_addr_valid(&i_addr(iauth).addr)) {
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth connection to %s failed: host
came back as unresolved", i_host(iauth));
+ log_write(LS_IAUTH, L_NOTICE, 0, "IAuth connection to %s failed: host
came back as unresolved", i_host(iauth));
return;
}
iauth_reconnect(iauth);
@@ -454,9 +453,12 @@
IOResult result;
int fd;
- if (s_fd(&i_socket(iauth)) != -1)
+ if (i_GetConnected(iauth)) {
iauth_disconnect(iauth);
- Debug((DEBUG_INFO, "IAuth attempt connection to %s port %p.", i_host(iauth),
i_port(iauth)));
+ iauth_schedule_reconnect(iauth);
+ return;
+ }
+ log_write(LS_IAUTH, L_DEBUG, 0, "IAuth attempt connection to %s port %p.",
i_host(iauth), i_port(iauth));
if (!irc_in_addr_valid(&i_addr(iauth).addr)
&& !ircd_aton(&i_addr(iauth).addr, i_host(iauth))) {
i_query(iauth).vptr = iauth;
@@ -466,27 +468,32 @@
}
local = irc_in_addr_is_ipv4(&i_addr(iauth).addr) ? &VirtualHost_v4 :
&VirtualHost_v6;
fd = os_socket(local, SOCK_STREAM, "IAuth");
- if (fd < 0)
+ if (fd < 0) {
+ iauth_schedule_reconnect(iauth);
return;
+ }
if (!os_set_sockbufs(fd, SERVER_TCP_WINDOW, SERVER_TCP_WINDOW)) {
- close(fd);
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth reconnect unable to set socket
buffers: %s", strerror(errno));
- return;
+ log_write(LS_IAUTH, L_WARNING, 0, "IAuth reconnect unable to set socket
buffers: %s", strerror(errno));
+ goto failure;
}
+ s_fd(&i_socket(iauth)) = fd;
result = os_connect_nonb(fd, &i_addr(iauth));
if (result == IO_FAILURE) {
- close(fd);
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth reconnect unable to initiate
connection: %s", strerror(errno));
- return;
+ log_write(LS_IAUTH, L_NOTICE, 0, "IAuth reconnect unable to initiate
connection: %s", strerror(errno));
+ goto failure;
}
- s_fd(&i_socket(iauth)) = fd;
if (!socket_add(&i_socket(iauth), iauth_sock_callback, iauth,
(result == IO_SUCCESS) ? SS_CONNECTED : SS_CONNECTING,
SOCK_EVENT_READABLE | SOCK_EVENT_WRITABLE, fd)) {
- close(fd);
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth reconnect unable to add socket:
%s", strerror(errno));
- return;
+ log_write(LS_IAUTH, L_WARNING, 0, "IAuth reconnect unable to add socket:
%s", strerror(errno));
+ goto failure;
}
+ return;
+failure:
+ close(fd);
+ i_ClrConnected(iauth);
+ iauth_schedule_reconnect(iauth);
+ return;
}
/** Read input from \a iauth.
@@ -500,9 +507,8 @@
char readbuf[SERVER_TCP_WINDOW];
length = 0;
- if (IO_FAILURE == os_recv_nonb(s_fd(&i_socket(iauth)), readbuf,
sizeof(readbuf), &length))
- return;
- if (length == 0) {
+ if (IO_FAILURE == os_recv_nonb(s_fd(&i_socket(iauth)), readbuf,
sizeof(readbuf), &length)
+ || length == 0) {
iauth_reconnect(iauth);
return;
}
@@ -619,13 +625,12 @@
i_ClrBlocked(iauth);
iauth_write(iauth);
break;
- case ET_EOF:
- iauth_disconnect(iauth);
- break;
case ET_ERROR:
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth socket error: %s",
strerror(ev_data(ev)));
- log_write(LS_SOCKET, L_ERROR, 0, "IAuth socket error: %s",
strerror(ev_data(ev)));
+ log_write(LS_IAUTH, L_ERROR, 0, "IAuth socket error: %s",
strerror(ev_data(ev)));
+ /* and fall through to the ET_EOF case */
+ case ET_EOF:
iauth_disconnect(iauth);
+ iauth_schedule_reconnect(iauth);
break;
default:
assert(0 && "Unrecognized event type");
@@ -642,7 +647,7 @@
{
/* TODO: this could probably be more intelligent */
if (ev_type(ev) == ET_EXPIRE) {
- sendto_opmask_butone(0, SNO_OLDSNO, "IAuth request timed out;
reconnecting");
+ log_write(LS_IAUTH, L_NOTICE, 0, "IAuth request timed out; reconnecting");
iauth_reconnect(t_data(ev_timer(ev)));
}
}
@@ -693,6 +698,7 @@
/* Allocate and initialize IAuthRequest struct. */
if (!(iar = MyCalloc(1, sizeof(*iar))))
return exit_client(cptr, cptr, &me, "IAuth memory allocation failed");
+ cli_iauth(cptr) = iar;
iar->iar_next = &i_list_head(iauth);
iar->iar_prev = i_list_head(iauth).iar_prev;
iar->iar_client = cptr;
@@ -714,9 +720,11 @@
if (cli_iauth(cptr)) {
iauth_dispose_request(iauth_active, cli_iauth(cptr));
cli_iauth(cptr) = NULL;
- } else if (IsIAuthed(cptr) && i_GetIClass(iauth_active)) {
- /* TODO: report quit to iauth */
}
+ if (!i_GetConnected(iauth_active))
+ return;
+ iauth_send(iauth_active, "ExitUser %x", cptr);
+ iauth_write(iauth_active);
}
/** Find pending request with a particular ID.
Index: ircu2.10/ircd/ircd_log.c
diff -u ircu2.10/ircd/ircd_log.c:1.20 ircu2.10/ircd/ircd_log.c:1.21
--- ircu2.10/ircd/ircd_log.c:1.20 Sun Mar 20 08:06:17 2005
+++ ircu2.10/ircd/ircd_log.c Sun May 1 09:11:01 2005
@@ -22,7 +22,7 @@
*/
/** @file
* @brief IRC logging implementation.
- * @version $Id: ircd_log.c,v 1.20 2005/03/20 16:06:17 entrope Exp $
+ * @version $Id: ircd_log.c,v 1.21 2005/05/01 16:11:01 entrope Exp $
*/
#include "config.h"
@@ -162,8 +162,8 @@
S(OPER, -1, SNO_OLDREALOP),
S(RESOLVER, -1, 0),
S(SOCKET, -1, 0),
+ S(IAUTH, -1, SNO_NETWORK),
S(DEBUG, -1, SNO_DEBUG),
- S(OLDLOG, -1, 0),
#undef S
{ LS_LAST_SYSTEM, 0, 0, -1, 0, -1, 0 }
};
Index: ircu2.10/ircd/s_misc.c
diff -u ircu2.10/ircd/s_misc.c:1.47 ircu2.10/ircd/s_misc.c:1.48
--- ircu2.10/ircd/s_misc.c:1.47 Wed Mar 30 20:05:56 2005
+++ ircu2.10/ircd/s_misc.c Sun May 1 09:11:01 2005
@@ -22,7 +22,7 @@
*/
/** @file
* @brief Miscellaneous support functions.
- * @version $Id: s_misc.c,v 1.47 2005/03/31 04:05:56 entrope Exp $
+ * @version $Id: s_misc.c,v 1.48 2005/05/01 16:11:01 entrope Exp $
*/
#include "config.h"
@@ -245,9 +245,8 @@
--UserStats.opers;
if (MyConnect(bcptr))
Count_clientdisconnects(bcptr, UserStats);
- else {
+ else
Count_remoteclientquits(UserStats, bcptr);
- }
}
else if (IsServer(bcptr))
{
@@ -284,7 +283,7 @@
/* bcptr->user->server->serv->client_list[IndexYXX(bcptr)] = NULL; */
RemoveYXXClient(cli_user(bcptr)->server, cli_yxx(bcptr));
if (IsIAuthed(bcptr) || cli_iauth(bcptr))
- iauth_exit_client(bcptr);
+ iauth_exit_client(bcptr);
}
/* Remove bcptr from the client list */
----------------------- End of diff -----------------------
_______________________________________________
Patches mailing list
[email protected]
http://undernet.sbg.org/mailman/listinfo/patches