Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commit 82add47a authored by deuce's avatar deuce

More log fixes.

parent b30d0d72
......@@ -1737,7 +1737,7 @@ static void receive_thread(void* arg)
if (*xfer.data_sess != -1) {
int status = cryptPopData(*xfer.data_sess, buf, sizeof(buf), &rd);
if (status != CRYPT_OK) {
GCES(status, *xfer.data_sock, *xfer.data_sess, estr, "flushing data");
GCES(status, *xfer.data_sock, *xfer.data_sess, estr, "popping data");
rd = -1;
}
}
......
......@@ -328,6 +328,7 @@ public:
char local_addr[INET6_ADDRSTRLEN];
#ifdef USE_CRYPTLIB
CRYPT_SESSION ssh_session;
int session_channel;
bool ssh_mode;
SOCKET passthru_socket;
bool passthru_output_thread_running;
......
......@@ -566,11 +566,11 @@ static int writebuf(http_session_t *session, const char *buf, size_t len)
return(sent);
}
#define HANDLE_CRYPT_CALL(status, session) handle_crypt_call_except2(status, session, CRYPT_OK, CRYPT_OK, __FILE__, __LINE__)
#define HANDLE_CRYPT_CALL_EXCEPT(status, ignore, session) handle_crypt_call_except2(status, session, ignore, ignore, __FILE__, __LINE__)
#define HANDLE_CRYPT_CALL_EXCEPT2(status, ignore, ignore2, session) handle_crypt_call_except2(status, session, ignore, ignore2, __FILE__, __LINE__)
#define HANDLE_CRYPT_CALL(status, session, action) handle_crypt_call_except2(status, session, action, CRYPT_OK, CRYPT_OK, __FILE__, __LINE__)
#define HANDLE_CRYPT_CALL_EXCEPT(status, session, action, ignore) handle_crypt_call_except2(status, session, action, ignore, ignore, __FILE__, __LINE__)
#define HANDLE_CRYPT_CALL_EXCEPT2(status, session, action, ignore, ignore2) handle_crypt_call_except2(status, session, action, ignore, ignore2, __FILE__, __LINE__)
static BOOL handle_crypt_call_except2(int status, http_session_t *session, int ignore, int ignore2, const char *file, int line)
static BOOL handle_crypt_call_except2(int status, http_session_t *session, const char *action, int ignore, int ignore2, const char *file, int line)
{
if (status == CRYPT_OK)
return TRUE;
......@@ -578,7 +578,7 @@ static BOOL handle_crypt_call_except2(int status, http_session_t *session, int i
return FALSE;
if (status == ignore2)
return FALSE;
GCES(status, session, "popping data after timeout");
GCES(status, session, action);
return FALSE;
}
......@@ -637,8 +637,8 @@ static int sess_sendbuf(http_session_t *session, const char *buf, size_t len, BO
}
status = CRYPT_OK;
}
if(!HANDLE_CRYPT_CALL(status, session)) {
HANDLE_CRYPT_CALL_EXCEPT(cryptFlushData(session->tls_sess), CRYPT_ERROR_COMPLETE, session);
if(cryptStatusOK(status)) {
HANDLE_CRYPT_CALL_EXCEPT(cryptFlushData(session->tls_sess), session, "flushing data", CRYPT_ERROR_COMPLETE);
if (failed)
*failed=TRUE;
return tls_sent;
......@@ -680,7 +680,7 @@ static int sess_sendbuf(http_session_t *session, const char *buf, size_t len, BO
if(failed && sent<len)
*failed=TRUE;
if(session->is_tls)
HANDLE_CRYPT_CALL(cryptFlushData(session->tls_sess), session);
HANDLE_CRYPT_CALL(cryptFlushData(session->tls_sess), session, "flushing data");
return(sent);
}
......@@ -1002,7 +1002,7 @@ static int close_session_socket(http_session_t *session)
SLEEP(1);
}
pthread_mutex_unlock(&session->outbuf_write);
HANDLE_CRYPT_CALL(cryptDestroySession(session->tls_sess), session);
HANDLE_CRYPT_CALL(cryptDestroySession(session->tls_sess), session, "destroying session");
}
return close_socket(&session->socket);
}
......@@ -2001,7 +2001,7 @@ static int sess_recv(http_session_t *session, char *buf, size_t length, int flag
buf[0] = session->peeked;
return 1;
}
if (HANDLE_CRYPT_CALL_EXCEPT2(cryptPopData(session->tls_sess, &session->peeked, 1, &len), CRYPT_ERROR_TIMEOUT, CRYPT_ERROR_COMPLETE, session)) {
if (HANDLE_CRYPT_CALL_EXCEPT2(cryptPopData(session->tls_sess, &session->peeked, 1, &len), session, "popping data", CRYPT_ERROR_TIMEOUT, CRYPT_ERROR_COMPLETE)) {
if (len == 1) {
session->peeked_valid = TRUE;
buf[0] = session->peeked;
......@@ -2017,7 +2017,7 @@ static int sess_recv(http_session_t *session, char *buf, size_t length, int flag
session->peeked_valid = FALSE;
return 1;
}
if (HANDLE_CRYPT_CALL_EXCEPT2(cryptPopData(session->tls_sess, buf, length, &len), CRYPT_ERROR_TIMEOUT, CRYPT_ERROR_COMPLETE, session)) {
if (HANDLE_CRYPT_CALL_EXCEPT2(cryptPopData(session->tls_sess, buf, length, &len), session, "popping data", CRYPT_ERROR_TIMEOUT, CRYPT_ERROR_COMPLETE)) {
if (len == 0) {
session->tls_pending = FALSE;
len = -1;
......@@ -6157,7 +6157,7 @@ static int close_session_no_rb(http_session_t *session)
{
if (session) {
if (session->is_tls)
HANDLE_CRYPT_CALL(cryptDestroySession(session->tls_sess), session);
HANDLE_CRYPT_CALL(cryptDestroySession(session->tls_sess), session, "destroying session");
return close_socket(&session->socket);
}
return 0;
......@@ -6208,7 +6208,7 @@ void http_session_thread(void* arg)
if (session.is_tls) {
/* Create and initialize the TLS session */
if (!HANDLE_CRYPT_CALL(cryptCreateSession(&session.tls_sess, CRYPT_UNUSED, CRYPT_SESSION_SSL_SERVER), &session)) {
if (!HANDLE_CRYPT_CALL(cryptCreateSession(&session.tls_sess, CRYPT_UNUSED, CRYPT_SESSION_SSL_SERVER), &session, "creating session")) {
close_session_no_rb(&session);
thread_down();
return;
......@@ -6222,25 +6222,25 @@ void http_session_thread(void* arg)
if(user.misc&(DELETED|INACTIVE))
continue;
if (user.alias[0] && user.pass[0]) {
if(HANDLE_CRYPT_CALL(cryptSetAttributeString(session.tls_sess, CRYPT_SESSINFO_USERNAME, user.alias, strlen(user.alias)), &session))
HANDLE_CRYPT_CALL(cryptSetAttributeString(session.tls_sess, CRYPT_SESSINFO_PASSWORD, user.pass, strlen(user.pass)), &session);
if(HANDLE_CRYPT_CALL(cryptSetAttributeString(session.tls_sess, CRYPT_SESSINFO_USERNAME, user.alias, strlen(user.alias)), &session, "getting username"))
HANDLE_CRYPT_CALL(cryptSetAttributeString(session.tls_sess, CRYPT_SESSINFO_PASSWORD, user.pass, strlen(user.pass)), &session, "getting password");
}
}
#endif
if (scfg.tls_certificate != -1) {
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_SSL_OPTIONS, CRYPT_SSLOPTION_DISABLE_CERTVERIFY), &session);
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_PRIVATEKEY, scfg.tls_certificate), &session);
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_SSL_OPTIONS, CRYPT_SSLOPTION_DISABLE_CERTVERIFY), &session, "disabling certificate verification");
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_PRIVATEKEY, scfg.tls_certificate), &session, "setting provate key");
}
BOOL nodelay=TRUE;
setsockopt(session.socket,IPPROTO_TCP,TCP_NODELAY,(char*)&nodelay,sizeof(nodelay));
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_NETWORKSOCKET, session.socket), &session);
if (!HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_ACTIVE, 1), &session)) {
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_NETWORKSOCKET, session.socket), &session, "setting network socket");
if (!HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_SESSINFO_ACTIVE, 1), &session, "setting session active")) {
close_session_no_rb(&session);
thread_down();
return;
}
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_OPTION_NET_READTIMEOUT, 1), &session);
HANDLE_CRYPT_CALL(cryptSetAttribute(session.tls_sess, CRYPT_OPTION_NET_READTIMEOUT, 1), &session, "setting read timeout");
}
/* Start up the output buffer */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment