summaryrefslogtreecommitdiff
path: root/lib/Apache/Defaults.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Apache/Defaults.pm')
-rw-r--r--lib/Apache/Defaults.pm72
1 files changed, 52 insertions, 20 deletions
diff --git a/lib/Apache/Defaults.pm b/lib/Apache/Defaults.pm
index 70d5385..0978456 100644
--- a/lib/Apache/Defaults.pm
+++ b/lib/Apache/Defaults.pm
@@ -11,3 +11,3 @@ use Carp;
11 11
12our $VERSION = '1.00'; 12our $VERSION = '1.03';
13 13
@@ -33,3 +33,3 @@ sub new {
33 } else { 33 } else {
34 @servlist = qw(/usr/sbin/httpd /usr/sbin/apache2); 34 @servlist = qw(/usr/sbin/apachectl /usr/sbin/httpd /usr/sbin/apache2);
35 } 35 }
@@ -46,6 +46,37 @@ sub new {
46 46
47 if ($v = delete $_{environ}) { 47 my $envfile = delete $_{environ};
48 my $env = Shell::GetEnv->new('sh', ". $v", 48 croak "unrecognized arguments" if keys(%_);
49 { startup => 0 }); 49
50 if ($env->status) { 50 if ($envfile) {
51 unless (-f $envfile) {
52 if ($self->{on_error} eq 'return') {
53 $self->{status} = 127;
54 $self->{error} = "environment file $envfile does not exist";
55 return $self;
56 } else {
57 croak "environment file $envfile does not exist";
58 }
59 }
60 unless (-r $envfile) {
61 if ($self->{on_error} eq 'return') {
62 $self->{status} = 127;
63 $self->{error} = "environment file $envfile is not readable";
64 return $self;
65 } else {
66 croak "environment file $envfile is not readable";
67 }
68 }
69
70 my $env = eval {
71 Shell::GetEnv->new('sh', ". $envfile", { startup => 0 });
72 };
73 if ($@) {
74 if ($self->{on_error} eq 'return') {
75 $self->{status} = 127;
76 $self->{error} = $@;
77 return $self;
78 } else {
79 croak $@;
80 }
81 } elsif ($env->status) {
51 if ($self->{on_error} eq 'return') { 82 if ($self->{on_error} eq 'return') {
@@ -53,2 +84,3 @@ sub new {
53 $self->{error} = "Failed to inherit environment"; 84 $self->{error} = "Failed to inherit environment";
85 return $self;
54 } else { 86 } else {
@@ -57,8 +89,7 @@ sub new {
57 } 89 }
58 } 90 } else {
59 $self->{environ} = $env->envs; 91 $self->{environ} = $env->envs;
92 }
60 } 93 }
61 94
62 croak "unrecognized arguments" if keys(%_);
63
64 $self->_get_version_info unless $self->status; 95 $self->_get_version_info unless $self->status;
@@ -76,3 +107,2 @@ sub probe {
76 107
77 open(my $nullout, '>', File::Spec->devnull);
78 open(my $nullin, '<', File::Spec->devnull); 108 open(my $nullin, '<', File::Spec->devnull);
@@ -384,4 +414,10 @@ The default used in the absense of this attribute is:
384 414
385 [ '/usr/sbin/httpd', '/usr/sbin/apache2' ] 415 [ '/usr/sbin/apachectl', '/usr/sbin/httpd', '/usr/sbin/apache2' ]
386 416
417The use of B<apachectl> is preferred over directly invoking B<httpd> daemon,
418because the apache configuration file might contain referenmces to environment
419variables defined elsewhere, which will cause B<httpd> to fail. B<apachectl>
420takes care of this by including the file with variable definitions prior to
421calling B<httpd>. See also C<environ>, below.
422
387=item C<environ> 423=item C<environ>
@@ -389,9 +425,5 @@ The default used in the absense of this attribute is:
389Name of the shell script that sets the environment for B<httpd> invocation. 425Name of the shell script that sets the environment for B<httpd> invocation.
390 426Usually, this is the same script that is sourced by B<apachectl> prior to
391If invoked with the B<-V> option, B<httpd> attempts to read its configuration 427passing control over to B<httpd>. This option provides another solution to
392file and will fail if the latter contains references to the environment 428the environment problem mentioned above. E.g.:
393variables defined elsewhere. This is quite common in Debian-based
394distributions, which define the environment variables in file
395F</etc/apache2/envvars>. To avoid such failures, use the C<environ> attribute,
396e.g.:
397 429
@@ -401,3 +433,3 @@ e.g.:
401 433
402Controls the error handling. Allowed values are C<croak> and C<return>. 434Controls error handling. Allowed values are C<croak> and C<return>.
403If the value is C<croak> (the default), the method will I<croak> if an 435If the value is C<croak> (the default), the method will I<croak> if an

Return to:

Send suggestions and report system problems to the System administrator.