X-Git-Url: https://jfr.im/git/solanum.git/blobdiff_plain/b585278b3212ec5d13f5e1cf15feb25b043f3753..589dbf4d0fbab929d901edb551ea74a82150f7e9:/authd/provider.h diff --git a/authd/provider.h b/authd/provider.h index 7145d07d..07b8a794 100644 --- a/authd/provider.h +++ b/authd/provider.h @@ -44,7 +44,7 @@ struct auth_client_data struct auth_client { - uint16_t cid; /* Client ID */ + uint32_t cid; /* Client ID */ char l_ip[HOSTIPLEN + 1]; /* Listener IP address */ uint16_t l_port; /* Listener port */ @@ -58,6 +58,8 @@ struct auth_client char username[USERLEN + 1]; /* Used for ident lookup */ bool providers_starting; /* Providers are still warming up */ + bool providers_cancelled; /* Providers are being cancelled */ + unsigned int providers_active; /* Number of active providers */ unsigned int refcount; /* Held references */ struct auth_client_data *data; /* Provider-specific data */ @@ -104,7 +106,7 @@ extern struct auth_provider ident_provider; extern struct auth_provider blacklist_provider; extern struct auth_provider opm_provider; -extern rb_dictionary *auth_providers; +extern rb_dlink_list auth_providers; extern rb_dictionary *auth_clients; void load_provider(struct auth_provider *provider); @@ -115,7 +117,7 @@ void destroy_providers(void); void cancel_providers(struct auth_client *auth); void provider_done(struct auth_client *auth, uint32_t id); -void accept_client(struct auth_client *auth, uint32_t id); +void accept_client(struct auth_client *auth); void reject_client(struct auth_client *auth, uint32_t id, const char *data, const char *fmt, ...); void handle_new_connection(int parc, char *parv[]); @@ -138,16 +140,26 @@ auth_client_unref(struct auth_client *auth) /* Get a provider by name */ static inline struct auth_provider * -get_provider(const char *name) +find_provider(const char *name) { - return rb_dictionary_retrieve(auth_providers, name); + rb_dlink_node *ptr; + + RB_DLINK_FOREACH(ptr, auth_providers.head) + { + struct auth_provider *provider = ptr->data; + + if(strcasecmp(provider->name, name) == 0) + return provider; + } + + return NULL; } /* Get a provider's id by name */ static inline bool get_provider_id(const char *name, uint32_t *id) { - struct auth_provider *provider = get_provider(name); + struct auth_provider *provider = find_provider(name); if(provider != NULL) { @@ -165,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_client_ref(auth); - 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_client_unref(auth); -} - /* Check if provider is operating on this auth client */ static inline bool is_provider_running(struct auth_client *auth, uint32_t provider)