Commit 4daaec6b authored by Guillem Jover's avatar Guillem Jover

dpkg: Do not fail when removing non-existent files on read-only filesystems

Trying to rmdir(2) or unlink(2) a non-existent pathname on at least
Linux returns with EROFS. Handle this case specifically to check if
the pathname exists with access(2).

Closes: #838877
parent 1e365818
......@@ -67,6 +67,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
- Hook it into the dpkg-buildpackage machinery.
Based on a patch by Jérémy Bobbio <lunar@debian.org>. Closes: #138409
* Enable dpkg-buildpackage -Jauto by default. Closes: #842845
* Fix dpkg to not fail when removing non-existent backup files on read-only
filesystems. Closes: #838877
* Architecture support:
- Add support for AIX operating system.
- Add a version pseudo-field to the arch tables.
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment