summaryrefslogtreecommitdiff
path: root/dpi/file.c
diff options
context:
space:
mode:
authorJorge Arellano Cid <jcid@dillo.org>2009-11-01 16:31:59 -0300
committerJorge Arellano Cid <jcid@dillo.org>2009-11-01 16:31:59 -0300
commitf22fea661d0755029173a21fa72f7c131ee884e7 (patch)
tree48a0f4ae5bf1225709a4571a134a5900964fd354 /dpi/file.c
parente909b151a01c444a1630dc524249190d333620b2 (diff)
Introduce basic shared-secret-based authentication
Diffstat (limited to 'dpi/file.c')
-rw-r--r--dpi/file.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/dpi/file.c b/dpi/file.c
index ce7dcee7..8f18c19b 100644
--- a/dpi/file.c
+++ b/dpi/file.c
@@ -844,14 +844,30 @@ static int File_num_clients(void)
* Serve this client.
* (this function runs on its own thread)
*/
-static void *File_serve_client(void *data)
+static void File_serve_client(void *data)
{
- char *dpip_tag, *cmd = NULL, *url = NULL, *path;
+ char *dpip_tag = NULL, *cmd = NULL, *url = NULL, *path, *auth, *p;
ClientInfo *Client = data;
+ /* Authenticate our client... */
+ auth = sock_handler_read(Client->sh);
+ if ((p = strchr(auth, '<')) != NULL) {
+ /* auth and dpip's tag are in one chunk, separate them */
+ dpip_tag = dStrdup(p);
+ *p = 0;
+ }
+ MSG("auth={%s}\n", auth);
+ if (a_Dpip_check_auth(auth) == -1) {
+ dFree(dpip_tag);
+ dFree(auth);
+ return;
+ }
+ dFree(auth);
+
/* Read the dpi command */
- dpip_tag = sock_handler_read(Client->sh);
- _MSG("dpip_tag={%s}\n", dpip_tag);
+ if (!dpip_tag)
+ dpip_tag = sock_handler_read(Client->sh);
+ MSG("dpip_tag={%s}\n", dpip_tag);
if (dpip_tag) {
cmd = a_Dpip_get_attr(dpip_tag, "cmd");
@@ -864,8 +880,8 @@ static void *File_serve_client(void *data)
MSG("file.dpi:: Failed to parse 'url'\n");
}
}
+ dFree(cmd);
}
- dFree(cmd);
dFree(dpip_tag);
if (!DPIBYE && url) {
@@ -886,8 +902,6 @@ static void *File_serve_client(void *data)
/* flag the the transfer finished */
Client->done = 1;
-
- return NULL;
}
/*