From: Michael Tremer Date: Wed, 25 Jun 2025 10:01:44 +0000 (+0000) Subject: client: Call the auth callback when we need authentication X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3b8646eeaba225e5ee6464b3fa46169f649eebe;p=people%2Fms%2Fpakfire.git client: Call the auth callback when we need authentication Signed-off-by: Michael Tremer --- diff --git a/src/pakfire/client.c b/src/pakfire/client.c index 96bf46c3..2c3046a6 100644 --- a/src/pakfire/client.c +++ b/src/pakfire/client.c @@ -220,12 +220,30 @@ static int pakfire_client_xfer_auth(struct pakfire_client* self, struct pakfire_ return 0; } +/* + This function is being called when the client needs authentication and + does not have any credentials whatsoever. +*/ +static int pakfire_client_auth_required(struct pakfire_client* self) { + // Call the authentication callback + if (self->auth.callback) + return self->auth.callback(self, self->auth.data); + + ERROR(self->ctx, "Authentication required but no authentication callback set\n"); + + return -ENOTSUP; +} + static int pakfire_client_init(sd_event_source* event, void* data) { struct pakfire_client* self = data; + int r; DEBUG(self->ctx, "Initializing client...\n"); - // XXX TODO + // Request authentication + r = pakfire_client_auth_required(self); + if (r < 0) + return r; return 0; } diff --git a/src/pakfire/client.h b/src/pakfire/client.h index b7b9b11e..6e0b8fd6 100644 --- a/src/pakfire/client.h +++ b/src/pakfire/client.h @@ -53,7 +53,7 @@ typedef enum { } pakfire_client_auth_status; typedef int (*pakfire_client_auth_callback) - (struct pakfire_client* client, pakfire_client_auth_status status, void* data); + (struct pakfire_client* client, void* data); int pakfire_client_set_auth_callback(struct pakfire_client* client, pakfire_client_auth_callback callback, void* data);