]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/blacklist/lib/libblacklist.3
MFC r354399: blacklist: update to NetBSD snapshot on 20191106
[FreeBSD/FreeBSD.git] / contrib / blacklist / lib / libblacklist.3
1 .\" $NetBSD: libblacklist.3,v 1.8 2017/10/22 10:31:57 abhinav Exp $
2 .\"
3 .\" Copyright (c) 2015 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
5 .\"
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Christos Zoulas.
8 .\"
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
11 .\" are met:
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\"    notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\"    notice, this list of conditions and the following disclaimer in the
16 .\"    documentation and/or other materials provided with the distribution.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
29 .\"
30 .Dd May 5, 2017
31 .Dt LIBBLACKLIST 3
32 .Os
33 .Sh NAME
34 .Nm blacklist_open ,
35 .Nm blacklist_close ,
36 .Nm blacklist_r ,
37 .Nm blacklist ,
38 .Nm blacklist_sa ,
39 .Nm blacklist_sa_r
40 .Nd Blacklistd notification library
41 .Sh LIBRARY
42 .Lb libblacklist
43 .Sh SYNOPSIS
44 .In blacklist.h
45 .Ft struct blacklist *
46 .Fn blacklist_open "void"
47 .Ft void
48 .Fn blacklist_close "struct blacklist *cookie"
49 .Ft int
50 .Fn blacklist "int action" "int fd" "const char *msg"
51 .Ft int
52 .Fn blacklist_r "struct blacklist *cookie" "int action" "int fd" "const char *msg"
53 .Ft int
54 .Fn blacklist_sa "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
55 .Ft int
56 .Fn blacklist_sa_r "struct blacklist *cookie" "int action" "int fd" "const struct sockaddr *sa" "socklen_t salen" "const char *msg"
57 .Sh DESCRIPTION
58 These functions can be used by daemons to notify
59 .Xr blacklistd 8
60 about successful and failed remote connections so that blacklistd can
61 block or release port access to prevent Denial of Service attacks.
62 .Pp
63 The function
64 .Fn blacklist_open
65 creates the necessary state to communicate with
66 .Xr blacklistd 8
67 and returns a pointer to it, or
68 .Dv NULL
69 on failure.
70 .Pp
71 The
72 .Fn blacklist_close
73 function frees all memory and resources used.
74 .Pp
75 The
76 .Fn blacklist
77 function sends a message to
78 .Xr blacklistd 8 ,
79 with an integer
80 .Ar action
81 argument specifying the type of notification,
82 a file descriptor
83 .Ar fd
84 specifying the accepted file descriptor connected to the client,
85 and an optional message in the
86 .Ar msg
87 argument.
88 .Pp
89 The
90 .Ar action
91 parameter can take these values:
92 .Bl -tag -width ".Va BLACKLIST_ABUSIVE_BEHAVIOR"
93 .It Va BLACKLIST_AUTH_FAIL
94 There was an unsuccessful authentication attempt.
95 .It Va BLACKLIST_AUTH_OK
96 A user successfully authenticated.
97 .It Va BLACKLIST_ABUSIVE_BEHAVIOR
98 The sending daemon has detected abusive behavior
99 from the remote system.  The remote address should
100 be blocked as soon as possible.
101 .It Va BLACKLIST_BAD_USER
102 The sending daemon has determined the username
103 presented for authentication is invalid.  The
104 .Xr blacklistd 8
105 daemon compares the username to a configured list of forbidden
106 usernames and
107 blocks the address immediately if a forbidden username matches.
108 (The
109 .Ar BLACKLIST_BAD_USER
110 support is not currently available.)
111 .El
112 .Pp
113 The
114 .Fn blacklist_r
115 function is more efficient because it keeps the blacklist state around.
116 .Pp
117 The
118 .Fn blacklist_sa
119 and
120 .Fn blacklist_sa_r
121 functions can be used with unconnected sockets, where
122 .Xr getpeername 2
123 will not work, the server will pass the peer name in the message.
124 .Pp
125 By default,
126 .Xr syslogd 8
127 is used for message logging.
128 The internal
129 .Fn bl_create
130 function can be used to create the required internal
131 state and specify a custom logging function.
132 .Sh RETURN VALUES
133 The function
134 .Fn blacklist_open
135 returns a cookie on success and
136 .Dv NULL
137 on failure setting
138 .Dv errno
139 to an appropriate value.
140 .Pp
141 The functions
142 .Fn blacklist ,
143 .Fn blacklist_sa ,
144 and
145 .Fn blacklist_sa_r
146 return
147 .Dv 0
148 on success and
149 .Dv \-1
150 on failure setting
151 .Dv errno
152 to an appropriate value.
153 .Sh SEE ALSO
154 .Xr blacklistd.conf 5 ,
155 .Xr blacklistd 8
156 .Sh AUTHORS
157 .An Christos Zoulas