xref: /minix3/crypto/external/bsd/heimdal/dist/lib/krb5/krb5_krbhst_init.3 (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc.\"	$NetBSD: krb5_krbhst_init.3,v 1.1.1.2 2011/04/14 14:09:23 elric Exp $
2*ebfedea0SLionel Sambuc.\"
3*ebfedea0SLionel Sambuc.\" Copyright (c) 2001-2005 Kungliga Tekniska Högskolan
4*ebfedea0SLionel Sambuc.\" (Royal Institute of Technology, Stockholm, Sweden).
5*ebfedea0SLionel Sambuc.\" All rights reserved.
6*ebfedea0SLionel Sambuc.\"
7*ebfedea0SLionel Sambuc.\" Redistribution and use in source and binary forms, with or without
8*ebfedea0SLionel Sambuc.\" modification, are permitted provided that the following conditions
9*ebfedea0SLionel Sambuc.\" are met:
10*ebfedea0SLionel Sambuc.\"
11*ebfedea0SLionel Sambuc.\" 1. Redistributions of source code must retain the above copyright
12*ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer.
13*ebfedea0SLionel Sambuc.\"
14*ebfedea0SLionel Sambuc.\" 2. Redistributions in binary form must reproduce the above copyright
15*ebfedea0SLionel Sambuc.\"    notice, this list of conditions and the following disclaimer in the
16*ebfedea0SLionel Sambuc.\"    documentation and/or other materials provided with the distribution.
17*ebfedea0SLionel Sambuc.\"
18*ebfedea0SLionel Sambuc.\" 3. Neither the name of the Institute nor the names of its contributors
19*ebfedea0SLionel Sambuc.\"    may be used to endorse or promote products derived from this software
20*ebfedea0SLionel Sambuc.\"    without specific prior written permission.
21*ebfedea0SLionel Sambuc.\"
22*ebfedea0SLionel Sambuc.\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23*ebfedea0SLionel Sambuc.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*ebfedea0SLionel Sambuc.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*ebfedea0SLionel Sambuc.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26*ebfedea0SLionel Sambuc.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*ebfedea0SLionel Sambuc.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*ebfedea0SLionel Sambuc.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*ebfedea0SLionel Sambuc.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*ebfedea0SLionel Sambuc.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*ebfedea0SLionel Sambuc.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*ebfedea0SLionel Sambuc.\" SUCH DAMAGE.
33*ebfedea0SLionel Sambuc.\"
34*ebfedea0SLionel Sambuc.\" Id
35*ebfedea0SLionel Sambuc.\"
36*ebfedea0SLionel Sambuc.Dd May 10, 2005
37*ebfedea0SLionel Sambuc.Dt KRB5_KRBHST_INIT 3
38*ebfedea0SLionel Sambuc.Os
39*ebfedea0SLionel Sambuc.Sh NAME
40*ebfedea0SLionel Sambuc.Nm krb5_krbhst_init ,
41*ebfedea0SLionel Sambuc.Nm krb5_krbhst_init_flags ,
42*ebfedea0SLionel Sambuc.Nm krb5_krbhst_next ,
43*ebfedea0SLionel Sambuc.Nm krb5_krbhst_next_as_string ,
44*ebfedea0SLionel Sambuc.Nm krb5_krbhst_reset ,
45*ebfedea0SLionel Sambuc.Nm krb5_krbhst_free ,
46*ebfedea0SLionel Sambuc.Nm krb5_krbhst_format_string ,
47*ebfedea0SLionel Sambuc.Nm krb5_krbhst_get_addrinfo
48*ebfedea0SLionel Sambuc.Nd lookup Kerberos KDC hosts
49*ebfedea0SLionel Sambuc.Sh LIBRARY
50*ebfedea0SLionel SambucKerberos 5 Library (libkrb5, -lkrb5)
51*ebfedea0SLionel Sambuc.Sh SYNOPSIS
52*ebfedea0SLionel Sambuc.In krb5/krb5.h
53*ebfedea0SLionel Sambuc.Ft krb5_error_code
54*ebfedea0SLionel Sambuc.Fn krb5_krbhst_init "krb5_context context" "const char *realm" "unsigned int type" "krb5_krbhst_handle *handle"
55*ebfedea0SLionel Sambuc.Ft krb5_error_code
56*ebfedea0SLionel Sambuc.Fn krb5_krbhst_init_flags "krb5_context context" "const char *realm" "unsigned int type" "int flags" "krb5_krbhst_handle *handle"
57*ebfedea0SLionel Sambuc.Ft krb5_error_code
58*ebfedea0SLionel Sambuc.Fn "krb5_krbhst_next" "krb5_context context" "krb5_krbhst_handle handle" "krb5_krbhst_info **host"
59*ebfedea0SLionel Sambuc.Ft krb5_error_code
60*ebfedea0SLionel Sambuc.Fn krb5_krbhst_next_as_string "krb5_context context" "krb5_krbhst_handle handle" "char *hostname" "size_t hostlen"
61*ebfedea0SLionel Sambuc.Ft void
62*ebfedea0SLionel Sambuc.Fn krb5_krbhst_reset "krb5_context context" "krb5_krbhst_handle handle"
63*ebfedea0SLionel Sambuc.Ft void
64*ebfedea0SLionel Sambuc.Fn krb5_krbhst_free "krb5_context context" "krb5_krbhst_handle handle"
65*ebfedea0SLionel Sambuc.Ft krb5_error_code
66*ebfedea0SLionel Sambuc.Fn krb5_krbhst_format_string "krb5_context context" "const krb5_krbhst_info *host" "char *hostname" "size_t hostlen"
67*ebfedea0SLionel Sambuc.Ft krb5_error_code
68*ebfedea0SLionel Sambuc.Fn krb5_krbhst_get_addrinfo "krb5_context context" "krb5_krbhst_info *host" "struct addrinfo **ai"
69*ebfedea0SLionel Sambuc.Sh DESCRIPTION
70*ebfedea0SLionel SambucThese functions are used to sequence through all Kerberos hosts of a
71*ebfedea0SLionel Sambucparticular realm and service. The service type can be the KDCs, the
72*ebfedea0SLionel Sambucadministrative servers, the password changing servers, or the servers
73*ebfedea0SLionel Sambucfor Kerberos 4 ticket conversion.
74*ebfedea0SLionel Sambuc.Pp
75*ebfedea0SLionel SambucFirst a handle to a particular service is obtained by calling
76*ebfedea0SLionel Sambuc.Fn krb5_krbhst_init
77*ebfedea0SLionel Sambuc(or
78*ebfedea0SLionel Sambuc.Fn krb5_krbhst_init_flags )
79*ebfedea0SLionel Sambucwith the
80*ebfedea0SLionel Sambuc.Fa realm
81*ebfedea0SLionel Sambucof interest and the type of service to lookup. The
82*ebfedea0SLionel Sambuc.Fa type
83*ebfedea0SLionel Sambuccan be one of:
84*ebfedea0SLionel Sambuc.Pp
85*ebfedea0SLionel Sambuc.Bl -tag -width Ds -compact -offset indent
86*ebfedea0SLionel Sambuc.It KRB5_KRBHST_KDC
87*ebfedea0SLionel Sambuc.It KRB5_KRBHST_ADMIN
88*ebfedea0SLionel Sambuc.It KRB5_KRBHST_CHANGEPW
89*ebfedea0SLionel Sambuc.It KRB5_KRBHST_KRB524
90*ebfedea0SLionel Sambuc.El
91*ebfedea0SLionel Sambuc.Pp
92*ebfedea0SLionel SambucThe
93*ebfedea0SLionel Sambuc.Fa handle
94*ebfedea0SLionel Sambucis returned to the caller, and should be passed to the other
95*ebfedea0SLionel Sambucfunctions.
96*ebfedea0SLionel Sambuc.Pp
97*ebfedea0SLionel SambucThe
98*ebfedea0SLionel Sambuc.Fa flag
99*ebfedea0SLionel Sambucargument to
100*ebfedea0SLionel Sambuc.Nm krb5_krbhst_init_flags
101*ebfedea0SLionel Sambucis the same flags as
102*ebfedea0SLionel Sambuc.Fn krb5_send_to_kdc_flags
103*ebfedea0SLionel Sambucuses.
104*ebfedea0SLionel SambucPossible values are:
105*ebfedea0SLionel Sambuc.Pp
106*ebfedea0SLionel Sambuc.Bl -tag -width KRB5_KRBHST_FLAGS_LARGE_MSG -compact -offset indent
107*ebfedea0SLionel Sambuc.It KRB5_KRBHST_FLAGS_MASTER
108*ebfedea0SLionel Sambuconly talk to master (readwrite) KDC
109*ebfedea0SLionel Sambuc.It KRB5_KRBHST_FLAGS_LARGE_MSG
110*ebfedea0SLionel Sambucthis is a large message, so use transport that can handle that.
111*ebfedea0SLionel Sambuc.El
112*ebfedea0SLionel Sambuc.Pp
113*ebfedea0SLionel SambucFor each call to
114*ebfedea0SLionel Sambuc.Fn krb5_krbhst_next
115*ebfedea0SLionel Sambucinformation on a new host is returned. The former function returns in
116*ebfedea0SLionel Sambuc.Fa host
117*ebfedea0SLionel Sambuca pointer to a structure containing information about the host, such
118*ebfedea0SLionel Sambucas protocol, hostname, and port:
119*ebfedea0SLionel Sambuc.Bd -literal -offset indent
120*ebfedea0SLionel Sambuctypedef struct krb5_krbhst_info {
121*ebfedea0SLionel Sambuc    enum { KRB5_KRBHST_UDP,
122*ebfedea0SLionel Sambuc	   KRB5_KRBHST_TCP,
123*ebfedea0SLionel Sambuc	   KRB5_KRBHST_HTTP } proto;
124*ebfedea0SLionel Sambuc    unsigned short port;
125*ebfedea0SLionel Sambuc    struct addrinfo *ai;
126*ebfedea0SLionel Sambuc    struct krb5_krbhst_info *next;
127*ebfedea0SLionel Sambuc    char hostname[1];
128*ebfedea0SLionel Sambuc} krb5_krbhst_info;
129*ebfedea0SLionel Sambuc.Ed
130*ebfedea0SLionel Sambuc.Pp
131*ebfedea0SLionel SambucThe related function,
132*ebfedea0SLionel Sambuc.Fn krb5_krbhst_next_as_string ,
133*ebfedea0SLionel Sambucreturn the same information as a URL-like string.
134*ebfedea0SLionel Sambuc.Pp
135*ebfedea0SLionel SambucWhen there are no more hosts, these functions return
136*ebfedea0SLionel Sambuc.Dv KRB5_KDC_UNREACH .
137*ebfedea0SLionel Sambuc.Pp
138*ebfedea0SLionel SambucTo re-iterate over all hosts, call
139*ebfedea0SLionel Sambuc.Fn krb5_krbhst_reset
140*ebfedea0SLionel Sambucand the next call to
141*ebfedea0SLionel Sambuc.Fn krb5_krbhst_next
142*ebfedea0SLionel Sambucwill return the first host.
143*ebfedea0SLionel Sambuc.Pp
144*ebfedea0SLionel SambucWhen done with the handle,
145*ebfedea0SLionel Sambuc.Fn krb5_krbhst_free
146*ebfedea0SLionel Sambucshould be called.
147*ebfedea0SLionel Sambuc.Pp
148*ebfedea0SLionel SambucTo use a
149*ebfedea0SLionel Sambuc.Va krb5_krbhst_info ,
150*ebfedea0SLionel Sambucthere are two functions:
151*ebfedea0SLionel Sambuc.Fn krb5_krbhst_format_string
152*ebfedea0SLionel Sambucthat will return a printable representation of that struct
153*ebfedea0SLionel Sambucand
154*ebfedea0SLionel Sambuc.Fn krb5_krbhst_get_addrinfo
155*ebfedea0SLionel Sambucthat will return a
156*ebfedea0SLionel Sambuc.Va struct addrinfo
157*ebfedea0SLionel Sambucthat can then be used for communicating with the server mentioned.
158*ebfedea0SLionel Sambuc.Sh EXAMPLES
159*ebfedea0SLionel SambucThe following code will print the KDCs of the realm
160*ebfedea0SLionel Sambuc.Dq MY.REALM :
161*ebfedea0SLionel Sambuc.Bd -literal -offset indent
162*ebfedea0SLionel Sambuckrb5_krbhst_handle handle;
163*ebfedea0SLionel Sambucchar host[MAXHOSTNAMELEN];
164*ebfedea0SLionel Sambuckrb5_krbhst_init(context, "MY.REALM", KRB5_KRBHST_KDC, &handle);
165*ebfedea0SLionel Sambucwhile(krb5_krbhst_next_as_string(context, handle,
166*ebfedea0SLionel Sambuc				 host, sizeof(host)) == 0)
167*ebfedea0SLionel Sambuc    printf("%s\\n", host);
168*ebfedea0SLionel Sambuckrb5_krbhst_free(context, handle);
169*ebfedea0SLionel Sambuc.Ed
170*ebfedea0SLionel Sambuc.\" .Sh BUGS
171*ebfedea0SLionel Sambuc.Sh SEE ALSO
172*ebfedea0SLionel Sambuc.Xr getaddrinfo 3 ,
173*ebfedea0SLionel Sambuc.Xr krb5_get_krbhst 3 ,
174*ebfedea0SLionel Sambuc.Xr krb5_send_to_kdc_flags 3
175*ebfedea0SLionel Sambuc.Sh HISTORY
176*ebfedea0SLionel SambucThese functions first appeared in Heimdal 0.3g.
177