igc: disable hw.igc.sbp
[freebsd/src.git] / crypto / openssh / sandbox-pledge.c
blob302f1cfedd3dab43e7f53870b37515f0ad6970b7
1 /* $OpenBSD: sandbox-pledge.c,v 1.2 2020/10/18 11:32:01 djm Exp $ */
2 /*
3 * Copyright (c) 2015 Theo de Raadt <deraadt@openbsd.org>
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.
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.
18 #include "includes.h"
20 #ifdef SANDBOX_PLEDGE
22 #include <sys/types.h>
23 #include <sys/ioctl.h>
24 #include <sys/syscall.h>
25 #include <sys/socket.h>
26 #include <sys/wait.h>
28 #include <errno.h>
29 #include <limits.h>
30 #include <stdarg.h>
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <pwd.h>
36 #include "log.h"
37 #include "ssh-sandbox.h"
38 #include "xmalloc.h"
40 struct ssh_sandbox {
41 pid_t child_pid;
44 struct ssh_sandbox *
45 ssh_sandbox_init(struct monitor *m)
47 struct ssh_sandbox *box;
49 debug3_f("preparing pledge sandbox");
50 box = xcalloc(1, sizeof(*box));
51 box->child_pid = 0;
53 return box;
56 void
57 ssh_sandbox_child(struct ssh_sandbox *box)
59 if (pledge("stdio", NULL) == -1)
60 fatal_f("pledge()");
63 void
64 ssh_sandbox_parent_finish(struct ssh_sandbox *box)
66 free(box);
67 debug3_f("finished");
70 void
71 ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)
73 box->child_pid = child_pid;
74 /* Nothing to do here */
77 #endif /* SANDBOX_PLEDGE */