From ce1f3a2c616b86da657c1c796efa5f4d18c30c39 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 2 Nov 2015 18:49:52 +0100 Subject: wrap every unlink call to check for != /dev/null Unlinking /dev/null is bad, we shouldn't do that. Also, we should print at least a warning if we tried to unlink a file but didn't manage to pull it of (ignoring the case were the file is /dev/null or doesn't exist in the first place). This got triggered by a relatively unlikely to cause problem in pkgAcquire::Worker::PrepareFiles which would while temporary uncompressed files (which are set to keep compressed) figure out that to files are the same and prepare for sharing by deleting them. Bad move. That also shows why not printing a warning is a bad idea as this hide the error for in non-root test runs. Git-Dch: Ignore --- apt-pkg/edsp/edsplistparser.cc | 6 ++---- apt-pkg/edsp/edspsystem.cc | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'apt-pkg/edsp') diff --git a/apt-pkg/edsp/edsplistparser.cc b/apt-pkg/edsp/edsplistparser.cc index 77a0edc22..85a57479e 100644 --- a/apt-pkg/edsp/edsplistparser.cc +++ b/apt-pkg/edsp/edsplistparser.cc @@ -31,12 +31,10 @@ public: edspListParserPrivate() { std::string const states = _config->FindFile("Dir::State::extended_states"); - if (states != "/dev/null") - unlink(states.c_str()); + RemoveFile("edspListParserPrivate", states); extendedstates.Open(states, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600); std::string const prefs = _config->FindFile("Dir::Etc::preferences"); - if (prefs != "/dev/null") - unlink(prefs.c_str()); + RemoveFile("edspListParserPrivate", prefs); preferences.Open(prefs, FileFd::WriteOnly | FileFd::Create | FileFd::Exclusive, 0600); } }; diff --git a/apt-pkg/edsp/edspsystem.cc b/apt-pkg/edsp/edspsystem.cc index 4c16f76d2..95abc1527 100644 --- a/apt-pkg/edsp/edspsystem.cc +++ b/apt-pkg/edsp/edspsystem.cc @@ -57,8 +57,8 @@ public: if (tempDir.empty()) return; - unlink(tempStatesFile.c_str()); - unlink(tempPrefsFile.c_str()); + RemoveFile("DeInitialize", tempStatesFile); + RemoveFile("DeInitialize", tempPrefsFile); rmdir(tempDir.c_str()); } -- cgit v1.2.3