Comment 0 for bug 1865049

Revision history for this message
Shengjing Zhu (zhsj) wrote :

Hi,

dpkg 1.8.11 has fixed this issue when running with read-only root. The Debian bug is https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=838877

Could you backport the fix to Xenial?

The patch is trival and looks safe to backport.

https://salsa.debian.org/dpkg-team/dpkg/commit/4daaec6

diff --git a/lib/dpkg/path-remove.c b/lib/dpkg/path-remove.c
index 3086408e8..ab26b4a8d 100644
--- a/lib/dpkg/path-remove.c
+++ b/lib/dpkg/path-remove.c
@@ -137,6 +137,13 @@ path_remove_tree(const char *pathname)
   if (errno == ENOTDIR)
    return;
  }
+ /* Trying to remove a directory or a file on a read-only filesystem,
+ * even if non-existent, always returns EROFS. */
+ if (errno == EROFS) {
+ if (access(pathname, F_OK) < 0 && errno == ENOENT)
+ return;
+ errno = EROFS;
+ }
  if (errno != ENOTEMPTY && errno != EEXIST) /* Huh? */
   ohshite(_("unable to securely remove '%.255s'"), pathname);

Thanks.