Bug#753531: apt-get clean executes 'rm /*' if Dir::Cache is set to ""
On Thu, 3 Jul 2014 08:59:57 +0200
Michael Vogt <mvo@debian.org> wrote:
>
> Thanks for your bugreport.
>
> > (warning: attached patch is not a solution, it is just intended to
> > show the problem)
> >
> > Setting Dir::Cache::archives and Dir::Cache to the empty string (as
> > instructed by man 5 apt.conf) do NOT disable cache but set it to
> > '/'.
> >
> > Consequence: apt-get clean then effectively cleans '/' and removes
> > all files here.
> >
> > Not true anymore but even worse, on squeeze it also removes the
> > '/lib64' symlink, breaking the loader and preventing any new
> > dynamically linked binary to be launched.
>
> This sounds like we want to improve the description of the apt.conf
> manpage. I assume your use-case was to disable the binary cache? Maybe
> you can suggest a way to make the description clearer to avoid the
> issue for others?
>
> As for protecting against this, I attached a patch that makes clean a
> bit more careful and fix the example where Dir::Cache::archives="" is
> empty. But there is only so much we can do, e.g. if someone sets
> Dir::Cache=/vmlinuz its hard to have a programmatic way to detect that
> this is a bad idea. But I'm happy to protect against obvious ones
> (like Clean("/")).
>
Hi Michael, and thanks for your answer.
The use-case was indeed to disable the bin cache. Your patch is a good
protection against misreading the manual. Btw, I tried with '/dev/null'
only because it is handled differently in configuration.cc, I don't
think it's useful to protect against this.
For the manpage, I believe changing "their names" and "empty string"
to the actual values would be clear enough (attached patch).
Regards
--
Cédric
diff --git a/doc/apt.conf.5.xml b/doc/apt.conf.5.xml
index fcbf20d..ffecc6c 100644
--- a/doc/apt.conf.5.xml
+++ b/doc/apt.conf.5.xml
@@ -608,10 +608,11 @@ DPkg::Pre-Install-Pkgs {"/usr/sbin/dpkg-preconfigure --apt";};
information, such as the two package caches <literal>srcpkgcache</literal> and
<literal>pkgcache</literal> as well as the location to place downloaded archives,
<literal>Dir::Cache::archives</literal>. Generation of caches can be turned off
- by setting their names to the empty string. This will slow down startup but
- save disk space. It is probably preferable to turn off the pkgcache rather
- than the srcpkgcache. Like <literal>Dir::State</literal> the default
- directory is contained in <literal>Dir::Cache</literal></para>
+ by setting <literal>pkgcache</literal> or <literal>srcpkgcache</literal> to
+ <literal>""</literal>. This will slow down startup but save disk space. It
+ is probably preferable to turn off the pkgcache rather than the srcpkgcache.
+ Like <literal>Dir::State</literal> the default directory is contained in
+ <literal>Dir::Cache</literal></para>
<para><literal>Dir::Etc</literal> contains the location of configuration files,
<literal>sourcelist</literal> gives the location of the sourcelist and
Reply to: