From: Michael Tremer Date: Tue, 17 Oct 2023 10:18:41 +0000 (+0000) Subject: buildservice: Initialize a Kerberos context X-Git-Tag: 0.9.30~1460 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ff5cb6bab8d37c2a320749093d26de2e564adccc;p=pakfire.git buildservice: Initialize a Kerberos context Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/buildservice.c b/src/libpakfire/buildservice.c index 096a0d92b..d75068487 100644 --- a/src/libpakfire/buildservice.c +++ b/src/libpakfire/buildservice.c @@ -30,6 +30,8 @@ #include #include +#include + #define DEFAULT_KEYTAB "/etc/krb5.keytab" struct pakfire_buildservice { @@ -42,8 +44,30 @@ struct pakfire_buildservice { // A HTTP Client struct pakfire_downloader* httpclient; + + // Kerberos Context + krb5_context krb5_ctx; }; +static int pakfire_buildservice_setup_auth(struct pakfire_buildservice* service) { + const char* error = NULL; + int r; + + // Setup a Kerberos context + r = krb5_init_context(&service->krb5_ctx); + if (r) { + error = krb5_get_error_message(service->krb5_ctx, r); + + CTX_ERROR(service->ctx, "Could not initialize Kerberos: %s\n", error); + krb5_free_error_message(service->krb5_ctx, error); + + goto ERROR; + } + +ERROR: + return r; +} + static int pakfire_buildservice_setup(struct pakfire_buildservice* service) { struct pakfire_config* config = NULL; const char* url = NULL; @@ -83,6 +107,11 @@ static int pakfire_buildservice_setup(struct pakfire_buildservice* service) { if (r) goto ERROR; + // Setup authentication + r = pakfire_buildservice_setup_auth(service); + if (r) + goto ERROR; + ERROR: if (config) pakfire_config_unref(config); @@ -91,6 +120,8 @@ ERROR: } static void pakfire_buildservice_free(struct pakfire_buildservice* service) { + if (service->krb5_ctx) + krb5_free_context(service->krb5_ctx); if (service->httpclient) pakfire_downloader_unref(service->httpclient); if (service->ctx)