mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-27 22:03:31 +01:00
tor --list-fingerprint to print fingerprint and exit
svn:r2627
This commit is contained in:
parent
80f43a8c6e
commit
9510d9a792
2
doc/TODO
2
doc/TODO
@ -11,7 +11,7 @@ ARMA - arma claims
|
||||
X Abandoned
|
||||
|
||||
0.0.9pre5/6: ("Launch" version)
|
||||
- "tor --list-fingerprint" to print fingerprint and exit.
|
||||
o "tor --list-fingerprint" to print fingerprint and exit.
|
||||
- Oct 20 16:45:10.237 [warn] parse_addr_port(): Port '0' out of range
|
||||
o add and document DirPolicy config option
|
||||
- clean up parse_*_policy code
|
||||
|
@ -184,6 +184,8 @@ config_get_commandlines(int argc, char **argv)
|
||||
// log(LOG_DEBUG,"Commandline: skipping over -f.");
|
||||
i += 2; /* this is the config file option. ignore it. */
|
||||
continue;
|
||||
} else if (!strcmp(argv[i],"--list-fingerprint")) {
|
||||
i += 1; /* command-line option. ignore it. */
|
||||
}
|
||||
|
||||
new = tor_malloc(sizeof(struct config_line_t));
|
||||
@ -726,19 +728,27 @@ getconfig(int argc, char **argv, or_options_t *options)
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* learn config file name, get config lines, assign them */
|
||||
i = 1;
|
||||
while (i < argc-1 && strcmp(argv[i],"-f")) {
|
||||
i++;
|
||||
/* learn config file name, get config lines, assign them */
|
||||
fname = NULL;
|
||||
using_default_torrc = 1;
|
||||
options->command = CMD_RUN_TOR;
|
||||
for (i = 1; i < argc; ++i) {
|
||||
if (i < argc-1 && !strcmp(argv[i],"-f")) {
|
||||
if (fname) {
|
||||
log(LOG_WARN, "Duplicate -f options on command line.");
|
||||
tor_free(fname);
|
||||
}
|
||||
|
||||
if (i < argc-1) { /* we found one */
|
||||
fname = tor_strdup(argv[i+1]);
|
||||
using_default_torrc = 0;
|
||||
} else {
|
||||
++i;
|
||||
} else if (!strcmp(argv[i],"--list-fingerprint")) {
|
||||
options->command = CMD_LIST_FINGERPRINT;
|
||||
}
|
||||
}
|
||||
|
||||
if (using_default_torrc) {
|
||||
/* didn't find one, try CONFDIR */
|
||||
char *fn;
|
||||
using_default_torrc = 1;
|
||||
fn = get_default_conf_file();
|
||||
if (fn && file_status(fn) == FN_FILE) {
|
||||
fname = fn;
|
||||
|
@ -706,6 +706,11 @@ static int init_from_config(int argc, char **argv) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Bail out at this point if we're not going to be a server: we want
|
||||
* to not fork, and to log stuff to stderr. */
|
||||
if (options.command != CMD_RUN_TOR)
|
||||
return 0;
|
||||
|
||||
/* Configure the log(s) */
|
||||
if (config_init_logs(&options)<0)
|
||||
return -1;
|
||||
@ -1095,11 +1100,31 @@ static int tor_init(int argc, char *argv[]) {
|
||||
void tor_cleanup(void) {
|
||||
/* Remove our pid file. We don't care if there was an error when we
|
||||
* unlink, nothing we could do about it anyways. */
|
||||
if(options.PidFile)
|
||||
if(options.PidFile && options.command == CMD_RUN_TOR)
|
||||
unlink(options.PidFile);
|
||||
crypto_global_cleanup();
|
||||
}
|
||||
|
||||
/** Read/create keys as needed, and echo our fingerprint to stdout. */
|
||||
void do_list_fingerprint(void)
|
||||
{
|
||||
char buf[FINGERPRINT_LEN+1];
|
||||
crypto_pk_env_t *k;
|
||||
if (init_keys() < 0) {
|
||||
log_fn(LOG_ERR,"Error initializing keys; exiting");
|
||||
return;
|
||||
}
|
||||
if (!(k = get_identity_key())) {
|
||||
log_fn(LOG_ERR,"Error: missing identity key.");
|
||||
return;
|
||||
}
|
||||
if (crypto_pk_get_fingerprint(k, buf, 1)<0) {
|
||||
log_fn(LOG_ERR, "Error computing fingerprint");
|
||||
return;
|
||||
}
|
||||
printf("%s %s\n", options.Nickname, buf);
|
||||
}
|
||||
|
||||
#ifdef MS_WINDOWS_SERVICE
|
||||
void nt_service_control(DWORD request)
|
||||
{
|
||||
@ -1169,7 +1194,17 @@ int tor_main(int argc, char *argv[]) {
|
||||
#else
|
||||
if (tor_init(argc, argv)<0)
|
||||
return -1;
|
||||
switch (options.command) {
|
||||
case CMD_RUN_TOR:
|
||||
do_main_loop();
|
||||
break;
|
||||
case CMD_LIST_FINGERPRINT:
|
||||
do_list_fingerprint();
|
||||
break;
|
||||
default:
|
||||
log_fn(LOG_ERR, "Illegal command number %d: internal error.",
|
||||
options.command);
|
||||
}
|
||||
tor_cleanup();
|
||||
return -1;
|
||||
#endif
|
||||
|
@ -832,6 +832,10 @@ typedef struct exit_redirect_t {
|
||||
|
||||
/** Configuration options for a Tor process */
|
||||
typedef struct {
|
||||
/** What should the tor process actually do? */
|
||||
enum {
|
||||
CMD_RUN_TOR=0, CMD_LIST_FINGERPRINT
|
||||
} command;
|
||||
struct config_line_t *LogOptions; /**< List of configuration lines
|
||||
* for logfiles */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user