Report forwarded
to debian-bugs-dist@lists.debian.org, APT Development Team <deity@lists.debian.org>: Bug#970440; Package apt.
(Wed, 16 Sep 2020 12:09:04 GMT) (full text, mbox, link).
Acknowledgement sent
to Jonny Grant <jg@jguk.org>:
New Bug report received and forwarded. Copy sent to APT Development Team <deity@lists.debian.org>.
(Wed, 16 Sep 2020 12:09:04 GMT) (full text, mbox, link).
Subject: apt-get update could show that not running as root when it fails
Date: Wed, 16 Sep 2020 13:05:06 +0100
Package: apt
Version: 2.0.2ubuntu0.1
Current output:
$ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
Expected output:
$ apt-get update
Reading package lists... Done
E: Could not open lock file /var/lib/apt/lists/lock not running as root - open Permission denied
E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/
W: Problem unlinking the file /var/cache/apt/pkgcache.bin - RemoveCaches (13: Permission denied)
W: Problem unlinking the file /var/cache/apt/srcpkgcache.bin - RemoveCaches (13: Permission denied)
it's easy enough to check uid is 0 by calling getuid()
There's no real reason to show the errno value 13, we don't all know these by heart. you could put EPERM if you wish to use the macro name
Debbugs is free software and licensed under the terms of the GNU
Public License version 2. The current version can be obtained
from https://bugs.debian.org/debbugs-source/.