- fprintf(stderr, "Invitation succesfully accepted.\n");
- shutdown(sock, SHUT_RDWR);
- success = true;
+ask_netname:
+ if(ask_netname && tty) {
+ fprintf(stderr, "Enter a new netname: ");
+ if(!fgets(line, sizeof line, stdin)) {
+ fprintf(stderr, "Error while reading stdin: %s\n", strerror(errno));
+ return false;
+ }
+ if(!*line || *line == '\n')
+ goto ask_netname;
+
+ line[strlen(line) - 1] = 0;
+
+ char newbase[PATH_MAX];
+ snprintf(newbase, sizeof newbase, CONFDIR SLASH "tinc" SLASH "%s", line);
+ if(rename(confbase, newbase)) {
+ fprintf(stderr, "Error trying to rename %s to %s: %s\n", confbase, newbase, strerror(errno));
+ goto ask_netname;
+ }
+
+ netname = line;
+ make_names(false);
+ }
+
+ fprintf(stderr, "Configuration stored in: %s\n", confbase);