summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2019-08-25 12:53:27 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2019-08-25 12:53:27 (GMT)
commit0e7e7c20b7a953c1d5ad2d816aca21974d7802c9 (patch) (side-by-side diff)
treef0b0da7acb1d6c57e3c9fca9d480866fd07924cf
parent447c9ac19f0ecac9a728de36409cc8d7afdf3001 (diff)
downloadapache-defaults-master.tar.gz
apache-defaults-master.tar.bz2
Make sure constructor never croaks if on_error is set to 'return'HEADv1.02master
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Changes3
-rw-r--r--lib/Apache/Defaults.pm49
2 files changed, 43 insertions, 9 deletions
diff --git a/Changes b/Changes
index 6ba79e2..414580e 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,6 @@
+1.02 2019-08-25
+ - Make sure constructor never croaks if on_error is set to 'return'
+ Improve diagnostics.
1.01 2018-07-17
- Prefer apachectl over invoking httpd directly.
1.00 2018-02-24
diff --git a/lib/Apache/Defaults.pm b/lib/Apache/Defaults.pm
index 6108d23..5fa8217 100644
--- a/lib/Apache/Defaults.pm
+++ b/lib/Apache/Defaults.pm
@@ -9,7 +9,7 @@ use Text::ParseWords;
use Symbol 'gensym';
use Carp;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
sub new {
my $class = shift;
@@ -44,23 +44,54 @@ sub new {
croak "No suitable httpd binary found";
}
- if ($v = delete $_{environ}) {
- my $env = Shell::GetEnv->new('sh', ". $v",
- { startup => 0 });
- if ($env->status) {
+ my $envfile = delete $_{environ};
+ croak "unrecognized arguments" if keys(%_);
+
+ if ($envfile) {
+ unless (-f $envfile) {
+ if ($self->{on_error} eq 'return') {
+ $self->{status} = 127;
+ $self->{error} = "environment file $envfile does not exist";
+ return $self;
+ } else {
+ croak "environment file $envfile does not exist";
+ }
+ }
+ unless (-r $envfile) {
+ if ($self->{on_error} eq 'return') {
+ $self->{status} = 127;
+ $self->{error} = "environment file $envfile is not readable";
+ return $self;
+ } else {
+ croak "environment file $envfile is not readable";
+ }
+ }
+
+ my $env = eval {
+ Shell::GetEnv->new('sh', ". $envfile", { startup => 0 });
+ };
+ if ($@) {
+ if ($self->{on_error} eq 'return') {
+ $self->{status} = 127;
+ $self->{error} = $@;
+ return $self;
+ } else {
+ croak $@;
+ }
+ } elsif ($env->status) {
if ($self->{on_error} eq 'return') {
$self->{status} = $env->status;
$self->{error} = "Failed to inherit environment";
+ return $self;
} else {
croak sprintf("Got status %d trying to inherit environment",
$env->status);
}
- }
- $self->{environ} = $env->envs;
+ } else {
+ $self->{environ} = $env->envs;
+ }
}
- croak "unrecognized arguments" if keys(%_);
-
$self->_get_version_info unless $self->status;
$self->_get_module_info unless $self->status;

Return to:

Send suggestions and report system problems to the System administrator.