diff options
| author | Guilhem Moulin <guilhem@fripost.org> | 2016-12-01 11:39:38 +0100 | 
|---|---|---|
| committer | Guilhem Moulin <guilhem@fripost.org> | 2016-12-01 11:39:55 +0100 | 
| commit | 8184304b3e7c5ae92779f7f6bc8c4bb1aeb2d8eb (patch) | |
| tree | 9b25d606eb0395cae654fc31e48ccce167928404 | |
| parent | 37a1daaf01431038de4ea983c4093fd2e271336f (diff) | |
Revert "lacme: avoid spawning multiple accountd processes."
This reverts commit 8faab5db6571972156f45b5838b23dbb0fadd5c4.
We can't reuse the socket pair as we don't connect(2) to it.
| -rwxr-xr-x | lacme | 44 | 
1 files changed, 20 insertions, 24 deletions
| @@ -395,7 +395,6 @@ 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 = @_; @@ -403,30 +402,27 @@ sub acme_client($@) {      my $client;      my $conf = $CONFIG->{client};      if (defined (my $accountd = $CONFIG->{accountd})) { -        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; -            }; +        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}; +        $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; | 
