environment_add(&env, "REMOTEADDRESS=%s", address);
environment_add(&env, "NAME=%s", myself->name);
+ free(address);
+ free(port);
+
execute_script("invitation-accepted", &env);
environment_exit(&env);
}
// Read the new node's Name from the file
- char buf[1024];
+ char buf[1024] = "";
fgets(buf, sizeof(buf), f);
+ size_t buflen = strlen(buf);
- if(*buf) {
- buf[strlen(buf) - 1] = 0;
+ // Strip whitespace at the end
+ while(buflen && strchr(" \t\r\n", buf[buflen - 1])) {
+ buf[--buflen] = 0;
}
+ // Split the first line into variable and value
len = strcspn(buf, " \t=");
char *name = buf + len;
name += strspn(name, " \t");
buf[len] = 0;
+ // Check that it is a valid Name
if(!*buf || !*name || strcasecmp(buf, "Name") || !check_id(name) || !strcmp(name, myself->name)) {
logger(DEBUG_ALWAYS, LOG_ERR, "Invalid invitation file %s\n", cookie);
fclose(f);
}
}
+#ifndef DISABLE_LEGACY
bool send_metakey(connection_t *c) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
-
if(!myself->connection->rsa) {
logger(DEBUG_CONNECTIONS, LOG_ERR, "Peer %s (%s) uses legacy protocol which we don't support", c->name, c->hostname);
return false;
c->status.encryptout = true;
return result;
-#endif
}
bool metakey_h(connection_t *c, const char *request) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
-
if(!myself->connection->rsa) {
return false;
}
c->allow_request = CHALLENGE;
return send_challenge(c);
-#endif
}
bool send_challenge(connection_t *c) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
const size_t len = rsa_size(c->rsa);
char buffer[len * 2 + 1];
/* Send the challenge */
return send_request(c, "%d %s", CHALLENGE, buffer);
-#endif
}
bool challenge_h(connection_t *c, const char *request) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
-
if(!myself->connection->rsa) {
return false;
}
} else {
return true;
}
-
-#endif
}
bool send_chal_reply(connection_t *c) {
}
bool chal_reply_h(connection_t *c, const char *request) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
char hishash[MAX_STRING_SIZE];
if(sscanf(request, "%*d " MAX_STRING, hishash) != 1) {
}
return send_ack(c);
-#endif
}
static bool send_upgrade(connection_t *c) {
-#ifdef DISABLE_LEGACY
- return false;
-#else
/* Special case when protocol_minor is 1: the other end is Ed25519 capable,
* but doesn't know our key yet. So send it now. */
bool result = send_request(c, "%d %s", ACK, pubkey);
free(pubkey);
return result;
-#endif
}
+#else
+bool send_metakey(connection_t *c) {
+ (void)c;
+ return false;
+}
+
+bool metakey_h(connection_t *c, const char *request) {
+ (void)c;
+ (void)request;
+ return false;
+}
+
+bool send_challenge(connection_t *c) {
+ (void)c;
+ return false;
+}
+
+bool challenge_h(connection_t *c, const char *request) {
+ (void)c;
+ (void)request;
+ return false;
+}
+
+bool send_chal_reply(connection_t *c) {
+ (void)c;
+ return false;
+}
+
+bool chal_reply_h(connection_t *c, const char *request) {
+ (void)c;
+ (void)request;
+ return false;
+}
+
+static bool send_upgrade(connection_t *c) {
+ (void)c;
+ return false;
+}
+#endif
bool send_ack(connection_t *c) {
if(c->protocol_minor == 1) {