From 140d36fd16a3d4f1fce0c54474b946d0577f1fde Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 22 May 2024 22:46:31 +0200 Subject: pkgcachegen: Do not try to chmod or write to /dev/null When -o Dir::Cache::pkgcache or -o Dir::Cache is set to /dev/null we accidentally changed its mode to 0666; which is certainly not intended. Avoid this issue by exiting the function early if the file specified is /dev/null. --- apt-pkg/pkgcachegen.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 504756104..981d360d2 100644 --- a/apt-pkg/pkgcachegen.cc +++ b/apt-pkg/pkgcachegen.cc @@ -1637,6 +1637,10 @@ static DynamicMMap* CreateDynamicMMap(FileFd * const CacheF, unsigned long Flags static bool writeBackMMapToFile(pkgCacheGenerator * const Gen, DynamicMMap * const Map, std::string const &FileName) { + // Do not write the file back to /dev/null or try to change its mode... + if (FileName == "/dev/null") + return true; + FileFd SCacheF(FileName, FileFd::WriteAtomic); if (SCacheF.IsOpen() == false || SCacheF.Failed()) return false; -- cgit v1.2.3-70-g09d2