From: Michael Tremer Date: Tue, 30 Jan 2024 18:45:16 +0000 (+0000) Subject: pwd: Remove legacy logger X-Git-Tag: 0.9.30~1227 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6e49624aa6155ef880118b4b89b472f0b3a65c6d;p=pakfire.git pwd: Remove legacy logger Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/pwd.c b/src/libpakfire/pwd.c index 4b40ad430..6478e431e 100644 --- a/src/libpakfire/pwd.c +++ b/src/libpakfire/pwd.c @@ -29,9 +29,7 @@ #include #endif -// Enable legacy logging -#define PAKFIRE_LEGACY_LOGGING - +#include #include #include #include @@ -173,14 +171,17 @@ static int pakfire_getsubid(struct pakfire* pakfire, const char* owner, int count; int r = -1; - if (!subid_init(PACKAGE_NAME, stderr)) { - ERROR(pakfire, "Could not setup subid: %m\n"); - return 1; + struct pakfire_ctx* ctx = pakfire_ctx(pakfire); + + r = subid_init(PACKAGE_NAME, stderr); + if (r) { + CTX_ERROR(ctx, "Could not setup subid: %m\n"); + goto ERROR; } count = callback(owner, &ranges); if (count < 0) { - ERROR(pakfire, "Could not fetch subids for %s: %m\n", owner); + CTX_ERROR(ctx, "Could not fetch subids for %s: %m\n", owner); goto ERROR; } @@ -195,6 +196,8 @@ static int pakfire_getsubid(struct pakfire* pakfire, const char* owner, ERROR: if (ranges) free(ranges); + if (ctx) + pakfire_ctx_unref(ctx); return r; } @@ -216,6 +219,8 @@ static int pakfire_fgetsubid(struct pakfire* pakfire, struct pakfire_subid* subi size_t length = 0; char* p = NULL; + struct pakfire_ctx* ctx = pakfire_ctx(pakfire); + // Read the next line while (1) { r = getline(&line, &length, f); @@ -257,7 +262,7 @@ static int pakfire_fgetsubid(struct pakfire* pakfire, struct pakfire_subid* subi // Check if length is greater than zero if (subid->length == 0) { - DEBUG(pakfire, "Length equals zero: %s\n", line); + CTX_DEBUG(ctx, "Length equals zero: %s\n", line); r = 1; goto ERROR; } @@ -270,9 +275,12 @@ ERROR: free(line); if (!r) - DEBUG(pakfire, "Parsed SUBID entry: name=%s, id=%u, length=%zu\n", + CTX_DEBUG(ctx, "Parsed SUBID entry: name=%s, id=%u, length=%zu\n", subid->name, subid->id, subid->length); + if (ctx) + pakfire_ctx_unref(ctx); + return r; } @@ -292,7 +300,9 @@ static int pakfire_getsubid(struct pakfire* pakfire, const char* path, const cha if (!owner) return 1; - DEBUG(pakfire, "Fetching SUBID from %s for %s\n", path, owner); + struct pakfire_ctx* ctx = pakfire_ctx(pakfire); + + CTX_DEBUG(ctx, "Fetching SUBID from %s for %s\n", path, owner); // Open /etc/subuid FILE* f = fopen(path, "r"); @@ -302,7 +312,7 @@ static int pakfire_getsubid(struct pakfire* pakfire, const char* path, const cha break; default: - ERROR(pakfire, "Could not open %s: %m\n", path); + CTX_ERROR(ctx, "Could not open %s: %m\n", path); break; } @@ -337,12 +347,14 @@ static int pakfire_getsubid(struct pakfire* pakfire, const char* path, const cha } // No match found - DEBUG(pakfire, "No match found for %s\n", owner); + CTX_DEBUG(ctx, "No match found for %s\n", owner); r = 1; END: if (f) fclose(f); + if (ctx) + pakfire_ctx_unref(ctx); return r; }