1 .\" $NetBSD: krb5_principal.3,v 1.3 2014/04/24 13:45:34 pettai Exp $
3 .\" Copyright (c) 2003 - 2007 Kungliga Tekniska Högskolan
4 .\" (Royal Institute of Technology, Stockholm, Sweden).
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" 3. Neither the name of the Institute nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
40 .Nm krb5_get_default_principal ,
42 .Nm krb5_build_principal ,
43 .Nm krb5_build_principal_ext ,
44 .Nm krb5_build_principal_va ,
45 .Nm krb5_build_principal_va_ext ,
46 .Nm krb5_copy_principal ,
47 .Nm krb5_free_principal ,
48 .Nm krb5_make_principal ,
50 .Nm krb5_parse_name_flags ,
51 .Nm krb5_parse_nametype ,
52 .Nm krb5_princ_set_realm ,
53 .Nm krb5_principal_compare ,
54 .Nm krb5_principal_compare_any_realm ,
55 .Nm krb5_principal_get_comp_string ,
56 .Nm krb5_principal_get_realm ,
57 .Nm krb5_principal_get_type ,
58 .Nm krb5_principal_match ,
59 .Nm krb5_principal_set_type ,
60 .Nm krb5_realm_compare ,
61 .Nm krb5_sname_to_principal ,
62 .Nm krb5_sock_to_principal ,
63 .Nm krb5_unparse_name ,
64 .Nm krb5_unparse_name_flags ,
65 .Nm krb5_unparse_name_fixed ,
66 .Nm krb5_unparse_name_fixed_flags ,
67 .Nm krb5_unparse_name_fixed_short ,
68 .Nm krb5_unparse_name_short
69 .Nd Kerberos 5 principal handling functions
71 Kerberos 5 Library (libkrb5, -lkrb5)
77 .Fn krb5_free_principal "krb5_context context" "krb5_principal principal"
79 .Fn krb5_parse_name "krb5_context context" "const char *name" "krb5_principal *principal"
81 .Fn krb5_parse_name_flags "krb5_context context" "const char *name" "int flags" "krb5_principal *principal"
83 .Fn "krb5_unparse_name" "krb5_context context" "krb5_const_principal principal" "char **name"
85 .Fn "krb5_unparse_name_flags" "krb5_context context" "krb5_const_principal principal" "int flags" "char **name"
87 .Fn krb5_unparse_name_fixed "krb5_context context" "krb5_const_principal principal" "char *name" "size_t len"
89 .Fn krb5_unparse_name_fixed_flags "krb5_context context" "krb5_const_principal principal" "int flags" "char *name" "size_t len"
91 .Fn "krb5_unparse_name_short" "krb5_context context" "krb5_const_principal principal" "char **name"
93 .Fn krb5_unparse_name_fixed_short "krb5_context context" "krb5_const_principal principal" "char *name" "size_t len"
95 .Fn krb5_princ_set_realm "krb5_context context" "krb5_principal principal" "krb5_realm *realm"
97 .Fn krb5_build_principal "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "..."
99 .Fn krb5_build_principal_va "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "va_list ap"
101 .Fn "krb5_build_principal_ext" "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "..."
103 .Fn krb5_build_principal_va_ext "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "va_list ap"
105 .Fn krb5_make_principal "krb5_context context" "krb5_principal *principal" "krb5_const_realm realm" "..."
107 .Fn krb5_copy_principal "krb5_context context" "krb5_const_principal inprinc" "krb5_principal *outprinc"
109 .Fn krb5_principal_compare "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
111 .Fn krb5_principal_compare_any_realm "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
113 .Fn krb5_principal_get_comp_string "krb5_context context" "krb5_const_principal principal" "unsigned int component"
115 .Fn krb5_principal_get_realm "krb5_context context" "krb5_const_principal principal"
117 .Fn krb5_principal_get_type "krb5_context context" "krb5_const_principal principal"
119 .Fn krb5_principal_match "krb5_context context" "krb5_const_principal principal" "krb5_const_principal pattern"
121 .Fn krb5_principal_set_type "krb5_context context" "krb5_principal principal" "int type"
123 .Fn krb5_realm_compare "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
125 .Fn krb5_sname_to_principal "krb5_context context" "const char *hostname" "const char *sname" "int32_t type" "krb5_principal *ret_princ"
127 .Fn krb5_sock_to_principal "krb5_context context" "int socket" "const char *sname" "int32_t type" "krb5_principal *principal"
129 .Fn krb5_get_default_principal "krb5_context context" "krb5_principal *princ"
131 .Fn krb5_parse_nametype "krb5_context context" "const char *str" "int32_t *type"
134 holds the name of a user or service in Kerberos.
136 A principal has two parts, a
140 The PrincipalName consists of one or more components. In printed form,
141 the components are separated by /.
142 The PrincipalName also has a name-type.
144 Examples of a principal are
145 .Li nisse/root@EXAMPLE.COM
147 .Li host/datan.kth.se@KTH.SE .
150 .Fn krb5_parse_name_flags
151 passes a principal name in
153 to the kerberos principal structure.
154 .Fn krb5_parse_name_flags
157 argument the following flags can be passed in
159 .It Dv KRB5_PRINCIPAL_PARSE_NO_REALM
160 requires the input string to be without a realm, and no realm is
164 .It Dv KRB5_PRINCIPAL_PARSE_REQUIRE_REALM
165 requires the input string to with a realm.
168 .Fn krb5_unparse_name
170 .Fn krb5_unparse_name_flags
180 argument the following flags can be passed in
182 .It Dv KRB5_PRINCIPAL_UNPARSE_SHORT
183 no realm if the realm is one of the local realms.
184 .It Dv KRB5_PRINCIPAL_UNPARSE_NO_REALM
185 never include any realm in the principal name.
186 .It Dv KRB5_PRINCIPAL_UNPARSE_DISPLAY
193 .Fn krb5_unparse_name_fixed
195 .Fn krb5_unparse_name_fixed_flags
198 but instead unparses the principal into a fixed size buffer.
200 .Fn krb5_unparse_name_short
201 just returns the principal without the realm if the principal is
202 in the default realm. If the principal isn't, the full name is
204 .Fn krb5_unparse_name_fixed_short
206 .Fn krb5_unparse_name_short
207 but on a fixed size buffer.
209 .Fn krb5_build_principal
210 builds a principal from the realm
214 The following arguments form the components of the principal.
215 The list of components is terminated with
218 .Fn krb5_build_principal_va
220 .Fn krb5_build_principal
223 .Fn krb5_build_principal_ext
225 .Fn krb5_build_principal_va_ext
226 take a list of length-value pairs, the list is terminated with a zero
229 .Fn krb5_make_principal
230 works the same way as
231 .Fn krb5_build_principal ,
232 except it figures out the length of the realm itself.
234 .Fn krb5_copy_principal
235 makes a copy of a principal.
236 The copy needs to be freed with
237 .Fn krb5_free_principal .
239 .Fn krb5_principal_compare
240 compares the two principals, including realm of the principals and returns
242 if they are the same and
246 .Fn krb5_principal_compare_any_realm
247 works the same way as
248 .Fn krb5_principal_compare
249 but doesn't compare the realm component of the principal.
251 .Fn krb5_realm_compare
252 compares the realms of the two principals and returns
254 is they are the same, and
258 .Fn krb5_principal_match
263 The pattern is a globbing expression, where each component (separated
264 by /) is matched against the corresponding component of the principal.
267 .Fn krb5_principal_get_realm
269 .Fn krb5_principal_get_comp_string
270 functions return parts of the
272 either the realm or a specific component.
273 Both functions return string pointers to data inside the principal, so
274 they are valid only as long as the principal exists.
279 .Fn krb5_principal_get_comp_string
280 is the index of the component to return, from zero to the total number of
281 components minus one. If the index is out of range
285 .Fn krb5_principal_get_realm
287 .Fn krb5_principal_get_comp_string
289 .Fn krb5_princ_component
290 and related macros, described as internal in the MIT API
292 Unlike the macros, these functions return strings, not
296 was that it was believed that principal components could contain
297 binary data, but this belief was unfounded, and it has been decided
298 that principal components are infact UTF8, so it's safe to use zero
301 It's generally not necessary to look at the components of a principal.
303 .Fn krb5_principal_get_type
305 .Fn krb5_principal_set_type
306 get and sets the name type for a principal.
307 Name type handling is tricky and not often needed,
308 don't use this unless you know what you do.
310 .Fn krb5_sname_to_principal
312 .Fn krb5_sock_to_principal
313 are for easy creation of
315 principals that can, for instance, be used to lookup a key in a keytab.
316 For both functions the
318 parameter will be used for the first component of the created principal.
324 will be used instead.
326 .Fn krb5_sname_to_principal
329 for the second component.
334 this name will be looked up with
340 the local hostname will be used.
342 .Fn krb5_sock_to_principal
347 which should be a bound
352 There must be a mapping between the address and
354 The function may try to resolve the name in DNS.
356 .Fn krb5_get_default_principal
357 tries to find out what's a reasonable default principal by looking at
358 the environment it is running in.
360 .Fn krb5_parse_nametype
361 parses and returns the name type integer value in
363 On failure the function returns an error code and set the error
367 .Xr krb5_425_conv_principal 3 ,
371 You can not have a NUL in a component in some of the variable argument
373 Until someone can give a good example of where it would be a good idea
374 to have NUL's in a component, this will not be fixed.