diff options
-rw-r--r-- | common/sys/net.c | 20 | ||||
-rw-r--r-- | daemon/logind/logind.c | 4 |
2 files changed, 18 insertions, 6 deletions
diff --git a/common/sys/net.c b/common/sys/net.c index 232d5bb1..efeda16a 100644 --- a/common/sys/net.c +++ b/common/sys/net.c @@ -188,9 +188,11 @@ int toread(int fd, void *buf, int len) { int l; for( l = 0 ; len > 0 ; ) - if( (l = read(fd, buf, len)) <= 0 ) + if( (l = read(fd, buf, len)) <= 0 ) { + if (errno == EINTR || errno == EAGAIN) + continue; return -1; - else{ + }else{ buf += l; len -= l; } @@ -204,9 +206,11 @@ int towrite(int fd, const void *buf, int len) { int l; for( l = 0 ; len > 0 ; ) - if( (l = write(fd, buf, len)) <= 0 ) + if( (l = write(fd, buf, len)) <= 0){ + if (errno == EINTR || errno == EAGAIN) + continue; return -1; - else{ + }else{ buf += l; len -= l; } @@ -293,9 +297,17 @@ int recv_remote_fd(int tunnel, const char *tunnel_path) } cmsg = CMSG_FIRSTHDR(&msg); + if (!cmsg) { + // kernel indicates there's no ancillary data + return -1; + } + assert(cmsg->cmsg_type == SCM_RIGHTS); if (cmsg->cmsg_type != SCM_RIGHTS) + { + // invalid message!? return -1; + } return *(int*)CMSG_DATA(cmsg); } diff --git a/daemon/logind/logind.c b/daemon/logind/logind.c index 213d8a02..4346e32d 100644 --- a/daemon/logind/logind.c +++ b/daemon/logind/logind.c @@ -11,8 +11,8 @@ // TODO: // 1. cache guest's usernum and check if too many guests online // 2. [drop] change close connection to 'wait until user hit then close' -// 3. regular check text screen files instead of HUP? -// 4. start mbbsd for some parameter? +// 3. [done] regular check text screen files instead of HUP? +// 4. re-start mbbsd if pipe broken? #include <stdio.h> #include <ctype.h> |