summaryrefslogtreecommitdiffabout
path: root/lib/Apache/Defaults.pm
Unidiff
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
@@ -9,7 +9,7 @@ use Text::ParseWords;
9use Symbol 'gensym'; 9use Symbol 'gensym';
10use Carp; 10use Carp;
11 11
12our $VERSION = '1.01'; 12our $VERSION = '1.02';
13 13
14sub new { 14sub new {
15 my $class = shift; 15 my $class = shift;
@@ -44,23 +44,54 @@ sub new {
44 croak "No suitable httpd binary found"; 44 croak "No suitable httpd binary found";
45 } 45 }
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') {
52 $self->{status} = $env->status; 83 $self->{status} = $env->status;
53 $self->{error} = "Failed to inherit environment"; 84 $self->{error} = "Failed to inherit environment";
85 return $self;
54 } else { 86 } else {
55 croak sprintf("Got status %d trying to inherit environment", 87 croak sprintf("Got status %d trying to inherit environment",
56 $env->status); 88 $env->status);
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;
65 $self->_get_module_info unless $self->status; 96 $self->_get_module_info unless $self->status;
66 97

Return to:

Send suggestions and report system problems to the System administrator.