diff options
author | Keegan McAllister <mcallister.keegan@gmail.com> | 2012-03-26 21:02:23 -0400 |
---|---|---|
committer | Keegan McAllister <mcallister.keegan@gmail.com> | 2012-03-31 16:19:33 -0400 |
commit | ba6387f36cc28ad4e793a45b4dec5d2b0ea69e2b (patch) | |
tree | edbf503cc841d604213b3a71179e6113e0bf4d6a /src | |
parent | 519d1ee282dba336c6ff40b21a165b6f3f35dc40 (diff) |
Allow CryptoExceptions to be fatal
Diffstat (limited to 'src')
-rw-r--r-- | src/crypto/crypto.h | 4 | ||||
-rw-r--r-- | src/frontend/mosh-server.cc | 6 | ||||
-rw-r--r-- | src/frontend/stmclient.cc | 10 |
3 files changed, 15 insertions, 5 deletions
diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index 1ed7582..c0b3d18 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -32,7 +32,9 @@ namespace Crypto { class CryptoException { public: string text; - CryptoException( string s_text ) : text( s_text ) {}; + bool fatal; + CryptoException( string s_text, bool s_fatal = false ) + : text( s_text ), fatal( s_fatal ) {}; }; class Base64Key { diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index d7988c5..27e8e3a 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -592,7 +592,11 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network fprintf( stderr, "%s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); spin(); } catch ( Crypto::CryptoException e ) { - fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); + if ( e.fatal ) { + throw; + } else { + fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); + } } } } diff --git a/src/frontend/stmclient.cc b/src/frontend/stmclient.cc index b191914..5a57783 100644 --- a/src/frontend/stmclient.cc +++ b/src/frontend/stmclient.cc @@ -398,9 +398,13 @@ void STMClient::main( void ) req.tv_nsec = 200000000; /* 0.2 sec */ nanosleep( &req, NULL ); } catch ( Crypto::CryptoException e ) { - wchar_t tmp[ 128 ]; - swprintf( tmp, 128, L"Crypto exception: %s", e.text.c_str() ); - overlays.get_notification_engine().set_notification_string( wstring( tmp ) ); + if ( e.fatal ) { + throw; + } else { + wchar_t tmp[ 128 ]; + swprintf( tmp, 128, L"Crypto exception: %s", e.text.c_str() ); + overlays.get_notification_engine().set_notification_string( wstring( tmp ) ); + } } } } |