🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #23

Bug#1139592: mmdebstrap: improve error message for unreadable files such as --keyring

#23
From: Johannes Schauer Marin Rodrigues
Date: Wed, 07 Oct 2026 09:30
93 lines
5450 bytes
--===============5429652727986582826==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable

Hi,

Quoting Helmut Grohne (2026-06-09 13:59:27)
> If you mmdebstrap --keyring=3D/path/to/somekeyring ...  and that keyring
> happens to not be readable by your subuid range (e.g.  when it is not
> world readable) the error message is not very helpful.  The permission
> problem is not displayed at all. Instead, a missing key is reported:

I can reproduce the problem. There is some code which attempted to warn but
uses the wrong logic:

if (-e $options->{apttrusted} && !-r $options->{apttrusted}) {
    warning "cannot read $options->{apttrusted}";
}

The above assumes that the unshared user is able to see whether the file ex=
ists
but that can fail if there are insufficient permissions along the path. The=
 new
code now also considers whether the unprivileged _apt user is able to read =
the
keyring:

    foreach my $path ($options->{apttrusted}, $options->{apttrustedparts}) {
        if (!-e $path) {
            warning("keyring does not exist (or insufficient permissions): "
                  . $path);
            next;
        }
        if (!-r $path) {
            warning("keyring cannot be read: " . $path);
            next;
        }
        my @testcmd =3D (
            '/usr/lib/apt/apt-helper', 'drop-privs', '--', 'test', '-r', $p=
ath
        );
        my $pid =3D fork() // error "fork() failed: $!";
        if ($pid =3D=3D 0) {
            open(STDOUT, '>', '/dev/null')
              or error "cannot open /dev/null for writing: $!";
            open(STDERR, '>', '/dev/null')
              or error "cannot open /dev/null for writing: $!";
            exec { $testcmd[0] } @testcmd
              or error("cannot exec " . (join " ", @testcmd) . ": $!");
        }
        waitpid $pid, 0;
        if ($? !=3D 0) {
            warning "apt is unable to read $path after dropping privileges";
        }
    }

But, please be careful when using the --keyring argument. apt developers
deprecated the Dir::Etc::Trusted option:

W: http://archive.ubuntu.com/ubuntu/dists/resolute/InRelease: Loading /home=
/josch/mmdebstrap/target/usr/share/keyrings/ubuntu-archive-keyring.gpg from=
 deprecated option Dir::Etc::Trusted

Instead, you should be using the keyring option in your sources.list.

Thanks!

cheers, josch
--===============5429652727986582826==
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Description: signature
Content-Type: application/pgp-signature; name="signature.asc"; charset="us-ascii"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEElFhU6KL81LF4wVq58sulx4+9g+EFAmrGDpkACgkQ8sulx4+9
g+Ec1Q/9HmMU64c7oIPLZNB/nb12PFfvNx0jJ0VL6EKAQxrvXjCG+pZ7v6+p2d9w
lqNJY3ie/XEL9/8JcqXyktxiEen1G9pEq8hDbcpUNr4NhL8nlHsg6RWUE+tPt+8W
E9J+TVCj8iXoBV5Y0VtOqNXTvCO18umkmNHm2S5xaDxz3HNWLHAfe5lc13iMTQYG
4NxW8UvcQIWzA6sa3WhVJtHJIY7Zt+47Z/PcXKJYCH0axZEivEf/UqKT9lWUq1y/
B6UnMsa7uhdvRu9Pq8RXxIo0i+bTrwe9ITu8ieyeksL/0Yc9l3q7tOSUoSr4O7Pp
tH5ygdk1yldrB9orSo5wi+v+0sBV1iZEdka5Iu9RyXc6Cv69LHo6vJ4LU1zPzmzn
8M7G/asV5pKjecdu3EgWryPTpo9nolTVuQJOSKlzBd25CGUxUDNddhRbxspY4/qC
1X+KYuew8BXOoVI0Tf5Gkwe2VlQZNRAR+AKnBBXwlCDv2/QaSdjFy189d+EX6O5Z
GaqvM0yq+YeAcwZdukwurXGiVXhCA0uSiWrXZqa2cV9ohbMLd76xXMJvbyxab9wh
LEcj3bb/76ve34w26ym41XjRcx9p/BNTB2cpofEiQOhEvPIMeGK04GLHeABC5d3b
yTfmM3O4uuCq3ifJMe16IoZfhRmmydj57VphqBZEqDUrwnmZzzI=
=Yzb/
-----END PGP SIGNATURE-----

--===============5429652727986582826==--
Technical Details
Message-ID: <NLw8h-43iI-1@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
References: <N4kBP-bIeY-1@gated-at.bofh.it> <N4kBP-bIeY-1@gated-at.bofh.it>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.samoylyk.net!gothmog.csi.it!bofh.it!news.nic.it!robomod
From: Johannes Schauer Marin Rodrigues <josch@debian.org>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1139592: mmdebstrap: improve error message for unreadable files such as --keyring
Date: Wed, 07 Oct 2026 11:30:01 +0200
Message-ID: <NLw8h-43iI-1@gated-at.bofh.it>
References: <N4kBP-bIeY-1@gated-at.bofh.it> <N4kBP-bIeY-1@gated-at.bofh.it>
X-Original-To: 1139592@bugs.debian.org, Helmut Grohne <helmut@subdivi.de>
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Wed Oct  7 09:21:10 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.7
Reply-To: Johannes Schauer Marin Rodrigues <josch@debian.org>, 1139592@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: josch@debian.org
X-Debian-Pr-Message: followup 1139592
X-Debian-Pr-Package: mmdebstrap
X-Debian-Pr-Source: mmdebstrap
Content-Type: multipart/signed; micalg="pgp-sha512"; protocol="application/pgp-signature"; boundary="===============5429652727986582826=="
MIME-Version: 1.0
Content-Disposition: inline
User-Agent: alot/0.0.0
X-Debian-User: josch
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/1995509
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 93
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 07 Oct 2026 11:19:25 +0200
X-Original-Message-ID: <179136476561.21057.6340426045898872248@localhost>
X-Original-References: <20260609115927.GA552832@subdivi.de> <20260609115927.GA552832@subdivi.de>