2 * Copyright (c) 2015 Joyent, Inc
3 * Author: Alex Wilson <alex.wilson@joyent.com>
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.
20 #ifdef SANDBOX_SOLARIS
21 #ifndef USE_SOLARIS_PRIVS
22 # error "--with-solaris-privs must be used with the Solaris sandbox"
25 #include <sys/types.h>
38 #include "ssh-sandbox.h"
46 ssh_sandbox_init(struct monitor *monitor)
48 struct ssh_sandbox *box = NULL;
50 box = xcalloc(1, sizeof(*box));
52 /* Start with "basic" and drop everything we don't need. */
53 box->pset = solaris_basic_privset();
55 if (box->pset == NULL) {
60 /* Drop everything except the ability to use already-opened files */
61 if (priv_delset(box->pset, PRIV_FILE_LINK_ANY) != 0 ||
62 #ifdef PRIV_NET_ACCESS
63 priv_delset(box->pset, PRIV_NET_ACCESS) != 0 ||
65 priv_delset(box->pset, PRIV_PROC_EXEC) != 0 ||
66 priv_delset(box->pset, PRIV_PROC_FORK) != 0 ||
67 priv_delset(box->pset, PRIV_PROC_INFO) != 0 ||
68 priv_delset(box->pset, PRIV_PROC_SESSION) != 0) {
73 /* These may not be available on older Solaris-es */
74 # if defined(PRIV_FILE_READ) && defined(PRIV_FILE_WRITE)
75 if (priv_delset(box->pset, PRIV_FILE_READ) != 0 ||
76 priv_delset(box->pset, PRIV_FILE_WRITE) != 0) {
86 ssh_sandbox_child(struct ssh_sandbox *box)
88 if (setppriv(PRIV_SET, PRIV_PERMITTED, box->pset) != 0 ||
89 setppriv(PRIV_SET, PRIV_LIMIT, box->pset) != 0 ||
90 setppriv(PRIV_SET, PRIV_INHERITABLE, box->pset) != 0)
91 fatal("setppriv: %s", strerror(errno));
95 ssh_sandbox_parent_finish(struct ssh_sandbox *box)
97 priv_freeset(box->pset);
103 ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)
105 /* Nothing to do here */
108 #endif /* SANDBOX_SOLARIS */