Opened 11 months ago

Closed 9 months ago

#19904 closed defect (fixed)

evutil_secure_rng_add_bytes() not present in openbsd libevent 2

Reported by: nickm Owned by: nickm
Priority: Medium Milestone: Tor: 0.2.9.x-final
Component: Core Tor/Tor Version:
Severity: Normal Keywords: openbsd, TorCoreTeam201608
Cc: cb@… Actual Points: 0
Parent ID: Points: 0
Reviewer: Sponsor:

Description

For decent reasons, OpenBSD removes evutil_secure_rng_add_bytes(). But now that Tor requires Libevent 2, Tor should detect this absence and not call evutil_secure_rng_add_bytes() if it isn't there.

Child Tickets

Attachments (1)

linkjig.patch (1.2 KB) - added by rubiate 10 months ago.
Check for libevent functions after determining how to link it

Download all attachments as: .zip

Change History (9)

comment:1 Changed 11 months ago by nickm

  • Actual Points set to 0

This is a bugfix on 0.2.5.4-alpha, but I recommend no backport, since it didn't matter still we started requiring libevent 2, and openbsd started caring.

Fixed in e788c577f11ef4

Changed 10 months ago by rubiate

Check for libevent functions after determining how to link it

comment:2 Changed 10 months ago by rubiate

  • Cc cb@… added

The check for functions is happening before it has figured out how to link libevent, but it still works(ish) by accident.

Other platforms are happy enough with -levent so they find (or don't find) the functions, and the function check fails on OpenBSD because it can't link it, so everyone gets (almost) the right result.

Although, on OpenBSD it also fails to find evutil_secure_rng_set_urandom_device_file() which is available.

comment:3 Changed 10 months ago by nickm

  • Keywords TorCoreTeam201609 added; TorCoreTeam201608 removed

Move unfinished items assigned to me to september.

comment:4 Changed 10 months ago by nickm

  • Keywords TorCoreTeam201608 added; TorCoreTeam201609 removed

comment:5 Changed 9 months ago by nickm

  • Status changed from new to needs_information

(I'm not sure this was actually true; did we fix this along with the other libevent2 issues on OpenBSD?)

comment:6 Changed 9 months ago by rubiate

Nope, it can't find evutil_secure_rng_add_bytes or evutil_secure_rng_set_urandom_device_file because it's still looking with -levent

configure:8355: checking for evutil_secure_rng_set_urandom_device_file
configure:8355: gcc -std=gnu99 -o conftest -g -O2 -I/usr/local/include -I${top_srcdir}/src/common -L/usr/local/lib conftest.c -levent -lpthread >&5
/tmpcc7rk6IF.o: In function `main':
/tor/conftest.c:99: undefined reference to `evutil_secure_rng_set_urandom_device_file'
[...]
configure:8355: checking for evutil_secure_rng_add_bytes
configure:8355: gcc -std=gnu99 -o conftest -g -O2 -I/usr/local/include -I${top_srcdir}/src/common -L/usr/local/lib conftest.c -levent -lpthread >&5
/tmp
cc2XrDZc.o: In function `main':
/tor/conftest.c:99: undefined reference to `evutil_secure_rng_add_bytes'

With things moved around, it can find evutil_secure_rng_set_urandom_device_file

configure:8507: checking for evutil_secure_rng_set_urandom_device_file
configure:8507: gcc -std=gnu99 -o conftest -g -O2 -I/usr/local/include -I${top_srcdir}/src/common -L/usr/local/lib conftest.c -levent_extra -levent_core -lpthread >&5
configure:8507: $? = 0
configure:8507: result: yes
[...]
configure:8507: checking for evutil_secure_rng_add_bytes
configure:8507: gcc -std=gnu99 -o conftest -g -O2 -I/usr/local/include -I${top_srcdir}/src/common -L/usr/local/lib conftest.c -levent_extra -levent_core -lpthread >&5
/tmpccmjPCe2.o: In function `main':
/tor/conftest.c:103: undefined reference to `evutil_secure_rng_add_bytes'

Updated to apply against current master:

diff --git a/configure.ac b/configure.ac
index f6edb3a..23371d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -490,21 +490,17 @@ void *event_init(void);],
 event_init();
 ], [--with-libevent-dir], [/opt/libevent])
 
-dnl Now check for particular libevent functions.
+dnl Determine the incantation needed to link libevent.
 save_LIBS="$LIBS"
 save_LDFLAGS="$LDFLAGS"
 save_CPPFLAGS="$CPPFLAGS"
-LIBS="-levent $STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $LIBS"
+
+LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
 LDFLAGS="$TOR_LDFLAGS_libevent $LDFLAGS"
 CPPFLAGS="$TOR_CPPFLAGS_libevent $CPPFLAGS"
-AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
-                evutil_secure_rng_add_bytes \
-])
 
 AC_CHECK_HEADERS(event2/event.h event2/dns.h event2/bufferevent_ssl.h)
 
-LIBS="$STATIC_LIBEVENT_FLAGS $TOR_LIB_WS32 $save_LIBS"
-
 if test "$enable_static_libevent" = "yes"; then
    if test "$tor_cv_library_libevent_dir" = "(system)"; then
      AC_MSG_ERROR("You must specify an explicit --with-libevent-dir=x option when using --enable-static-libevent")
@@ -527,6 +523,11 @@ else
      fi
 fi
 
+dnl Now check for particular libevent functions.
+AC_CHECK_FUNCS([evutil_secure_rng_set_urandom_device_file \
+                evutil_secure_rng_add_bytes \
+])
+
 LIBS="$save_LIBS"
 LDFLAGS="$save_LDFLAGS"
 CPPFLAGS="$save_CPPFLAGS"

comment:7 Changed 9 months ago by nickm

  • Status changed from needs_information to needs_review

comment:8 Changed 9 months ago by nickm

  • Resolution set to fixed
  • Status changed from needs_review to closed

Thanks; applied to master as 6055bba8cc18f4d918fdd20f648e5e5deab37946.

Note: See TracTickets for help on using tickets.