Main index | Section 3 | 日本語 | Options |
#include <taclib.h>
Before issuing any TACACS+ requests, the library must be made aware of the servers it can contact. The easiest way to configure the library is to call tac_config(). tac_config() causes the library to read a configuration file whose format is described in tacplus.conf(5). The pathname of the configuration file is passed as the file argument to tac_config(). This argument may also be given as NULL, in which case the standard configuration file /etc/tacplus.conf is used. tac_config() returns 0 on success, or -1 if an error occurs.
The library can also be configured programmatically by calls to tac_add_server(). The host parameter specifies the server host, either as a fully qualified domain name or as a dotted-quad IP address in text form. The port parameter specifies the TCP port to contact on the server. If port is given as 0, the library uses port 49, the standard TACACS+ port. The shared secret for the server host is passed to the secret parameter. It may be any null-terminated string of bytes. The timeout for receiving replies from the server is passed to the timeout parameter, in units of seconds. The flags parameter is a bit mask of flags to specify various characteristics of the server. It may contain:
TAC_SRVR_SINGLE_CONNECT | |
Causes the library to attempt to negotiate single connection mode when communicating with the server. In single connection mode, the original TCP connection is held open for multiple TACACS+ sessions. Older servers do not support this mode, and some of them become confused if the client attempts to negotiate it. | |
tac_add_server() returns 0 on success, or -1 if an error occurs.
tac_add_server() may be called multiple times, and it may be used together with tac_config(). At most 10 servers may be specified. When multiple servers are given, they are tried in round-robin fashion until a working, accessible server is found. Once the library finds such a server, it continues to use it as long as it works.
tac_set_av() only applies to the context of an authorization request. The format for an attribute value pair is defined in the TACACS+ protocol specification. The index specified can be any value between 0 and 255 inclusive and indicates the position in the list to place the attribute value pair. Calling tac_set_av() with same index twice effectively replaces the value at that position. Use tac_clear_avs() to clear all attribute value pairs that may have been set.
TAC_AUTHEN_STATUS_PASS | |
TAC_AUTHEN_STATUS_FAIL | |
TAC_AUTHEN_STATUS_GETDATA | |
TAC_AUTHEN_STATUS_GETUSER | |
TAC_AUTHEN_STATUS_GETPASS | |
TAC_AUTHEN_STATUS_RESTART | |
TAC_AUTHEN_STATUS_ERROR | |
TAC_AUTHEN_STATUS_FOLLOW | |
The only flag is the no-echo flag, which can be tested using the macro TAC_AUTHEN_NOECHO().
In the case of tac_get_data(), the len argument points to a location into which the library will store the actual length of the received data, not including the null terminator. This argument may be given as NULL if the caller is not interested in the length.
When it receives the CONTINUE packet, the server may again request more information by returning TAC_AUTHEN_STATUS_GETDATA, TAC_AUTHEN_STATUS_GETUSER, or TAC_AUTHEN_STATUS_GETPASS. The application should send further CONTINUEs until some other status is received from the server.
TAC_AUTHOR_STATUS_PASS_ADD | |
TAC_AUTHOR_STATUS_PASS_REPL | |
TAC_AUTHOR_STATUS_FAIL | |
TAC_AUTHOR_STATUS_ERROR | |
The number of AV pairs received is obtained using TAC_AUTHEN_AV_COUNT().
TAC_ACCT_STATUS_SUCCESS | |
TAC_ACCT_STATUS_ERROR | |
TAC_ACCT_STATUS_FOLLOW | |
An authorization response packet from the server may also contain attribute value (AV) pairs. To extract these, use tac_get_av() or tac_get_av_value(). tac_get_av() takes the index of the AV pair as it is positioned in the list. The indexes start at 0 (use TAC_AUTHEN_AV_COUNT() on the return value of tac_send_author() to get the total number of items in this list). Alternatively, tac_get_av_value() can be used. tac_get_av_value() takes the attribute name and returns the corresponding value only, not the AV pair. These functions return dynamically-allocated copies of the information from the packet. The caller is responsible for freeing the copies when it no longer needs them. The data returned from these functions is guaranteed to be terminated by a null byte.
tac_add_server() | |
tac_config() | |
tac_create_authen() | |
tac_create_author() | |
tac_create_acct() | |
tac_send_authen() | |
tac_send_author() | |
tac_send_acct() | |
tac_set_av() | |
tac_set_data() | |
tac_set_msg() | |
tac_set_port() | |
tac_set_priv() | |
tac_set_rem_addr() | |
tac_set_user() | |
The following functions return a non- NULL pointer on success. If they are unable to allocate sufficient virtual memory, they return NULL and record an error message which can be retrieved using tac_strerror().
tac_get_av() | |
tac_get_av_value() | |
tac_get_data() | |
tac_get_msg() | |
The following functions return a non- NULL pointer on success. If they are unable to allocate sufficient virtual memory, they return NULL, without recording an error message.
tac_open() | |
/etc/tacplus.conf | |
draft-grant-tacacs-02.txt (Internet Draft), The TACACS+ Protocol, Version 1.78,
, ,LIBTACPLUS (3) | December 11, 2009 |
Main index | Section 3 | 日本語 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.