summaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authorThierry Vignaud <thierry.vignaud@gmail.com>2020-04-27 10:17:56 +0200
committerThierry Vignaud <thierry.vignaud@gmail.com>2020-04-29 14:46:06 +0200
commit34c3f9d61ef86a46e3b774130fe3877f4ec0ea32 (patch)
treeb71caac8943906af4fe2b8f402d408612460d292 /t
parent9bdd99afee76630ee6de7bdf61f63bd0b487a2eb (diff)
downloadurpmi-34c3f9d61ef86a46e3b774130fe3877f4ec0ea32.tar
urpmi-34c3f9d61ef86a46e3b774130fe3877f4ec0ea32.tar.gz
urpmi-34c3f9d61ef86a46e3b774130fe3877f4ec0ea32.tar.bz2
urpmi-34c3f9d61ef86a46e3b774130fe3877f4ec0ea32.tar.xz
urpmi-34c3f9d61ef86a46e3b774130fe3877f4ec0ea32.zip
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.
Diffstat (limited to 't')
-rwxr-xr-xt/simple-httpd8
1 files changed, 6 insertions, 2 deletions
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 <document root> <log dir> <port>\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";