X-Git-Url: https://git.distorted.org.uk/~mdw/secnet/blobdiff_plain/4ac7fd3ff73c98100d8a8546668d0212e4af3ffa..5e7a5e2d42c1b06f249debca72c10ad33d157402:/udp.c diff --git a/udp.c b/udp.c index a6ab49a..8947058 100644 --- a/udp.c +++ b/udp.c @@ -183,6 +183,14 @@ static bool_t udp_sendmsg(void *commst, struct buffer_if *buf, return True; } +void udp_destroy_socket(struct udpcommon *uc, struct udpsock *us) +{ + if (us->fd>=0) { + close(us->fd); + us->fd=-1; + } +} + bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us, int failmsgclass) { @@ -224,6 +232,7 @@ bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us, char *argv[5], addrstr[33], portstr[5]; const char *addrfam; int port; + afterfork(); switch (addr->sa.sa_family) { case AF_INET: sprintf(addrstr,"%08lX",(long)addr->sin.sin_addr.s_addr); @@ -259,7 +268,14 @@ bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us, FAIL("waitpid for authbind"); } if (status) { - lg_exitstatus(FAIL_LG,status,"authbind"); + if (WIFEXITED(status) && WEXITSTATUS(status)<127) { + int es=WEXITSTATUS(status); + lg_perror(FAIL_LG,es, + "authbind exited with error exit status %d;" + " indicates error",es); + } else { + lg_exitstatus(FAIL_LG,status,"authbind"); + } goto failed; } } else { @@ -269,10 +285,7 @@ bool_t udp_make_socket(struct udpcommon *uc, struct udpsock *us, return True; failed: - if (us->fd>=0) { - close(us->fd); - us->fd=-1; - } + udp_destroy_socket(uc,us); return False; #undef FAIL