]> git.meshlink.io Git - meshlink/blobdiff - src/tincctl.c
Build fails: Adding protocol.o object to library and using -fPIC
[meshlink] / src / tincctl.c
index fdb72e05469e4634b5ee411ce99e5b71e24a0520..c28c20ec8599fa4532ed3fb219ab92925c2fad31 100644 (file)
 #include "tincctl.h"
 #include "top.h"
 
+#ifndef MSG_NOSIGNAL
+#define MSG_NOSIGNAL 0
+#endif
+
 static char **orig_argv;
 static int orig_argc;
 
@@ -354,7 +358,7 @@ static FILE *ask_and_open(const char *filename, const char *what, const char *mo
   Generate a public/private ECDSA keypair, and ask for a file to store
   them in.
 */
-static bool ecdsa_keygen(bool ask) {
+bool ecdsa_keygen(bool ask) {
        ecdsa_t *key;
        FILE *f;
        char *pubname, *privname;
@@ -408,7 +412,7 @@ static bool ecdsa_keygen(bool ask) {
   Generate a public/private RSA keypair, and ask for a file to store
   them in.
 */
-static bool rsa_keygen(int bits, bool ask) {
+bool rsa_keygen(int bits, bool ask) {
        rsa_t *key;
        FILE *f;
        char *pubname, *privname;
@@ -529,7 +533,7 @@ bool sendline(int fd, char *format, ...) {
        blen++;
 
        while(blen) {
-               int result = send(fd, p, blen, 0);
+               int result = send(fd, p, blen, MSG_NOSIGNAL);
                if(result == -1 && errno == EINTR)
                        continue;
                else if(result <= 0)
@@ -741,6 +745,11 @@ bool connect_tincd(bool verbose) {
        freeaddrinfo(res);
 #endif
 
+#ifdef SO_NOSIGPIPE
+       static const int one = 1;
+       setsockopt(c, SOL_SOCKET, SO_NOSIGPIPE, (void *)&one, sizeof one);
+#endif
+
        char data[4096];
        int version;