You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Markus Wichitill <ma...@gmx.de> on 2004/07/20 04:28:03 UTC
[apreq-2] Various test issues
After a pause, I've been doing some apreq2 testing again.
First, to work with current mp2 CVS and its changed server API, request.pm
needs this patch:
Index: glue/perl/t/response/TestApReq/request.pm
===================================================================
RCS file:
/home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
retrieving revision 1.33
diff -u -r1.33 request.pm
--- glue/perl/t/response/TestApReq/request.pm 18 Jul 2004 23:24:51 -0000 1.33
+++ glue/perl/t/response/TestApReq/request.pm 19 Jul 2004 23:22:22 -0000
@@ -26,7 +26,8 @@
sub handler {
my $r = shift;
- my $temp_dir = $r->server->server_root_relative('logs');
+ my $temp_dir =
+ File::Spec->catfile(Apache::ServerUtil::server_root, 'logs');
my $req = Apache::Request->new($r, POST_MAX => 1_000_000,
TEMP_DIR => $temp_dir);
Under Win32, the linkfile part of the upload test needs another :APR open to
work, otherwise the open will fail with permission denied:
Index: glue/perl/t/response/TestApReq/upload.pm
===================================================================
RCS file:
/home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/upload.pm,v
retrieving revision 1.1
diff -u -r1.1 upload.pm
--- glue/perl/t/response/TestApReq/upload.pm 12 Jul 2004 13:10:14 -0000 1.1
+++ glue/perl/t/response/TestApReq/upload.pm 20 Jul 2004 00:33:35 -0000
@@ -41,7 +41,8 @@
my $link_file = File::Spec->catfile($temp_dir, "linkfile");
unlink $link_file if -f $link_file;
$upload->link($link_file) or die "Can't link to $link_file: $!";
- open $fh, "<", $link_file or die "Can't open $link_file: $!";
+ open $fh, "<:APR", $link_file, $upload->pool
+ or die "Can't open $link_file: $!";
binmode $fh;
read $fh, $data, $upload->size;
close $fh;
Under Linux, when I run the upload test as root and if all files belong to
root, I think not enough files get chowned to nobody (?):
root@red /usr/src/httpd-apreq-2/glue/perl
$ perl t/TEST -verbose t/apreq/upload.t
[warning] setting ulimit to allow core files
ulimit -c unlimited; /usr/local/perl/bin/perl
/usr/src/httpd-apreq-2/glue/perl/t/TEST -verbose 't/apreq/upload.t'
make: Nothing to be done for `all'.
[warning] root mode: changing the files ownership to 'nobody' (65534:65533)
[warning] testing whether 'nobody' is able to -rwx
/usr/src/httpd-apreq-2/glue/perl/t
"/usr/local/perl/bin/perl" -Mlib=/usr/local/perl/lib -MApache::TestRun -e
'eval { Apache::TestRun::run_root_fs_test(65534, 65533,
q[/usr/src/httpd-apreq-2/glue/perl/t]) }';
[warning] result: OK
[warning] the client side drops 'root' permissions and becomes 'nobody'
/usr/local/apache2/bin/httpd -d /usr/src/httpd-apreq-2/glue/perl/t -f
/usr/src/httpd-apreq-2/glue/perl/t/conf/httpd.conf -D APACHE2 -D
PERL_USEITHREADS
using Apache/2.0.50 (worker MPM)
waiting 60 seconds for server to start: ..
waiting 60 seconds for server to start: ok (waited 1 secs)
server localhost:8529 started
t/apreq/upload....1..20
# Running under perl version 5.008004 for linux
# Current time local: Tue Jul 20 03:09:34 2004
# Current time GMT: Tue Jul 20 01:09:34 20040
# Using Test.pm version 1.25
# Using Apache/Test.pm version 1.13
Cannot open /usr/src/httpd-apreq-2/glue/perl/httpd: Permission denied at
t/apreq/upload.t line 27.
When all files belong to another non-root user and the test is executed as
that users, it works.
All apreq/cgi.t tests that worked before fail in that case however, since
test_cgi.pl can't be executed due to the lack of mod_cgid in the generated
t/conf/httpd.conf.
not ok 1
# Failed test 1 in t/apreq/cgi.t at line 51
# # of keys : 15, key_len 5
# testing : GET long query
# expected: 90
# received: #!/usr/local/perl/bin/perl
Finally, it would be nice if the apreq tests would include the apache\bin
directory in the PATH under Win32. Unlike for mp2, I couldn't figure out how
to do it this time.
Re: [apreq-2] Various test issues
Posted by Stas Bekman <st...@stason.org>.
Markus Wichitill wrote:
> Randy Kobes wrote:
>
>> Running the tests as root (for any package) generally casues
>> problems with Apache-Test, for reasons of permissions, as
>> you saw. I don't think there's a general fix yet, apart from
>> running the tests as non-root.
>
>
> Well, ever since the tests did the chowning to nobody, it worked fine.
> It's just that in this case the test upload files are written to
> perl/glue (the CWD), which isn't owned by nobody, unlike perl/glue/t.
> Maybe they should be moved to t:
Correct. A-T changes the files ownership only under t/ where all the
activity should happen and not outside of it, since it's impossible to
know what other dirs may need to be chdired and whether it's a safe
thing to do at all (since we are running as root)
Other than that A-T works just fine when run as root as long as the
directory where t/ resides is accessible (rx) by the user Apache is
running under.
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [apreq-2] Various test issues
Posted by Joe Schaefer <jo...@sunstarsys.com>.
Stas Bekman <st...@stason.org> writes:
> use blib;
> use Apache2;
+1.
--
Joe Schaefer
Re: [apreq-2] Various test issues
Posted by Stas Bekman <st...@stason.org>.
Markus Wichitill wrote:
>>> mod_cgid is enabled. If tests are run as root, it's included in the
>>> generated httpd.conf. And I don't see any permissions that would
>>> preclude
>>> the tests from including it when not run as root.
>>
>>
>> Neither do I - the system httpd.conf is parsed for available
>> modules, which should find mod_cgi and/or mod_cgid, if
>> enabled. I'll try to reproduce your problem (although
>> I'm using mod_cgi - not sure if that makes a difference).
>
>
> Silly me, I didn't look at my system httpd.conf's permissions, only the
> modules'. After "chmod o+r httpd.conf", it works, not that the test can
> rely on that of course.
>
> Well, actually for me it only works if A-R is already installed globally
> (which it wasn't after a Perl 5.8.5 upgrade), since the test assumes
> MP_INST_APACHE2=1. error_log of "perl t/TEST -verbose t/apreq/cgi.t":
>
> [Thu Jul 22 01:59:12 2004] [error] [client 127.0.0.1] Premature end of
> script headers: test_cgi.pl
> Can't locate Apache/Request.pm in @INC (@INC contains:
> ../../blib/lib/Apache2 ../../blib/arch/Apache2 /usr/local/perl/lib .) at
> test_cgi.pl line 13.
>
> In my case, it's blib/lib/Apache/Request.pm. Would the following work
> for MP_INST_APACHE2=1, too?
that's the right thing to do.
> Index: glue/perl/t/apreq/cgi.t
> ===================================================================
> RCS file: /home/cvspublic/httpd-apreq-2/glue/perl/t/apreq/cgi.t,v
> retrieving revision 1.5
> diff -u -r1.5 cgi.t
> --- glue/perl/t/apreq/cgi.t 11 Jul 2004 02:21:52 -0000 1.5
> +++ glue/perl/t/apreq/cgi.t 22 Jul 2004 00:53:20 -0000
> @@ -149,11 +149,11 @@
> use strict;
> use File::Basename;
> use warnings FATAL => 'all';
> +use lib qw(../../blib/lib
> + ../../blib/arch);
> use Apache2;
> use APR;
> use APR::Pool;
> -use lib qw(../../blib/lib/Apache2
> - ../../blib/arch/Apache2);
> use Apache::Request;
> use Apache::Cookie;
btw blib.pm does all the work for you, no need to work hard to setup lib
and arch sub-dirs.
use blib qw(../..);
use Apache2;
or even:
use blib;
use Apache2;
NAME
blib - Use MakeMaker's uninstalled version of a package
SYNOPSIS
perl -Mblib script [args...]
perl -Mblib=dir script [args...]
DESCRIPTION
Looks for MakeMaker-like 'blib' directory structure starting in
dir (or
current directory) and working back up to five levels of '..'.
...
--
__________________________________________________________________
Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org http://ticketmaster.com
Re: [apreq-2] Various test issues
Posted by Markus Wichitill <ma...@gmx.de>.
>> mod_cgid is enabled. If tests are run as root, it's included in the
>> generated httpd.conf. And I don't see any permissions that would preclude
>> the tests from including it when not run as root.
>
> Neither do I - the system httpd.conf is parsed for available
> modules, which should find mod_cgi and/or mod_cgid, if
> enabled. I'll try to reproduce your problem (although
> I'm using mod_cgi - not sure if that makes a difference).
Silly me, I didn't look at my system httpd.conf's permissions, only the
modules'. After "chmod o+r httpd.conf", it works, not that the test can rely
on that of course.
Well, actually for me it only works if A-R is already installed globally
(which it wasn't after a Perl 5.8.5 upgrade), since the test assumes
MP_INST_APACHE2=1. error_log of "perl t/TEST -verbose t/apreq/cgi.t":
[Thu Jul 22 01:59:12 2004] [error] [client 127.0.0.1] Premature end of
script headers: test_cgi.pl
Can't locate Apache/Request.pm in @INC (@INC contains:
../../blib/lib/Apache2 ../../blib/arch/Apache2 /usr/local/perl/lib .) at
test_cgi.pl line 13.
In my case, it's blib/lib/Apache/Request.pm. Would the following work for
MP_INST_APACHE2=1, too?
Index: glue/perl/t/apreq/cgi.t
===================================================================
RCS file: /home/cvspublic/httpd-apreq-2/glue/perl/t/apreq/cgi.t,v
retrieving revision 1.5
diff -u -r1.5 cgi.t
--- glue/perl/t/apreq/cgi.t 11 Jul 2004 02:21:52 -0000 1.5
+++ glue/perl/t/apreq/cgi.t 22 Jul 2004 00:53:20 -0000
@@ -149,11 +149,11 @@
use strict;
use File::Basename;
use warnings FATAL => 'all';
+use lib qw(../../blib/lib
+ ../../blib/arch);
use Apache2;
use APR;
use APR::Pool;
-use lib qw(../../blib/lib/Apache2
- ../../blib/arch/Apache2);
use Apache::Request;
use Apache::Cookie;
Re: [apreq-2] Various test issues
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Tue, 20 Jul 2004, Markus Wichitill wrote:
> Randy Kobes wrote:
> > Running the tests as root (for any package) generally casues
> > problems with Apache-Test, for reasons of permissions, as
> > you saw. I don't think there's a general fix yet, apart from
> > running the tests as non-root.
>
> Well, ever since the tests did the chowning to nobody, it worked fine. It's
> just that in this case the test upload files are written to perl/glue (the
> CWD), which isn't owned by nobody, unlike perl/glue/t. Maybe they should be
> moved to t:
That sounds right - thanks.
>
> >>All apreq/cgi.t tests that worked before fail in that case however, since
> >>test_cgi.pl can't be executed due to the lack of mod_cgid in the generated
> >>t/conf/httpd.conf.
>
> > Is mod_cgi (or mod_cgid, if this is for a multi-threaded
> > unix mpm) enabled in your system httpd.conf? We should
> > probably skip those tests if one of these, as appropriate,
> > isn't available.
>
> mod_cgid is enabled. If tests are run as root, it's included in the
> generated httpd.conf. And I don't see any permissions that would preclude
> the tests from including it when not run as root.
Neither do I - the system httpd.conf is parsed for available
modules, which should find mod_cgi and/or mod_cgid, if
enabled. I'll try to reproduce your problem (although
I'm using mod_cgi - not sure if that makes a difference).
> >>Under Win32, the linkfile part of the upload test needs another :APR open to
> >>work, otherwise the open will fail with permission denied:
>
> > Strange - that worked for me without the patch
>
> Maybe you didn't get a real hardlink but a copy because of a different
> partition or a FAT partition? If it's a real NTFS hardlink, it would make
> sense if the open() needs :APR like the open() in the tempname() test.
>
> > what is your $temp_dir?
>
> C:\\DOKUME~1\\mawic\\Temp, which is on the only partition on this WinXP Home
> system.
That make sense - thanks. I'll apply that patch to use :APR
in a few days, when I return.
--
best regards,
randy
Re: [apreq-2] Various test issues
Posted by Markus Wichitill <ma...@gmx.de>.
Randy Kobes wrote:
> Running the tests as root (for any package) generally casues
> problems with Apache-Test, for reasons of permissions, as
> you saw. I don't think there's a general fix yet, apart from
> running the tests as non-root.
Well, ever since the tests did the chowning to nobody, it worked fine. It's
just that in this case the test upload files are written to perl/glue (the
CWD), which isn't owned by nobody, unlike perl/glue/t. Maybe they should be
moved to t:
Index: glue/perl/t/apreq/upload.t
===================================================================
RCS file: /home/cvspublic/httpd-apreq-2/glue/perl/t/apreq/upload.t,v
retrieving revision 1.1
diff -u -r1.1 upload.t
--- glue/perl/t/apreq/upload.t 12 Jul 2004 13:10:14 -0000 1.1
+++ glue/perl/t/apreq/upload.t 20 Jul 2004 03:39:24 -0000
@@ -23,7 +23,7 @@
my $url = ( ($name =~ /\.pod$/) ?
"getfiles-perl-pod/" : "/getfiles-binary-" ) . $name;
my $content = GET_BODY_ASSERT($url);
- my $path = File::Spec->catfile($cwd, $name);
+ my $path = File::Spec->catfile($cwd, "t", $name);
open my $fh, ">", $path or die "Cannot open $path: $!";
binmode $fh;
print $fh $content;
@@ -33,7 +33,7 @@
eval {require Digest::MD5;};
my $has_md5 = $@ ? 0 : 1;
-foreach my $file( map {File::Spec->catfile($cwd, $_)} @names) {
+foreach my $file( map {File::Spec->catfile($cwd, "t", $_)} @names) {
my $size = -s $file;
my $cs = $has_md5 ? cs($file) : 0;
my $basename = File::Basename::basename($file);
>>All apreq/cgi.t tests that worked before fail in that case however, since
>>test_cgi.pl can't be executed due to the lack of mod_cgid in the generated
>>t/conf/httpd.conf.
> Is mod_cgi (or mod_cgid, if this is for a multi-threaded
> unix mpm) enabled in your system httpd.conf? We should
> probably skip those tests if one of these, as appropriate,
> isn't available.
mod_cgid is enabled. If tests are run as root, it's included in the
generated httpd.conf. And I don't see any permissions that would preclude
the tests from including it when not run as root.
>>Under Win32, the linkfile part of the upload test needs another :APR open to
>>work, otherwise the open will fail with permission denied:
> Strange - that worked for me without the patch
Maybe you didn't get a real hardlink but a copy because of a different
partition or a FAT partition? If it's a real NTFS hardlink, it would make
sense if the open() needs :APR like the open() in the tempname() test.
> what is your $temp_dir?
C:\\DOKUME~1\\mawic\\Temp, which is on the only partition on this WinXP Home
system.
Re: [apreq-2] Various test issues
Posted by Randy Kobes <ra...@theoryx5.uwinnipeg.ca>.
On Tue, 20 Jul 2004, Markus Wichitill wrote:
> After a pause, I've been doing some apreq2 testing again.
>
> First, to work with current mp2 CVS and its changed server API, request.pm
> needs this patch:
>
> Index: glue/perl/t/response/TestApReq/request.pm
> ===================================================================
> RCS file:
> /home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/request.pm,v
> retrieving revision 1.33
> diff -u -r1.33 request.pm
> --- glue/perl/t/response/TestApReq/request.pm 18 Jul 2004 23:24:51 -0000 1.33
> +++ glue/perl/t/response/TestApReq/request.pm 19 Jul 2004 23:22:22 -0000
> @@ -26,7 +26,8 @@
>
> sub handler {
> my $r = shift;
> - my $temp_dir = $r->server->server_root_relative('logs');
> + my $temp_dir =
> + File::Spec->catfile(Apache::ServerUtil::server_root, 'logs');
> my $req = Apache::Request->new($r, POST_MAX => 1_000_000,
> TEMP_DIR => $temp_dir);
>
>
Thanks - I'll apply that in a few days (I'm away from
my Win32 machine until then).
> Under Win32, the linkfile part of the upload test needs another :APR open to
> work, otherwise the open will fail with permission denied:
>
> Index: glue/perl/t/response/TestApReq/upload.pm
> ===================================================================
> RCS file:
> /home/cvspublic/httpd-apreq-2/glue/perl/t/response/TestApReq/upload.pm,v
> retrieving revision 1.1
> diff -u -r1.1 upload.pm
> --- glue/perl/t/response/TestApReq/upload.pm 12 Jul 2004 13:10:14 -0000 1.1
> +++ glue/perl/t/response/TestApReq/upload.pm 20 Jul 2004 00:33:35 -0000
> @@ -41,7 +41,8 @@
> my $link_file = File::Spec->catfile($temp_dir, "linkfile");
> unlink $link_file if -f $link_file;
> $upload->link($link_file) or die "Can't link to $link_file: $!";
> - open $fh, "<", $link_file or die "Can't open $link_file: $!";
> + open $fh, "<:APR", $link_file, $upload->pool
> + or die "Can't open $link_file: $!";
> binmode $fh;
> read $fh, $data, $upload->size;
> close $fh;
>
Strange - that worked for me without the patch ... It's
probably worth applying (with a note), but I'm curious -
what is your $temp_dir?
> Under Linux, when I run the upload test as root and if all files belong to
> root, I think not enough files get chowned to nobody (?):
>
> root@red /usr/src/httpd-apreq-2/glue/perl
> $ perl t/TEST -verbose t/apreq/upload.t
> [warning] setting ulimit to allow core files
> ulimit -c unlimited; /usr/local/perl/bin/perl
> /usr/src/httpd-apreq-2/glue/perl/t/TEST -verbose 't/apreq/upload.t'
> make: Nothing to be done for `all'.
> [warning] root mode: changing the files ownership to 'nobody' (65534:65533)
> [warning] testing whether 'nobody' is able to -rwx
> /usr/src/httpd-apreq-2/glue/perl/t
> "/usr/local/perl/bin/perl" -Mlib=/usr/local/perl/lib -MApache::TestRun -e
> 'eval { Apache::TestRun::run_root_fs_test(65534, 65533,
> q[/usr/src/httpd-apreq-2/glue/perl/t]) }';
>
> [warning] result: OK
> [warning] the client side drops 'root' permissions and becomes 'nobody'
> /usr/local/apache2/bin/httpd -d /usr/src/httpd-apreq-2/glue/perl/t -f
> /usr/src/httpd-apreq-2/glue/perl/t/conf/httpd.conf -D APACHE2 -D
> PERL_USEITHREADS
> using Apache/2.0.50 (worker MPM)
>
> waiting 60 seconds for server to start: ..
> waiting 60 seconds for server to start: ok (waited 1 secs)
> server localhost:8529 started
> t/apreq/upload....1..20
> # Running under perl version 5.008004 for linux
> # Current time local: Tue Jul 20 03:09:34 2004
> # Current time GMT: Tue Jul 20 01:09:34 20040
> # Using Test.pm version 1.25
> # Using Apache/Test.pm version 1.13
> Cannot open /usr/src/httpd-apreq-2/glue/perl/httpd: Permission denied at
> t/apreq/upload.t line 27.
>
>
> When all files belong to another non-root user and the test is executed as
> that users, it works.
Running the tests as root (for any package) generally casues
problems with Apache-Test, for reasons of permissions, as
you saw. I don't think there's a general fix yet, apart from
running the tests as non-root.
> All apreq/cgi.t tests that worked before fail in that case however, since
> test_cgi.pl can't be executed due to the lack of mod_cgid in the generated
> t/conf/httpd.conf.
>
> not ok 1
> # Failed test 1 in t/apreq/cgi.t at line 51
> # # of keys : 15, key_len 5
> # testing : GET long query
> # expected: 90
> # received: #!/usr/local/perl/bin/perl
Is mod_cgi (or mod_cgid, if this is for a multi-threaded
unix mpm) enabled in your system httpd.conf? We should
probably skip those tests if one of these, as appropriate,
isn't available.
> Finally, it would be nice if the apreq tests would include the apache\bin
> directory in the PATH under Win32. Unlike for mp2, I couldn't figure out how
> to do it this time.
I'll take a look when I return - thanks.
--
best regards,
randy