Don't enable device events when there is no valid filedescriptor.
[tinc] / src / net_setup.c
index 44c8d8d..c643449 100644 (file)
@@ -293,7 +293,7 @@ bool setup_myself(void) {
        /* Generate packet encryption key */
 
        if(!get_config_string(lookup_config(myself->connection->config_tree, "Cipher"), &cipher))
-               cipher = xstrdup("aes256");
+               cipher = xstrdup("blowfish");
 
        if(!cipher_open_by_name(&myself->incipher, cipher)) {
                logger(LOG_ERR, "Unrecognized cipher type!");
@@ -308,7 +308,7 @@ bool setup_myself(void) {
        /* Check if we want to use message authentication codes... */
 
        if(!get_config_string(lookup_config(myself->connection->config_tree, "Digest"), &digest))
-               digest = xstrdup("sha256");
+               digest = xstrdup("sha1");
 
        int maclength = 4;
        get_config_int(lookup_config(myself->connection->config_tree, "MACLength"), &maclength);
@@ -349,12 +349,14 @@ bool setup_myself(void) {
        if(!setup_device())
                return false;
 
-       event_set(&device_ev, device_fd, EV_READ|EV_PERSIST, handle_device_data, NULL);
+       if(device_fd >= 0) {
+               event_set(&device_ev, device_fd, EV_READ|EV_PERSIST, handle_device_data, NULL);
 
-       if (event_add(&device_ev, NULL) < 0) {
-               logger(LOG_ERR, "event_add failed: %s", strerror(errno));
-               close_device();
-               return false;
+               if (event_add(&device_ev, NULL) < 0) {
+                       logger(LOG_ERR, "event_add failed: %s", strerror(errno));
+                       close_device();
+                       return false;
+               }
        }
 
        /* Run tinc-up script to further initialize the tap interface */