From 5c240db0bf7751d74ba438a1ca4ef0d051a53df7 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 6 Jan 2020 09:14:22 -0500 Subject: Restore feature where nt-services detect non-"run_tor" modes. Followup for #32883. --- src/app/main/main.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/app/main/main.c') diff --git a/src/app/main/main.c b/src/app/main/main.c index 4275a98bd0..2a5cb4aa07 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -1279,6 +1279,13 @@ tor_run_main(const tor_main_configuration_t *tor_cfg) #endif } + if (tor_cfg->run_tor_only && get_options()->command != CMD_RUN_TOR) { + log_err(LD_CONFIG, "Unsupported command when running as an NT service."); + result = -1; + tor_cleanup(); + goto done; + } + switch (get_options()->command) { case CMD_RUN_TOR: #ifdef NT_SERVICE -- cgit v1.2.3-54-g00ecf From b6f099672b90cb606d89bfcb0cae01ea49e46b9c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Mon, 6 Jan 2020 09:19:09 -0500 Subject: Make ntmain.h functions stubs when NT_SERVICE not enabled. This lets us simplify main.c a little, and avoid a practracker exception. Followup from #32883. --- src/app/main/main.c | 15 ++++----------- src/app/main/ntmain.h | 3 ++- 2 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src/app/main/main.c') diff --git a/src/app/main/main.c b/src/app/main/main.c index 2a5cb4aa07..9c60d3c0f5 100644 --- a/src/app/main/main.c +++ b/src/app/main/main.c @@ -1238,15 +1238,10 @@ tor_run_main(const tor_main_configuration_t *tor_cfg) memcpy(argv + tor_cfg->argc, tor_cfg->argv_owned, tor_cfg->argc_owned*sizeof(char*)); -#ifdef NT_SERVICE - { - int done = 0; - result = nt_service_parse_options(argc, argv, &done); - if (done) { - goto done; - } - } -#endif /* defined(NT_SERVICE) */ + int done = 0; + result = nt_service_parse_options(argc, argv, &done); + if (done) + goto done; pubsub_install(); @@ -1288,9 +1283,7 @@ tor_run_main(const tor_main_configuration_t *tor_cfg) switch (get_options()->command) { case CMD_RUN_TOR: -#ifdef NT_SERVICE nt_service_set_state(SERVICE_RUNNING); -#endif result = run_tor_main_loop(); break; case CMD_KEYGEN: diff --git a/src/app/main/ntmain.h b/src/app/main/ntmain.h index c39386c054..e23641bffa 100644 --- a/src/app/main/ntmain.h +++ b/src/app/main/ntmain.h @@ -22,7 +22,8 @@ int nt_service_is_stopping(void); void nt_service_set_state(DWORD state); #else #define nt_service_is_stopping() 0 +#define nt_service_parse_options(a, b, c) (0) +#define nt_service_set_state(s) STMT_NIL #endif /* defined(NT_SERVICE) */ #endif /* !defined(TOR_NTMAIN_H) */ - -- cgit v1.2.3-54-g00ecf