summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorderaadt@openbsd.org <deraadt@openbsd.org>2015-10-02 01:39:52 +0000
committerDamien Miller <djm@mindrot.org>2015-10-06 12:24:54 +1100
commitb19e1b4ab11884c4f62aee9f8ab53127a4732658 (patch)
treed2cb63c0fcc0d0b9e203e9c7042bd2c3cff64dc1
parentc61b42f2678f21f05653ac2d3d241b48ab5d59ac (diff)
upstream commit
a sandbox using tame ok djm Upstream-ID: 4ca24e47895e72f5daaa02f3e3d3e5ca2d820fa3
-rw-r--r--sandbox-tame.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/sandbox-tame.c b/sandbox-tame.c
new file mode 100644
index 000000000..f94065f03
--- /dev/null
+++ b/sandbox-tame.c
@@ -0,0 +1,71 @@
1/* $OpenBSD: sandbox-tame.c,v 1.1 2015/10/02 01:39:52 deraadt Exp $ */
2/*
3 * Copyright (c) 2015 Theo de Raadt <deraadt@mindrot.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include <sys/types.h>
19#include <sys/ioctl.h>
20#include <sys/syscall.h>
21#include <sys/socket.h>
22#include <sys/wait.h>
23
24#include <errno.h>
25#include <limits.h>
26#include <stdarg.h>
27#include <stdio.h>
28#include <stdlib.h>
29#include <unistd.h>
30#include <pwd.h>
31
32#include "log.h"
33#include "ssh-sandbox.h"
34#include "xmalloc.h"
35
36struct ssh_sandbox {
37 pid_t child_pid;
38};
39
40struct ssh_sandbox *
41ssh_sandbox_init(void)
42{
43 struct ssh_sandbox *box;
44
45 debug3("%s: preparing tame sandbox", __func__);
46 box = xcalloc(1, sizeof(*box));
47 box->child_pid = 0;
48
49 return box;
50}
51
52void
53ssh_sandbox_child(struct ssh_sandbox *box)
54{
55 if (tame("stdio", NULL) == -1)
56 fatal("%s: tame()", __func__);
57}
58
59void
60ssh_sandbox_parent_finish(struct ssh_sandbox *box)
61{
62 free(box);
63 debug3("%s: finished", __func__);
64}
65
66void
67ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)
68{
69 box->child_pid = child_pid;
70 /* Nothing to do here */
71}