rb_helper *authd_helper = NULL;
authd_cmd_handler authd_cmd_handlers[256] = {
['C'] = handle_new_connection,
- ['D'] = resolve_dns,
+ ['D'] = handle_resolve_dns,
+ ['E'] = handle_cancel_connection,
['O'] = handle_options,
['R'] = handle_reload,
['S'] = handle_stat,
handle_stat(int parc, char *parv[])
{
authd_stat_handler handler;
+ long lrid;
if(parc < 3)
{
return;
}
+ if((lrid = strtol(parv[1], NULL, 16)) > UINT32_MAX)
+ {
+ warn_opers(L_CRIT, "BUG: handle_stat got a rid that was too large: %lx", lrid);
+ return;
+ }
+
if (!(handler = authd_stat_handlers[(unsigned char)parv[2][0]]))
return;
- handler(parv[1], parv[2][0]);
+ handler((uint32_t)lrid, parv[2][0]);
}
static void
{
struct auth_opts_handler *handler;
- if(parc < 4)
+ if(parc < 3)
{
- warn_opers(L_CRIT, "BUG: handle_options received too few parameters (at least 4 expected, got %d)", parc);
+ warn_opers(L_CRIT, "BUG: handle_options received too few parameters (at least 3 expected, got %d)", parc);
return;
}
static void
error_cb(rb_helper *helper)
{
- exit(1);
+ exit(EX_ERROR);
}
#ifndef _WIN32
#endif
}
+static void
+do_exit(void)
+{
+ destroy_providers();
+}
+
int
main(int argc, char *argv[])
{
if(authd_helper == NULL)
{
fprintf(stderr, "authd is not meant to be invoked by end users\n");
- exit(1);
+ exit(EX_ERROR);
}
rb_set_time();
init_providers();
rb_init_prng(NULL, RB_PRNG_DEFAULT);
- rb_helper_loop(authd_helper, 0);
+ atexit(do_exit);
- destroy_providers();
+ rb_helper_loop(authd_helper, 0);
return 0;
}