aboutsummaryrefslogtreecommitdiff
path: root/src/common/sandbox.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-11-18 11:00:16 -0500
committerNick Mathewson <nickm@torproject.org>2013-11-18 11:00:16 -0500
commitfbc20294aaf67f9434d5b1e107b8e1c43e42a3a4 (patch)
tree0d0f0b0aa37423e8f36f11e8410849e48be59ba6 /src/common/sandbox.c
parent7a2b30fe16eacc040b3dd11f8c39c410628c2f43 (diff)
parentc81f64ab44f71a97649a44e10d6fcbf15aa8c835 (diff)
downloadtor-fbc20294aaf67f9434d5b1e107b8e1c43e42a3a4.tar
tor-fbc20294aaf67f9434d5b1e107b8e1c43e42a3a4.tar.gz
Merge branch 'backtrace_squashed'
Conflicts: src/common/sandbox.c src/common/sandbox.h src/common/util.c src/or/main.c src/test/include.am src/test/test.c
Diffstat (limited to 'src/common/sandbox.c')
-rw-r--r--src/common/sandbox.c47
1 files changed, 7 insertions, 40 deletions
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index aaba9c776..7ef577dbe 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -1290,16 +1290,6 @@ install_syscall_filter(sandbox_cfg_t* cfg)
return (rc < 0 ? -rc : rc);
}
-/** Additional file descriptor to use when logging seccomp2 failures */
-static int sigsys_debugging_fd = -1;
-
-/** Use the file descriptor <b>fd</b> to log seccomp2 failures. */
-static void
-sigsys_set_debugging_fd(int fd)
-{
- sigsys_debugging_fd = fd;
-}
-
/**
* Function called when a SIGSYS is caught by the application. It notifies the
* user that an error has occurred and either terminates or allows the
@@ -1309,8 +1299,8 @@ static void
sigsys_debugging(int nr, siginfo_t *info, void *void_context)
{
ucontext_t *ctx = (ucontext_t *) (void_context);
- char message[256];
- int rv = 0, syscall, length, err;
+ char number[32];
+ int syscall;
(void) nr;
if (info->si_code != SYS_SECCOMP)
@@ -1321,24 +1311,11 @@ sigsys_debugging(int nr, siginfo_t *info, void *void_context)
syscall = ctx->uc_mcontext.gregs[REG_SYSCALL];
- strlcpy(message, "\n\n(Sandbox) Caught a bad syscall attempt (syscall 0x",
- sizeof(message));
- (void) format_hex_number_sigsafe(syscall, message+strlen(message),
- sizeof(message)-strlen(message));
- strlcat(message, ")\n", sizeof(message));
- length = strlen(message);
-
- err = 0;
- if (sigsys_debugging_fd >= 0) {
- rv = write(sigsys_debugging_fd, message, length);
- err += rv != length;
- }
-
- rv = write(STDOUT_FILENO, message, length);
- err += rv != length;
-
- if (err)
- _exit(2);
+ format_dec_number_sigsafe(syscall, number, sizeof(number));
+ tor_log_err_sigsafe("(Sandbox) Caught a bad syscall attempt (syscall ",
+ number,
+ ")\n",
+ NULL);
#if defined(DEBUGGING_CLOSE)
_exit(1);
@@ -1453,16 +1430,6 @@ sandbox_init(sandbox_cfg_t *cfg)
#endif
}
-void
-sandbox_set_debugging_fd(int fd)
-{
-#ifdef USE_LIBSECCOMP
- sigsys_set_debugging_fd(fd);
-#else
- (void)fd;
-#endif
-}
-
#ifndef USE_LIBSECCOMP
int
sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file,