]> git.ipfire.org Git - pakfire.git/commitdiff
db: Set correct absolute path for read filelists
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 29 Nov 2022 15:50:18 +0000 (15:50 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 29 Nov 2022 15:50:18 +0000 (15:50 +0000)
This prevents Pakfire from deleteing files in the host system.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/db.c

index f584eb7bed3d2110ef8d779df097a32311eeb028..b3d72bd8777a7e26c3b868041a9e13be96778e46 100644 (file)
@@ -2094,6 +2094,7 @@ static int pakfire_db_load_file_digest(struct pakfire_db* db, struct pakfire_fil
 static int pakfire_db_load_file(struct pakfire_db* db, struct pakfire_filelist* filelist,
                sqlite3_stmt* stmt) {
        struct pakfire_file* file = NULL;
+       char abspath[PATH_MAX];
        int r;
 
        // Create a new file object
@@ -2118,6 +2119,20 @@ static int pakfire_db_load_file(struct pakfire_db* db, struct pakfire_filelist*
                goto ERROR;
        }
 
+       // Make the absolute path
+       r = pakfire_path(db->pakfire, abspath, "%s", path);
+       if (r) {
+               ERROR(db->pakfire, "%s: Could not make absolute path: %m\n", path);
+               goto ERROR;
+       }
+
+       // Set the absolute path
+       r = pakfire_file_set_abspath(file, abspath);
+       if (r) {
+               ERROR(db->pakfire, "%s: Could not set absolute path %s: %m\n", path, abspath);
+               goto ERROR;
+       }
+
        // Size
        size_t size = sqlite3_column_int64(stmt, 1);
        if (size)