Bladeren bron

dpkg: On purge correctly remove a symlink pointing to a directory

The code was treating symlinks to directories as directories, but then
it was trying to rmdir(2) them, which failed. In such case just verify
it's a symlink and unlink(2) them instead.
Guillem Jover 15 jaren geleden
bovenliggende
commit
216b7a30ba
2 gewijzigde bestanden met toevoegingen van 11 en 0 verwijderingen
  1. 2 0
      debian/changelog
  2. 9 0
      src/remove.c

+ 2 - 0
debian/changelog

@@ -61,6 +61,8 @@ dpkg (1.16.1) UNRELEASED; urgency=low
   * On package removal, keep only directories actually containing conffiles,
   * On package removal, keep only directories actually containing conffiles,
     and not directories just matching the substring in the conffile or the
     and not directories just matching the substring in the conffile or the
     directory itself. Thanks to Ondřej Surý <ondrej@debian.org>.
     directory itself. Thanks to Ondřej Surý <ondrej@debian.org>.
+  * On purge correctly remove symlinks acting as directories, when they are
+    not being used by any other package's files.
 
 
   [ Updated dpkg translations ]
   [ Updated dpkg translations ]
   * German (Sven Joachim). Closes: #620312
   * German (Sven Joachim). Closes: #620312

+ 9 - 0
src/remove.c

@@ -362,6 +362,15 @@ static void removal_bulk_remove_leftover_dirs(struct pkginfo *pkg) {
     }
     }
     if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
     if (errno != ENOTDIR) ohshite(_("cannot remove `%.250s'"),fnvb.buf);
 
 
+    if (lstat(fnvb.buf, &stab) == 0 && S_ISLNK(stab.st_mode)) {
+      debug(dbg_eachfiledetail, "removal_bulk is a symlink to a directory");
+
+      if (unlink(fnvb.buf))
+        ohshite(_("cannot remove '%.250s'"), fnvb.buf);
+
+      continue;
+    }
+
     push_leftover(&leftover,namenode);
     push_leftover(&leftover,namenode);
     continue;
     continue;
   }
   }