From 2539dce2a049a8f6bb0d44cac51f07ad48e691d3 Mon Sep 17 00:00:00 2001 From: "deraadt@openbsd.org" Date: Fri, 9 Oct 2015 01:37:08 +0000 Subject: upstream commit Change all tame callers to namechange to pledge(2). Upstream-ID: 17e654fc27ceaf523c60f4ffd9ec7ae4e7efc7f2 --- sandbox-pledge.c | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 sandbox-pledge.c (limited to 'sandbox-pledge.c') diff --git a/sandbox-pledge.c b/sandbox-pledge.c new file mode 100644 index 000000000..1d3e247d7 --- /dev/null +++ b/sandbox-pledge.c @@ -0,0 +1,77 @@ +/* $OpenBSD: sandbox-pledge.c,v 1.1 2015/10/09 01:37:08 deraadt Exp $ */ +/* + * Copyright (c) 2015 Theo de Raadt + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include "includes.h" + +#ifdef SANDBOX_TAME + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "log.h" +#include "ssh-sandbox.h" +#include "xmalloc.h" + +struct ssh_sandbox { + pid_t child_pid; +}; + +struct ssh_sandbox * +ssh_sandbox_init(struct monitor *m) +{ + struct ssh_sandbox *box; + + debug3("%s: preparing pledge sandbox", __func__); + box = xcalloc(1, sizeof(*box)); + box->child_pid = 0; + + return box; +} + +void +ssh_sandbox_child(struct ssh_sandbox *box) +{ + if (pledge("stdio", NULL) == -1) + fatal("%s: pledge()", __func__); +} + +void +ssh_sandbox_parent_finish(struct ssh_sandbox *box) +{ + free(box); + debug3("%s: finished", __func__); +} + +void +ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid) +{ + box->child_pid = child_pid; + /* Nothing to do here */ +} + +#endif /* SANDBOX_TAME */ -- cgit v1.2.3 From fafe1d84a210fb3dae7744f268059cc583db8c12 Mon Sep 17 00:00:00 2001 From: Damien Miller Date: Wed, 14 Oct 2015 09:22:15 -0700 Subject: s/SANDBOX_TAME/SANDBOX_PLEDGE/g --- configure.ac | 2 +- sandbox-pledge.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'sandbox-pledge.c') diff --git a/configure.ac b/configure.ac index 346a90c73..a6f947eb8 100644 --- a/configure.ac +++ b/configure.ac @@ -3099,7 +3099,7 @@ if test "x$sandbox_arg" = "xpledge" || \ test "x$ac_cv_func_pledge" != "xyes" && \ AC_MSG_ERROR([pledge sandbox requires pledge(2) support]) SANDBOX_STYLE="pledge" - AC_DEFINE([SANDBOX_TAME], [1], [Sandbox using pledge(2)]) + AC_DEFINE([SANDBOX_PLEDGE], [1], [Sandbox using pledge(2)]) elif test "x$sandbox_arg" = "xsystrace" || \ ( test -z "$sandbox_arg" && test "x$have_systr_policy_kill" = "x1" ) ; then test "x$have_systr_policy_kill" != "x1" && \ diff --git a/sandbox-pledge.c b/sandbox-pledge.c index 1d3e247d7..d28fc2727 100644 --- a/sandbox-pledge.c +++ b/sandbox-pledge.c @@ -17,7 +17,7 @@ #include "includes.h" -#ifdef SANDBOX_TAME +#ifdef SANDBOX_PLEDGE #include #include @@ -74,4 +74,4 @@ ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid) /* Nothing to do here */ } -#endif /* SANDBOX_TAME */ +#endif /* SANDBOX_PLEDGE */ -- cgit v1.2.3