aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2018-04-19 15:23:49 +0300
committerSergey Poznyakoff <gray@gnu.org>2018-04-19 15:23:49 +0300
commitc7f7295dbd260099a58eefeea9594995672fd170 (patch)
tree748315bcff141bb2bfeb2df628c3b624c2e6272a
parentd21aabb64b7178667349199ff852326365899258 (diff)
downloadacmeman-c7f7295dbd260099a58eefeea9594995672fd170.tar.gz
acmeman-c7f7295dbd260099a58eefeea9594995672fd170.tar.bz2
Always report incorrect termination of a subprocess
-rwxr-xr-xacmeman29
1 files changed, 16 insertions, 13 deletions
diff --git a/acmeman b/acmeman
index 99f158a..e6fee16 100755
--- a/acmeman
+++ b/acmeman
@@ -624,12 +624,26 @@ sub prep_dir {
}
exit(EX_CANTCREAT);
}
}
}
+sub runcmd {
+ my $cmd = shift;
+ debug(1, "running $cmd");
+ unless ($dry_run) {
+ system($cmd);
+ if ($? == -1) {
+ error("$cmd: failed to execute: $!");
+ } elsif ($? & 127) {
+ error("$cmd: died on signal ".($? & 127));
+ } elsif (my $code = ($? >> 8)) {
+ error("$cmd: exited with code $code");
+ }
+ }
+}
sub debug_to_loglevel {
my @lev = ('err', 'info', 'debug');
return $lev[$debug > $#lev ? $#lev : $debug];
}
@@ -1182,35 +1196,24 @@ $challenge = Protocol::ACME::Challenge::LocalFile->new({
my $renewed = 0;
foreach my $vhost (@domlist) {
next unless selected_domain($vhost);
if ($force || domain_cert_expires($vhost)) {
if (register_domain_certificate($vhost)) {
if (my $cmd = $vhost->postrenew) {
- debug(1, "running $cmd");
- unless ($dry_run) {
- system($cmd);
- if ($? == -1) {
- error("$cmd: failed to execute: $!");
- } elsif ($? & 127) {
- error("$cmd: died on signal ".($? & 127));
- } elsif (my $code = ($? >> 8)) {
- error("$cmd: exited with code $code");
- }
- }
+ runcmd($cmd);
} else {
$renewed++;
}
}
}
}
if ($renewed) {
if ($config->isset(qw(core postrenew))) {
foreach my $cmd ($config->get(qw(core postrenew))) {
- debug(1, "running $cmd");
- system($cmd) unless $dry_run;
+ runcmd($cmd);
}
} else {
error("certificates changed, but no postrenew command is defined (core.postrenew)");
}
}

Return to:

Send suggestions and report system problems to the System administrator.