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