[dpkg] 170/187: dpkg: Do not fail when removing non-existent files on read-only filesystems
Reiner Herrmann
reiner at reiner-h.de
Sun Nov 6 12:46:41 UTC 2016
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository dpkg.
commit 4daaec6bb83c65bc7b83022dd241b5d6bbf83b86
Author: Guillem Jover <guillem at debian.org>
Date: Fri Nov 4 05:28:26 2016 +0100
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
---
debian/changelog | 2 ++
lib/dpkg/path-remove.c | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index dbc88ce..6fcc881 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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 at 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.
diff --git a/lib/dpkg/path-remove.c b/lib/dpkg/path-remove.c
index 3086408..ab26b4a 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);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list