Fix: Handle hang-up gracefully in run-as
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 Sep 2015 19:50:02 +0000 (15:50 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 18 Sep 2015 21:12:42 +0000 (17:12 -0400)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/common/runas.c

index daba9937ce364d5113c2f6dfb61cbbb98f3b16e2..42ca55266ca43767b38c9e2af46cef74efd6933f 100644 (file)
@@ -216,7 +216,9 @@ int do_recv_fd(struct run_as_worker *worker,
                return 0;
        }
        len = lttcomm_recv_fds_unix_sock(worker->sockpair[0], fd, 1);
-       if (len < 0) {
+       if (!len) {
+               return -1;
+       } else if (len < 0) {
                PERROR("lttcomm_recv_fds_unix_sock");
                return -1;
        }
@@ -392,14 +394,19 @@ int run_as_cmd(struct run_as_worker *worker,
        /* receive return value */
        readlen = lttcomm_recv_unix_sock(worker->sockpair[0], &recvret,
                        sizeof(recvret));
-       if (readlen < sizeof(recvret)) {
+       if (!readlen) {
+               ERR("Run-as worker has hung-up during run_as_cmd");
+               recvret.ret = -1;
+               recvret._errno = EIO;
+               goto end;
+       } else if (readlen < sizeof(recvret)) {
                PERROR("Error reading response from run_as");
                recvret.ret = -1;
                recvret._errno = errno;
        }
        if (do_recv_fd(worker, cmd, &recvret.ret)) {
                recvret.ret = -1;
-               recvret._errno = -EIO;
+               recvret._errno = EIO;
        }
 
 end:
This page took 0.026146 seconds and 4 git commands to generate.