From 82efb83295af6712b5fdbf0ecb6ddee0c8a12b21 Mon Sep 17 00:00:00 2001 From: Perry Werneck Date: Mon, 28 Jan 2019 14:50:58 -0200 Subject: [PATCH] Working on LDAP support for windows. --- lib3270.cbp | 6 +++--- src/lib3270/linux/connect.c | 5 ++++- src/lib3270/ssl/negotiate.c | 4 +--- src/lib3270/ssl/windows/getcrl.c | 17 +++++++++++++++-- src/lib3270/windows/connect.c | 13 ++++++------- 5 files changed, 29 insertions(+), 16 deletions(-) diff --git a/lib3270.cbp b/lib3270.cbp index af465ad..431c23f 100644 --- a/lib3270.cbp +++ b/lib3270.cbp @@ -139,15 +139,15 @@ - - + + diff --git a/src/lib3270/linux/connect.c b/src/lib3270/linux/connect.c index a4fbbfb..cdbec03 100644 --- a/src/lib3270/linux/connect.c +++ b/src/lib3270/linux/connect.c @@ -246,7 +246,10 @@ static void net_connected(H3270 *hSession, int fd unused, LIB3270_IO_FLAG flag u if(hSession->ssl.enabled) { hSession->ssl.host = 1; - ssl_init(hSession); + + if(ssl_init(hSession)) + return errno = ENOTCONN; + } debug("** SSL init %s","ends"); #endif // HAVE_LIBSSL diff --git a/src/lib3270/ssl/negotiate.c b/src/lib3270/ssl/negotiate.c index a32e27d..3b992ed 100644 --- a/src/lib3270/ssl/negotiate.c +++ b/src/lib3270/ssl/negotiate.c @@ -18,14 +18,12 @@ * programa; se não, escreva para a Free Software Foundation, Inc., 51 Franklin * St, Fifth Floor, Boston, MA 02110-1301 USA * - * Este programa está nomeado como ssl.c e possui - linhas de código. + * Este programa está nomeado como - e possui - linhas de código. * * Contatos: * * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) * erico.mendonca@gmail.com (Erico Mascarenhas Mendonça) - * licinio@bb.com.br (Licínio Luis Branco) - * kraucer@bb.com.br (Kraucer Fernandes Mazuco) * * * References: diff --git a/src/lib3270/ssl/windows/getcrl.c b/src/lib3270/ssl/windows/getcrl.c index 686c498..2666e72 100644 --- a/src/lib3270/ssl/windows/getcrl.c +++ b/src/lib3270/ssl/windows/getcrl.c @@ -79,6 +79,7 @@ typedef struct _curldata { size_t length; SSL_ERROR_MESSAGE * message; + char errbuf[CURL_ERROR_SIZE]; unsigned char contents[CRL_DATA_LENGTH]; } CURLDATA; @@ -188,6 +189,8 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) curl_easy_setopt(hCurl, CURLOPT_URL, consturl); curl_easy_setopt(hCurl, CURLOPT_FOLLOWLOCATION, 1L); + curl_easy_setopt(hCurl, CURLOPT_ERRORBUFFER, crl_data); + curl_easy_setopt(hCurl, CURLOPT_WRITEFUNCTION, internal_curl_write_callback); curl_easy_setopt(hCurl, CURLOPT_WRITEDATA, (void *) crl_data); @@ -197,8 +200,18 @@ X509_CRL * lib3270_get_X509_CRL(H3270 *hSession, SSL_ERROR_MESSAGE * message) { message->error = hSession->ssl.error = 0; message->title = N_( "Security error" ); - message->text = N_( "Error loading CRL" ); - message->description = curl_easy_strerror(res); + + if(crl_data->errbuf[0]) + { + message->text = curl_easy_strerror(res); + message->description = crl_data->errbuf; + } + else + { + message->text = N_( "Error loading CRL" ); + message->description = curl_easy_strerror(res); + } + lib3270_write_log(hSession,"ssl","%s: %s",consturl, message->description); return NULL; } diff --git a/src/lib3270/windows/connect.c b/src/lib3270/windows/connect.c index 6b7574f..8c84fff 100644 --- a/src/lib3270/windows/connect.c +++ b/src/lib3270/windows/connect.c @@ -249,14 +249,11 @@ int lib3270_reconnect(H3270 *hSession, int seconds) lib3270_st_changed(hSession, LIB3270_STATE_RESOLVING, True); - // s = getaddrinfo(hSession->host.current, hSession->host.srvc, &hints, &result); if(lib3270_run_task(hSession, background_connect, &host) || hSession->sock < 0) { - char buffer[4096]; - char msg[4096]; - - snprintf(buffer,4095,_( "Can't connect to %s"), lib3270_get_url(hSession)); + lib3270_autoptr(char) message = lib3270_strdup_printf(_( "Can't connect to %s"), lib3270_get_url(hSession)); + char msg[4096]; strncpy(msg,host.message,4095); #ifdef HAVE_ICONV @@ -283,7 +280,7 @@ int lib3270_reconnect(H3270 *hSession, int seconds) lib3270_popup_dialog( hSession, LIB3270_NOTIFY_ERROR, _( "Connection error" ), - buffer, + message, "%s", msg); @@ -298,7 +295,9 @@ int lib3270_reconnect(H3270 *hSession, int seconds) if(hSession->ssl.enabled) { hSession->ssl.host = 1; - ssl_init(hSession); + if(ssl_init(hSession)) + return errno = ENOTCONN; + } #endif // HAVE_LIBSSL -- libgit2 0.21.2