diff options
-rw-r--r-- | Changes | 10 | ||||
-rw-r--r-- | MANIFEST.SKIP | 1 | ||||
-rw-r--r-- | Makefile.PL | 4 | ||||
-rw-r--r-- | lib/Apache/Defaults.pm | 70 |
4 files changed, 64 insertions, 21 deletions
@@ -1,3 +1,9 @@ | |||
1 | 1.03 2021-02-12 | ||
2 | - Change bugtracker address. | ||
3 | 1.02 2019-08-25 | ||
4 | - Make sure constructor never croaks if on_error is set to 'return' | ||
5 | Improve diagnostics. | ||
6 | 1.01 2018-07-17 | ||
7 | - Prefer apachectl over invoking httpd directly. | ||
1 | 1.00 2018-02-24 | 8 | 1.00 2018-02-24 |
2 | 9 | - Initial release. | |
3 | * Initial release. | ||
diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP index 58696be..3fb78f0 100644 --- a/MANIFEST.SKIP +++ b/MANIFEST.SKIP | |||
@@ -24,2 +24,3 @@ | |||
24 | \bblibdirs\.ts$ # 6.18 through 6.25 generated this | 24 | \bblibdirs\.ts$ # 6.18 through 6.25 generated this |
25 | \bMANIFEST\.SKIP$ | ||
25 | 26 | ||
diff --git a/Makefile.PL b/Makefile.PL index 9918d74..7cdd45a 100644 --- a/Makefile.PL +++ b/Makefile.PL | |||
@@ -29,2 +29,6 @@ WriteMakefile(NAME => 'Apache::Defaults', | |||
29 | }, | 29 | }, |
30 | bugtracker => { | ||
31 | web => 'https://puszcza.gnu.org.ua/bugs/?group=apache-defaults', | ||
32 | mailto => 'gray+apache-defaults@gnu.org.ua' | ||
33 | } | ||
30 | }, | 34 | }, |
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 | ||
12 | our $VERSION = '1.00'; | 12 | our $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,7 +89,6 @@ sub new { | |||
57 | } | 89 | } |
58 | } | 90 | } else { |
59 | $self->{environ} = $env->envs; | 91 | $self->{environ} = $env->envs; |
60 | } | 92 | } |
61 | 93 | } | |
62 | croak "unrecognized arguments" if keys(%_); | ||
63 | 94 | ||
@@ -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,3 +414,9 @@ 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' ] |
416 | |||
417 | The use of B<apachectl> is preferred over directly invoking B<httpd> daemon, | ||
418 | because the apache configuration file might contain referenmces to environment | ||
419 | variables defined elsewhere, which will cause B<httpd> to fail. B<apachectl> | ||
420 | takes care of this by including the file with variable definitions prior to | ||
421 | calling B<httpd>. See also C<environ>, below. | ||
386 | 422 | ||
@@ -389,9 +425,5 @@ The default used in the absense of this attribute is: | |||
389 | Name of the shell script that sets the environment for B<httpd> invocation. | 425 | Name of the shell script that sets the environment for B<httpd> invocation. |
390 | 426 | Usually, this is the same script that is sourced by B<apachectl> prior to | |
391 | If invoked with the B<-V> option, B<httpd> attempts to read its configuration | 427 | passing control over to B<httpd>. This option provides another solution to |
392 | file and will fail if the latter contains references to the environment | 428 | the environment problem mentioned above. E.g.: |
393 | variables defined elsewhere. This is quite common in Debian-based | ||
394 | distributions, which define the environment variables in file | ||
395 | F</etc/apache2/envvars>. To avoid such failures, use the C<environ> attribute, | ||
396 | e.g.: | ||
397 | 429 | ||
@@ -401,3 +433,3 @@ e.g.: | |||
401 | 433 | ||
402 | Controls the error handling. Allowed values are C<croak> and C<return>. | 434 | Controls error handling. Allowed values are C<croak> and C<return>. |
403 | If the value is C<croak> (the default), the method will I<croak> if an | 435 | If the value is C<croak> (the default), the method will I<croak> if an |