1*ebfedea0SLionel Sambuc.\" $NetBSD: krb5_get_credentials.3,v 1.1.1.2 2011/04/14 14:09:23 elric Exp $ 2*ebfedea0SLionel Sambuc.\" 3*ebfedea0SLionel Sambuc.\" Copyright (c) 2004 - 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 July 26, 2004 37*ebfedea0SLionel Sambuc.Dt KRB5_GET_CREDENTIALS 3 38*ebfedea0SLionel Sambuc.Os 39*ebfedea0SLionel Sambuc.Sh NAME 40*ebfedea0SLionel Sambuc.Nm krb5_get_credentials , 41*ebfedea0SLionel Sambuc.Nm krb5_get_credentials_with_flags , 42*ebfedea0SLionel Sambuc.Nm krb5_get_kdc_cred , 43*ebfedea0SLionel Sambuc.Nm krb5_get_renewed_creds 44*ebfedea0SLionel Sambuc.Nd get credentials from the KDC using krbtgt 45*ebfedea0SLionel Sambuc.Sh LIBRARY 46*ebfedea0SLionel SambucKerberos 5 Library (libkrb5, -lkrb5) 47*ebfedea0SLionel Sambuc.Sh SYNOPSIS 48*ebfedea0SLionel Sambuc.In krb5/krb5.h 49*ebfedea0SLionel Sambuc.Ft krb5_error_code 50*ebfedea0SLionel Sambuc.Fo krb5_get_credentials 51*ebfedea0SLionel Sambuc.Fa "krb5_context context" 52*ebfedea0SLionel Sambuc.Fa "krb5_flags options" 53*ebfedea0SLionel Sambuc.Fa "krb5_ccache ccache" 54*ebfedea0SLionel Sambuc.Fa "krb5_creds *in_creds" 55*ebfedea0SLionel Sambuc.Fa "krb5_creds **out_creds" 56*ebfedea0SLionel Sambuc.Fc 57*ebfedea0SLionel Sambuc.Ft krb5_error_code 58*ebfedea0SLionel Sambuc.Fo krb5_get_credentials_with_flags 59*ebfedea0SLionel Sambuc.Fa "krb5_context context" 60*ebfedea0SLionel Sambuc.Fa "krb5_flags options" 61*ebfedea0SLionel Sambuc.Fa "krb5_kdc_flags flags" 62*ebfedea0SLionel Sambuc.Fa "krb5_ccache ccache" 63*ebfedea0SLionel Sambuc.Fa "krb5_creds *in_creds" 64*ebfedea0SLionel Sambuc.Fa "krb5_creds **out_creds" 65*ebfedea0SLionel Sambuc.Fc 66*ebfedea0SLionel Sambuc.Ft krb5_error_code 67*ebfedea0SLionel Sambuc.Fo krb5_get_kdc_cred 68*ebfedea0SLionel Sambuc.Fa "krb5_context context" 69*ebfedea0SLionel Sambuc.Fa "krb5_ccache id" 70*ebfedea0SLionel Sambuc.Fa "krb5_kdc_flags flags" 71*ebfedea0SLionel Sambuc.Fa "krb5_addresses *addresses" 72*ebfedea0SLionel Sambuc.Fa "Ticket *second_ticket" 73*ebfedea0SLionel Sambuc.Fa "krb5_creds *in_creds" 74*ebfedea0SLionel Sambuc.Fa "krb5_creds **out_creds" 75*ebfedea0SLionel Sambuc.Fc 76*ebfedea0SLionel Sambuc.Ft krb5_error_code 77*ebfedea0SLionel Sambuc.Fo krb5_get_renewed_creds 78*ebfedea0SLionel Sambuc.Fa "krb5_context context" 79*ebfedea0SLionel Sambuc.Fa "krb5_creds *creds" 80*ebfedea0SLionel Sambuc.Fa "krb5_const_principal client" 81*ebfedea0SLionel Sambuc.Fa "krb5_ccache ccache" 82*ebfedea0SLionel Sambuc.Fa "const char *in_tkt_service" 83*ebfedea0SLionel Sambuc.Fc 84*ebfedea0SLionel Sambuc.Sh DESCRIPTION 85*ebfedea0SLionel Sambuc.Fn krb5_get_credentials_with_flags 86*ebfedea0SLionel Sambucget credentials specified by 87*ebfedea0SLionel Sambuc.Fa in_creds->server 88*ebfedea0SLionel Sambucand 89*ebfedea0SLionel Sambuc.Fa in_creds->client 90*ebfedea0SLionel Sambuc(the rest of the 91*ebfedea0SLionel Sambuc.Fa in_creds 92*ebfedea0SLionel Sambucstructure is ignored) 93*ebfedea0SLionel Sambucby first looking in the 94*ebfedea0SLionel Sambuc.Fa ccache 95*ebfedea0SLionel Sambucand if doesn't exists or is expired, fetch the credential from the KDC 96*ebfedea0SLionel Sambucusing the krbtgt in 97*ebfedea0SLionel Sambuc.Fa ccache . 98*ebfedea0SLionel SambucThe credential is returned in 99*ebfedea0SLionel Sambuc.Fa out_creds 100*ebfedea0SLionel Sambucand should be freed using the function 101*ebfedea0SLionel Sambuc.Fn krb5_free_creds . 102*ebfedea0SLionel Sambuc.Pp 103*ebfedea0SLionel SambucValid flags to pass into 104*ebfedea0SLionel Sambuc.Fa options 105*ebfedea0SLionel Sambucargument are: 106*ebfedea0SLionel Sambuc.Pp 107*ebfedea0SLionel Sambuc.Bl -tag -width "KRB5_GC_EXPIRED_OK" -compact 108*ebfedea0SLionel Sambuc.It KRB5_GC_CACHED 109*ebfedea0SLionel SambucOnly check the 110*ebfedea0SLionel Sambuc.Fa ccache , 111*ebfedea0SLionel Sambucdon't got out on network to fetch credential. 112*ebfedea0SLionel Sambuc.It KRB5_GC_USER_USER 113*ebfedea0SLionel SambucRequest a user to user ticket. 114*ebfedea0SLionel SambucThis option doesn't store the resulting user to user credential in 115*ebfedea0SLionel Sambucthe 116*ebfedea0SLionel Sambuc.Fa ccache . 117*ebfedea0SLionel Sambuc.It KRB5_GC_EXPIRED_OK 118*ebfedea0SLionel Sambucreturns the credential even if it is expired, default behavior is trying 119*ebfedea0SLionel Sambucto refetch the credential from the KDC. 120*ebfedea0SLionel Sambuc.El 121*ebfedea0SLionel Sambuc.Pp 122*ebfedea0SLionel Sambuc.Fa Flags 123*ebfedea0SLionel Sambucare KDCOptions, note the caller must fill in the bit-field and not 124*ebfedea0SLionel Sambucuse the integer associated structure. 125*ebfedea0SLionel Sambuc.Pp 126*ebfedea0SLionel Sambuc.Fn krb5_get_credentials 127*ebfedea0SLionel Sambucworks the same way as 128*ebfedea0SLionel Sambuc.Fn krb5_get_credentials_with_flags 129*ebfedea0SLionel Sambucexcept that the 130*ebfedea0SLionel Sambuc.Fa flags 131*ebfedea0SLionel Sambucfield is missing. 132*ebfedea0SLionel Sambuc.Pp 133*ebfedea0SLionel Sambuc.Fn krb5_get_kdc_cred 134*ebfedea0SLionel Sambucdoes the same as the functions above, but the caller must fill in all 135*ebfedea0SLionel Sambucthe information andits closer to the wire protocol. 136*ebfedea0SLionel Sambuc.Pp 137*ebfedea0SLionel Sambuc.Fn krb5_get_renewed_creds 138*ebfedea0SLionel Sambucrenews a credential given by 139*ebfedea0SLionel Sambuc.Fa in_tkt_service 140*ebfedea0SLionel Sambuc(if 141*ebfedea0SLionel Sambuc.Dv NULL 142*ebfedea0SLionel Sambucthe default 143*ebfedea0SLionel Sambuc.Li krbtgt ) 144*ebfedea0SLionel Sambucusing the credential cache 145*ebfedea0SLionel Sambuc.Fa ccache . 146*ebfedea0SLionel SambucThe result is stored in 147*ebfedea0SLionel Sambuc.Fa creds 148*ebfedea0SLionel Sambucand should be freed using 149*ebfedea0SLionel Sambuc.Fa krb5_free_creds . 150*ebfedea0SLionel Sambuc.Sh EXAMPLES 151*ebfedea0SLionel SambucHere is a example function that get a credential from a credential cache 152*ebfedea0SLionel Sambuc.Fa id 153*ebfedea0SLionel Sambucor the KDC and returns it to the caller. 154*ebfedea0SLionel Sambuc.Bd -literal 155*ebfedea0SLionel Sambuc#include <krb5/krb5.h> 156*ebfedea0SLionel Sambuc 157*ebfedea0SLionel Sambucint 158*ebfedea0SLionel Sambucgetcred(krb5_context context, krb5_ccache id, krb5_creds **creds) 159*ebfedea0SLionel Sambuc{ 160*ebfedea0SLionel Sambuc krb5_error_code ret; 161*ebfedea0SLionel Sambuc krb5_creds in; 162*ebfedea0SLionel Sambuc 163*ebfedea0SLionel Sambuc ret = krb5_parse_name(context, "client@EXAMPLE.COM", 164*ebfedea0SLionel Sambuc &in.client); 165*ebfedea0SLionel Sambuc if (ret) 166*ebfedea0SLionel Sambuc krb5_err(context, 1, ret, "krb5_parse_name"); 167*ebfedea0SLionel Sambuc 168*ebfedea0SLionel Sambuc ret = krb5_parse_name(context, "host/server.example.com@EXAMPLE.COM", 169*ebfedea0SLionel Sambuc &in.server); 170*ebfedea0SLionel Sambuc if (ret) 171*ebfedea0SLionel Sambuc krb5_err(context, 1, ret, "krb5_parse_name"); 172*ebfedea0SLionel Sambuc 173*ebfedea0SLionel Sambuc ret = krb5_get_credentials(context, 0, id, &in, creds); 174*ebfedea0SLionel Sambuc if (ret) 175*ebfedea0SLionel Sambuc krb5_err(context, 1, ret, "krb5_get_credentials"); 176*ebfedea0SLionel Sambuc 177*ebfedea0SLionel Sambuc return 0; 178*ebfedea0SLionel Sambuc} 179*ebfedea0SLionel Sambuc.Ed 180*ebfedea0SLionel Sambuc.Sh SEE ALSO 181*ebfedea0SLionel Sambuc.Xr krb5 3 , 182*ebfedea0SLionel Sambuc.Xr krb5_get_forwarded_creds 3 , 183*ebfedea0SLionel Sambuc.Xr krb5.conf 5 184