Stas Bekman wrote:
Enrico Sorcinelli wrote:

On Tue, 09 Mar 2004 11:22:59 +0100
Arnaud Blancher <[EMAIL PROTECTED]> wrote:


t/hooks/cleanup.........................ok 1/2# Failed test 2 in t/hooks/cleanup.t at line 40
t/hooks/cleanup.........................FAILED test 2
Failed 1/2 tests, 50.00% okay
t/hooks/cleanup2........................NOK 1# Failed test 1 in t/hooks/cleanup2.t at line 28
t/hooks/cleanup2........................FAILED test 1



Me too, today, I've had these errors first time I launched tests, but when I
retried second time with:


    t/TEST -verbose t/hooks/cleanup t/hooks/cleanup2
the tests passed (then after mp installation, all my apps work fine).

Curiously, it seems that only first time I run tests I've errors (I've
reproduced this several times by ricompiling mod_perl from scratch).

BTW, my error_log, _only_ first time, says:

[Tue Mar 09 13:12:21 2004] [error] [client 127.0.0.1] can't open /usr/local/src/mod_perl-1.99_13/t/htdocs/hooks/cleanup: Permission denied at
/usr/local/src/mod_perl-1.99_13/Apache-Test/lib/Apache/TestUtil.pm line 96.


[Tue Mar 09 13:12:27 2004] [error] [client 127.0.0.1] can't open /usr/local/src/mod_perl-1.99_13/t/htdocs/hooks/cleanup2: Permission denied at
/usr/local/src/mod_perl-1.99_13/Apache-Test/lib/Apache/TestUtil.pm line 96.


it's because Apache-Test chown's all files before it starts the server. In case of cleanup tests, a directory was created on the client side as root so the server side running as nobody couldn't read/write it. When you run it second time Apache-Test has chowned that newly created directory and the test has passed. tricky. I'm trying to mend those problems.

the other failed tests were due to the modperl-1.99_13 directory relocation to a new place. Some Apache-Test config variables, were still pointing at the previous location. I'll try to fix that too.

I think the following relatively simple solution fixes all these and future problems when running under root. It'll be in cvs shortly:


Index: Apache-Test/lib/Apache/TestRun.pm
===================================================================
RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
retrieving revision 1.156
diff -u -r1.156 TestRun.pm
--- Apache-Test/lib/Apache/TestRun.pm   4 Mar 2004 05:51:31 -0000       1.156
+++ Apache-Test/lib/Apache/TestRun.pm   9 Mar 2004 20:37:30 -0000
@@ -881,6 +881,7 @@

$self->check_perms($user, $uid, $gid);

+        $self->become_nonroot($user, $uid, $gid);
     }
 }

@@ -986,6 +987,22 @@
         skip_test_suite();
         exit_perl 0;
     }
+}
+
+sub become_nonroot {
+    my ($self, $user, $uid, $gid) = @_;
+
+    warning "the client side drops 'root' permissions and becomes '$user'";
+
+    # first must change gid and egid ("$gid $gid" for an empty
+    # setgroups() call as explained in perlvar.pod)
+    my $groups = "$gid $gid";
+    $( = $) = $groups;
+    die "failed to change gid to $gid" unless $( eq $groups && $) eq $groups;
+
+    # only now can change uid and euid
+    $< = $> = $uid+0;
+    die "failed to change uid to $uid" unless $< == $uid && $> == $uid;
 }

sub run_request {


__________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to