xref: /dflybsd-src/crypto/openssh/platform-listen.c (revision ba1276acd1c8c22d225b1bcf370a14c878644f44)
1*ba1276acSMatthew Dillon /*
2*ba1276acSMatthew Dillon  * Copyright (c) 2006 Darren Tucker.  All rights reserved.
3*ba1276acSMatthew Dillon  *
4*ba1276acSMatthew Dillon  * Permission to use, copy, modify, and distribute this software for any
5*ba1276acSMatthew Dillon  * purpose with or without fee is hereby granted, provided that the above
6*ba1276acSMatthew Dillon  * copyright notice and this permission notice appear in all copies.
7*ba1276acSMatthew Dillon  *
8*ba1276acSMatthew Dillon  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*ba1276acSMatthew Dillon  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*ba1276acSMatthew Dillon  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*ba1276acSMatthew Dillon  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*ba1276acSMatthew Dillon  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*ba1276acSMatthew Dillon  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*ba1276acSMatthew Dillon  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*ba1276acSMatthew Dillon  */
16*ba1276acSMatthew Dillon 
17*ba1276acSMatthew Dillon #include "includes.h"
18*ba1276acSMatthew Dillon 
19*ba1276acSMatthew Dillon #include <stdarg.h>
20*ba1276acSMatthew Dillon #include <stdio.h>
21*ba1276acSMatthew Dillon #include <string.h>
22*ba1276acSMatthew Dillon #include <unistd.h>
23*ba1276acSMatthew Dillon 
24*ba1276acSMatthew Dillon #include "log.h"
25*ba1276acSMatthew Dillon #include "misc.h"
26*ba1276acSMatthew Dillon #include "platform.h"
27*ba1276acSMatthew Dillon 
28*ba1276acSMatthew Dillon #include "openbsd-compat/openbsd-compat.h"
29*ba1276acSMatthew Dillon 
30*ba1276acSMatthew Dillon void
platform_pre_listen(void)31*ba1276acSMatthew Dillon platform_pre_listen(void)
32*ba1276acSMatthew Dillon {
33*ba1276acSMatthew Dillon #ifdef LINUX_OOM_ADJUST
34*ba1276acSMatthew Dillon 	/* Adjust out-of-memory killer so listening process is not killed */
35*ba1276acSMatthew Dillon 	oom_adjust_setup();
36*ba1276acSMatthew Dillon #endif
37*ba1276acSMatthew Dillon }
38*ba1276acSMatthew Dillon 
39*ba1276acSMatthew Dillon void
platform_post_listen(void)40*ba1276acSMatthew Dillon platform_post_listen(void)
41*ba1276acSMatthew Dillon {
42*ba1276acSMatthew Dillon #ifdef SYSTEMD_NOTIFY
43*ba1276acSMatthew Dillon 	ssh_systemd_notify_ready();
44*ba1276acSMatthew Dillon #endif
45*ba1276acSMatthew Dillon }
46*ba1276acSMatthew Dillon 
47*ba1276acSMatthew Dillon void
platform_pre_fork(void)48*ba1276acSMatthew Dillon platform_pre_fork(void)
49*ba1276acSMatthew Dillon {
50*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PROCESS_CONTRACTS
51*ba1276acSMatthew Dillon 	solaris_contract_pre_fork();
52*ba1276acSMatthew Dillon #endif
53*ba1276acSMatthew Dillon }
54*ba1276acSMatthew Dillon 
55*ba1276acSMatthew Dillon void
platform_pre_restart(void)56*ba1276acSMatthew Dillon platform_pre_restart(void)
57*ba1276acSMatthew Dillon {
58*ba1276acSMatthew Dillon #ifdef SYSTEMD_NOTIFY
59*ba1276acSMatthew Dillon 	ssh_systemd_notify_reload();
60*ba1276acSMatthew Dillon #endif
61*ba1276acSMatthew Dillon #ifdef LINUX_OOM_ADJUST
62*ba1276acSMatthew Dillon 	oom_adjust_restore();
63*ba1276acSMatthew Dillon #endif
64*ba1276acSMatthew Dillon }
65*ba1276acSMatthew Dillon 
66*ba1276acSMatthew Dillon void
platform_post_fork_parent(pid_t child_pid)67*ba1276acSMatthew Dillon platform_post_fork_parent(pid_t child_pid)
68*ba1276acSMatthew Dillon {
69*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PROCESS_CONTRACTS
70*ba1276acSMatthew Dillon 	solaris_contract_post_fork_parent(child_pid);
71*ba1276acSMatthew Dillon #endif
72*ba1276acSMatthew Dillon }
73*ba1276acSMatthew Dillon 
74*ba1276acSMatthew Dillon void
platform_post_fork_child(void)75*ba1276acSMatthew Dillon platform_post_fork_child(void)
76*ba1276acSMatthew Dillon {
77*ba1276acSMatthew Dillon #ifdef USE_SOLARIS_PROCESS_CONTRACTS
78*ba1276acSMatthew Dillon 	solaris_contract_post_fork_child();
79*ba1276acSMatthew Dillon #endif
80*ba1276acSMatthew Dillon #ifdef LINUX_OOM_ADJUST
81*ba1276acSMatthew Dillon 	oom_adjust_restore();
82*ba1276acSMatthew Dillon #endif
83*ba1276acSMatthew Dillon }
84*ba1276acSMatthew Dillon 
85