redirect apt-helper drop-privs output to /dev/null as we are only interested in the exit status and want to avoid spurious error messages from apt

This commit is contained in:
Johannes Schauer Marin Rodrigues 2023-01-26 09:28:35 +01:00
parent 06f84b84ae
commit 7910ca79ac
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1

View file

@ -2251,10 +2251,21 @@ sub run_setup() {
# root mode when the path of the chroot is not in a world-readable # root mode when the path of the chroot is not in a world-readable
# location. # location.
my $partial = '/var/lib/apt/lists/partial'; my $partial = '/var/lib/apt/lists/partial';
if ( my @testcmd = (
system('/usr/lib/apt/apt-helper', 'drop-privs', '--', 'test', '/usr/lib/apt/apt-helper', 'drop-privs', '--', 'test',
'-r', "$options->{root}$partial") != 0 '-r', "$options->{root}$partial"
) { );
my $pid = fork() // error "fork() failed: $!";
if ($pid == 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 ($? != 0) {
warning "Download is performed unsandboxed as root as file" warning "Download is performed unsandboxed as root as file"
. " $options->{root}$partial couldn't be accessed by user _apt"; . " $options->{root}$partial couldn't be accessed by user _apt";
open my $fh, '>>', $tmpfile open my $fh, '>>', $tmpfile