xref: /minix3/crypto/external/bsd/heimdal/dist/lib/krb5/krb5_verify_user.3 (revision ebfedea0ce5bbe81e252ddf32d732e40fb633fae)
1*ebfedea0SLionel Sambuc.\"	$NetBSD: krb5_verify_user.3,v 1.1.1.2 2011/04/14 14:09:24 elric Exp $
2*ebfedea0SLionel Sambuc.\"
3*ebfedea0SLionel Sambuc.\" Copyright (c) 2001 - 2006 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  1, 2006
37*ebfedea0SLionel Sambuc.Dt KRB5_VERIFY_USER 3
38*ebfedea0SLionel Sambuc.Os
39*ebfedea0SLionel Sambuc.Sh NAME
40*ebfedea0SLionel Sambuc.Nm krb5_verify_user ,
41*ebfedea0SLionel Sambuc.Nm krb5_verify_user_lrealm ,
42*ebfedea0SLionel Sambuc.Nm krb5_verify_user_opt ,
43*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_init ,
44*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_alloc ,
45*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_free ,
46*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_set_ccache ,
47*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_set_flags ,
48*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_set_service ,
49*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_set_secure ,
50*ebfedea0SLionel Sambuc.Nm krb5_verify_opt_set_keytab
51*ebfedea0SLionel Sambuc.Nd Heimdal password verifying functions
52*ebfedea0SLionel Sambuc.Sh LIBRARY
53*ebfedea0SLionel SambucKerberos 5 Library (libkrb5, -lkrb5)
54*ebfedea0SLionel Sambuc.Sh SYNOPSIS
55*ebfedea0SLionel Sambuc.In krb5/krb5.h
56*ebfedea0SLionel Sambuc.Ft krb5_error_code
57*ebfedea0SLionel Sambuc.Fn "krb5_verify_user" "krb5_context context" " krb5_principal principal" "krb5_ccache ccache" "const char *password" "krb5_boolean secure" "const char *service"
58*ebfedea0SLionel Sambuc.Ft krb5_error_code
59*ebfedea0SLionel Sambuc.Fn "krb5_verify_user_lrealm" "krb5_context context" "krb5_principal principal" "krb5_ccache ccache" "const char *password" "krb5_boolean secure" "const char *service"
60*ebfedea0SLionel Sambuc.Ft void
61*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_init "krb5_verify_opt *opt"
62*ebfedea0SLionel Sambuc.Ft void
63*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_alloc "krb5_verify_opt **opt"
64*ebfedea0SLionel Sambuc.Ft void
65*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_free "krb5_verify_opt *opt"
66*ebfedea0SLionel Sambuc.Ft void
67*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_ccache "krb5_verify_opt *opt" "krb5_ccache ccache"
68*ebfedea0SLionel Sambuc.Ft void
69*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_keytab "krb5_verify_opt *opt" "krb5_keytab keytab"
70*ebfedea0SLionel Sambuc.Ft void
71*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_secure "krb5_verify_opt *opt" "krb5_boolean secure"
72*ebfedea0SLionel Sambuc.Ft void
73*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_service "krb5_verify_opt *opt" "const char *service"
74*ebfedea0SLionel Sambuc.Ft void
75*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_flags "krb5_verify_opt *opt" "unsigned int flags"
76*ebfedea0SLionel Sambuc.Ft krb5_error_code
77*ebfedea0SLionel Sambuc.Fo krb5_verify_user_opt
78*ebfedea0SLionel Sambuc.Fa "krb5_context context"
79*ebfedea0SLionel Sambuc.Fa "krb5_principal principal"
80*ebfedea0SLionel Sambuc.Fa "const char *password"
81*ebfedea0SLionel Sambuc.Fa "krb5_verify_opt *opt"
82*ebfedea0SLionel Sambuc.Fc
83*ebfedea0SLionel Sambuc.Sh DESCRIPTION
84*ebfedea0SLionel SambucThe
85*ebfedea0SLionel Sambuc.Nm krb5_verify_user
86*ebfedea0SLionel Sambucfunction verifies the password supplied by a user.
87*ebfedea0SLionel SambucThe principal whose password will be verified is specified in
88*ebfedea0SLionel Sambuc.Fa principal .
89*ebfedea0SLionel SambucNew tickets will be obtained as a side-effect and stored in
90*ebfedea0SLionel Sambuc.Fa ccache
91*ebfedea0SLionel Sambuc(if
92*ebfedea0SLionel Sambuc.Dv NULL ,
93*ebfedea0SLionel Sambucthe default ccache is used).
94*ebfedea0SLionel Sambuc.Fn krb5_verify_user
95*ebfedea0SLionel Sambucwill call
96*ebfedea0SLionel Sambuc.Fn krb5_cc_initialize
97*ebfedea0SLionel Sambucon the given
98*ebfedea0SLionel Sambuc.Fa ccache ,
99*ebfedea0SLionel Sambucso
100*ebfedea0SLionel Sambuc.Fa ccache
101*ebfedea0SLionel Sambucmust only initialized with
102*ebfedea0SLionel Sambuc.Fn krb5_cc_resolve
103*ebfedea0SLionel Sambucor
104*ebfedea0SLionel Sambuc.Fn krb5_cc_gen_new .
105*ebfedea0SLionel SambucIf the password is not supplied in
106*ebfedea0SLionel Sambuc.Fa password
107*ebfedea0SLionel Sambuc(and is given as
108*ebfedea0SLionel Sambuc.Dv NULL )
109*ebfedea0SLionel Sambucthe user will be prompted for it.
110*ebfedea0SLionel SambucIf
111*ebfedea0SLionel Sambuc.Fa secure
112*ebfedea0SLionel Sambucthe ticket will be verified against the locally stored service key
113*ebfedea0SLionel Sambuc.Fa service
114*ebfedea0SLionel Sambuc(by default
115*ebfedea0SLionel Sambuc.Ql host
116*ebfedea0SLionel Sambucif given as
117*ebfedea0SLionel Sambuc.Dv NULL
118*ebfedea0SLionel Sambuc).
119*ebfedea0SLionel Sambuc.Pp
120*ebfedea0SLionel SambucThe
121*ebfedea0SLionel Sambuc.Fn krb5_verify_user_lrealm
122*ebfedea0SLionel Sambucfunction does the same, except that it ignores the realm in
123*ebfedea0SLionel Sambuc.Fa principal
124*ebfedea0SLionel Sambucand tries all the local realms (see
125*ebfedea0SLionel Sambuc.Xr krb5.conf 5 ) .
126*ebfedea0SLionel SambucAfter a successful return, the principal is set to the authenticated
127*ebfedea0SLionel Sambucrealm. If the call fails, the principal will not be meaningful, and
128*ebfedea0SLionel Sambucshould only be freed with
129*ebfedea0SLionel Sambuc.Xr krb5_free_principal 3 .
130*ebfedea0SLionel Sambuc.Pp
131*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_alloc
132*ebfedea0SLionel Sambucand
133*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_free
134*ebfedea0SLionel Sambucallocates and frees a
135*ebfedea0SLionel Sambuc.Li krb5_verify_opt .
136*ebfedea0SLionel SambucYou should use the the alloc and free function instead of allocation
137*ebfedea0SLionel Sambucthe structure yourself, this is because in a future release the
138*ebfedea0SLionel Sambucstructure wont be exported.
139*ebfedea0SLionel Sambuc.Pp
140*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_init
141*ebfedea0SLionel Sambucresets all opt to default values.
142*ebfedea0SLionel Sambuc.Pp
143*ebfedea0SLionel SambucNone of the krb5_verify_opt_set function makes a copy of the data
144*ebfedea0SLionel Sambucstructure that they are called with. It's up the caller to free them
145*ebfedea0SLionel Sambucafter the
146*ebfedea0SLionel Sambuc.Fn krb5_verify_user_opt
147*ebfedea0SLionel Sambucis called.
148*ebfedea0SLionel Sambuc.Pp
149*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_ccache
150*ebfedea0SLionel Sambucsets the
151*ebfedea0SLionel Sambuc.Fa ccache
152*ebfedea0SLionel Sambucthat user of
153*ebfedea0SLionel Sambuc.Fa opt
154*ebfedea0SLionel Sambucwill use. If not set, the default credential cache will be used.
155*ebfedea0SLionel Sambuc.Pp
156*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_keytab
157*ebfedea0SLionel Sambucsets the
158*ebfedea0SLionel Sambuc.Fa keytab
159*ebfedea0SLionel Sambucthat user of
160*ebfedea0SLionel Sambuc.Fa opt
161*ebfedea0SLionel Sambucwill use. If not set, the default keytab will be used.
162*ebfedea0SLionel Sambuc.Pp
163*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_secure
164*ebfedea0SLionel Sambucif
165*ebfedea0SLionel Sambuc.Fa secure
166*ebfedea0SLionel Sambucif true, the password verification will require that the ticket will
167*ebfedea0SLionel Sambucbe verified against the locally stored service key. If not set,
168*ebfedea0SLionel Sambucdefault value is true.
169*ebfedea0SLionel Sambuc.Pp
170*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_service
171*ebfedea0SLionel Sambucsets the
172*ebfedea0SLionel Sambuc.Fa service
173*ebfedea0SLionel Sambucprincipal that user of
174*ebfedea0SLionel Sambuc.Fa opt
175*ebfedea0SLionel Sambucwill use. If not set, the
176*ebfedea0SLionel Sambuc.Ql host
177*ebfedea0SLionel Sambucservice will be used.
178*ebfedea0SLionel Sambuc.Pp
179*ebfedea0SLionel Sambuc.Fn krb5_verify_opt_set_flags
180*ebfedea0SLionel Sambucsets
181*ebfedea0SLionel Sambuc.Fa flags
182*ebfedea0SLionel Sambucthat user of
183*ebfedea0SLionel Sambuc.Fa opt
184*ebfedea0SLionel Sambucwill use.
185*ebfedea0SLionel SambucIf the flag
186*ebfedea0SLionel Sambuc.Dv KRB5_VERIFY_LREALMS
187*ebfedea0SLionel Sambucis used, the
188*ebfedea0SLionel Sambuc.Fa principal
189*ebfedea0SLionel Sambucwill be modified like
190*ebfedea0SLionel Sambuc.Fn krb5_verify_user_lrealm
191*ebfedea0SLionel Sambucmodifies it.
192*ebfedea0SLionel Sambuc.Pp
193*ebfedea0SLionel Sambuc.Fn krb5_verify_user_opt
194*ebfedea0SLionel Sambucfunction verifies the
195*ebfedea0SLionel Sambuc.Fa password
196*ebfedea0SLionel Sambucsupplied by a user.
197*ebfedea0SLionel SambucThe principal whose password will be verified is specified in
198*ebfedea0SLionel Sambuc.Fa principal .
199*ebfedea0SLionel SambucOptions the to the verification process is pass in in
200*ebfedea0SLionel Sambuc.Fa opt .
201*ebfedea0SLionel Sambuc.Sh EXAMPLES
202*ebfedea0SLionel SambucHere is a example program that verifies a password. it uses the
203*ebfedea0SLionel Sambuc.Ql host/`hostname`
204*ebfedea0SLionel Sambucservice principal in
205*ebfedea0SLionel Sambuc.Pa krb5.keytab .
206*ebfedea0SLionel Sambuc.Bd -literal
207*ebfedea0SLionel Sambuc#include <krb5/krb5.h>
208*ebfedea0SLionel Sambuc
209*ebfedea0SLionel Sambucint
210*ebfedea0SLionel Sambucmain(int argc, char **argv)
211*ebfedea0SLionel Sambuc{
212*ebfedea0SLionel Sambuc    char *user;
213*ebfedea0SLionel Sambuc    krb5_error_code error;
214*ebfedea0SLionel Sambuc    krb5_principal princ;
215*ebfedea0SLionel Sambuc    krb5_context context;
216*ebfedea0SLionel Sambuc
217*ebfedea0SLionel Sambuc    if (argc != 2)
218*ebfedea0SLionel Sambuc	errx(1, "usage: verify_passwd <principal-name>");
219*ebfedea0SLionel Sambuc
220*ebfedea0SLionel Sambuc    user = argv[1];
221*ebfedea0SLionel Sambuc
222*ebfedea0SLionel Sambuc    if (krb5_init_context(&context) < 0)
223*ebfedea0SLionel Sambuc	errx(1, "krb5_init_context");
224*ebfedea0SLionel Sambuc
225*ebfedea0SLionel Sambuc    if ((error = krb5_parse_name(context, user, &princ)) != 0)
226*ebfedea0SLionel Sambuc	krb5_err(context, 1, error, "krb5_parse_name");
227*ebfedea0SLionel Sambuc
228*ebfedea0SLionel Sambuc    error = krb5_verify_user(context, princ, NULL, NULL, TRUE, NULL);
229*ebfedea0SLionel Sambuc    if (error)
230*ebfedea0SLionel Sambuc        krb5_err(context, 1, error, "krb5_verify_user");
231*ebfedea0SLionel Sambuc
232*ebfedea0SLionel Sambuc    return 0;
233*ebfedea0SLionel Sambuc}
234*ebfedea0SLionel Sambuc.Ed
235*ebfedea0SLionel Sambuc.Sh SEE ALSO
236*ebfedea0SLionel Sambuc.Xr krb5_cc_gen_new 3 ,
237*ebfedea0SLionel Sambuc.Xr krb5_cc_initialize 3 ,
238*ebfedea0SLionel Sambuc.Xr krb5_cc_resolve 3 ,
239*ebfedea0SLionel Sambuc.Xr krb5_err 3 ,
240*ebfedea0SLionel Sambuc.Xr krb5_free_principal 3 ,
241*ebfedea0SLionel Sambuc.Xr krb5_init_context 3 ,
242*ebfedea0SLionel Sambuc.Xr krb5_kt_default 3 ,
243*ebfedea0SLionel Sambuc.Xr krb5.conf 5
244