aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-tcp-stream-openssl.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-09-24 06:41:54 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-09-24 06:41:54 +0800
commit1df3e6787e2c30adae410e1eda36907b578a4240 (patch)
tree1cca2ced9c319a0231e3d9d267458321104ec4be /camel/camel-tcp-stream-openssl.c
parenta02d89a2b723561eaea9a509d1da094a1af67b41 (diff)
downloadgsoc2013-evolution-1df3e6787e2c30adae410e1eda36907b578a4240.tar.gz
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/camel-tcp-stream-openssl.c')
-rw-r--r--camel/camel-tcp-stream-openssl.c46
1 files changed, 24 insertions, 22 deletions
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"),