summaryrefslogtreecommitdiffabout
path: root/lib/Apache/Defaults.pm
Side-by-side diff
Diffstat (limited to 'lib/Apache/Defaults.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--lib/Apache/Defaults.pm49
1 files changed, 40 insertions, 9 deletions
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
@@ -11,3 +11,3 @@ use Carp;
-our $VERSION = '1.01';
+our $VERSION = '1.02';
@@ -46,6 +46,37 @@ sub new {
- 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') {
@@ -53,2 +84,3 @@ sub new {
$self->{error} = "Failed to inherit environment";
+ return $self;
} else {
@@ -57,8 +89,7 @@ sub new {
}
- }
- $self->{environ} = $env->envs;
+ } else {
+ $self->{environ} = $env->envs;
+ }
}
- croak "unrecognized arguments" if keys(%_);
-
$self->_get_version_info unless $self->status;

Return to:

Send suggestions and report system problems to the System administrator.