From 3ba92aa8605653051955f2eb636925c25309fbdd Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 7 Sep 2018 17:01:32 +0200 Subject: [PATCH] [httpd] Better logging of unauthorized requests --- src/httpd_daap.c | 4 ++-- src/httpd_dacp.c | 2 ++ src/httpd_rsp.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/httpd_daap.c b/src/httpd_daap.c index 4fe2ce13..1cf05bd0 100644 --- a/src/httpd_daap.c +++ b/src/httpd_daap.c @@ -723,7 +723,7 @@ daap_request_authorize(struct httpd_request *hreq) { if (!session) { - DPRINTF(E_LOG, L_DAAP, "DAAP session not found: '%s'\n", hreq->uri_parsed->uri); + DPRINTF(E_LOG, L_DAAP, "Unauthorized request from '%s', DAAP session not found: '%s'\n", hreq->peer_address, hreq->uri_parsed->uri); return -1; } @@ -749,7 +749,7 @@ daap_request_authorize(struct httpd_request *hreq) ret = httpd_basic_auth(hreq->req, NULL, passwd, cfg_getstr(cfg_getsec(cfg, "library"), "name")); if (ret != 0) { - DPRINTF(E_LOG, L_DAAP, "Unsuccessful library authentication\n"); + DPRINTF(E_LOG, L_DAAP, "Unsuccessful library authorization attempt from '%s'\n", hreq->peer_address); return -1; } diff --git a/src/httpd_dacp.c b/src/httpd_dacp.c index 55f794dc..d26e4ab7 100644 --- a/src/httpd_dacp.c +++ b/src/httpd_dacp.c @@ -595,6 +595,8 @@ dacp_request_authorize(struct httpd_request *hreq) return 0; invalid: + DPRINTF(E_LOG, L_DACP, "Unauthorized request '%s' from '%s' (is peer trusted in your config?)\n", hreq->uri_parsed->uri, hreq->peer_address); + httpd_send_error(hreq->req, 403, "Forbidden"); return -1; } diff --git a/src/httpd_rsp.c b/src/httpd_rsp.c index d0a428b1..f0e6d7db 100644 --- a/src/httpd_rsp.c +++ b/src/httpd_rsp.c @@ -297,7 +297,7 @@ rsp_request_authorize(struct httpd_request *hreq) ret = httpd_basic_auth(hreq->req, NULL, passwd, cfg_getstr(cfg_getsec(cfg, "library"), "name")); if (ret != 0) { - DPRINTF(E_LOG, L_RSP, "Unsuccessful library authentication\n"); + DPRINTF(E_LOG, L_RSP, "Unsuccessful library authorization attempt from '%s'\n", hreq->peer_address); return -1; }