diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-22 22:46:31 +0200 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-22 22:48:04 +0200 |
| commit | 140d36fd16a3d4f1fce0c54474b946d0577f1fde (patch) | |
| tree | a3ccfa6cb178a06033155e155a88e0a9175bdeee /apt-pkg | |
| parent | 3347b7a00682a0498a2602ce3e4e72c2c3d49c75 (diff) | |
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.
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/pkgcachegen.cc | 4 |
1 files changed, 4 insertions, 0 deletions
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; |
