diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-09-24 06:41:54 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-09-24 06:41:54 +0800 |
commit | 1df3e6787e2c30adae410e1eda36907b578a4240 (patch) | |
tree | 1cca2ced9c319a0231e3d9d267458321104ec4be /camel | |
parent | a02d89a2b723561eaea9a509d1da094a1af67b41 (diff) | |
download | gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.gz gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.bz2 gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.lz gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.xz gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.zst gsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.zip |
Don't even try to alert the user if the session isn't interactive.
2001-09-23 Jeffrey Stedfast <fejj@ximian.com>
* camel-tcp-stream-openssl.c (ssl_verify): Don't even try to alert
the user if the session isn't interactive.
(errlib_error_to_errno): Make the default errno EINTR so that we
act just like CamelTcpStreamSSL.
* camel-pgp-context.c (pgp_sign): When the password is not
provided, set the exception to USER_CANCEL.
(pgp_clearsign): Same.
(pgp_encrypt): And here.
(pgp_decrypt): Here too.
svn path=/trunk/; revision=13088
Diffstat (limited to 'camel')
-rw-r--r-- | camel/ChangeLog | 16 | ||||
-rw-r--r-- | camel/camel-pgp-context.c | 8 | ||||
-rw-r--r-- | camel/camel-tcp-stream-openssl.c | 46 |
3 files changed, 43 insertions, 27 deletions
diff --git a/camel/ChangeLog b/camel/ChangeLog index 67013942ae..42da8598af 100644 --- a/camel/ChangeLog +++ b/camel/ChangeLog @@ -1,3 +1,16 @@ +2001-09-23 Jeffrey Stedfast <fejj@ximian.com> + + * camel-tcp-stream-openssl.c (ssl_verify): Don't even try to alert + the user if the session isn't interactive. + (errlib_error_to_errno): Make the default errno EINTR so that we + act just like CamelTcpStreamSSL. + + * camel-pgp-context.c (pgp_sign): When the password is not + provided, set the exception to USER_CANCEL. + (pgp_clearsign): Same. + (pgp_encrypt): And here. + (pgp_decrypt): Here too. + 2001-09-21 <NotZed@Ximian.com> * camel-store.c (create_folder): Set the exception if @@ -338,7 +351,8 @@ 2001-09-12 <NotZed@Ximian.com> - * camel-store.c (camel_store_delete_folder): Fixed warnings with a cast. + * camel-store.c (camel_store_delete_folder): Fixed warnings with a + cast. (camel_store_rename_folder): " 2001-09-14 Jeffrey Stedfast <fejj@ximian.com> diff --git a/camel/camel-pgp-context.c b/camel/camel-pgp-context.c index 95fafdc652..db87a0dd6c 100644 --- a/camel/camel-pgp-context.c +++ b/camel/camel-pgp-context.c @@ -521,7 +521,7 @@ pgp_sign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash, passphrase = pgp_get_passphrase (ctx->session, context->priv->type, (char *) userid); if (!passphrase) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cannot sign this message: no password provided")); goto exception; } @@ -696,7 +696,7 @@ pgp_clearsign (CamelCipherContext *ctx, const char *userid, CamelCipherHash hash passphrase = pgp_get_passphrase (ctx->session, context->priv->type, (char *) userid); if (!passphrase) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cannot sign this message: no password provided")); goto exception; } @@ -1075,7 +1075,7 @@ pgp_encrypt (CamelCipherContext *ctx, gboolean sign, const char *userid, GPtrArr passphrase = pgp_get_passphrase (ctx->session, context->priv->type, (char *) userid); if (!passphrase) { - camel_exception_set (ex, CAMEL_EXCEPTION_SYSTEM, + camel_exception_set (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cannot encrypt this message: no password provided")); goto exception; } @@ -1262,7 +1262,7 @@ pgp_decrypt (CamelCipherContext *ctx, CamelStream *istream, passphrase = pgp_get_passphrase (ctx->session, context->priv->type, NULL); if (!passphrase) { - camel_exception_setv (ex, CAMEL_EXCEPTION_SYSTEM, + camel_exception_setv (ex, CAMEL_EXCEPTION_USER_CANCEL, _("Cannot decrypt this message: no password provided")); goto exception; diff --git a/camel/camel-tcp-stream-openssl.c b/camel/camel-tcp-stream-openssl.c index 2702cd249b..3271754fd7 100644 --- a/camel/camel-tcp-stream-openssl.c +++ b/camel/camel-tcp-stream-openssl.c @@ -170,22 +170,23 @@ static void errlib_error_to_errno (int ret) { long error; - - error = ERR_get_error(); + + error = ERR_get_error (); if (error == 0) { if (ret == 0) errno = EINVAL; /* unexpected EOF */ /* otherwise errno should be set */ - } else + } else { /* ok, we get the shaft now. */ - errno = EIO; -} + errno = EINTR; + } +} static void ssl_error_to_errno (CamelTcpStreamOpenSSL *stream, int ret) { /* hm, a CamelException might be useful right about now! */ - + switch (SSL_get_error (stream->priv->ssl, ret)) { case SSL_ERROR_NONE: errno = 0; @@ -217,7 +218,7 @@ stream_read (CamelStream *stream, char *buffer, size_t n) if (camel_operation_cancel_check (NULL)) { errno = EINTR; - return -1; + return -1; } cancel_fd = camel_operation_cancel_fd (NULL); @@ -231,19 +232,19 @@ stream_read (CamelStream *stream, char *buffer, size_t n) flags = fcntl (tcp_stream_openssl->priv->sockfd, F_GETFL); fcntl (tcp_stream_openssl->priv->sockfd, F_SETFL, flags | O_NONBLOCK); - + do { nread = SSL_read (tcp_stream_openssl->priv->ssl, buffer, n); - + if (nread == 0) return nread; - + if (nread == -1 && errno == EAGAIN) { FD_ZERO (&rdset); FD_SET (tcp_stream_openssl->priv->sockfd, &rdset); FD_SET (cancel_fd, &rdset); fdmax = MAX (tcp_stream_openssl->priv->sockfd, cancel_fd) + 1; - + select (fdmax, &rdset, 0, 0, NULL); if (FD_ISSET (cancel_fd, &rdset)) { fcntl (tcp_stream_openssl->priv->sockfd, F_SETFL, flags); @@ -252,13 +253,13 @@ stream_read (CamelStream *stream, char *buffer, size_t n) } } } while (nread == -1 && errno == EAGAIN); - + fcntl (tcp_stream_openssl->priv->sockfd, F_SETFL, flags); } - + if (nread == -1) ssl_error_to_errno (tcp_stream_openssl, -1); - + return nread; } @@ -271,7 +272,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) if (camel_operation_cancel_check (NULL)) { errno = EINTR; - return -1; + return -1; } cancel_fd = camel_operation_cancel_fd (NULL); @@ -310,7 +311,7 @@ stream_write (CamelStream *stream, const char *buffer, size_t n) if (written == -1) ssl_error_to_errno (tcp_stream_openssl, -1); - + return written; } @@ -441,24 +442,25 @@ socket_connect (struct hostent *h, int port) static int ssl_verify (int ok, X509_STORE_CTX *ctx) { - SSL *ssl; CamelTcpStreamOpenSSL *stream; + CamelService *service; X509 *cert; + SSL *ssl; int err; - - ssl = X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx()); + + ssl = X509_STORE_CTX_get_ex_data (ctx, SSL_get_ex_data_X509_STORE_CTX_idx ()); stream = SSL_CTX_get_app_data (ssl->ctx); + service = stream ? stream->priv->service : NULL; cert = X509_STORE_CTX_get_current_cert (ctx); err = X509_STORE_CTX_get_error (ctx); - if (!ok && stream) { - CamelService *service = stream->priv->service; + if (!ok && stream && camel_session_is_interactive (service->session)) { char *prompt, *cert_str; char buf[257]; -#define GET_STRING(name) X509_NAME_oneline(name, buf, 256) +#define GET_STRING(name) X509_NAME_oneline (name, buf, 256) cert_str = g_strdup_printf (_("Issuer: %s\n" "Subject: %s"), |