Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Tor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Benjamin J. Thompson
Tor
Commits
5c240db0
Commit
5c240db0
authored
5 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Restore feature where nt-services detect non-"run_tor" modes.
Followup for #32883.
parent
dca26294
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/app/main/main.c
+7
-0
7 additions, 0 deletions
src/app/main/main.c
src/app/main/ntmain.c
+17
-35
17 additions, 35 deletions
src/app/main/ntmain.c
src/feature/api/tor_api_internal.h
+5
-0
5 additions, 0 deletions
src/feature/api/tor_api_internal.h
with
29 additions
and
35 deletions
src/app/main/main.c
+
7
−
0
View file @
5c240db0
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
src/app/main/ntmain.c
+
17
−
35
View file @
5c240db0
...
...
@@ -29,6 +29,8 @@
#include
"lib/evloop/compat_libevent.h"
#include
"lib/fs/winlib.h"
#include
"lib/log/win32err.h"
#include
"feature/api/tor_api.h"
#include
"feature/api/tor_api_internal.h"
#include
<windows.h>
#define GENSRV_SERVICENAME "tor"
...
...
@@ -263,7 +265,6 @@ nt_service_control(DWORD request)
static
void
nt_service_body
(
int
argc
,
char
**
argv
)
{
int
r
;
(
void
)
argc
;
/* unused */
(
void
)
argv
;
/* unused */
nt_service_loadlibrary
();
...
...
@@ -283,24 +284,20 @@ nt_service_body(int argc, char **argv)
return
;
}
r
=
tor_init
(
backup_argc
,
backup_argv
);
if
(
r
)
{
/* Failed to start the Tor service */
r
=
NT_SERVICE_ERROR_TORINIT_FAILED
;
service_status
.
dwCurrentState
=
SERVICE_STOPPED
;
service_status
.
dwWin32ExitCode
=
r
;
service_status
.
dwServiceSpecificExitCode
=
r
;
service_fns
.
SetServiceStatus_fn
(
hStatus
,
&
service_status
);
tor_main_configuration_t
*
cfg
=
tor_main_configuration_new
();
cfg
->
run_tor_only
=
1
;
if
(
tor_main_configuration_set_command_line
(
cfg
,
backup_argc
,
backup_argv
)
<
0
)
return
;
}
/* Set the service's status to SERVICE_RUNNING and start the main
* event loop */
service_status
.
dwCurrentState
=
SERVICE_RUNNING
;
service_fns
.
SetServiceStatus_fn
(
hStatus
,
&
service_status
);
set_main_thread
();
run_tor_main_loop
();
tor_cleanup
();
tor_run_main
(
cfg
);
tor_main_configuration_free
(
cfg
);
}
/** Main service entry point. Starts the service control dispatcher and waits
...
...
@@ -323,29 +320,14 @@ nt_service_main(void)
printf
(
"Service error %d : %s
\n
"
,
(
int
)
result
,
errmsg
);
tor_free
(
errmsg
);
if
(
result
==
ERROR_FAILED_SERVICE_CONTROLLER_CONNECT
)
{
if
(
tor_init
(
backup_argc
,
backup_argv
))
tor_main_configuration_t
*
cfg
=
tor_main_configuration_new
();
cfg
->
run_tor_only
=
1
;
if
(
tor_main_configuration_set_command_line
(
cfg
,
backup_argc
,
backup_argv
)
<
0
)
return
;
switch
(
get_options
()
->
command
)
{
case
CMD_RUN_TOR
:
run_tor_main_loop
();
break
;
case
CMD_LIST_FINGERPRINT
:
case
CMD_HASH_PASSWORD
:
case
CMD_VERIFY_CONFIG
:
case
CMD_DUMP_CONFIG
:
case
CMD_KEYGEN
:
case
CMD_KEY_EXPIRATION
:
log_err
(
LD_CONFIG
,
"Unsupported command (--list-fingerprint, "
"--hash-password, --keygen, --dump-config, --verify-config, "
"or --key-expiration) in NT service."
);
break
;
case
CMD_RUN_UNITTESTS
:
case
CMD_IMMEDIATE
:
default:
log_err
(
LD_CONFIG
,
"Illegal command number %d: internal error."
,
get_options
()
->
command
);
}
tor_cleanup
();
tor_run_main
(
cfg
);
tor_main_configuration_free
(
cfg
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/feature/api/tor_api_internal.h
+
5
−
0
View file @
5c240db0
...
...
@@ -29,6 +29,11 @@ struct tor_main_configuration_t {
/** Socket that Tor will use as an owning control socket. Owned. */
tor_socket_t
owning_controller_socket
;
/** Disable commands other than "run tor". Not for use from outside Tor
* itself; if you need to use this for embedding, please contact the tor
* developers. */
int
run_tor_only
;
};
#endif
/* !defined(TOR_API_INTERNAL_H) */
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment