}
FILE* pakfire_file_open(struct pakfire_file* file) {
- const char* path = pakfire_file_get_abspath(file);
+ const char* path = NULL;
+
+ // Fetch the absolute path of the file
+ path = pakfire_file_get_abspath(file);
if (!path)
return NULL;
+ // Fix the path if we have entered the jail
+ if (pakfire_ctx_has_flag(file->ctx, PAKFIRE_CTX_IN_JAIL)) {
+ path = pakfire_relpath(file->pakfire, path);
+ if (!path)
+ return NULL;
+ }
+
FILE* f = fopen(path, "r+");
if (!f)
ERROR(file->ctx, "Could not open %s: %m\n", path);