#include <shadow/subid.h>
#endif
-// Enable legacy logging
-#define PAKFIRE_LEGACY_LOGGING
-
+#include <pakfire/ctx.h>
#include <pakfire/logging.h>
#include <pakfire/pakfire.h>
#include <pakfire/pwd.h>
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;
}
ERROR:
if (ranges)
free(ranges);
+ if (ctx)
+ pakfire_ctx_unref(ctx);
return r;
}
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);
// 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;
}
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;
}
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");
break;
default:
- ERROR(pakfire, "Could not open %s: %m\n", path);
+ CTX_ERROR(ctx, "Could not open %s: %m\n", path);
break;
}
}
// 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;
}