You are viewing a plain text version of this content. The canonical link for it is here.
Posted to test-dev@httpd.apache.org by Stas Bekman <st...@stason.org> on 2003/07/22 13:08:48 UTC

Re: cvs commit: httpd-test/perl-framework/Apache-Test Changes

stas@apache.org wrote:
> stas        2003/07/22 04:05:21
> 
>   Modified:    perl-framework/Apache-Test/lib/Apache TestRun.pm
>                perl-framework/Apache-Test Changes
>   Log:
>   when the tests are run in the 'root' mode, check whether the
>   DocumentRoot is rwx before the tests are run and suggest possible
>   workarounds when the tests are doomed to fail, because of the
>   permission issues.

I'm trying to address the issues with Apache::Test being used from /root and 
other dirs which aren't rwx by the user httpd is run with. Do you think the 
sudo test will work everywhere where this issue is relevant? If not please 
post patches. To reproduce the problem copy Apache-Test to some dir under 
/root and try to run 'make test'.

>   Revision  Changes    Path
>   1.111     +44 -1     httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm
>   
>   Index: TestRun.pm
>   ===================================================================
>   RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/lib/Apache/TestRun.pm,v
>   retrieving revision 1.110
>   retrieving revision 1.111
>   diff -u -r1.110 -r1.111
>   --- TestRun.pm	14 May 2003 02:53:54 -0000	1.110
>   +++ TestRun.pm	22 Jul 2003 11:05:21 -0000	1.111
>   @@ -673,6 +673,11 @@
>    #    have the right permissions to write into the fs created by 'foo'.
>    #
>    # We solve that by 'chown -R bar.bar t/' in a portable way.
>   +#
>   +# 3. If the parent directory is not rwx for the chosen user, that user
>   +#    won't be able to read/write the DocumentRoot. In which case we
>   +#    have nothing else to do, but to tell the user to fix the situation.
>   +#
>    sub adjust_t_perms {
>        my $self = shift;
>    
>   @@ -686,11 +691,16 @@
>            my $user = $vars->{user};
>            my($uid, $gid) = (getpwnam($user))[2..3]
>                or die "Can't find out uid/gid of '$user'";
>   -        warning "root mode: changing the fs ownership to '$user' ($uid:$gid)";
>   +
>   +        warning "root mode: ". 
>   +            "changing the files ownership to '$user' ($uid:$gid)";
>            finddepth(sub {
>                $original_t_perms{$File::Find::name} = [(stat $_)[4..5]];
>                chown $uid, $gid, $_;
>            }, $vars->{t_dir});
>   +
>   +        $self->check_perms($user, $uid, $gid);
>   +
>        }
>    }
>    
>   @@ -700,11 +710,44 @@
>        return if Apache::TestConfig::WINFU;
>    
>        if (%original_t_perms) {
>   +        warning "root mode: restoring the original files ownership";
>            my $vars = $self->{test_config}->{vars};
>            while (my($file, $ids) = each %original_t_perms) {
>                next unless -e $file; # files could be deleted
>                chown @$ids, $file;
>            }
>   +    }
>   +}
>   +
>   +sub check_perms {
>   +    my ($self, $user, $uid, $gid) = @_;
>   +
>   +    # test that the base dir is rwx by the selected non-root user
>   +    my $vars = $self->{test_config}->{vars};
>   +    my $dir  = $vars->{t_dir};
>   +    my $perl = $vars->{perl};
>   +    my $check = qq[sudo -u '#$uid' $perl -e ] . 
>   +        qq['print -r "$dir" &&  -w _ && -x _ ? "OK" : "NOK"'];
>   +    warning "$check\n";
>   +    my $res   = qx[$check] || '';
>   +    warning "result: $res";
>   +    unless ($res eq 'OK') {
>   +        #$self->restore_t_perms;
>   +        error(<<"EOI") && die "\n";
>   +You are running the test suite under user 'root'.
>   +Apache cannot spawn child processes as 'root', therefore
>   +we attempt to run the test suite with user '$user' ($uid:$gid).
>   +The problem is that the path:
>   +  $dir
>   +must be 'rwx' by user '$user', so Apache can read and write under that
>   +path.
>   +
>   +There several ways to resolve this issue. For example move 
>   +'$dir' to '/tmp/' and repeat the 'make test' phase. 
>   +
>   +You can test whether the location is good by running the following test:
>   +  % $check
>   +EOI
>        }
>    }
>    
>   
>   
>   
>   1.32      +5 -0      httpd-test/perl-framework/Apache-Test/Changes
>   
>   Index: Changes
>   ===================================================================
>   RCS file: /home/cvs/httpd-test/perl-framework/Apache-Test/Changes,v
>   retrieving revision 1.31
>   retrieving revision 1.32
>   diff -u -r1.31 -r1.32
>   --- Changes	8 Jul 2003 07:57:03 -0000	1.31
>   +++ Changes	22 Jul 2003 11:05:21 -0000	1.32
>   @@ -8,6 +8,11 @@
>    
>    =item 1.04-dev - 
>    
>   +when the tests are run in the 'root' mode, check whether the
>   +DocumentRoot is rwx before the tests are run and suggest possible
>   +workarounds when the tests are doomed to fail, because of the
>   +permission issues. [Stas]
>   +
>    UPLOAD is now auto-exported, like the rest [David Wheeler
>    <da...@kineticode.com>]
>    
>   
>   
>   


-- 


__________________________________________________________________
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