Make OpenSSL a mandatory requirement
There is no point in having SSL/TLS IMAP support as optional, it's as useful if not more than the the non-encrypted connections. The Makefile was better organized to make it easier to change some options during compile. The SHAREDIR variable passed as configuration option has changed name.
This commit is contained in:
parent
820e9db522
commit
e907fe5fdf
2
Makefile
2
Makefile
|
@ -1,2 +1,2 @@
|
||||||
all nossl install uninstall clean:
|
all install uninstall clean:
|
||||||
cd src && $(MAKE) $@
|
cd src && $(MAKE) $@
|
||||||
|
|
2
README
2
README
|
@ -26,7 +26,7 @@ Changes
|
||||||
Installation
|
Installation
|
||||||
|
|
||||||
Compile time requirements are Lua (version 5.2 or 5.1), the PCRE library, and
|
Compile time requirements are Lua (version 5.2 or 5.1), the PCRE library, and
|
||||||
optionally the OpenSSL library (for SSL/TLS and CRAM-MD5 support).
|
the OpenSSL library.
|
||||||
|
|
||||||
Compile and install the program:
|
Compile and install the program:
|
||||||
|
|
||||||
|
|
22
src/Makefile
22
src/Makefile
|
@ -4,9 +4,21 @@ BINDIR = $(PREFIX)/bin
|
||||||
SHAREDIR = $(PREFIX)/share/imapfilter
|
SHAREDIR = $(PREFIX)/share/imapfilter
|
||||||
MANDIR = $(PREFIX)/man
|
MANDIR = $(PREFIX)/man
|
||||||
|
|
||||||
CFLAGS = -Wall -O -DMAKEFILE_SHAREDIR='"$(SHAREDIR)"'
|
MYCFLAGS =
|
||||||
LDFLAGS =
|
MYLDFLAGS =
|
||||||
LIBS = -lm -llua -lpcre -lssl -lcrypto
|
MYLIBS =
|
||||||
|
|
||||||
|
INCDIRS =
|
||||||
|
LIBDIRS =
|
||||||
|
|
||||||
|
LIBLUA = -llua
|
||||||
|
LIBPCRE = -lpcre
|
||||||
|
LIBSSL = -lssl
|
||||||
|
LIBCRYPTO = -lcrypto
|
||||||
|
|
||||||
|
CFLAGS = -Wall -O -DCONFIG_SHAREDIR='"$(SHAREDIR)"' $(INCDIRS) $(MYCFLAGS)
|
||||||
|
LDFLAGS = $(LIBDIRS) $(MYLDFLAGS)
|
||||||
|
LIBS = -lm $(LIBLUA) $(LIBPCRE) $(LIBSSL) $(LIBCRYPTO) $(MYLIBS)
|
||||||
|
|
||||||
MAN1 = imapfilter.1
|
MAN1 = imapfilter.1
|
||||||
MAN5 = imapfilter_config.5
|
MAN5 = imapfilter_config.5
|
||||||
|
@ -21,10 +33,6 @@ OBJ = auth.o buffer.o cert.o core.o file.o imapfilter.o list.o log.o lua.o \
|
||||||
|
|
||||||
all: $(BIN)
|
all: $(BIN)
|
||||||
|
|
||||||
nossl:
|
|
||||||
$(MAKE) $(BIN) CFLAGS="-Wall -O -DMAKEFILE_SHAREDIR='\"$(SHAREDIR)\"' \
|
|
||||||
-DNO_SSLTLS -DNO_CRAMMD5" LIBS="-lm -llua -lpcre"
|
|
||||||
|
|
||||||
$(BIN): $(OBJ)
|
$(BIN): $(OBJ)
|
||||||
$(CC) -o $(BIN) $(LDFLAGS) $(OBJ) $(LIBS)
|
$(CC) -o $(BIN) $(LDFLAGS) $(OBJ) $(LIBS)
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "imapfilter.h"
|
|
||||||
|
|
||||||
#ifndef NO_CRAMMD5
|
|
||||||
#include <openssl/hmac.h>
|
#include <openssl/hmac.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
|
#include "imapfilter.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Authenticate to the server with the Challenge-Response Authentication
|
* Authenticate to the server with the Challenge-Response Authentication
|
||||||
|
@ -57,4 +56,3 @@ auth_cram_md5(const char *user, const char *pass, unsigned char *chal)
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
#endif /* NO_CRAMMD5 */
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -7,14 +5,14 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "imapfilter.h"
|
|
||||||
#include "session.h"
|
|
||||||
|
|
||||||
#include <openssl/x509.h>
|
#include <openssl/x509.h>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/pem.h>
|
#include <openssl/pem.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
|
#include "imapfilter.h"
|
||||||
|
#include "session.h"
|
||||||
|
|
||||||
|
|
||||||
extern environment env;
|
extern environment env;
|
||||||
|
|
||||||
|
@ -207,4 +205,3 @@ mismatch_cert(void)
|
||||||
else
|
else
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* NO_SSLTLS */
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
|
@ -7,6 +7,9 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
|
#include <openssl/ssl.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
|
||||||
#include "imapfilter.h"
|
#include "imapfilter.h"
|
||||||
#include "session.h"
|
#include "session.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
|
@ -15,11 +18,6 @@
|
||||||
#include "pathnames.h"
|
#include "pathnames.h"
|
||||||
#include "regexp.h"
|
#include "regexp.h"
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
#include <openssl/ssl.h>
|
|
||||||
#include <openssl/err.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
extern buffer ibuf, obuf, nbuf, cbuf;
|
extern buffer ibuf, obuf, nbuf, cbuf;
|
||||||
extern regexp responses[];
|
extern regexp responses[];
|
||||||
|
@ -100,10 +98,8 @@ main(int argc, char *argv[])
|
||||||
|
|
||||||
regexp_compile(responses);
|
regexp_compile(responses);
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
SSL_library_init();
|
SSL_library_init();
|
||||||
SSL_load_error_strings();
|
SSL_load_error_strings();
|
||||||
#endif
|
|
||||||
|
|
||||||
start_lua();
|
start_lua();
|
||||||
#if LUA_VERSION_NUM < 502
|
#if LUA_VERSION_NUM < 502
|
||||||
|
@ -122,9 +118,7 @@ main(int argc, char *argv[])
|
||||||
#endif
|
#endif
|
||||||
stop_lua();
|
stop_lua();
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
ERR_free_strings();
|
ERR_free_strings();
|
||||||
#endif
|
|
||||||
|
|
||||||
regexp_free(responses);
|
regexp_free(responses);
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
#include <lua.h>
|
#include <lua.h>
|
||||||
#include <lualib.h>
|
#include <lualib.h>
|
||||||
|
|
||||||
#include "session.h"
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#endif
|
|
||||||
|
#include "session.h"
|
||||||
|
|
||||||
|
|
||||||
/* Fatal error exit codes. */
|
/* Fatal error exit codes. */
|
||||||
|
@ -79,15 +77,11 @@ typedef struct environment {
|
||||||
|
|
||||||
|
|
||||||
/* auth.c */
|
/* auth.c */
|
||||||
#ifndef NO_CRAMMD5
|
|
||||||
unsigned char *auth_cram_md5(const char *user, const char *pass,
|
unsigned char *auth_cram_md5(const char *user, const char *pass,
|
||||||
unsigned char *chal);
|
unsigned char *chal);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* cert.c */
|
/* cert.c */
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
int get_cert(session *ssn);
|
int get_cert(session *ssn);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* core.c */
|
/* core.c */
|
||||||
LUALIB_API int luaopen_ifcore(lua_State *lua);
|
LUALIB_API int luaopen_ifcore(lua_State *lua);
|
||||||
|
@ -218,12 +212,10 @@ int close_connection(session *ssn);
|
||||||
ssize_t socket_read(session *ssn, char *buf, size_t len, long timeout,
|
ssize_t socket_read(session *ssn, char *buf, size_t len, long timeout,
|
||||||
int timeoutfail);
|
int timeoutfail);
|
||||||
ssize_t socket_write(session *ssn, const char *buf, size_t len);
|
ssize_t socket_write(session *ssn, const char *buf, size_t len);
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
int open_secure_connection(session *ssn);
|
int open_secure_connection(session *ssn);
|
||||||
int close_secure_connection(session *ssn);
|
int close_secure_connection(session *ssn);
|
||||||
ssize_t socket_secure_read(session *ssn, char *buf, size_t len);
|
ssize_t socket_secure_read(session *ssn, char *buf, size_t len);
|
||||||
ssize_t socket_secure_write(session *ssn, const char *buf, size_t len);
|
ssize_t socket_secure_write(session *ssn, const char *buf, size_t len);
|
||||||
#endif
|
|
||||||
|
|
||||||
/* system.c */
|
/* system.c */
|
||||||
LUALIB_API int luaopen_ifsys(lua_State *lua);
|
LUALIB_API int luaopen_ifsys(lua_State *lua);
|
||||||
|
|
|
@ -3,28 +3,28 @@
|
||||||
|
|
||||||
|
|
||||||
/* Lua imapfilter set functions file. */
|
/* Lua imapfilter set functions file. */
|
||||||
#define PATHNAME_COMMON MAKEFILE_SHAREDIR "/common.lua"
|
#define PATHNAME_COMMON CONFIG_SHAREDIR "/common.lua"
|
||||||
|
|
||||||
/* Lua imapfilter set functions file. */
|
/* Lua imapfilter set functions file. */
|
||||||
#define PATHNAME_SET MAKEFILE_SHAREDIR "/set.lua"
|
#define PATHNAME_SET CONFIG_SHAREDIR "/set.lua"
|
||||||
|
|
||||||
/* Lua imapfilter account functions file. */
|
/* Lua imapfilter account functions file. */
|
||||||
#define PATHNAME_ACCOUNT MAKEFILE_SHAREDIR "/account.lua"
|
#define PATHNAME_ACCOUNT CONFIG_SHAREDIR "/account.lua"
|
||||||
|
|
||||||
/* Lua imapfilter mailbox functions file. */
|
/* Lua imapfilter mailbox functions file. */
|
||||||
#define PATHNAME_MAILBOX MAKEFILE_SHAREDIR "/mailbox.lua"
|
#define PATHNAME_MAILBOX CONFIG_SHAREDIR "/mailbox.lua"
|
||||||
|
|
||||||
/* Lua imapfilter message functions file. */
|
/* Lua imapfilter message functions file. */
|
||||||
#define PATHNAME_MESSAGE MAKEFILE_SHAREDIR "/message.lua"
|
#define PATHNAME_MESSAGE CONFIG_SHAREDIR "/message.lua"
|
||||||
|
|
||||||
/* Lua imapfilter message functions file. */
|
/* Lua imapfilter message functions file. */
|
||||||
#define PATHNAME_OPTIONS MAKEFILE_SHAREDIR "/options.lua"
|
#define PATHNAME_OPTIONS CONFIG_SHAREDIR "/options.lua"
|
||||||
|
|
||||||
/* Lua imapfilter regex functions file. */
|
/* Lua imapfilter regex functions file. */
|
||||||
#define PATHNAME_REGEX MAKEFILE_SHAREDIR "/regex.lua"
|
#define PATHNAME_REGEX CONFIG_SHAREDIR "/regex.lua"
|
||||||
|
|
||||||
/* Lua imapfilter auxiliary functions file. */
|
/* Lua imapfilter auxiliary functions file. */
|
||||||
#define PATHNAME_AUXILIARY MAKEFILE_SHAREDIR "/auxiliary.lua"
|
#define PATHNAME_AUXILIARY CONFIG_SHAREDIR "/auxiliary.lua"
|
||||||
|
|
||||||
|
|
||||||
#endif /* PATHNAMES_H */
|
#endif /* PATHNAMES_H */
|
||||||
|
|
|
@ -181,7 +181,6 @@ request_login(session **ssnptr, const char *server, const char *port, const
|
||||||
if (response_capability(ssn, t) == -1)
|
if (response_capability(ssn, t) == -1)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
if (!ssn->ssl && ssn->capabilities & CAPABILITY_STARTTLS &&
|
if (!ssn->ssl && ssn->capabilities & CAPABILITY_STARTTLS &&
|
||||||
get_option_boolean("starttls")) {
|
get_option_boolean("starttls")) {
|
||||||
t = send_request(ssn, "STARTTLS");
|
t = send_request(ssn, "STARTTLS");
|
||||||
|
@ -198,10 +197,8 @@ request_login(session **ssnptr, const char *server, const char *port, const
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
if (rg != STATUS_PREAUTH) {
|
if (rg != STATUS_PREAUTH) {
|
||||||
#ifndef NO_CRAMMD5
|
|
||||||
if (ssn->capabilities & CAPABILITY_CRAMMD5 &&
|
if (ssn->capabilities & CAPABILITY_CRAMMD5 &&
|
||||||
get_option_boolean("crammd5")) {
|
get_option_boolean("crammd5")) {
|
||||||
unsigned char *in, *out;
|
unsigned char *in, *out;
|
||||||
|
@ -221,7 +218,6 @@ request_login(session **ssnptr, const char *server, const char *port, const
|
||||||
} else
|
} else
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
if (r != STATUS_OK) {
|
if (r != STATUS_OK) {
|
||||||
t = send_request(ssn, "LOGIN \"%s\" \"%s\"",
|
t = send_request(ssn, "LOGIN \"%s\" \"%s\"",
|
||||||
ssn->username, ssn->password);
|
ssn->username, ssn->password);
|
||||||
|
|
|
@ -320,14 +320,10 @@ response_capability(session *ssn, int tag)
|
||||||
|
|
||||||
if (xstrcasestr(s, "NAMESPACE"))
|
if (xstrcasestr(s, "NAMESPACE"))
|
||||||
ssn->capabilities |= CAPABILITY_NAMESPACE;
|
ssn->capabilities |= CAPABILITY_NAMESPACE;
|
||||||
#ifndef NO_CRAMMD5
|
|
||||||
if (xstrcasestr(s, "AUTH=CRAM-MD5"))
|
if (xstrcasestr(s, "AUTH=CRAM-MD5"))
|
||||||
ssn->capabilities |= CAPABILITY_CRAMMD5;
|
ssn->capabilities |= CAPABILITY_CRAMMD5;
|
||||||
#endif
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
if (xstrcasestr(s, "STARTTLS"))
|
if (xstrcasestr(s, "STARTTLS"))
|
||||||
ssn->capabilities |= CAPABILITY_STARTTLS;
|
ssn->capabilities |= CAPABILITY_STARTTLS;
|
||||||
#endif
|
|
||||||
if (xstrcasestr(s, "CHILDREN"))
|
if (xstrcasestr(s, "CHILDREN"))
|
||||||
ssn->capabilities |= CAPABILITY_CHILDREN;
|
ssn->capabilities |= CAPABILITY_CHILDREN;
|
||||||
|
|
||||||
|
@ -341,7 +337,6 @@ response_capability(session *ssn, int tag)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_CRAMMD5
|
|
||||||
/*
|
/*
|
||||||
* Process the data that server sent due to IMAP AUTHENTICATE client request.
|
* Process the data that server sent due to IMAP AUTHENTICATE client request.
|
||||||
*/
|
*/
|
||||||
|
@ -361,7 +356,6 @@ response_authenticate(session *ssn, int tag, unsigned char **cont)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -41,9 +41,7 @@ session_init(session *ssn)
|
||||||
ssn->username = NULL;
|
ssn->username = NULL;
|
||||||
ssn->password = NULL;
|
ssn->password = NULL;
|
||||||
ssn->socket = -1;
|
ssn->socket = -1;
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
ssn->sslsocket = NULL;
|
ssn->sslsocket = NULL;
|
||||||
#endif
|
|
||||||
ssn->protocol = PROTOCOL_NONE;
|
ssn->protocol = PROTOCOL_NONE;
|
||||||
ssn->capabilities = CAPABILITY_NONE;
|
ssn->capabilities = CAPABILITY_NONE;
|
||||||
ssn->ns.prefix = NULL;
|
ssn->ns.prefix = NULL;
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#define SESSION_H
|
#define SESSION_H
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* IMAP session. */
|
/* IMAP session. */
|
||||||
|
@ -15,9 +13,7 @@ typedef struct session {
|
||||||
const char *username; /* User name. */
|
const char *username; /* User name. */
|
||||||
const char *password; /* User password. */
|
const char *password; /* User password. */
|
||||||
int socket; /* Socket. */
|
int socket; /* Socket. */
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
SSL *sslsocket; /* SSL socket. */
|
SSL *sslsocket; /* SSL socket. */
|
||||||
#endif
|
|
||||||
unsigned int protocol; /* IMAP protocol. Currently IMAP4rev1 and
|
unsigned int protocol; /* IMAP protocol. Currently IMAP4rev1 and
|
||||||
* IMAP4 are supported. */
|
* IMAP4 are supported. */
|
||||||
unsigned int capabilities; /* Capabilities of the mail server. */
|
unsigned int capabilities; /* Capabilities of the mail server. */
|
||||||
|
|
37
src/socket.c
37
src/socket.c
|
@ -10,13 +10,11 @@
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/select.h>
|
#include <sys/select.h>
|
||||||
|
|
||||||
#include "imapfilter.h"
|
|
||||||
#include "session.h"
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
#endif
|
|
||||||
|
#include "imapfilter.h"
|
||||||
|
#include "session.h"
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -28,13 +26,6 @@ open_connection(session *ssn)
|
||||||
struct addrinfo hints, *res, *ressave;
|
struct addrinfo hints, *res, *ressave;
|
||||||
int n, sockfd;
|
int n, sockfd;
|
||||||
|
|
||||||
#ifdef NO_SSLTLS
|
|
||||||
if (ssn->ssl) {
|
|
||||||
error("SSL not supported by this build\n");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
memset(&hints, 0, sizeof(struct addrinfo));
|
memset(&hints, 0, sizeof(struct addrinfo));
|
||||||
|
|
||||||
hints.ai_family = AF_UNSPEC;
|
hints.ai_family = AF_UNSPEC;
|
||||||
|
@ -75,20 +66,17 @@ open_connection(session *ssn)
|
||||||
|
|
||||||
ssn->socket = sockfd;
|
ssn->socket = sockfd;
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
if (ssn->ssl) {
|
if (ssn->ssl) {
|
||||||
if (open_secure_connection(ssn) == -1) {
|
if (open_secure_connection(ssn) == -1) {
|
||||||
close_connection(ssn);
|
close_connection(ssn);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return ssn->socket;
|
return ssn->socket;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
/*
|
/*
|
||||||
* Initialize SSL/TLS connection.
|
* Initialize SSL/TLS connection.
|
||||||
*/
|
*/
|
||||||
|
@ -166,7 +154,6 @@ fail:
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif /* NO_SSLTLS */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -179,9 +166,7 @@ close_connection(session *ssn)
|
||||||
|
|
||||||
r = 0;
|
r = 0;
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
close_secure_connection(ssn);
|
close_secure_connection(ssn);
|
||||||
#endif
|
|
||||||
|
|
||||||
if (ssn->socket != -1) {
|
if (ssn->socket != -1) {
|
||||||
r = close(ssn->socket);
|
r = close(ssn->socket);
|
||||||
|
@ -194,7 +179,6 @@ close_connection(session *ssn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
/*
|
/*
|
||||||
* Shutdown SSL/TLS connection.
|
* Shutdown SSL/TLS connection.
|
||||||
*/
|
*/
|
||||||
|
@ -210,7 +194,6 @@ close_secure_connection(session *ssn)
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -242,7 +225,6 @@ socket_read(session *ssn, char *buf, size_t len, long timeout, int timeoutfail)
|
||||||
FD_ZERO(&fds);
|
FD_ZERO(&fds);
|
||||||
FD_SET(ssn->socket, &fds);
|
FD_SET(ssn->socket, &fds);
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
if (ssn->sslsocket) {
|
if (ssn->sslsocket) {
|
||||||
if (SSL_pending(ssn->sslsocket) > 0 ||
|
if (SSL_pending(ssn->sslsocket) > 0 ||
|
||||||
((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
|
((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
|
||||||
|
@ -252,9 +234,7 @@ socket_read(session *ssn, char *buf, size_t len, long timeout, int timeoutfail)
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
if ((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
|
if ((s = select(ssn->socket + 1, &fds, NULL, NULL, tvp)) > 0 &&
|
||||||
FD_ISSET(ssn->socket, &fds)) {
|
FD_ISSET(ssn->socket, &fds)) {
|
||||||
r = read(ssn->socket, buf, len);
|
r = read(ssn->socket, buf, len);
|
||||||
|
@ -285,7 +265,6 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
/*
|
/*
|
||||||
* Read data from a TLS/SSL connection.
|
* Read data from a TLS/SSL connection.
|
||||||
*/
|
*/
|
||||||
|
@ -332,7 +311,6 @@ socket_secure_read(session *ssn, char *buf, size_t len)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -354,15 +332,12 @@ socket_write(session *ssn, const char *buf, size_t len)
|
||||||
while (len) {
|
while (len) {
|
||||||
if ((s = select(ssn->socket + 1, NULL, &fds, NULL, NULL) > 0 &&
|
if ((s = select(ssn->socket + 1, NULL, &fds, NULL, NULL) > 0 &&
|
||||||
FD_ISSET(ssn->socket, &fds))) {
|
FD_ISSET(ssn->socket, &fds))) {
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
if (ssn->sslsocket) {
|
if (ssn->sslsocket) {
|
||||||
r = socket_secure_write(ssn, buf, len);
|
r = socket_secure_write(ssn, buf, len);
|
||||||
|
|
||||||
if (r <= 0)
|
if (r <= 0)
|
||||||
goto fail;
|
goto fail;
|
||||||
} else
|
} else {
|
||||||
#endif
|
|
||||||
{
|
|
||||||
r = write(ssn->socket, buf, len);
|
r = write(ssn->socket, buf, len);
|
||||||
|
|
||||||
if (r == -1) {
|
if (r == -1) {
|
||||||
|
@ -398,7 +373,6 @@ fail:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifndef NO_SSLTLS
|
|
||||||
/*
|
/*
|
||||||
* Write data to a TLS/SSL connection.
|
* Write data to a TLS/SSL connection.
|
||||||
*/
|
*/
|
||||||
|
@ -445,4 +419,3 @@ socket_secure_write(session *ssn, const char *buf, size_t len)
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
Loading…
Reference in New Issue