Bug introduced in commit 433132b90473538fa46fb6934ef8f7b7f36447b5: "Use send() and recv() for proxy communication (for MinGW's benefit)". Actually proxy_write() is used also for regular files in run_csd_script(): fd = mkstemp(fname); ... ret = proxy_write(vpninfo, fd, (void *)buf, buflen); so send() triggers error: Failed to write temporary CSD script file: Socket operation on non-socket The fix forces write() for regular files, keeping send() for sockets. Signed-off-by: Antonio Borneo <borneo.antonio at gmail.com> --- http.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/http.c b/http.c index 5d58846..6590977 100644 --- a/http.c +++ b/http.c @@ -1309,7 +1309,10 @@ static int proxy_write(struct openconnect_info *vpninfo, int fd, unsigned char *buf, size_t len) { size_t count; + struct stat statbuf; + if (fstat(fd, &statbuf) < 0) + return -1; for (count = 0; count < len; ) { fd_set rd_set, wr_set; int maxfd = fd; @@ -1328,7 +1331,10 @@ static int proxy_write(struct openconnect_info *vpninfo, int fd, if (!FD_ISSET(fd, &wr_set)) continue; - i = send(fd, (void *)&buf[count], len - count, 0); + if (S_ISREG(statbuf.st_mode)) + i = write(fd, buf + count, len - count); + else + i = send(fd, (void *)&buf[count], len - count, 0); if (i < 0) return -errno; -- 1.7.3.4