actually use warn_opers function
This commit is contained in:
parent
89d22b9af5
commit
b2ede1aa71
3 changed files with 23 additions and 6 deletions
|
@ -49,8 +49,10 @@ handle_stat(int parc, char *parv[])
|
||||||
authd_stat_handler handler;
|
authd_stat_handler handler;
|
||||||
|
|
||||||
if(parc < 3)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]]))
|
if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]]))
|
||||||
return;
|
return;
|
||||||
|
@ -64,8 +66,10 @@ handle_reload(int parc, char *parv[])
|
||||||
authd_reload_handler handler;
|
authd_reload_handler handler;
|
||||||
|
|
||||||
if(parc < 2)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!(handler = authd_reload_handlers[(unsigned char)parv[1][0]]))
|
if (!(handler = authd_reload_handlers[(unsigned char)parv[1][0]]))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -59,8 +59,10 @@ rb_dictionary *auth_clients;
|
||||||
void load_provider(struct auth_provider *provider)
|
void load_provider(struct auth_provider *provider)
|
||||||
{
|
{
|
||||||
if(rb_dlink_list_length(&auth_providers) >= MAX_PROVIDERS)
|
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
provider->init();
|
provider->init();
|
||||||
rb_dlinkAdd(provider, &provider->node, &auth_providers);
|
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. */
|
/* 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];
|
char buf[BUFSIZE];
|
||||||
va_list args;
|
va_list args;
|
||||||
|
@ -210,7 +212,7 @@ void warn_opers(provider_t id, const char *fmt, ...)
|
||||||
vsnprintf(buf, sizeof(buf), fmt, args);
|
vsnprintf(buf, sizeof(buf), fmt, args);
|
||||||
va_end(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 */
|
/* 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[])
|
void handle_new_connection(int parc, char *parv[])
|
||||||
{
|
{
|
||||||
if(parc < 7)
|
if(parc < 7)
|
||||||
|
{
|
||||||
|
warn_opers(L_CRIT, "BUG: received too few params for new connection (7 expected, got %d)", parc);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
start_auth(parv[1], parv[2], parv[3], parv[4], parv[5]);
|
start_auth(parv[1], parv[2], parv[3], parv[4], parv[5]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,14 @@ typedef enum
|
||||||
PROVIDER_BLACKLIST,
|
PROVIDER_BLACKLIST,
|
||||||
} provider_t;
|
} provider_t;
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
L_DEBUG = 'D',
|
||||||
|
L_INFO = 'I',
|
||||||
|
L_WARN = 'W',
|
||||||
|
L_CRIT ='C',
|
||||||
|
} notice_level_t;
|
||||||
|
|
||||||
struct auth_client
|
struct auth_client
|
||||||
{
|
{
|
||||||
uint16_t cid; /* Client ID */
|
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 reject_client(struct auth_client *auth, provider_t id, const char *reason);
|
||||||
|
|
||||||
void notice_client(struct auth_client *auth, const char *fmt, ...);
|
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[]);
|
void handle_new_connection(int parc, char *parv[]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue