Check that a file belongs to the package before removing it
[oweals/opkg-lede.git] / libopkg / opkg_remove.c
index b5045ea9905263cdc5ce0bcd149c82e5043d759e..4920587859b4e579e9720edb23cf21a0133e72f1 100644 (file)
    General Public License for more details.
 */
 
-#include "includes.h"
-#include "opkg_message.h"
-
+#include <stdio.h>
 #include <glob.h>
+#include <unistd.h>
 
+#include "opkg_message.h"
 #include "opkg_remove.h"
 #include "opkg_cmd.h"
-
 #include "file_util.h"
 #include "sprintf_alloc.h"
 #include "libbb/libbb.h"
@@ -342,6 +341,11 @@ remove_data_files_and_list(pkg_t *pkg)
      for (iter = str_list_first(installed_files); iter; iter = str_list_next(installed_files, iter)) {
          file_name = (char *)iter->data;
 
+         owner = file_hash_get_file_owner(file_name);
+         if (owner != pkg)
+                 /* File may have been claimed by another package. */
+                 continue;
+
          if (file_is_dir(file_name)) {
               str_list_append(&installed_dirs, file_name);
               continue;