diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2017-06-01 10:43:59 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2017-06-01 10:43:59 +0200 |
commit | 63bca29310bc899ce6c7068f376cbfb426da3571 (patch) | |
tree | d36bf603ac71368faebb087495ce343193881e5e /roles/MSA | |
parent | acd15ca11a510d3c5cb31f25e173de86fa570300 (diff) |
postfix-sender-login: handle EINTR in read(2) and write(2) calls.
Diffstat (limited to 'roles/MSA')
-rwxr-xr-x | roles/MSA/files/usr/local/bin/postfix-sender-login.pl | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/roles/MSA/files/usr/local/bin/postfix-sender-login.pl b/roles/MSA/files/usr/local/bin/postfix-sender-login.pl index 987482e..5f563c3 100755 --- a/roles/MSA/files/usr/local/bin/postfix-sender-login.pl +++ b/roles/MSA/files/usr/local/bin/postfix-sender-login.pl @@ -64,7 +64,6 @@ server(); sub server() { while(1) { accept(my $conn, $S) or do { - # try again if accept(2) was interrupted by a signal next if $! == EINTR; die "accept: $!"; }; @@ -77,6 +76,7 @@ sub server() { for (my $i = 0; $i < $len;) { my $n = syswrite($conn, $reply, $len-$i, $i) // do { + next if $! == EINTR; warn "Can't write: $!"; last; }; @@ -92,7 +92,10 @@ sub process_request($) { # keep reading until the request length is determined do { - my $n = sysread($conn, $buf, $BUFSIZE, $offset) // return "TEMP can't read: $!"; + my $n = sysread($conn, $buf, $BUFSIZE, $offset) // do { + next if $! == EINTR; + return "TEMP can't read: $!"; + }; return "TEMP EOF" if $n == 0; $offset += $n; } until ($buf =~ /\A(0|[1-9][0-9]*):/); @@ -101,7 +104,10 @@ sub process_request($) { my $strlen = length("$1") + 1; # [len]":" my $len = $strlen + $1 + 1; # [len]":"[string]"," while ($offset < $len) { - my $n = sysread($conn, $buf, $BUFSIZE, $offset) // return "TEMP can't read: $!"; + my $n = sysread($conn, $buf, $BUFSIZE, $offset) // do { + next if $! == EINTR; + return "TEMP can't read: $!"; + }; return "TEMP EOF" if $n == 0; $offset += $n; } @@ -116,10 +122,10 @@ sub process_request($) { $key =~ /\A(.+)@([^\@]+)\z/ or return "NOTFOUND "; # invalid sender address my ($localpart, $domainpart) = ($1, $2); - my $ldap = Net::LDAPI::->new( $LDAPI ) - // return "TEMP couldn't create Net::LDAPI object"; - $ldap->bind( undef, sasl => Authen::SASL::->new(mechanism => 'EXTERNAL') ) - or return "TEMP LDAP: couldn't bind"; + my $ldap = Net::LDAPI::->new( $LDAPI ) // + return "TEMP couldn't create Net::LDAPI object"; + $ldap->bind( undef, sasl => Authen::SASL::->new(mechanism => 'EXTERNAL') ) or + return "TEMP LDAP: couldn't bind"; my $reply = lookup_sender($ldap, $localpart, $domainpart); $ldap->unbind(); |