#define SetDead(x) ((x)->flags |= FLAG_DEAD)
#define SetSSLWWantsR(x) ((x)->flags |= FLAG_SSL_W_WANTS_R)
#define SetSSLRWantsW(x) ((x)->flags |= FLAG_SSL_R_WANTS_W)
-#define SetZipSSL(x) ((x)->flags |= FLAG_ZIPSSL)
-#define ClearSSL(x) ((x)->flags &= ~FLAG_SSL)
-#define ClearZip(x) ((x)->flags &= ~FLAG_ZIP)
#define ClearCork(x) ((x)->flags &= ~FLAG_CORK)
-#define ClearDead(x) ((x)->flags &= ~FLAG_DEAD)
#define ClearSSLWWantsR(x) ((x)->flags &= ~FLAG_SSL_W_WANTS_R)
#define ClearSSLRWantsW(x) ((x)->flags &= ~FLAG_SSL_R_WANTS_W)
-#define ClearZipSSL(x) ((x)->flags &= ~FLAG_ZIPSSL)
#define NO_WAIT 0x0
#define WAIT_PLAIN 0x1
{
char inbuf[READBUF_SIZE];
conn_t *conn = data;
- const char *err = remote_closed;
int length;
if(conn == NULL)
return;
return;
}
+ const char *err;
if(IsSSL(conn) && length == RB_RW_SSL_ERROR)
err = rb_get_ssl_strerror(conn->mod_fd);
else
static void
ssl_send_certfp(conn_t *conn)
{
- uint8_t buf[9 + RB_SSL_CERTFP_LEN];
+ uint8_t buf[13 + RB_SSL_CERTFP_LEN];
- int len = rb_get_ssl_certfp(conn->mod_fd, &buf[9], certfp_method);
+ int len = rb_get_ssl_certfp(conn->mod_fd, &buf[13], certfp_method);
if (!len)
return;
lrb_assert(len <= RB_SSL_CERTFP_LEN);
buf[0] = 'F';
uint32_to_buf(&buf[1], conn->id);
- uint32_to_buf(&buf[5], len);
- mod_cmd_write_queue(conn->ctl, buf, 9 + len);
+ uint32_to_buf(&buf[5], certfp_method);
+ uint32_to_buf(&buf[9], len);
+ mod_cmd_write_queue(conn->ctl, buf, 13 + len);
}
static void
}
#endif
-static void
-init_prng(mod_ctl_t * ctl, mod_ctl_buf_t * ctl_buf)
-{
- char *path;
- prng_seed_t seed_type;
-
- seed_type = (prng_seed_t) ctl_buf->buf[1];
- path = (char *) &ctl_buf->buf[2];
- rb_init_prng(path, seed_type);
-}
-
-
static void
ssl_new_keys(mod_ctl_t * ctl, mod_ctl_buf_t * ctl_buf)
{
key = buf;
buf += strlen(key) + 1;
dhparam = buf;
- if(strlen(dhparam) == 0)
- dhparam = NULL;
buf += strlen(dhparam) + 1;
cipher_list = buf;
+ if(strlen(key) == 0)
+ key = cert;
+ if(strlen(dhparam) == 0)
+ dhparam = NULL;
if(strlen(cipher_list) == 0)
cipher_list = NULL;
ssl_new_keys(ctl, ctl_buf);
break;
}
- case 'I':
- init_prng(ctl, ctl_buf);
- break;
case 'S':
{
process_stats(ctl, ctl_buf);
main(int argc, char **argv)
{
const char *s_ctlfd, *s_pipe, *s_pid;
- int ctlfd, pipefd, x, maxfd;
+ int ctlfd, pipefd, maxfd;
maxfd = maxconn();
s_ctlfd = getenv("CTL_FD");
ctlfd = atoi(s_ctlfd);
pipefd = atoi(s_pipe);
ppid = atoi(s_pid);
- x = 0;
+
#ifndef _WIN32
- for(x = 0; x < maxfd; x++)
+ int x;
+
+ for(x = 3; x < maxfd; x++)
{
- if(x != ctlfd && x != pipefd && x > 2)
+ if(x != ctlfd && x != pipefd)
close(x);
}
+
x = open("/dev/null", O_RDWR);
if(x >= 0)
close(x);
}
#endif
+
setup_signals();
rb_lib_init(NULL, NULL, NULL, 0, maxfd, 1024, 4096);
rb_init_rawbuffers(1024);
+ rb_init_prng(NULL, RB_PRNG_DEFAULT);
ssld_ssl_ok = rb_supports_ssl();
mod_ctl = rb_malloc(sizeof(mod_ctl_t));
mod_ctl->F = rb_open(ctlfd, RB_FD_SOCKET, "ircd control socket");
/* this is really useless... */
send_i_am_useless(mod_ctl);
/* sleep until the ircd kills us */
- rb_sleep(2 << 30, 0);
+ rb_sleep(1 << 30, 0);
exit(1);
}