From: Michael Tremer Date: Fri, 18 Oct 2024 16:01:36 +0000 (+0000) Subject: pakfire: Check if we have a valid distribution configuration X-Git-Tag: 0.9.30~1003 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1861eeeb684ec1910489a9bc49a6be0bba507b5f;p=pakfire.git pakfire: Check if we have a valid distribution configuration Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pakfire.c b/src/libpakfire/pakfire.c index 4917f8ccc..ef43e3942 100644 --- a/src/libpakfire/pakfire.c +++ b/src/libpakfire/pakfire.c @@ -565,24 +565,16 @@ const char* pakfire_get_distro_version_id(struct pakfire* pakfire) { const char* pakfire_get_distro_tag(struct pakfire* pakfire) { int r; - if (*pakfire->distro.tag) - return pakfire->distro.tag; - - const char* id = pakfire_get_distro_id(pakfire); - const char* version_id = pakfire_get_distro_version_id(pakfire); - - // Break if the configuration is incomplete - if (!id || !version_id) { - errno = EINVAL; - return NULL; + // Generate the tag + if (!*pakfire->distro.tag) { + r = pakfire_string_format(pakfire->distro.tag, + "%s%s", pakfire->distro.id, pakfire->distro.version_id); + if (r < 0) { + errno = -r; + return NULL; + } } - // Format string - r = pakfire_string_format(pakfire->distro.tag, "%s%s", id, version_id); - if (r < 0) - return NULL; - - // Return the tag return pakfire->distro.tag; } @@ -995,6 +987,13 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, struct pakfire_ctx* if (*p->distro.slogan) CTX_DEBUG(p->ctx, " slogan = %s\n", p->distro.slogan); + // Check if the distribution has been configured + if (!*p->distro.id || !*p->distro.version_id) { + CTX_ERROR(p->ctx, "Invalid distribution configuration\n"); + r = -EINVAL; + goto ERROR; + } + // Bump RLIMIT_NOFILE to maximum r = pakfire_rlimit_set(p, PAKFIRE_RLIMIT_NOFILE_MAX); if (r)