]> jfr.im git - solanum.git/blobdiff - authd/authd.c
Merge branch 'master' of github.com:charybdis-ircd/charybdis
[solanum.git] / authd / authd.c
index 8aabf267add461b191c1cf8d843cc39667a6e3fc..b122db2ee71f642f0c942b809cd1ddecea442a57 100644 (file)
@@ -78,9 +78,9 @@ handle_options(int parc, char *parv[])
 {
        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;
        }
 
@@ -104,13 +104,13 @@ handle_reload(int parc, char *parv[])
 {
        authd_reload_handler handler;
 
-       if(parc < 2)
+       if(parc <= 2)
        {
                /* Reload all handlers */
                for(size_t i = 0; i < 256; i++)
                {
                        if ((handler = authd_reload_handlers[(unsigned char) i]) != NULL)
-                               handler(parv[1][0]);
+                               handler('\0');
                }
 
                return;
@@ -147,7 +147,7 @@ parse_request(rb_helper *helper)
 static void
 error_cb(rb_helper *helper)
 {
-       exit(1);
+       exit(EX_ERROR);
 }
 
 #ifndef _WIN32
@@ -187,6 +187,12 @@ setup_signals(void)
 #endif
 }
 
+static void
+do_exit(void)
+{
+       destroy_providers();
+}
+
 int
 main(int argc, char *argv[])
 {
@@ -196,7 +202,7 @@ 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();
@@ -208,9 +214,9 @@ main(int argc, char *argv[])
        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;
 }