1 .\" Copyright (c) 2003 - 2007 Kungliga Tekniska Högskolan
2 .\" (Royal Institute of Technology, Stockholm, Sweden).
3 .\" All rights reserved.
5 .\" Redistribution and use in source and binary forms, with or without
6 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in the
14 .\" documentation and/or other materials provided with the distribution.
16 .\" 3. Neither the name of the Institute nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 .Nm krb5_get_default_principal ,
40 .Nm krb5_build_principal ,
41 .Nm krb5_build_principal_ext ,
42 .Nm krb5_build_principal_va ,
43 .Nm krb5_build_principal_va_ext ,
44 .Nm krb5_copy_principal ,
45 .Nm krb5_free_principal ,
46 .Nm krb5_make_principal ,
48 .Nm krb5_parse_name_flags ,
49 .Nm krb5_parse_nametype ,
50 .Nm krb5_princ_set_realm ,
51 .Nm krb5_principal_compare ,
52 .Nm krb5_principal_compare_any_realm ,
53 .Nm krb5_principal_get_comp_string ,
54 .Nm krb5_principal_get_realm ,
55 .Nm krb5_principal_get_type ,
56 .Nm krb5_principal_match ,
57 .Nm krb5_principal_set_type ,
58 .Nm krb5_realm_compare ,
59 .Nm krb5_sname_to_principal ,
60 .Nm krb5_sock_to_principal ,
61 .Nm krb5_unparse_name ,
62 .Nm krb5_unparse_name_flags ,
63 .Nm krb5_unparse_name_fixed ,
64 .Nm krb5_unparse_name_fixed_flags ,
65 .Nm krb5_unparse_name_fixed_short ,
66 .Nm krb5_unparse_name_short
67 .Nd Kerberos 5 principal handling functions
69 Kerberos 5 Library (libkrb5, -lkrb5)
75 .Fn krb5_free_principal "krb5_context context" "krb5_principal principal"
77 .Fn krb5_parse_name "krb5_context context" "const char *name" "krb5_principal *principal"
79 .Fn krb5_parse_name_flags "krb5_context context" "const char *name" "int flags" "krb5_principal *principal"
81 .Fn "krb5_unparse_name" "krb5_context context" "krb5_const_principal principal" "char **name"
83 .Fn "krb5_unparse_name_flags" "krb5_context context" "krb5_const_principal principal" "int flags" "char **name"
85 .Fn krb5_unparse_name_fixed "krb5_context context" "krb5_const_principal principal" "char *name" "size_t len"
87 .Fn krb5_unparse_name_fixed_flags "krb5_context context" "krb5_const_principal principal" "int flags" "char *name" "size_t len"
89 .Fn "krb5_unparse_name_short" "krb5_context context" "krb5_const_principal principal" "char **name"
91 .Fn krb5_unparse_name_fixed_short "krb5_context context" "krb5_const_principal principal" "char *name" "size_t len"
93 .Fn krb5_princ_set_realm "krb5_context context" "krb5_principal principal" "krb5_realm *realm"
95 .Fn krb5_build_principal "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "..."
97 .Fn krb5_build_principal_va "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "va_list ap"
99 .Fn "krb5_build_principal_ext" "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "..."
101 .Fn krb5_build_principal_va_ext "krb5_context context" "krb5_principal *principal" "int rlen" "krb5_const_realm realm" "va_list ap"
103 .Fn krb5_make_principal "krb5_context context" "krb5_principal *principal" "krb5_const_realm realm" "..."
105 .Fn krb5_copy_principal "krb5_context context" "krb5_const_principal inprinc" "krb5_principal *outprinc"
107 .Fn krb5_principal_compare "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
109 .Fn krb5_principal_compare_any_realm "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
111 .Fn krb5_principal_get_comp_string "krb5_context context" "krb5_const_principal principal" "unsigned int component"
113 .Fn krb5_principal_get_realm "krb5_context context" "krb5_const_principal principal"
115 .Fn krb5_principal_get_type "krb5_context context" "krb5_const_principal principal"
117 .Fn krb5_principal_match "krb5_context context" "krb5_const_principal principal" "krb5_const_principal pattern"
119 .Fn krb5_principal_set_type "krb5_context context" "krb5_principal principal" "int type"
121 .Fn krb5_realm_compare "krb5_context context" "krb5_const_principal princ1" "krb5_const_principal princ2"
123 .Fn krb5_sname_to_principal "krb5_context context" "const char *hostname" "const char *sname" "int32_t type" "krb5_principal *ret_princ"
125 .Fn krb5_sock_to_principal "krb5_context context" "int socket" "const char *sname" "int32_t type" "krb5_principal *principal"
127 .Fn krb5_get_default_principal "krb5_context context" "krb5_principal *princ"
129 .Fn krb5_parse_nametype "krb5_context context" "const char *str" "int32_t *type"
132 holds the name of a user or service in Kerberos.
134 A principal has two parts, a
138 The PrincipalName consists of one or more components. In printed form,
139 the components are separated by /.
140 The PrincipalName also has a name-type.
142 Examples of a principal are
143 .Li nisse/root@EXAMPLE.COM
145 .Li host/datan.kth.se@KTH.SE .
148 .Fn krb5_parse_name_flags
149 passes a principal name in
151 to the kerberos principal structure.
152 .Fn krb5_parse_name_flags
155 argument the following flags can be passed in
157 .It Dv KRB5_PRINCIPAL_PARSE_NO_REALM
158 requries the input string to be without a realm, and no realm is
162 .It Dv KRB5_PRINCIPAL_PARSE_REQUIRE_REALM
163 requries the input string to with a realm.
166 .Fn krb5_unparse_name
168 .Fn krb5_unparse_name_flags
178 argument the following flags can be passed in
180 .It Dv KRB5_PRINCIPAL_UNPARSE_SHORT
181 no realm if the realm is one of the local realms.
182 .It Dv KRB5_PRINCIPAL_UNPARSE_NO_REALM
183 never include any realm in the principal name.
184 .It Dv KRB5_PRINCIPAL_UNPARSE_DISPLAY
191 .Fn krb5_unparse_name_fixed
193 .Fn krb5_unparse_name_fixed_flags
196 but instead unparses the principal into a fixed size buffer.
198 .Fn krb5_unparse_name_short
199 just returns the principal without the realm if the principal is
200 in the default realm. If the principal isn't, the full name is
202 .Fn krb5_unparse_name_fixed_short
204 .Fn krb5_unparse_name_short
205 but on a fixed size buffer.
207 .Fn krb5_build_principal
208 builds a principal from the realm
212 The following arguments form the components of the principal.
213 The list of components is terminated with
216 .Fn krb5_build_principal_va
218 .Fn krb5_build_principal
221 .Fn krb5_build_principal_ext
223 .Fn krb5_build_principal_va_ext
224 take a list of length-value pairs, the list is terminated with a zero
227 .Fn krb5_make_principal
228 works the same way as
229 .Fn krb5_build_principal ,
230 except it figures out the length of the realm itself.
232 .Fn krb5_copy_principal
233 makes a copy of a principal.
234 The copy needs to be freed with
235 .Fn krb5_free_principal .
237 .Fn krb5_principal_compare
238 compares the two principals, including realm of the principals and returns
240 if they are the same and
244 .Fn krb5_principal_compare_any_realm
245 works the same way as
246 .Fn krb5_principal_compare
247 but doesn't compare the realm component of the principal.
249 .Fn krb5_realm_compare
250 compares the realms of the two principals and returns
252 is they are the same, and
256 .Fn krb5_principal_match
261 The pattern is a globbing expression, where each component (separated
262 by /) is matched against the corresponding component of the principal.
265 .Fn krb5_principal_get_realm
267 .Fn krb5_principal_get_comp_string
268 functions return parts of the
270 either the realm or a specific component.
271 Both functions return string pointers to data inside the principal, so
272 they are valid only as long as the principal exists.
277 .Fn krb5_principal_get_comp_string
278 is the index of the component to return, from zero to the total number of
279 components minus one. If the index is out of range
283 .Fn krb5_principal_get_realm
285 .Fn krb5_principal_get_comp_string
287 .Fn krb5_princ_component
288 and related macros, described as internal in the MIT API
290 Unlike the macros, these functions return strings, not
294 was that it was believed that principal components could contain
295 binary data, but this belief was unfounded, and it has been decided
296 that principal components are infact UTF8, so it's safe to use zero
299 It's generally not necessary to look at the components of a principal.
301 .Fn krb5_principal_get_type
303 .Fn krb5_principal_set_type
304 get and sets the name type for a principal.
305 Name type handling is tricky and not often needed,
306 don't use this unless you know what you do.
308 .Fn krb5_sname_to_principal
310 .Fn krb5_sock_to_principal
311 are for easy creation of
313 principals that can, for instance, be used to lookup a key in a keytab.
314 For both functions the
316 parameter will be used for the first component of the created principal.
322 will be used instead.
324 .Fn krb5_sname_to_principal
327 for the second component.
332 this name will be looked up with
338 the local hostname will be used.
340 .Fn krb5_sock_to_principal
345 which should be a bound
350 There must be a mapping between the address and
352 The function may try to resolve the name in DNS.
354 .Fn krb5_get_default_principal
355 tries to find out what's a reasonable default principal by looking at
356 the environment it is running in.
358 .Fn krb5_parse_nametype
359 parses and returns the name type integer value in
361 On failure the function returns an error code and set the error
365 .Xr krb5_425_conv_principal 3 ,
369 You can not have a NUL in a component in some of the variable argument
371 Until someone can give a good example of where it would be a good idea
372 to have NUL's in a component, this will not be fixed.