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
e8682c85
Commit
e8682c85
authored
7 years ago
by
Nick Mathewson
Browse files
Options
Downloads
Patches
Plain Diff
Add a small library to emulate tor_run_main() with exec()
parent
fa02ea10
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
configure.ac
+1
-0
1 addition, 0 deletions
configure.ac
src/tools/include.am
+5
-0
5 additions, 0 deletions
src/tools/include.am
src/tools/tor_runner.c
+78
-0
78 additions, 0 deletions
src/tools/tor_runner.c
with
85 additions
and
0 deletions
.gitignore
+
1
−
0
View file @
e8682c85
...
...
@@ -211,6 +211,7 @@ uptime-*.json
/src/test/fuzz/lf-fuzz-*
# /src/tools/
/src/tools/libtorrunner.a
/src/tools/tor-checkkey
/src/tools/tor-resolve
/src/tools/tor-cov-resolve
...
...
This diff is collapsed.
Click to expand it.
configure.ac
+
1
−
0
View file @
e8682c85
...
...
@@ -375,6 +375,7 @@ AH_BOTTOM([
AM_CONDITIONAL(BUILD_NT_SERVICES, test "x$bwin32" = "xtrue")
AM_CONDITIONAL(BUILD_LIBTORRUNNER, test "x$bwin32" != "xtrue")
dnl Enable C99 when compiling with MIPSpro
AC_MSG_CHECKING([for MIPSpro compiler])
...
...
This diff is collapsed.
Click to expand it.
src/tools/include.am
+
5
−
0
View file @
e8682c85
...
...
@@ -45,3 +45,8 @@ src_tools_tor_cov_gencert_LDADD = src/common/libor-testing.a \
endif
EXTRA_DIST += src/tools/tor-fw-helper/README
if BUILD_LIBTORRUNNER
noinst_LIBRARIES += src/tools/libtorrunner.a
src_tools_libtorrunner_a_SOURCES = src/tools/tor_runner.c src/or/tor_api.c
endif
This diff is collapsed.
Click to expand it.
src/tools/tor_runner.c
0 → 100644
+
78
−
0
View file @
e8682c85
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
* Copyright (c) 2007-2017, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include
"tor_api.h"
#include
"tor_api_internal.h"
#include
"orconfig.h"
#ifdef HAVE_UNISTD_H
#include
<unistd.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include
<sys/wait.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include
<sys/socket.h>
#endif
#include
<stdlib.h>
#include
<string.h>
#ifndef __GNUC__
#define __attribute__(x)
#endif
static
void
child
(
const
tor_main_configuration_t
*
cfg
)
__attribute__
((
noreturn
));
int
tor_run_main
(
const
tor_main_configuration_t
*
cfg
)
{
pid_t
pid
=
fork
();
if
(
pid
==
0
)
{
child
(
cfg
);
exit
(
0
);
/* Unreachable */
}
pid_t
stopped_pid
;
int
status
=
0
;
do
{
stopped_pid
=
waitpid
(
pid
,
&
status
,
0
);
}
while
(
stopped_pid
==
-
1
);
/* Note: these return values are not documented. No return value is
* documented! */
if
(
stopped_pid
!=
pid
)
{
return
-
99999
;
}
if
(
WIFSTOPPED
(
status
))
{
return
WEXITSTATUS
(
status
);
}
if
(
WIFSIGNALED
(
status
))
{
return
-
WTERMSIG
(
status
);
}
return
-
999988
;
}
static
void
child
(
const
tor_main_configuration_t
*
cfg
)
{
/* XXXX Close unused file descriptors. */
char
**
args
=
calloc
(
cfg
->
argc
+
1
,
sizeof
(
char
*
));
memcpy
(
args
,
cfg
->
argv
,
cfg
->
argc
*
sizeof
(
char
*
));
args
[
cfg
->
argc
]
=
NULL
;
int
rv
=
execv
(
BINDIR
"/tor"
,
args
);
if
(
rv
<
0
)
{
exit
(
254
);
}
else
{
abort
();
/* Unreachable */
}
}
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