From e991d1ec08e3575699d15d70f740d5bb370846d7 Mon Sep 17 00:00:00 2001 From: Ron Pedde Date: Fri, 13 Apr 2007 23:31:57 +0000 Subject: [PATCH] logging for bad passwords as suggested by mas --- src/configfile.c | 8 +++++++- src/ff-plugins.h | 1 + src/plugin.c | 6 ++++++ src/plugins/out-daap.c | 8 ++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/configfile.c b/src/configfile.c index ae8c93f2..d60bb367 100644 --- a/src/configfile.c +++ b/src/configfile.c @@ -425,10 +425,16 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) { return TRUE; } - if(!password) + if(!password) { + DPRINTF(E_LOG,L_MISC,"admin: Invalid password from %s (null)\n", + pwsc->hostname); return FALSE; + } res = !strcmp(password,adminpassword); + if(!res) + DPRINTF(E_LOG,L_MISC,"admin: Invalid password from %s (%s)\n", + pwsc->hostname, password); free(adminpassword); return res; } diff --git a/src/ff-plugins.h b/src/ff-plugins.h index 9348316d..71083fb9 100644 --- a/src/ff-plugins.h +++ b/src/ff-plugins.h @@ -136,6 +136,7 @@ typedef struct tag_plugin_input_fn { int (*ws_fd)(struct tag_ws_conninfo *); char* (*ws_getrequestheader)(struct tag_ws_conninfo *, char *); int (*ws_writebinary)(struct tag_ws_conninfo *, char *, int); + char* (*ws_gethostname)(struct tag_ws_conninfo *); /* misc helpers */ char* (*server_ver)(void); diff --git a/src/plugin.c b/src/plugin.c index d2f8ab0e..ab11d499 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -94,6 +94,7 @@ int _plugin_ssc_transcode(WS_CONNINFO *pwsc, MP3FILE *pmp3, int offset, int head char *pi_ws_uri(WS_CONNINFO *pwsc); void pi_ws_will_close(WS_CONNINFO *pwsc); int pi_ws_fd(WS_CONNINFO *pwsc); +char *pi_ws_gethostname(WS_CONNINFO *pwsc); /* misc helpers */ char *pi_server_ver(void); @@ -126,6 +127,7 @@ PLUGIN_INPUT_FN pi = { pi_ws_fd, ws_getrequestheader, ws_writebinary, + pi_ws_gethostname, pi_server_ver, pi_server_name, @@ -687,6 +689,10 @@ int pi_ws_fd(WS_CONNINFO *pwsc) { return pwsc->fd; } +char *pi_ws_gethostname(WS_CONNINFO *pwsc) { + return pwsc->hostname; +} + void pi_log(int level, char *fmt, ...) { char buf[256]; va_list ap; diff --git a/src/plugins/out-daap.c b/src/plugins/out-daap.c index e1200b47..51e8c4b2 100644 --- a/src/plugins/out-daap.c +++ b/src/plugins/out-daap.c @@ -212,11 +212,15 @@ int plugin_auth(WS_CONNINFO *pwsc, char *username, char *password) { return TRUE; } else { _ppi->conf_dispose_string(readpassword); + _ppi->log(E_LOG,"out-daap: Invalid password from %s (%s)\n", + _ppi->ws_gethostname(pwsc),password); return FALSE; } } else { if(strcasecmp(password,readpassword)) { _ppi->conf_dispose_string(readpassword); + _ppi->log(E_LOG,"out-daap: Invalid password from %s (%s)\n", + _ppi->ws_gethostname(pwsc),password); return FALSE; } else { _ppi->conf_dispose_string(readpassword); @@ -353,9 +357,9 @@ void plugin_handler(WS_CONNINFO *pwsc) { } } - _ppi->log(E_DBG,"Index %s: offset %d, limit %d\n",index_req, + _ppi->log(E_DBG,"Index %s: offset %d, limit %d\n",index_req, ppi->dq.offset,ppi->dq.limit); - } + } if(_ppi->ws_getvar(pwsc,"query")) {