Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libratbox/configure
Original file line number Diff line number Diff line change
Expand Up @@ -14052,7 +14052,7 @@ fi



for ac_func in snprintf vsnprintf socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strdup strndup strlcpy strlcat strnlen fstat signalfd select poll kevent kqueue1 port_create epoll_ctl epoll_create1 arc4random getrusage timerfd_create accept4 pipe2
for ac_func in snprintf vsnprintf socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strdup strndup strlcpy strlcat strnlen fstat signalfd select poll kevent kqueue1 port_create epoll_ctl epoll_create1 arc4random arc4random_stir getrusage timerfd_create accept4 pipe2
do :
as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
Expand Down
2 changes: 1 addition & 1 deletion libratbox/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ AC_CHECK_TYPE([sa_family_t], [],


dnl check for various functions...
AC_CHECK_FUNCS([snprintf vsnprintf socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strdup strndup strlcpy strlcat strnlen fstat signalfd select poll kevent kqueue1 port_create epoll_ctl epoll_create1 arc4random getrusage timerfd_create accept4 pipe2])
AC_CHECK_FUNCS([snprintf vsnprintf socketpair gettimeofday writev sendmsg gmtime_r strtok_r usleep posix_spawn strdup strndup strlcpy strlcat strnlen fstat signalfd select poll kevent kqueue1 port_create epoll_ctl epoll_create1 arc4random arc4random_stir getrusage timerfd_create accept4 pipe2])

AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if you have nanosleep]))
AC_SEARCH_LIBS(timer_create, rt, AC_DEFINE(HAVE_TIMER_CREATE, 1, [Define if you have timer_create]))
Expand Down
7 changes: 0 additions & 7 deletions libratbox/include/arc4random.h

This file was deleted.

3 changes: 3 additions & 0 deletions libratbox/include/libratbox_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
/* Define to 1 if you have the `arc4random' function. */
#undef HAVE_ARC4RANDOM

/* Define to 1 if you have the `arc4random_stir' function. */
#undef HAVE_ARC4RANDOM_STIR

/* Define to 1 if you have the <arpa/inet.h> header file. */
#undef HAVE_ARPA_INET_H

Expand Down
1 change: 1 addition & 0 deletions libratbox/include/ratbox_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include "librb-config.h"
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <stdarg.h>
#include <assert.h>
Expand Down
8 changes: 8 additions & 0 deletions libratbox/include/rb_arc4random.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

#include "librb-config.h"

#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_ARC4RANDOM)
extern void rb_arc4random_stir(void);
extern uint32_t rb_arc4random(void);
extern void rb_arc4random_addrandom(uint8_t *dat, int datlen);
#endif
6 changes: 3 additions & 3 deletions libratbox/src/arc4random.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ arc4_getword(struct arc4_stream *as)
}

void
arc4random_stir(void)
rb_arc4random_stir(void)
{
if(!rs_initialized)
{
Expand All @@ -185,15 +185,15 @@ arc4random_stir(void)
}

void
arc4random_addrandom(uint8_t *dat, int datlen)
rb_arc4random_addrandom(uint8_t *dat, int datlen)
{
if(!rs_initialized)
arc4random_stir();
arc4_addrandom(&rs, dat, datlen);
}

uint32_t
arc4random(void)
rb_arc4random(void)
{
if(!rs_initialized)
arc4random_stir();
Expand Down
6 changes: 1 addition & 5 deletions libratbox/src/commio.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,10 @@ static int rb_fd_set_cloexec(int fd, bool doclose)
int
rb_set_cloexec(rb_fde_t *F, bool doclose)
{
int res;
int fd;
if(F == NULL)
return 0;

fd = F->fd;

return rb_fd_set_cloexec(fd, doclose);
return rb_fd_set_cloexec(F->fd, doclose);
}


Expand Down
29 changes: 25 additions & 4 deletions libratbox/src/nossl.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,30 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
* USA
*/

#include "libratbox_config.h"
#include "ratbox_lib.h"
#if !defined(HAVE_OPENSSL) && !defined(HAVE_GNUTLS) && !defined(HAVE_MBEDTLS)

#include "arc4random.h"
#ifndef HAVE_ARC4RANDOM
#include "rb_arc4random.h"

extern void rb_arc4random_stir(void);
extern uint32_t rb_arc4random(void);
extern void rb_arc4random_addrandom(uint8_t *dat, int datlen);

#define arc4random_stir() rb_arc4random_stir()
#define arc4random() rb_arc4random()
#define arc4random_addrandom(x, y) rb_arc4random_addrandom(x, y)

#endif

/* newer *bsd doesn't have arc4random_stir */
#if defined(HAVE_ARC4RANDOM) && !defined(HAVE_ARC4RANDOM_STIR)
#define arc4random_stir()
#define NOARC4STIR 1
#endif



#include "commio-int.h"
#include "commio-ssl.h"
Expand All @@ -52,19 +70,22 @@ rb_ssl_listen(rb_fde_t *F, int backlog, bool defer_accept)
errno = ENOSYS;
return -1;
}

#ifndef NOARC4STIR
static void
rb_stir_arc4random(void *unused)
{
arc4random_stir();
}
#endif

int
rb_init_prng(const char *path, prng_seed_t seed_type)
{
/* xxx this ignores the parameters above */
arc4random_stir();
#ifndef NOARC4STIR
rb_arc4random_stir();
rb_event_addish("rb_stir_arc4random", rb_stir_arc4random, NULL, 300);
#endif
return 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/supported.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* charybdis: A slightly useful ircd.
* ircd-ratbox: A slightly useful ircd.
* supported.c: isupport (005) numeric
*
* Copyright (C) 2006-2008 Jilles Tjoelker
Expand Down