logging for bad passwords as suggested by mas

This commit is contained in:
Ron Pedde 2007-04-13 23:31:57 +00:00
parent 69ec57328e
commit e991d1ec08
4 changed files with 20 additions and 3 deletions

View File

@ -425,10 +425,16 @@ int config_auth(WS_CONNINFO *pwsc, char *user, char *password) {
return TRUE; return TRUE;
} }
if(!password) if(!password) {
DPRINTF(E_LOG,L_MISC,"admin: Invalid password from %s (null)\n",
pwsc->hostname);
return FALSE; return FALSE;
}
res = !strcmp(password,adminpassword); res = !strcmp(password,adminpassword);
if(!res)
DPRINTF(E_LOG,L_MISC,"admin: Invalid password from %s (%s)\n",
pwsc->hostname, password);
free(adminpassword); free(adminpassword);
return res; return res;
} }

View File

@ -136,6 +136,7 @@ typedef struct tag_plugin_input_fn {
int (*ws_fd)(struct tag_ws_conninfo *); int (*ws_fd)(struct tag_ws_conninfo *);
char* (*ws_getrequestheader)(struct tag_ws_conninfo *, char *); char* (*ws_getrequestheader)(struct tag_ws_conninfo *, char *);
int (*ws_writebinary)(struct tag_ws_conninfo *, char *, int); int (*ws_writebinary)(struct tag_ws_conninfo *, char *, int);
char* (*ws_gethostname)(struct tag_ws_conninfo *);
/* misc helpers */ /* misc helpers */
char* (*server_ver)(void); char* (*server_ver)(void);

View File

@ -94,6 +94,7 @@ int _plugin_ssc_transcode(WS_CONNINFO *pwsc, MP3FILE *pmp3, int offset, int head
char *pi_ws_uri(WS_CONNINFO *pwsc); char *pi_ws_uri(WS_CONNINFO *pwsc);
void pi_ws_will_close(WS_CONNINFO *pwsc); void pi_ws_will_close(WS_CONNINFO *pwsc);
int pi_ws_fd(WS_CONNINFO *pwsc); int pi_ws_fd(WS_CONNINFO *pwsc);
char *pi_ws_gethostname(WS_CONNINFO *pwsc);
/* misc helpers */ /* misc helpers */
char *pi_server_ver(void); char *pi_server_ver(void);
@ -126,6 +127,7 @@ PLUGIN_INPUT_FN pi = {
pi_ws_fd, pi_ws_fd,
ws_getrequestheader, ws_getrequestheader,
ws_writebinary, ws_writebinary,
pi_ws_gethostname,
pi_server_ver, pi_server_ver,
pi_server_name, pi_server_name,
@ -687,6 +689,10 @@ int pi_ws_fd(WS_CONNINFO *pwsc) {
return pwsc->fd; return pwsc->fd;
} }
char *pi_ws_gethostname(WS_CONNINFO *pwsc) {
return pwsc->hostname;
}
void pi_log(int level, char *fmt, ...) { void pi_log(int level, char *fmt, ...) {
char buf[256]; char buf[256];
va_list ap; va_list ap;

View File

@ -212,11 +212,15 @@ int plugin_auth(WS_CONNINFO *pwsc, char *username, char *password) {
return TRUE; return TRUE;
} else { } else {
_ppi->conf_dispose_string(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; return FALSE;
} }
} else { } else {
if(strcasecmp(password,readpassword)) { if(strcasecmp(password,readpassword)) {
_ppi->conf_dispose_string(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; return FALSE;
} else { } else {
_ppi->conf_dispose_string(readpassword); _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); ppi->dq.offset,ppi->dq.limit);
} }
if(_ppi->ws_getvar(pwsc,"query")) { if(_ppi->ws_getvar(pwsc,"query")) {