oidentd suppport

This commit is contained in:
nohar 2005-05-12 08:29:27 +00:00
parent f66513d224
commit a48019b5fd
9 changed files with 115 additions and 21 deletions

28
configure vendored
View File

@ -272,7 +272,7 @@ PACKAGE_STRING=
PACKAGE_BUGREPORT=
ac_unique_file="src/bip.c"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC LEX LEXLIB LEX_OUTPUT_ROOT DEBUG_TRUE DEBUG_FALSE LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA PACKAGE VERSION ACLOCAL AUTOCONF AUTOMAKE AUTOHEADER MAKEINFO SET_MAKE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT YACC LEX LEXLIB LEX_OUTPUT_ROOT DEBUG_TRUE DEBUG_FALSE OIDENTD_TRUE OIDENTD_FALSE LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@ -805,6 +805,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug Turn on debugging
--enable-oidentd Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)
--disable-ssl Drop OpenSSL support
Some influential environment variables:
@ -2925,6 +2926,29 @@ else
DEBUG_FALSE=
fi
oidentd=false
# Check whether --enable-oidentd or --disable-oidentd was given.
if test "${enable_oidentd+set}" = set; then
enableval="$enable_oidentd"
cat >>confdefs.h <<\_ACEOF
#define HAVE_OIDENTD
_ACEOF
fi;
#[oidentd=true]
if test x$debug = xtrue; then
OIDENTD_TRUE=
OIDENTD_FALSE='#'
else
OIDENTD_TRUE='#'
OIDENTD_FALSE=
fi
requires_libssl=yes
# Check whether --enable-ssl or --disable-ssl was given.
if test "${enable_ssl+set}" = set; then
@ -3661,6 +3685,8 @@ s,@LEXLIB@,$LEXLIB,;t t
s,@LEX_OUTPUT_ROOT@,$LEX_OUTPUT_ROOT,;t t
s,@DEBUG_TRUE@,$DEBUG_TRUE,;t t
s,@DEBUG_FALSE@,$DEBUG_FALSE,;t t
s,@OIDENTD_TRUE@,$OIDENTD_TRUE,;t t
s,@OIDENTD_FALSE@,$OIDENTD_FALSE,;t t
s,@LIBOBJS@,$LIBOBJS,;t t
s,@LTLIBOBJS@,$LTLIBOBJS,;t t
CEOF

View File

@ -12,6 +12,15 @@ AC_ARG_ENABLE(debug,
[debug=true])
AM_CONDITIONAL(DEBUG, test x$debug = xtrue)
oidentd=false
AC_ARG_ENABLE(oidentd,
[ --enable-oidentd Enable oidentd support (bip overwrites ~/.oidentd.conf with this on!)],
AC_DEFINE([HAVE_OIDENTD], [], [Enable oidentd.conf management support])
)
#[oidentd=true]
AM_CONDITIONAL(OIDENTD, test x$debug = xtrue)
requires_libssl=yes
AC_ARG_ENABLE(ssl,
[ --disable-ssl Drop OpenSSL support],

View File

@ -3,8 +3,8 @@ bip_SOURCES = conf.y lex.l bip.c connection.c irc.c line.c log.c md5.c util.c
bipmkpw_SOURCES = bipmkpw.c md5.c util.c
AM_YFLAGS= -d
if DEBUG
AM_CFLAGS=-Wall -g
AM_LDFLAGS=-g
AM_CFLAGS+=-Wall -g
AM_LDFLAGS+=-g
else
AM_CFLAGS=-Wall
AM_CFLAGS+=-Wall
endif

View File

@ -369,9 +369,9 @@ install uninstall-am uninstall all-redirect all-am all installdirs \
mostlyclean-generic distclean-generic clean-generic \
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
@DEBUG_TRUE@ AM_CFLAGS=-Wall -g
@DEBUG_TRUE@ AM_LDFLAGS=-g
@DEBUG_FALSE@ AM_CFLAGS=-Wall
@DEBUG_TRUE@ AM_CFLAGS+=-Wall -g
@DEBUG_TRUE@ AM_LDFLAGS+=-g
@DEBUG_FALSE@ AM_CFLAGS+=-Wall
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.

View File

@ -3,6 +3,9 @@
/* Define to 1 if you have the `ssl' library (-lssl). */
#undef HAVE_LIBSSL
/* Enable oidentd.conf management support */
#undef HAVE_OIDENTD
/* Name of package */
#undef PACKAGE

View File

@ -21,7 +21,7 @@ extern int errno;
static SSL_CTX *sslctx = NULL;
static BIO *errbio = NULL;
extern char *conf_ssl_certfile;
static int SSLize(connection_t *cn);
static int SSLize(connection_t *cn, int *nc);
static int SSL_init_context(void);
#endif
@ -563,7 +563,7 @@ static int check_event_read(fd_set *fds, connection_t *cn)
return 1;
}
static int check_event_write(fd_set *fds, connection_t *cn)
static int check_event_write(fd_set *fds, connection_t *cn, int *nc)
{
if (cn_is_in_error(cn)) {
mylog(LOG_DEBUGVERB, "Error on fd %d (state %d)",
@ -588,8 +588,8 @@ static int check_event_write(fd_set *fds, connection_t *cn)
int err, err2;
socklen_t errSize = sizeof(err);
err2 = getsockopt(cn->handle, SOL_SOCKET, SO_ERROR,(void *)&err,
&errSize);
err2 = getsockopt(cn->handle, SOL_SOCKET, SO_ERROR,
(void *)&err, &errSize);
if (err2 < 0) {
mylog(LOG_WARN, "fd:%d getsockopt error: %s",
@ -600,7 +600,7 @@ static int check_event_write(fd_set *fds, connection_t *cn)
CONN_NEED_SSLIZE) ? 0 : 1;
} else if (err == EINPROGRESS || err == EALREADY) {
mylog(LOG_INFO, "fd:%d Connection in progress...",
mylog(LOG_DEBUG, "fd:%d Connection in progress...",
cn->handle);
return connection_timedout(cn);
} else if (err == EISCONN || err == 0) {
@ -611,7 +611,8 @@ static int check_event_write(fd_set *fds, connection_t *cn)
}
#endif
cn->connected = CONN_OK;
mylog(LOG_INFO, "fd:%d Connection established !",
*nc = 1;
mylog(LOG_DEBUG, "fd:%d Connection established !",
cn->handle);
return 1;
} else {
@ -626,7 +627,7 @@ static int check_event_write(fd_set *fds, connection_t *cn)
#ifdef HAVE_LIBSSL
if (cn->connected == CONN_NEED_SSLIZE) {
if (SSLize(cn))
if (SSLize(cn, nc))
return connection_timedout(cn);
return 0;
}
@ -691,7 +692,7 @@ int cn_want_write(connection_t *cn)
return !list_is_empty(cn->outgoing);
}
list_t *wait_event(list_t *cn_list, int *msec)
list_t *wait_event(list_t *cn_list, int *msec, int *nc)
{
fd_set fds_read, fds_write, fds_except;
int maxfd = -1, err;
@ -699,6 +700,7 @@ list_t *wait_event(list_t *cn_list, int *msec)
list_iterator_t it;
struct timeval tv;
struct timeval btv, etv;
*nc = 0;
cn_newdata = list_new(NULL);
FD_ZERO(&fds_read);
@ -795,7 +797,7 @@ list_t *wait_event(list_t *cn_list, int *msec)
list_add_first(cn_newdata, cn);
continue;
}
if (check_event_write(&fds_write, cn))
if (check_event_write(&fds_write, cn, nc))
connection_ready_output(cn);
if (check_event_read(&fds_read, cn)) {
@ -1097,7 +1099,7 @@ prng_end:
return 0;
}
static int SSLize(connection_t *cn)
static int SSLize(connection_t *cn, int *nc)
{
int err, err2;
@ -1139,6 +1141,7 @@ static int SSLize(connection_t *cn)
return 1;
}*/
cn->connected = CONN_OK;
*nc = 1;
return 0;
}
if (err2 == SSL_ERROR_ZERO_RETURN || err2 == SSL_ERROR_SSL) {
@ -1263,7 +1266,7 @@ int main(int argc,char* argv[])
while (cont) {
conn2 = accept_new(conn);
if (conn2) {
mylog(LOG_INFO, "New client");
mylog(LOG_DEBUG, "New client");
cont = 0;
}
sleep(1);

View File

@ -90,7 +90,7 @@ void connection_close(connection_t *cn);
void write_line(connection_t *cn, char *line);
void write_line_fast(connection_t *cn, char *line);
list_t *read_lines(connection_t *cn, int *error);
list_t *wait_event(list_t *cn_list, int *msec);
list_t *wait_event(list_t *cn_list, int *msec, int *nc);
int cn_is_connected(connection_t *cn);
int cn_is_listening(connection_t *cn);

View File

@ -1821,6 +1821,54 @@ void irc_server_shutdown(struct link_server *s)
}
#ifdef HAVE_OIDENTD
/* ugly */
void oidentd_dump(list_t *connl)
{
list_iterator_t it;
FILE *f;
char *home;
char tmpbuf[256];
home = getenv("HOME");
if (!home)
return;
strcpy(tmpbuf, home);
strcat(tmpbuf, "/.oidentd.conf");
f = fopen(tmpbuf, "w");
if (!f)
return;
for (list_it_init(connl, &it); list_it_item(&it); list_it_next(&it)) {
connection_t *c = list_it_item(&it);
struct link_any *la = c->user_data;
if (c->connected == CONN_OK && la &&
TYPE(la) == IRC_TYPE_SERVER) {
struct link_server *ls = (struct link_server*)la;
struct link *l = LINK(ls);
char *localip, *remoteip;
int localport, remoteport;
localip = connection_localip(CONN(ls));
localport = connection_localport(CONN(ls));
remoteip = connection_remoteip(CONN(ls));
remoteport = connection_remoteport(CONN(ls));
fprintf(f, "to %s lport %d from %s fport %d {\n",
remoteip, remoteport, localip,
localport);
fprintf(f, "\treply %s\n", l->user);
fprintf(f, "}\n");
free(localip);
free(remoteip);
}
}
fclose(f);
}
#endif
struct link_client *reloading_client;
/*
* The main loop
@ -1934,8 +1982,13 @@ void irc_main(connection_t *inc, list_t *ll)
}
}
int nc;
/* Da main loop */
list_t *ready = wait_event(&connl, &timeleft);
list_t *ready = wait_event(&connl, &timeleft, &nc);
#ifdef HAVE_OIDENTD
if (nc)
oidentd_dump(&connl);
#endif
while ((conn = list_remove_first(ready))) {
struct link_any *lc =
(struct link_any *)conn->user_data;

View File

@ -617,7 +617,7 @@ static char *log_beautify(char *buf, char *dest, int *raw)
}
son = p;
/* 'date time blawithnoexcl bla bla ! bla' --> ? */
while (*p && *p != '!' && *p != ' ')
while (*p && *p != '!' && *p != ' ' && *p != ':')
p++;
if (!p || !p[0] || !p[1])
return buf;