X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Fconf.c;h=4108d8ba2c648c9736954ef2f607e78c1117330d;hb=e9043e17c76f92b787c9ecdaf1a2ae7916f690a6;hp=49b78bbc0593acfe5f56e080dc14b20161ab7b17;hpb=bf8e3ce13dba6109757c14dc0013a315a75d2ba3;p=tinc diff --git a/src/conf.c b/src/conf.c index 49b78bbc..4108d8ba 100644 --- a/src/conf.c +++ b/src/conf.c @@ -410,66 +410,3 @@ bool read_server_config() { return x == 0; } - -FILE *ask_and_open(const char *filename, const char *what, const char *mode) { - FILE *r; - char *directory; - char *fn; - - /* Check stdin and stdout */ - if(!isatty(0) || !isatty(1)) { - /* Argh, they are running us from a script or something. Write - the files to the current directory and let them burn in hell - for ever. */ - fn = xstrdup(filename); - } else { - /* Ask for a file and/or directory name. */ - fprintf(stdout, _("Please enter a file to save %s to [%s]: "), - what, filename); - fflush(stdout); - - fn = readline(stdin, NULL, NULL); - - if(!fn) { - fprintf(stderr, _("Error while reading stdin: %s\n"), - strerror(errno)); - return NULL; - } - - if(!strlen(fn)) - /* User just pressed enter. */ - fn = xstrdup(filename); - } - -#ifdef HAVE_MINGW - if(fn[0] != '\\' && fn[0] != '/' && !strchr(fn, ':')) { -#else - if(fn[0] != '/') { -#endif - /* The directory is a relative path or a filename. */ - char *p; - - directory = get_current_dir_name(); - asprintf(&p, "%s/%s", directory, fn); - free(fn); - free(directory); - fn = p; - } - - umask(0077); /* Disallow everything for group and other */ - - /* Open it first to keep the inode busy */ - - r = fopen(fn, mode); - - if(!r) { - fprintf(stderr, _("Error opening file `%s': %s\n"), - fn, strerror(errno)); - free(fn); - return NULL; - } - - free(fn); - - return r; -}