udp: Report authbind exit status as errno value if it seems appropriate
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Oct 2014 23:49:02 +0000 (00:49 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 8 Oct 2014 17:25:18 +0000 (18:25 +0100)
authbind-helper is documented as indicating an errno value in its exit
status.  When the exit status is small enough that it's unlikely to
have come from the runtime system, print it as an errno value instead
of using lg_exitstatus.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
udp.c

diff --git a/udp.c b/udp.c
index a6ab49a..838fd51 100644 (file)
--- a/udp.c
+++ b/udp.c
@@ -259,7 +259,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 {