$OpenBSD: patch-lib_Apache_TestConfig_pm,v 1.2 2008/05/01 10:12:22 simon Exp $ --- lib/Apache/TestConfig.pm.orig Thu Nov 15 00:59:24 2007 +++ lib/Apache/TestConfig.pm Thu May 1 00:47:59 2008 @@ -60,7 +60,7 @@ use vars qw(%Usage); # variables stored in $Apache::TestConfigData::vars my @data_vars_must = qw(httpd apxs); -my @data_vars_opt = qw(user group port); +my @data_vars_opt = qw(user group port chroot); # mapping from $Apache::TestConfigData::vars to $ENV settings my %vars_to_env = ( httpd => 'APACHE_TEST_HTTPD', @@ -68,6 +68,7 @@ my %vars_to_env = ( user => 'APACHE_TEST_USER', group => 'APACHE_TEST_GROUP', port => 'APACHE_TEST_PORT', + chroot=> 'APACHE_TEST_CHROOT', ); %Usage = ( @@ -100,6 +101,7 @@ my %vars_to_env = ( sslcaorg => 'SSL CA organization to use for tests (default is asf)', libmodperl => 'path to mod_perl\'s .so (full or relative to LIBEXECDIR)', defines => 'values to add as -D defines (for example, "VAR1 VAR2")', + chroot => 'switch to enable httpd chroot behavior', (map { $_ . '_module_name', "$_ module name"} qw(cgi ssl thread access auth php)), ); @@ -156,6 +158,7 @@ my %passenv = map { $_,1 } qw{ APACHE_TEST_GROUP APACHE_TEST_USER APACHE_TEST_PORT + APACHE_TEST_CHROOT }; sub passenv { @@ -303,6 +306,7 @@ sub new { $vars->{documentroot} ||= catfile $vars->{serverroot}, 'htdocs'; $vars->{perlpod} ||= $self->find_in_inc('pods') || $self->find_in_inc('pod'); + $vars->{chroot} ||= $self->default_chroot; $vars->{perl} ||= $^X; $vars->{t_conf} ||= catfile $vars->{serverroot}, 'conf'; $vars->{sslca} ||= catfile $vars->{t_conf}, 'ssl', 'ca'; @@ -732,6 +736,17 @@ sub default_httpd { $ENV{APACHE_TEST_HTTPD}; } +sub default_chroot { + my $uid = $>; + + my $chroot = $ENV{APACHE_TEST_CHROOT} || 0; + + if ($chroot && $uid != 0) { + die "cannot run tests in chroot as normal user"; + } + + $chroot; +} my $localhost; sub default_localhost { @@ -846,7 +861,9 @@ sub find_apache_module { ($vars->{src_dir}, $self->apxs('LIBEXECDIR'), catfile($sroot, 'modules'), - catfile($sroot, 'libexec')); + catfile($sroot, 'libexec'), + '/usr/lib/apache/modules', + '%%LOCALBASE%%/lib'); for (@trys) { my $file = catfile $_, $module; @@ -2593,6 +2610,12 @@ a tty. But sometimes there is a program that can answe (e.g. when testing A-T itself). If this variable is true the interactive config won't be skipped (if needed). +=head2 APACHE_TEST_CHROOT + +Under OpenBSD the httpd(8) runs per default in a chroot environment. +As this conflicts with the usual test setup and requires root privileges, +the default in C is to do no chroot. +With C set, the httpd is started chrooted. =head1 Special Placeholders