diff --git a/authd/authd.c b/authd/authd.c index 335f55f5..e1145184 100644 --- a/authd/authd.c +++ b/authd/authd.c @@ -49,8 +49,10 @@ handle_stat(int parc, char *parv[]) authd_stat_handler handler; if(parc < 3) - /* XXX Should log this somehow */ + { + warn_opers(L_CRIT, "BUG: handle_stat received too few parameters (at least 3 expected, got %d)", parc); return; + } if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]])) return; @@ -64,8 +66,10 @@ handle_reload(int parc, char *parv[]) authd_reload_handler handler; if(parc < 2) - /* XXX Should log this somehow */ + { + warn_opers(L_CRIT, "BUG: handle_reload received too few parameters (at least 2 expected, got %d)", parc); return; + } if (!(handler = authd_reload_handlers[(unsigned char)parv[1][0]])) return; diff --git a/authd/provider.c b/authd/provider.c index d227bed3..f0000b1b 100644 --- a/authd/provider.c +++ b/authd/provider.c @@ -59,8 +59,10 @@ rb_dictionary *auth_clients; void load_provider(struct auth_provider *provider) { if(rb_dlink_list_length(&auth_providers) >= MAX_PROVIDERS) - /* XXX should probably warn here */ + { + warn_opers(L_CRIT, "Exceeded maximum level of authd providers (%d max)", MAX_PROVIDERS); return; + } provider->init(); rb_dlinkAdd(provider, &provider->node, &auth_providers); @@ -201,7 +203,7 @@ void notice_client(struct auth_client *auth, const char *fmt, ...) } /* Send a warning to the IRC daemon for logging, etc. */ -void warn_opers(provider_t id, const char *fmt, ...) +void warn_opers(notice_level_t level, const char *fmt, ...) { char buf[BUFSIZE]; va_list args; @@ -210,7 +212,7 @@ void warn_opers(provider_t id, const char *fmt, ...) vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); - rb_helper_write(authd_helper, "W %c :%s", id, buf); + rb_helper_write(authd_helper, "W %c :%s", level, buf); } /* Begin authenticating user */ @@ -272,7 +274,10 @@ static void start_auth(const char *cid, const char *l_ip, const char *l_port, co void handle_new_connection(int parc, char *parv[]) { if(parc < 7) + { + warn_opers(L_CRIT, "BUG: received too few params for new connection (7 expected, got %d)", parc); return; + } start_auth(parv[1], parv[2], parv[3], parv[4], parv[5]); } diff --git a/authd/provider.h b/authd/provider.h index 84d62318..9184e2fc 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -34,6 +34,14 @@ typedef enum PROVIDER_BLACKLIST, } provider_t; +typedef enum +{ + L_DEBUG = 'D', + L_INFO = 'I', + L_WARN = 'W', + L_CRIT ='C', +} notice_level_t; + struct auth_client { uint16_t cid; /* Client ID */ @@ -94,7 +102,7 @@ void accept_client(struct auth_client *auth, provider_t id); void reject_client(struct auth_client *auth, provider_t id, const char *reason); void notice_client(struct auth_client *auth, const char *fmt, ...); -void warn_opers(provider_t id, const char *fmt, ...); +void warn_opers(notice_level_t level, const char *fmt, ...); void handle_new_connection(int parc, char *parv[]);