aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlacme44
1 files changed, 24 insertions, 20 deletions
diff --git a/lacme b/lacme
index 839d53d..cf2f9eb 100755
--- a/lacme
+++ b/lacme
@@ -395,6 +395,7 @@ sub spawn_webserver() {
# If $args->{in} is defined, the data is written to the client's STDIN.
# If $args->{out} is defined, its value is set to client's STDOUT data.
#
+my $ACCOUNTD = 0;
sub acme_client($@) {
my $args = shift;
my @args = @_;
@@ -402,27 +403,30 @@ sub acme_client($@) {
my $client;
my $conf = $CONFIG->{client};
if (defined (my $accountd = $CONFIG->{accountd})) {
- socketpair($client, my $s, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!";
- my $pid = fork() // "fork: $!";
- unless ($pid) {
- drop_privileges($accountd->{user}, $accountd->{group}, '/');
- set_FD_CLOEXEC($s, 0);
- $client->close() or die "Can't close: $!";
- my @cmd = ($accountd->{command}, '--fdopen='.fileno($s));
- push @cmd, '--config='.$accountd->{config} if defined $accountd->{config};
- push @cmd, '--privkey='.$accountd->{privkey} if defined $accountd->{privkey};
- push @cmd, '--quiet' unless lc $accountd->{quiet} eq 'no';
- push @cmd, '--debug' if $OPTS{debug};
- exec { $cmd[0] } @cmd or die;
+ unless ($ACCOUNTD) {
+ socketpair($client, my $s, AF_UNIX, SOCK_STREAM, PF_UNSPEC) or die "socketpair: $!";
+ my $pid = fork() // "fork: $!";
+ unless ($pid) {
+ drop_privileges($accountd->{user}, $accountd->{group}, '/');
+ set_FD_CLOEXEC($s, 0);
+ $client->close() or die "Can't close: $!";
+ my @cmd = ($accountd->{command}, '--fdopen='.fileno($s));
+ push @cmd, '--config='.$accountd->{config} if defined $accountd->{config};
+ push @cmd, '--privkey='.$accountd->{privkey} if defined $accountd->{privkey};
+ push @cmd, '--quiet' unless lc $accountd->{quiet} eq 'no';
+ push @cmd, '--debug' if $OPTS{debug};
+ exec { $cmd[0] } @cmd or die;
+ }
+ print STDERR "[$$] Forking lacme-accountd, child PID $pid\n" if $OPTS{debug};
+ $ACCOUNTD = $pid;
+ $s->close() or die "Can't close: $!";
+ push @CLEANUP, sub() {
+ print STDERR "[$$] Shutting down lacme-accountd\n" if $OPTS{debug};
+ shutdown($client, SHUT_RDWR) or warn "shutdown: $!";
+ kill 15 => $pid;
+ waitpid $pid => 0;
+ };
}
- print STDERR "[$$] Forking lacme-accountd, child PID $pid\n" if $OPTS{debug};
- $s->close() or die "Can't close: $!";
- push @CLEANUP, sub() {
- print STDERR "[$$] Shutting down lacme-accountd\n" if $OPTS{debug};
- shutdown($client, SHUT_RDWR) or warn "shutdown: $!";
- kill 15 => $pid;
- waitpid $pid => 0;
- };
}
else {
my @stat;