1 .\" Copyright (c) 1998, 2001, 2002, Juniper Networks, Inc.
2 .\" All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
13 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 .\" $FreeBSD: src/lib/libtacplus/libtacplus.3,v 1.3.2.7 2002/10/09 08:50:42 pst Exp $
26 .\" $DragonFly: src/lib/libtacplus/libtacplus.3,v 1.8 2008/05/02 02:05:04 swildner Exp $
33 .Nd TACACS+ client library
39 .Fn tac_add_server "struct tac_handle *h" "const char *host" "int port" "const char *secret" "int timeout" "int flags"
41 .Fn tac_clear_avs "struct tac_handle *h"
43 .Fn tac_close "struct tac_handle *h"
45 .Fn tac_config "struct tac_handle *h" "const char *path"
47 .Fn tac_create_authen "struct tac_handle *h" "int action" "int type" "int service"
49 .Fn tac_create_author "struct tac_handle *h" "int method" "int type" "int service"
51 .Fn tac_get_av "struct tac_handle *h" "u_int index"
53 .Fn tac_get_av_value "struct tac_handle *h" "const char *attribute"
55 .Fn tac_get_data "struct tac_handle *h" "size_t *len"
57 .Fn tac_get_msg "struct tac_handle *h"
58 .Ft struct tac_handle *
61 .Fn tac_send_authen "struct tac_handle *h"
63 .Fn tac_send_author "struct tac_handle *h"
65 .Fn tac_set_av "struct tac_handle *h" "u_int index" "const char *av_pair"
67 .Fn tac_set_data "struct tac_handle *h" "const void *data" "size_t data_len"
69 .Fn tac_set_msg "struct tac_handle *h" "const char *msg"
71 .Fn tac_set_port "struct tac_handle *h" "const char *port"
73 .Fn tac_set_priv "struct tac_handle *h" "int priv"
75 .Fn tac_set_rem_addr "struct tac_handle *h" "const char *addr"
77 .Fn tac_set_user "struct tac_handle *h" "const char *user"
79 .Fn tac_strerror "struct tac_handle *h"
83 library implements the client side of the TACACS+ network access
84 control protocol. TACACS+ allows clients to perform authentication,
85 authorization, and accounting by means of network requests to remote
86 servers. This library currently supports only the authentication
87 and authorization portion of the protocol.
89 To use the library, an application must first call
92 .Va struct tac_handle * ,
93 which provides context for subsequent operations.
96 always succeed unless insufficient virtual memory is available. If
97 the necessary memory cannot be allocated,
102 Before issuing any TACACS+ requests, the library must be made aware
103 of the servers it can contact. The easiest way to configure the
107 causes the library to read a configuration file whose format is
110 The pathname of the configuration file is passed as the
114 This argument may also be given as
116 in which case the standard configuration file
117 .Pa /etc/tacplus.conf
120 returns 0 on success, or -1 if an error occurs.
122 The library can also be configured programmatically by calls to
126 parameter specifies the server host, either as a fully qualified
127 domain name or as a dotted-quad IP address in text form.
130 parameter specifies the TCP port to contact on the server. If
132 is given as 0, the library uses port 49, the standard TACACS+ port.
133 The shared secret for the server host is passed to the
135 parameter. It may be any null-terminated string of bytes.
136 The timeout for receiving replies from the server is passed to the
138 parameter, in units of seconds.
141 parameter is a bit mask of flags to specify various characteristics of
142 the server. It may contain:
144 .It Dv TAC_SRVR_SINGLE_CONNECT
145 Causes the library to attempt to negotiate single connection mode
146 when communicating with the server. In single connection mode, the
147 original TCP connection is held open for multiple TACACS+ sessions.
148 Older servers do not support this mode, and some of them become
149 confused if the client attempts to negotiate it.
153 returns 0 on success, or -1 if an error occurs.
156 may be called multiple times, and it may be used together with
158 At most 10 servers may be specified.
159 When multiple servers are given, they are tried in round-robin
160 fashion until a working, accessible server is found. Once the
161 library finds such a server, it continues to use it as long as it
163 .Sh CREATING A TACACS+ AUTHENTICATION REQUEST
164 To begin constructing a new authentication request, call
165 .Fn tac_create_authen .
171 arguments must be set to appropriate values as defined in the
172 TACACS+ protocol specification. The
174 header file contains symbolic constants for these values.
175 .Sh CREATING A TACACS+ AUTHORIZATION REQUEST
176 To begin constructing a new authorization request, call
177 .Fn tac_create_author .
183 arguments must be set to appropriate values as defined in the
184 TACACS+ protocol specification. The
186 header file contains symbolic constants for these values.
187 .Sh SETTING OPTIONAL PARAMETERS ON A REQUEST
188 After creating a request,
189 various optional parameters may be attached to it through calls to
194 .Fn tac_set_rem_addr ,
197 The library creates its own copies of any strings provided to these
198 functions, so that it is not necessary for the caller to preserve
199 them. By default, each of these parameters is empty except for the
200 privilege level, which defaults to
205 only applies to the context of an authorization request. The format
206 for an attribute value pair is defined in the TACACS+ protocol
207 specification. The index specified can be any value between 0 and
208 255 inclusive and indicates the position in the list to place the
209 attribute value pair. Calling
211 with same index twice effectively replaces the value at that position.
214 to clear all attribute value pairs that may have been set.
215 .Sh SENDING THE AUTHENTICATION REQUEST AND RECEIVING THE RESPONSE
216 After the TACACS+ authentication request has been constructed, it is
218 .Fn tac_send_authen .
219 This function connects to a server if not already connected, sends
220 the request, and waits for a reply. On failure,
222 returns -1. Otherwise, it returns the TACACS+ status code and flags,
223 packed into an integer value. The status can be extracted using the
225 .Fn TAC_AUTHEN_STATUS .
226 Possible status codes, defined in
230 .Bl -item -compact -offset indent
232 .Dv TAC_AUTHEN_STATUS_PASS
234 .Dv TAC_AUTHEN_STATUS_FAIL
236 .Dv TAC_AUTHEN_STATUS_GETDATA
238 .Dv TAC_AUTHEN_STATUS_GETUSER
240 .Dv TAC_AUTHEN_STATUS_GETPASS
242 .Dv TAC_AUTHEN_STATUS_RESTART
244 .Dv TAC_AUTHEN_STATUS_ERROR
246 .Dv TAC_AUTHEN_STATUS_FOLLOW
249 The only flag is the no-echo flag, which can be tested using the
251 .Fn TAC_AUTHEN_NOECHO .
252 .Sh EXTRACTING INFORMATION FROM THE SERVER'S AUTHENTICATION RESPONSE
253 An authentication response packet from the server may contain a
254 server message, a data string, or both. After a successful call to
255 .Fn tac_send_authen ,
256 this information may be retrieved from the response by calling
260 These functions return dynamically-allocated copies of the
261 information from the packet. The caller is responsible for freeing
262 the copies when it no longer needs them. The data returned from
263 these functions is guaranteed to be terminated by a null byte.
269 argument points to a location into which the library will store the
270 actual length of the received data, not including the null
271 terminator. This argument may be given as
273 if the caller is not interested in the length.
274 .Sh SENDING AUTHENTICATION CONTINUE PACKETS
277 returns a value containing one of the status codes
278 .Dv TAC_AUTHEN_STATUS_GETDATA ,
279 .Dv TAC_AUTHEN_STATUS_GETUSER ,
281 .Dv TAC_AUTHEN_STATUS_GETPASS ,
282 then the client must provide additional information to the server by
283 means of a TACACS+ CONTINUE packet. To do so, the application must
284 first set the packet's user message and/or data fields using
288 The client then sends the CONTINUE packet with
289 .Fn tac_send_authen .
291 .Fn tac_create_authen
294 be called to construct a CONTINUE packet; it is used only for the
295 initial authentication request.
297 When it receives the CONTINUE packet, the server may again request
298 more information by returning
299 .Dv TAC_AUTHEN_STATUS_GETDATA ,
300 .Dv TAC_AUTHEN_STATUS_GETUSER ,
302 .Dv TAC_AUTHEN_STATUS_GETPASS .
303 The application should send further CONTINUEs until some other
304 status is received from the server.
305 .Sh SENDING THE AUTHORIZATION REQUEST AND RECEIVING THE RESPONSE
306 After the TACACS+ authorization request has been constructed, it
308 .Fn tac_send_author .
309 This function connects to a server if not already connected, sends
310 the request, and waits for a reply. On failure,
312 returns -1. Otherwise, it returns the TACACS+ status code and
313 number of attribute value (AV) pairs received packed into an
314 integer value. The status can be extracted using the macro
315 .Fn TAC_AUTHOR_STATUS .
316 Possible status codes, defined in
320 .Bl -item -compact -offset indent
322 .Dv TAC_AUTHOR_STATUS_PASS_ADD
324 .Dv TAC_AUTHOR_STATUS_PASS_REPL
326 .Dv TAC_AUTHOR_STATUS_FAIL
328 .Dv TAC_AUTHOR_STATUS_ERROR
331 The number of AV pairs received is obtained using
332 .Fn TAC_AUTHEN_AV_COUNT .
333 .Sh EXTRACTING INFORMATION FROM THE SERVER'S AUTHORIZATION RESPONSE
334 Like an authentication response packet, an authorization
335 response packet from the
336 server may contain a server message, a data string, or both. Refer
337 to EXTRACTING INFORMATION FROM THE SERVER'S AUTHENTICATION RESPONSE
338 for instruction on extraction of those values.
340 An authorization response packet from the server may also contain
341 attribute value (AV) pairs. To extract these, use
344 .Fn tac_get_av_value .
346 takes the index of the AV pair as it is positioned in the list.
347 The indexes start at 0 (use
348 .Fn TAC_AUTHEN_AV_COUNT
349 on the return value of
351 to get the total number of items in this list).
356 takes the attribute name and returns the
357 corresponding value only, not the AV pair. These functions return
358 dynamically-allocated copies of the information from the packet.
359 The caller is responsible for freeing the copies when it no longer
360 needs them. The data returned from these functions is guaranteed
361 to be terminated by a null byte.
362 .Sh OBTAINING ERROR MESSAGES
363 Those functions which accept a
364 .Va struct tac_handle *
365 argument record an error message if they fail. The error message
366 can be retrieved by calling
368 The message text is overwritten on each new error for the given
369 .Va struct tac_handle * .
370 Thus the message must be copied if it is to be preserved through
371 subsequent library calls using the same handle.
373 To free the resources used by the TACACS+ library, call
376 The following functions return a non-negative value on success. If
377 they detect an error, they return -1 and record an error message
378 which can be retrieved using
381 .Bl -item -offset indent -compact
387 .Fn tac_create_authen
389 .Fn tac_create_author
410 The following functions return a
412 pointer on success. If they are unable to allocate sufficient
413 virtual memory, they return
415 and record an error message which can be retrieved using
418 .Bl -item -offset indent -compact
429 The following functions return a
431 pointer on success. If they are unable to allocate sufficient
432 virtual memory, they return
434 without recording an error message.
436 .Bl -item -offset indent -compact
441 .Pa /etc/tacplus.conf
447 .%T The TACACS+ Protocol, Version 1.78
448 .%O draft-grant-tacacs-02.txt (Internet Draft)
452 This software was written by
458 project by Juniper Networks, Inc.