j...@wxcvbn.org (Jérémie Courrèges-Anglas) writes: > Juan Francisco Cantero Hurtado <i...@juanfra.info> writes: > >> On Tue, Oct 08, 2013 at 02:31:12PM +0200, Jérémie Courrèges-Anglas wrote: >>> >>> Hi, >>> >>> A short time after I checked the arm build-failures[1], Juan Francisco >>> Cantero Hurtado sent me a patch to fix it (thanks!). >>> >>> In this diff: >>> - fix attempt for the build >>> - provide more debugging information wrt. /dev/urandom failure reported >>> by juanfra >>> - enable regress tests (they touch ocb) >>> >>> People with ARM boxes, please build, run make test and test the runtime >>> behavior. >> >> All tests passed. >> >> $ mosh-server new -v >> "Crypto exception: Could not read from /dev/urandom in Base64Key: >> Undefined error: 0"
Would you mind trying this? This seems to fix the behavior of mosh-server... I'm not asking for OKs since I don't understand what the issues really are. If people with any C++ knowledge could explain what's wrong with the original code in the second patch, thanks in advance. Index: patches/patch-src_crypto_crypto_cc =================================================================== RCS file: patches/patch-src_crypto_crypto_cc diff -N patches/patch-src_crypto_crypto_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_crypto_crypto_cc 13 Oct 2013 19:47:09 -0000 @@ -0,0 +1,24 @@ +$OpenBSD$ +TODO: autoconf bits +--- src/crypto/crypto.cc.orig Fri Oct 11 21:39:30 2013 ++++ src/crypto/crypto.cc Fri Oct 11 21:39:17 2013 +@@ -120,14 +120,19 @@ Base64Key::Base64Key( string printable_key ) + } + } + ++#define HAVE_ARC4RANDOM_BUF + Base64Key::Base64Key() + { ++#ifdef HAVE_ARC4RANDOM_BUF ++ arc4random_buf( key, sizeof( key ) ); ++#else + ifstream devrandom( rdev, ifstream::in | ifstream::binary ); + + devrandom.read( reinterpret_cast<char *>( key ), sizeof( key ) ); + if ( !devrandom ) { + throw CryptoException( "Could not read from " + string( rdev ) ); + } ++#endif + } + + string Base64Key::printable_key( void ) const Index: patches/patch-src_network_network_cc =================================================================== RCS file: patches/patch-src_network_network_cc diff -N patches/patch-src_network_network_cc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-src_network_network_cc 13 Oct 2013 19:45:34 -0000 @@ -0,0 +1,45 @@ +$OpenBSD$ +On ARM, even if try_bind's return value is true, it is not seen as such +by the caller, thus preventing mosh-server from finishing its +initialization. This simpler code fixes it. +--- src/network/network.cc.orig Sun Oct 13 21:39:03 2013 ++++ src/network/network.cc Sun Oct 13 21:41:25 2013 +@@ -250,24 +250,14 @@ Connection::Connection( const char *desired_ip, const + + /* try to bind to desired IP first */ + if ( desired_ip_addr != INADDR_ANY ) { +- try { +- if ( try_bind( sock(), desired_ip_addr, desired_port_low, desired_port_high ) ) { return; } +- } catch ( const NetworkException& e ) { +- struct in_addr sin_addr; +- sin_addr.s_addr = desired_ip_addr; +- fprintf( stderr, "Error binding to IP %s: %s: %s\n", +- inet_ntoa( sin_addr ), +- e.function.c_str(), strerror( e.the_errno ) ); +- } ++ if ( try_bind( sock(), desired_ip_addr, desired_port_low, desired_port_high ) ) { ++ return; ++ } + } + + /* now try any local interface */ +- try { +- if ( try_bind( sock(), INADDR_ANY, desired_port_low, desired_port_high ) ) { return; } +- } catch ( const NetworkException& e ) { +- fprintf( stderr, "Error binding to any interface: %s: %s\n", +- e.function.c_str(), strerror( e.the_errno ) ); +- throw; /* this time it's fatal */ ++ if ( try_bind( sock(), INADDR_ANY, desired_port_low, desired_port_high ) ) { ++ return; + } + + assert( false ); +@@ -298,7 +288,7 @@ bool Connection::try_bind( int socket, uint32_t addr, + fprintf( stderr, "Failed binding to %s:%d\n", + inet_ntoa( local_addr.sin_addr ), + ntohs( local_addr.sin_port ) ); +- throw NetworkException( "bind", errno ); ++ return false; + } + } +