1*ba1276acSMatthew Dillon /*
2*ba1276acSMatthew Dillon * Copyright (c) 2015 Joyent, Inc
3*ba1276acSMatthew Dillon * Author: Alex Wilson <alex.wilson@joyent.com>
4*ba1276acSMatthew Dillon *
5*ba1276acSMatthew Dillon * Permission to use, copy, modify, and distribute this software for any
6*ba1276acSMatthew Dillon * purpose with or without fee is hereby granted, provided that the above
7*ba1276acSMatthew Dillon * copyright notice and this permission notice appear in all copies.
8*ba1276acSMatthew Dillon *
9*ba1276acSMatthew Dillon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10*ba1276acSMatthew Dillon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11*ba1276acSMatthew Dillon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12*ba1276acSMatthew Dillon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13*ba1276acSMatthew Dillon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14*ba1276acSMatthew Dillon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15*ba1276acSMatthew Dillon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16*ba1276acSMatthew Dillon */
17*ba1276acSMatthew Dillon
18*ba1276acSMatthew Dillon #include "includes.h"
19*ba1276acSMatthew Dillon
20*ba1276acSMatthew Dillon #include <sys/types.h>
21*ba1276acSMatthew Dillon
22*ba1276acSMatthew Dillon #include <stdarg.h>
23*ba1276acSMatthew Dillon #include <unistd.h>
24*ba1276acSMatthew Dillon
25*ba1276acSMatthew Dillon #include "platform.h"
26*ba1276acSMatthew Dillon
27*ba1276acSMatthew Dillon #include "openbsd-compat/openbsd-compat.h"
28*ba1276acSMatthew Dillon
29*ba1276acSMatthew Dillon /*
30*ba1276acSMatthew Dillon * Drop any fine-grained privileges that are not needed for post-startup
31*ba1276acSMatthew Dillon * operation of ssh-agent
32*ba1276acSMatthew Dillon *
33*ba1276acSMatthew Dillon * Should be as close as possible to pledge("stdio cpath unix id proc exec", ...)
34*ba1276acSMatthew Dillon */
35*ba1276acSMatthew Dillon void
platform_pledge_agent(void)36*ba1276acSMatthew Dillon platform_pledge_agent(void)
37*ba1276acSMatthew Dillon {
38*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PRIVS
39*ba1276acSMatthew Dillon /*
40*ba1276acSMatthew Dillon * Note: Solaris priv dropping is closer to tame() than pledge(), but
41*ba1276acSMatthew Dillon * we will use what we have.
42*ba1276acSMatthew Dillon */
43*ba1276acSMatthew Dillon solaris_drop_privs_root_pinfo_net();
44*ba1276acSMatthew Dillon #endif
45*ba1276acSMatthew Dillon }
46*ba1276acSMatthew Dillon
47*ba1276acSMatthew Dillon /*
48*ba1276acSMatthew Dillon * Drop any fine-grained privileges that are not needed for post-startup
49*ba1276acSMatthew Dillon * operation of sftp-server
50*ba1276acSMatthew Dillon */
51*ba1276acSMatthew Dillon void
platform_pledge_sftp_server(void)52*ba1276acSMatthew Dillon platform_pledge_sftp_server(void)
53*ba1276acSMatthew Dillon {
54*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PRIVS
55*ba1276acSMatthew Dillon solaris_drop_privs_pinfo_net_fork_exec();
56*ba1276acSMatthew Dillon #endif
57*ba1276acSMatthew Dillon }
58*ba1276acSMatthew Dillon
59*ba1276acSMatthew Dillon /*
60*ba1276acSMatthew Dillon * Drop any fine-grained privileges that are not needed for the post-startup
61*ba1276acSMatthew Dillon * operation of the SSH client mux
62*ba1276acSMatthew Dillon *
63*ba1276acSMatthew Dillon * Should be as close as possible to pledge("stdio proc tty", ...)
64*ba1276acSMatthew Dillon */
65*ba1276acSMatthew Dillon void
platform_pledge_mux(void)66*ba1276acSMatthew Dillon platform_pledge_mux(void)
67*ba1276acSMatthew Dillon {
68*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PRIVS
69*ba1276acSMatthew Dillon solaris_drop_privs_root_pinfo_net_exec();
70*ba1276acSMatthew Dillon #endif
71*ba1276acSMatthew Dillon }
72