From 34c3f9d61ef86a46e3b774130fe3877f4ec0ea32 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Mon, 27 Apr 2020 10:17:56 +0200 Subject: fix failing when serving over HTTP from within /root rationale: If we switch from root to nobody/nogroup while running in /root, everytime simple-httpd accesses to a files while answering to urpmi will fail with "-1 EACCES (Permission denied)" Then t/tmp/error.log contains "Error - 404 - file not found" but that's hidden when running tests as part of CPAN testers. --- NEWS | 1 + t/simple-httpd | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index c9748f54..66be375d 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,7 @@ o display RPM version in cpan-testers logs o do not fail test when libnss.so is not found in Debian 9 or FreeBSD o fix failing to build some rpms on FreeBSD + o fix failing tests when serving over HTTP from within /root o fix test with rpm < 4.13 on CentOS7 o make sure genhdlist2 works o perform some file conflict tests only on Mageia diff --git a/t/simple-httpd b/t/simple-httpd index 1f758699..fcc9a301 100755 --- a/t/simple-httpd +++ b/t/simple-httpd @@ -6,6 +6,7 @@ use base qw(Net::Server::Single); use strict; +use Cwd 'getcwd'; @ARGV == 3 or die "usage: simple-httpd \n"; my ($DOCUMENT_ROOT, $SERVER_ROOT, $PORT) = @ARGV; @@ -23,8 +24,11 @@ sub configure_hook { my $root = $self->{server_root} = $SERVER_ROOT; $self->{server}->{port} = "*:$PORT"; # port and addr to bind - $self->{server}->{user} = 'nobody'; # user to run as - $self->{server}->{group} = 'nogroup' if -e '/etc/mageia-release'; # group to run as + # running as nobody will make all tests to fail when running as root and in /root (access denied -> 404) + if (getcwd() !~ m!^/root/!) { + $self->{server}->{user} = 'nobody'; # user to run as + $self->{server}->{group} = 'nogroup' if -e '/etc/mageia-release'; # group to run as + } $self->{server}->{log_file} = "$root/server.log"; -- cgit v1.2.1