]> jfr.im git - irc/charybdis-ircd/charybdis.git/commitdiff
authd: assume all providers are running
authorSimon Arlott <sa.me.uk>
Sun, 20 Aug 2017 11:53:44 +0000 (12:53 +0100)
committerSimon Arlott <sa.me.uk>
Sun, 20 Aug 2017 11:59:32 +0000 (12:59 +0100)
Otherwise ident returns without setting itself running causing problems.

Move opm/blacklist before ident/rdns so that they can receive completion
notifications.

authd/provider.c
authd/provider.h
authd/providers/blacklist.c
authd/providers/ident.c
authd/providers/opm.c
authd/providers/rdns.c

index 7def5714a400139cde552e5a81cce42415879a14..aabfa119e4134143deada922c66e791dedb1e94b 100644 (file)
@@ -62,6 +62,29 @@ static rb_dlink_list free_pids;
 static uint32_t allocated_pids;
 static struct ev_entry *timeout_ev;
 
+/* Set a provider's raw status */
+static inline void
+set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
+{
+       auth->data[provider].status = status;
+}
+
+/* Set the provider as running */
+static inline void
+set_provider_running(struct auth_client *auth, uint32_t provider)
+{
+       auth->providers_active++;
+       set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
+}
+
+/* Provider is no longer operating on this auth client */
+static inline void
+set_provider_done(struct auth_client *auth, uint32_t provider)
+{
+       set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
+       auth->providers_active--;
+}
+
 /* Initalise all providers */
 void
 init_providers(void)
@@ -69,10 +92,13 @@ init_providers(void)
        auth_clients = rb_dictionary_create("pending auth clients", rb_uint32cmp);
        timeout_ev = rb_event_addish("provider_timeout_event", provider_timeout_event, NULL, 1);
 
-       load_provider(&rdns_provider);
-       load_provider(&ident_provider);
+       /* FIXME must be started before rdns/ident to receive completion notification from them */
        load_provider(&blacklist_provider);
        load_provider(&opm_provider);
+
+       /* FIXME must be started after blacklist/opm in case of early completion notifications */
+       load_provider(&rdns_provider);
+       load_provider(&ident_provider);
 }
 
 /* Terminate all providers */
@@ -314,6 +340,7 @@ start_auth(const char *cid, const char *l_ip, const char *l_port, const char *c_
                lrb_assert(provider->start != NULL);
 
                /* Execute providers */
+               set_provider_running(auth, provider->id);
                if(!provider->start(auth))
                        /* Rejected immediately */
                        goto done;
index 9bcb7421407ee4475c0d4c10677b8a4e960fe797..07b8a794a1508db11070d978f62b5353a01aeb2a 100644 (file)
@@ -177,31 +177,6 @@ get_provider_status(struct auth_client *auth, uint32_t provider)
        return auth->data[provider].status;
 }
 
-/* Set a provider's raw status */
-static inline void
-set_provider_status(struct auth_client *auth, uint32_t provider, provider_status_t status)
-{
-       auth->data[provider].status = status;
-}
-
-/* Set the provider as running
- * If you're doing asynchronous work call this */
-static inline void
-set_provider_running(struct auth_client *auth, uint32_t provider)
-{
-       auth->providers_active++;
-       set_provider_status(auth, provider, PROVIDER_STATUS_RUNNING);
-}
-
-/* Provider is no longer operating on this auth client
- * You should use provider_done and not this */
-static inline void
-set_provider_done(struct auth_client *auth, uint32_t provider)
-{
-       set_provider_status(auth, provider, PROVIDER_STATUS_DONE);
-       auth->providers_active--;
-}
-
 /* Check if provider is operating on this auth client */
 static inline bool
 is_provider_running(struct auth_client *auth, uint32_t provider)
index ca0ca238bca31155ada941c30a53974e82bba869..1855c1d8cc494fd055355ba6affd47816122c5e2 100644 (file)
@@ -369,9 +369,11 @@ blacklists_start(struct auth_client *auth)
 
        lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
 
-       if(!rb_dlink_list_length(&blacklist_list))
+       if(!rb_dlink_list_length(&blacklist_list)) {
                /* Nothing to do... */
+               provider_done(auth, SELF_PID);
                return true;
+       }
 
        auth_client_ref(auth);
 
@@ -388,7 +390,6 @@ blacklists_start(struct auth_client *auth)
                }
        }
 
-       set_provider_running(auth, SELF_PID);
        return true;
 }
 
index d707469d889aa3609f026b4c5f62824dae878b6a..1d5e29cc60bd95f93ccc4c9610491a18cd458d78 100644 (file)
@@ -299,7 +299,7 @@ ident_start(struct auth_client *auth)
        {
                rb_free(query);
                notice_client(auth->cid, messages[REPORT_DISABLED]);
-               set_provider_done(auth, SELF_PID);
+               provider_done(auth, SELF_PID);
                return true;
        }
 
@@ -329,8 +329,6 @@ ident_start(struct auth_client *auth)
                        ident_connected,
                        auth, ident_timeout);
 
-       set_provider_running(auth, SELF_PID);
-
        return true;
 }
 
index fe84fdd4cbad7c7301e27f6e14c112afb30517ed..22b9ba3f174840dec01b558bdb8ba8c0347360fc 100644 (file)
@@ -619,9 +619,11 @@ opm_start(struct auth_client *auth)
 
        lrb_assert(get_provider_data(auth, SELF_PID) == NULL);
 
-       if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0)
+       if(!opm_enable || rb_dlink_list_length(&proxy_scanners) == 0) {
                /* Nothing to do... */
+               provider_done(auth, SELF_PID);
                return true;
+       }
 
        auth_client_ref(auth);
 
@@ -634,7 +636,6 @@ opm_start(struct auth_client *auth)
                opm_scan(auth);
        }
 
-       set_provider_running(auth, SELF_PID);
        return true;
 }
 
index b646846059615bf0937a5450a86173d1220ae869..a0232f60e49c2dad64a507eccc2bd67f973c4668 100644 (file)
@@ -137,7 +137,6 @@ rdns_start(struct auth_client *auth)
        query->query = lookup_hostname(auth->c_ip, dns_answer_callback, auth);
 
        notice_client(auth->cid, messages[REPORT_LOOKUP]);
-       set_provider_running(auth, SELF_PID);
        return true;
 }