logo       

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

Subject: Re: cvs commit: httpd-test/perl-framework/Apache-Test Changes
stas@xxxxxxxxxx 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
   <david@xxxxxxxxxxxxxx>]


--


__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@xxxxxxxxxx http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
audio.irate.dev...    yellowdog.gener...    ietf.ips/2002-0...    xfree86.fonts/2...    busybox/2003-07...    emacs.jdee/2004...    linux.mandrake....    hardware.microc...    user-groups.lin...    science.analysi...    version-control...    db.filemaker.de...    cluster.openmos...    mail.eyebrowse....    text.xml.xerces...    kde.devel.kwrit...    finance.moneyda...    gcc.regression/...    network.routing...    os.freebsd.deve...    recreation.radi...    qnx.openqnx.dev...    python.xml/2002...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe