[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#770388: apt-cache as a non-root user if a APT .list file is not readable



Package: apt
Version: 1.0.9.3
Severity: normal

Dear Maintainer,

running apt-cache or apt-search as a non-root user is (was) very slow on
my machine:

    $ time apt-cache show gmpc
    ...
    apt-cache show gmpc  4.95s user 0.59s system 83% cpu 6.601 total
    $ time sudo apt-cache show gmpc
    ...
    apt-cache show gmpc  0.06s user 0.04s system 62% cpu 0.172 total

I tracked down the problem using strace and it seems that if a APT .list
file is not readable by a non-root user, apt-cache (in this case) goes
much, much slower:

    $ time apt-cache show gmpc
    ...
    apt-cache show gmpc  0.06s user 0.05s system 74% cpu 0.139 total

    $ sudo touch /etc/apt/sources.list.d/foo.list
    $ sudo chmod 600 /etc/apt/sources.list.d/foo.list

    $ time apt-cache show gmpc
    E: Opening /etc/apt/sources.list.d/foo.list - ifstream::ifstream (13: Permission denied)
    E: The list of sources could not be read.
    E: The package lists or status file could not be parsed or opened.
    E: No packages found
    apt-cache show gmpc  0.05s user 0.04s system 73% cpu 0.120 total

    $ sudo apt-get update
    ...
    $ time apt-cache show gmpc
    ...
    apt-cache show gmpc  4.95s user 0.59s system 83% cpu 6.601 total

    $ sudo chmod 644 /etc/apt/sources.list.d/foo.list
    $ time apt-cache show gmpc
    ...
    apt-cache show gmpc  0.06s user 0.04s system 62% cpu 0.172 total


strace shows that, when it's fast, apt-cache open the Packages file in
/var/lib/apt/lists/ and jumps directly using fseek() to the right
position to read the information about the package.

But when it's slow, it does the following:

 * it opens the same Package file
 * it reads the whole file, 32kB per 32kB
 * it opens a temporary file in /tmp
 * it opens the related _InRelease file
 * it writes into the temporary file... stuff (checksums it seems, from
   the _InRelease file I guess?)
 * after reading the while _InRelease file, it closes it, seek to the
   beginning of the temporary file and reads everything, then closes it.
 * then, it starts again with the next Package file


So, yeah, it's much slower in the end.

 Jonathan




-- Package-specific info:

-- (no /etc/apt/preferences present) --


-- (/etc/apt/sources.list present, but not submitted) --


-- System Information:
Debian Release: jessie/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (101, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.16.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages apt depends on:
ii  debian-archive-keyring  2014.1
ii  gnupg                   1.4.18-4
ii  libapt-pkg4.12          1.0.9.3
ii  libc6                   2.19-13
ii  libgcc1                 1:4.9.2-1
ii  libstdc++6              4.9.2-1

apt recommends no packages.

Versions of packages apt suggests:
pn  apt-doc     <none>
ii  aptitude    0.6.11-1+b1
ii  dpkg-dev    1.17.21
ii  python-apt  0.9.3.11
ii  synaptic    0.81.2

-- debconf-show failed


Reply to: