aboutsummaryrefslogtreecommitdiff
path: root/dpi
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
parente909b151a01c444a1630dc524249190d333620b2 (diff)
Introduce basic shared-secret-based authentication
Diffstat (limited to 'dpi')
-rw-r--r--dpi/bookmarks.c5
-rw-r--r--dpi/file.c28
2 files changed, 24 insertions, 9 deletions
diff --git a/dpi/bookmarks.c b/dpi/bookmarks.c
index 648b5f82..66d8a23e 100644
--- a/dpi/bookmarks.c
+++ b/dpi/bookmarks.c
@@ -1653,7 +1653,8 @@ static int Bmsrv_parse_buf(SockHandler *sh, char *Buf)
if (st != 0) {
char *err =
DOCTYPE
- "<HTML><body id='dillo_bm'> Error on the bookmarks server...</body></html>";
+ "<HTML><body id='dillo_bm'> Error on the bookmarks server..."
+ " </body></html>";
if (sock_handler_write_str(sh, 1, err) != 0) {
return 1;
}
@@ -1686,7 +1687,7 @@ static void termination_handler(int signum)
/*
* -- MAIN -------------------------------------------------------------------
*/
-int main (void) {
+int main(void) {
struct sockaddr_un spun;
int temp_sock_descriptor;
socklen_t address_size;
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;
}
/*