Merge branch 'feature13864_squashed'

This commit is contained in:
Nick Mathewson
2015-02-02 13:32:53 -05:00
3 changed files with 31 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
o Minor features:
- Implement '-f -' CLI suboption to allow torrc to be read
from standard input, thus not requiring to store torrc in file
system. Implements feature 13865.
+2 -1
View File
@@ -42,7 +42,8 @@ COMMAND-LINE OPTIONS
[[opt-f]] **-f** __FILE__::
Specify a new configuration file to contain further Tor configuration
options. (Default: @CONFDIR@/torrc, or $HOME/.torrc if that file is not
options OR pass *-* to make Tor read its configuration from standard
input. (Default: @CONFDIR@/torrc, or $HOME/.torrc if that file is not
found)
[[opt-allow-missing-torrc]] **--allow-missing-torrc**::
+24 -1
View File
@@ -4201,6 +4201,17 @@ find_torrc_filename(config_line_t *cmd_arg,
return fname;
}
/** Read the torrc from standard input and return it as a string.
* Upon failure, return NULL.
*/
static char *
load_torrc_from_stdin(config_line_t *cmd_arg)
{
size_t sz_out;
return read_file_to_str_until_eof(STDIN_FILENO,SIZE_MAX,&sz_out);
}
/** Load a configuration file from disk, setting torrc_fname or
* torrc_defaults_fname if successful.
*
@@ -4341,7 +4352,19 @@ options_init_from_torrc(int argc, char **argv)
cf = tor_strdup("");
} else {
cf_defaults = load_torrc_from_disk(cmdline_only_options, 1);
cf = load_torrc_from_disk(cmdline_only_options, 0);
const config_line_t *f_line = config_line_find(cmdline_only_options,
"-f");
const int read_torrc_from_stdin =
(f_line != NULL && strcmp(f_line->value, "-") == 0);
if (read_torrc_from_stdin) {
cf = load_torrc_from_stdin(cmdline_only_options);
} else {
cf = load_torrc_from_disk(cmdline_only_options, 0);
}
if (!cf) {
if (config_line_find(cmdline_only_options, "--allow-missing-torrc")) {
cf = tor_strdup("");