summaryrefslogtreecommitdiffstats
path: root/client.c
diff options
context:
space:
mode:
authorSimon Rettberg2015-06-26 14:58:03 +0200
committerSimon Rettberg2015-06-26 14:58:03 +0200
commit2e37d6b71692508fa5d2764c1c80f3c7ca7c2894 (patch)
tree7a2e3240c380b9c532fc990dfefc1179eb3a1420 /client.c
parentFix the fix of the fix of SSL (diff)
downloadldadp-2e37d6b71692508fa5d2764c1c80f3c7ca7c2894.tar.gz
ldadp-2e37d6b71692508fa5d2764c1c80f3c7ca7c2894.tar.xz
ldadp-2e37d6b71692508fa5d2764c1c80f3c7ca7c2894.zip
Send search requests on the same connection the explicit bind was done on, so the user's permissions regarding visibility of search results will be applied
Diffstat (limited to 'client.c')
-rw-r--r--client.c30
1 files changed, 14 insertions, 16 deletions
diff --git a/client.c b/client.c
index f2c9683..906b718 100644
--- a/client.c
+++ b/client.c
@@ -15,7 +15,7 @@
static void client_haveIn(epoll_client_t *client);
static void client_haveOut(epoll_client_t *client);
-static void client_free(epoll_client_t *client)
+void client_free(epoll_client_t *client)
{
proxy_removeClient(client);
if (client->sendBuffer != NULL) free(client->sendBuffer);
@@ -31,7 +31,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
{
epoll_client_t *client = (epoll_client_t*)data;
if (doCleanup || client->kill) {
- printf("Client gone (1).\n");
+ //printf("Client gone (1).\n");
client_free(client);
return;
}
@@ -40,7 +40,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
if (haveIn) client_haveIn(client);
if (haveOut) client_haveOut(client);
if (client->kill) {
- printf("Client gone (2).\n");
+ //printf("Client gone (2).\n");
client_free(client);
}
return;
@@ -49,7 +49,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
if (!client->sslAccepted) {
// Still SSL-Connecting
if (!ssl_acceptClient(client)) {
- printf("SSL Client accept failed.\n");
+ printf("[Proxy] SSL Client accept failed.\n");
client_free(client);
return;
}
@@ -59,7 +59,7 @@ void client_callback(void *data, int haveIn, int haveOut, int doCleanup)
client_haveIn(client);
client_haveOut(client);
if (client->kill) {
- printf("Client gone (3).\n");
+ //printf("Client gone (3).\n");
client_free(client);
}
}
@@ -68,7 +68,7 @@ static void client_haveIn(epoll_client_t *client)
{
for (;;) {
if (client->rbPos >= REQLEN) {
- printf("[C->Proxy] Read buffer overflow. Disconnecting.\n");
+ printf("[Proxy] Buffer overflow reading from client. Disconnecting.\n");
client->kill = TRUE;
return;
}
@@ -80,7 +80,7 @@ static void client_haveIn(epoll_client_t *client)
if (ret < 0 && errno == EINTR) continue;
if (ret < 0 && errno == EAGAIN) break;
if (ret <= 0) {
- printf("Client gone while reading.\n");
+ printf("[Proxy] Client gone while reading (ret=%d, errno=%d).\n", (int)ret, errno);
client->kill = TRUE;
return;
}
@@ -90,7 +90,7 @@ static void client_haveIn(epoll_client_t *client)
if (ret <= 0) {
int err = SSL_get_error(client->ssl, ret);
if (SSL_BLOCKED(err)) break;
- printf("Client gone while reading (%d, %d).\n", (int)ret, err);
+ printf("[Proxy] SSL client gone while reading (ret=%d, err=%d).\n", (int)ret, err);
client->kill = TRUE;
return;
}
@@ -104,9 +104,8 @@ static void client_haveIn(epoll_client_t *client)
if (consumed == 0) break; // Length-Header not complete
len += consumed;
if (len > client->rbPos) break; // Body not complete yet
- printf("Received complete requrest...\n");
if (!proxy_fromClient(client, len)) {
- printf("Error parsing request from client.\n");
+ printf("[Proxy] Error parsing request from client.\n");
client->kill = TRUE;
return;
}
@@ -134,7 +133,7 @@ static void client_haveOut(epoll_client_t *client)
if (ret < 0 && errno == EINTR) continue;
if (ret < 0 && errno == EAGAIN) return;
if (ret <= 0) {
- printf("Cannot send to client (ret: %d, errno: %d)\n", (int)ret, errno);
+ printf("[Proxy] Cannot send to client (ret=%d, errno=%d)\n", (int)ret, errno);
client->kill = TRUE;
return;
}
@@ -147,7 +146,7 @@ static void client_haveOut(epoll_client_t *client)
client->writeBlocked = TRUE;
return; // Blocking
}
- printf("SSL client gone while sending (%d)\n", err);
+ printf("[Proxy] SSL cannot send to client (ret=%d, err=%d)\n", (int)ret, err);
ERR_print_errors_fp(stdout);
client->kill = TRUE;
return; // Closed
@@ -173,7 +172,7 @@ BOOL client_send(epoll_client_t *client, const char *buffer, size_t len, const B
// Nothing in send buffer, fire away
const int ret = write(client->fd, buffer, len);
if (ret == 0 || (ret < 0 && errno != EINTR && errno != EAGAIN)) {
- printf("Client gone when trying to send.\n");
+ printf("[Proxy] Client gone when trying to send.\n");
client->kill = TRUE;
return FALSE;
}
@@ -187,7 +186,7 @@ BOOL client_send(epoll_client_t *client, const char *buffer, size_t len, const B
// Buffer...
if (client->sbLen - client->sbFill < len) { // Buffer too small?
if (client->writeBlocked) {
- printf("SSL Write blocked and buffer to small (%d)\n", (int)client->sbLen);
+ printf("[Proxy] SSL write to client blocked and buffer to small (%d bytes)\n", (int)client->sbLen);
client->kill = TRUE;
return FALSE;
}
@@ -198,7 +197,7 @@ BOOL client_send(epoll_client_t *client, const char *buffer, size_t len, const B
}
// Sanity
if (client->sbFill + len > MAX_SEND_BUFFER) {
- printf("Dropping client as the send buffer would exceed %d bytes.\n", (int)MAX_SEND_BUFFER);
+ printf("[Proxy] Dropping client as the send buffer would exceed %d bytes.\n", (int)MAX_SEND_BUFFER);
client->kill = TRUE;
return FALSE;
}
@@ -207,7 +206,6 @@ BOOL client_send(epoll_client_t *client, const char *buffer, size_t len, const B
client->kill = TRUE;
return FALSE;
}
- printf("Send Buffer now %d\n", (int)client->sbLen);
}
}
// Finally append to buffer