mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +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
|
X Abandoned
|
||||||
|
|
||||||
0.0.9pre5/6: ("Launch" version)
|
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
|
- Oct 20 16:45:10.237 [warn] parse_addr_port(): Port '0' out of range
|
||||||
o add and document DirPolicy config option
|
o add and document DirPolicy config option
|
||||||
- clean up parse_*_policy code
|
- clean up parse_*_policy code
|
||||||
|
@ -184,6 +184,8 @@ config_get_commandlines(int argc, char **argv)
|
|||||||
// log(LOG_DEBUG,"Commandline: skipping over -f.");
|
// log(LOG_DEBUG,"Commandline: skipping over -f.");
|
||||||
i += 2; /* this is the config file option. ignore it. */
|
i += 2; /* this is the config file option. ignore it. */
|
||||||
continue;
|
continue;
|
||||||
|
} else if (!strcmp(argv[i],"--list-fingerprint")) {
|
||||||
|
i += 1; /* command-line option. ignore it. */
|
||||||
}
|
}
|
||||||
|
|
||||||
new = tor_malloc(sizeof(struct config_line_t));
|
new = tor_malloc(sizeof(struct config_line_t));
|
||||||
@ -726,19 +728,27 @@ getconfig(int argc, char **argv, or_options_t *options)
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* learn config file name, get config lines, assign them */
|
/* learn config file name, get config lines, assign them */
|
||||||
i = 1;
|
fname = NULL;
|
||||||
while (i < argc-1 && strcmp(argv[i],"-f")) {
|
using_default_torrc = 1;
|
||||||
i++;
|
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);
|
||||||
|
}
|
||||||
|
fname = tor_strdup(argv[i+1]);
|
||||||
|
using_default_torrc = 0;
|
||||||
|
++i;
|
||||||
|
} else if (!strcmp(argv[i],"--list-fingerprint")) {
|
||||||
|
options->command = CMD_LIST_FINGERPRINT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < argc-1) { /* we found one */
|
if (using_default_torrc) {
|
||||||
fname = tor_strdup(argv[i+1]);
|
|
||||||
using_default_torrc = 0;
|
|
||||||
} else {
|
|
||||||
/* didn't find one, try CONFDIR */
|
/* didn't find one, try CONFDIR */
|
||||||
char *fn;
|
char *fn;
|
||||||
using_default_torrc = 1;
|
|
||||||
fn = get_default_conf_file();
|
fn = get_default_conf_file();
|
||||||
if (fn && file_status(fn) == FN_FILE) {
|
if (fn && file_status(fn) == FN_FILE) {
|
||||||
fname = fn;
|
fname = fn;
|
||||||
|
@ -706,6 +706,11 @@ static int init_from_config(int argc, char **argv) {
|
|||||||
return -1;
|
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) */
|
/* Configure the log(s) */
|
||||||
if (config_init_logs(&options)<0)
|
if (config_init_logs(&options)<0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -1095,11 +1100,31 @@ static int tor_init(int argc, char *argv[]) {
|
|||||||
void tor_cleanup(void) {
|
void tor_cleanup(void) {
|
||||||
/* Remove our pid file. We don't care if there was an error when we
|
/* Remove our pid file. We don't care if there was an error when we
|
||||||
* unlink, nothing we could do about it anyways. */
|
* unlink, nothing we could do about it anyways. */
|
||||||
if(options.PidFile)
|
if(options.PidFile && options.command == CMD_RUN_TOR)
|
||||||
unlink(options.PidFile);
|
unlink(options.PidFile);
|
||||||
crypto_global_cleanup();
|
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
|
#ifdef MS_WINDOWS_SERVICE
|
||||||
void nt_service_control(DWORD request)
|
void nt_service_control(DWORD request)
|
||||||
{
|
{
|
||||||
@ -1169,7 +1194,17 @@ int tor_main(int argc, char *argv[]) {
|
|||||||
#else
|
#else
|
||||||
if (tor_init(argc, argv)<0)
|
if (tor_init(argc, argv)<0)
|
||||||
return -1;
|
return -1;
|
||||||
do_main_loop();
|
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();
|
tor_cleanup();
|
||||||
return -1;
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
|
@ -832,6 +832,10 @@ typedef struct exit_redirect_t {
|
|||||||
|
|
||||||
/** Configuration options for a Tor process */
|
/** Configuration options for a Tor process */
|
||||||
typedef struct {
|
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
|
struct config_line_t *LogOptions; /**< List of configuration lines
|
||||||
* for logfiles */
|
* for logfiles */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user