api-funcspec.tex: update semantics for admin_dbname and admin_lockfile
[krb5.git] / doc / kadm5 / api-funcspec.tex
1 \documentstyle[12pt,fullpage,changebar,rcsid]{article}
2
3 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4 %% Make _ actually generate an _, and allow line-breaking after it.
5 \let\underscore=\_
6 \catcode`_=13
7 \def_{\underscore\penalty75\relax}
8 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
9
10 \rcs$Id$
11
12 \setlength{\parskip}{.7\baselineskip}
13 \setlength{\parindent}{0pt}
14
15 \def\v#1{\verb+#1+}
16
17 \title{Kerberos Administration System \\
18         KADM5 API Functional Specifications\thanks{\rcsId}}
19 \author{Barry Jaspan}
20
21 \begin{document}
22
23 \sloppy
24 \maketitle
25
26 {\setlength{\parskip}{0pt}\tableofcontents}
27
28 \section{Introduction}
29
30 This document describes the Admin API that can be used to maintain
31 principals and policies.  It describes the data structures used for
32 each function and the interpretation of each data type field, the
33 semantics of each API function, and the possible return codes.
34
35 The Admin API is intended to be used by remote clients using an RPC
36 interface.  It is implemented by the admin server running on the
37 Kerberos master server.  It is also possible for a program running on
38 the Kerberos master server to use the Admin API directly, without
39 going through the admin server.
40
41 \section{Versions of the API}
42
43 The versions of this API and a brief description of the changes for
44 each are:
45
46 \begin{description}
47 \item[KADM5_API_VERSION_1] The initial version of this API, written by
48 OpenVision Technologies and donated to MIT for including in the public
49 release.  Originally called OVSEC_KADM_API_VERSION_1.  Most everything
50 has been renamed in one way or another, including functions, header
51 files, and data structures.  Where possible, the old OVSEC_KADM names
52 have been left behind for compatibility with version 1, and
53 KADM5_API_VERSION_1 is compatible with OVSEC_KADM_API_VERSION_1 at
54 compile-, link-, and run-time.
55
56 The OVSEC_KADM name compatibility will not be extended to new
57 functionality in future versions because no existing OVSEC_KADM
58 clients will use that functionality; new clients should be written to
59 the KADM5 API.
60
61 \item[KADM5_API_VERSION_2] This version contains the initial changes
62 necessary to make the OpenVision administration system work with the
63 mid-1996 MIT version of Kerberos 5.  Changes include
64 \begin{enumerate}
65 \item The kadm5_init functions now take a structure of parameters
66 instead of just a realm name, allowing the calling program to specify
67 non-default values for various configuration options.  See section
68 \ref{sec:configparams} for details.
69
70 \item The KADM5 API has been extended to support new features of the
71 Kerberos database, including multiple encryption and salt types per
72 principal.  See section \ref{sec:keys} for details.
73
74 \item kadm5_get_principal now allows a principal's keys to be
75 retrieved {\it by local clients only}.  This is necessary in order for
76 the kadm5 API to provide the primary Kerberos database interface.
77
78 \item The KADM5 authorization system has been completely changed.
79
80 \item The functions kadm5_flush, kadm5_get_principals, and
81 kadm5_get_policies have been added.
82
83 \item The KADM5 API now obeys a caller-allocates rather than
84 callee-allocates system.  kadm5_get_principal and kadm5_get_policy are
85 affected.
86 \end{enumerate}
87 \end{description}
88
89 \section{Policies and Password Quality}
90
91 The Admin API Password Quality mechanism provides the following
92 controls.  Note that two strings are defined to be ``significantly
93 different'' if they differ by at least one character. The compare is not
94 case sensitive.
95
96 \begin{itemize}
97 \item A minimum length can be required; a password with
98 fewer than the specified number of characters will not be accepted.
99
100 \item A minimum number of character classes can be required; a
101 password that does not contain at least one character from at least
102 the specified number of character classes will not be accepted.  The
103 character classes are defined by islower(), isupper(), isdigit(),
104 ispunct(), and other.
105
106 \item Passwords can be required to be different from
107 previous passwords; a password that generates the same encryption key
108 as any of the principal's specified previous number of passwords will
109 not be accepted.  This comparison is performed on the encryption keys
110 generated from the passwords, not on the passwords themselves.
111
112 \item A single ``forbidden password'' dictionary can be specified for all
113 users; a password that is not significantly different from every word
114 in the dictionary will not be accepted.
115 \end{itemize}
116
117 \section{Data Structures}
118
119 This section describes the data structures used by the Admin API.
120 They are defined in $<$kadm5/admin.h$>$.
121
122 \subsection{Principals, kadm5_principal_ent_t}
123 \label{sec:principal-structure}
124
125 A Kerberos principal entry is represented by a kadm5_principal_ent_t.
126 It contains a subset of the information stored in the master Kerberos
127 database as well as the additional information maintained by the admin
128 system.  In the current version, the only additional information is
129 the principal's policy and the aux_attributes flags.
130
131 The principal may or may not have a policy enforced on it.  If the
132 POLICY bit (see section \ref{sec:masks}) is set in aux_attributes, the
133 policy field names the principal's policy.  If the POLICY bit is not
134 set in aux_attributes, no policy is enforced on the principal and the
135 value of the policy field is undefined.
136
137 \begin{figure}[htbp]
138 \begin{verbatim}
139 typedef struct _kadm5_principal_ent_t {
140         krb5_principal principal;
141
142         krb5_timestamp princ_expire_time;
143         krb5_timestamp last_pwd_change;
144         krb5_timestamp pw_expiration;
145         krb5_deltat max_life;
146         krb5_principal mod_name;
147         krb5_timestamp mod_date;
148         krb5_flags attributes;
149         krb5_kvno kvno;
150         krb5_kvno mkvno;
151
152         char * policy;
153         u_int32 aux_attributes;
154
155         krb5_deltat max_renewable_life;
156         krb5_timestamp last_success;
157         krb5_timestamp last_failed;
158         krb5_kvno fail_auth_count;
159         krb5_int16 n_key_data;
160         krb5_int16 n_tl_data;
161         krb5_tl_data *tl_data;
162         krb5_key_data *key_data;
163 } kadm5_principal_ent_rec, *kadm5_principal_ent_t;
164 \end{verbatim}
165 \caption{Definition of kadm5_principal_ent_t.}
166 \label{fig:princ-t}
167 \end{figure}
168
169 The fields of an kadm5_principal_ent_t are interpreted as
170 follows.
171
172 \begin{description}
173 \item[principal] The name of the principal; must conform to Kerberos
174 naming specifications.
175
176 \item[princ_expire_time] The expire time of the principal as a Kerberos
177 timestamp.  No Kerberos tickets will be issued for a principal after
178 its expire time.
179
180 \item[last_pwd_change] The time this principal's password was last
181 changed, as a Kerberos timestamp.
182
183 \item[pw_expiration] The expire time of the user's current password, as a
184 Kerberos timestamp.  No application service tickets will be issued for the
185 principal once the password expire time has passed.  Note that the user can
186 only obtain tickets for services that have the PW_CHANGE_SERVICE bit set in
187 the attributes field.
188
189 \item[max_life] The maximum lifetime of any Kerberos ticket issued to
190 this principal.
191
192 \item[attributes] A bitfield of attributes for use by the KDC.  The
193 symbols and constant values are defined below; their interpretation
194 appears in the libkdb functional specification.
195
196 \begin{tabular}{clr}
197 {\bf Name} & {\bf Value} \\
198 KRB5_KDB_DISALLOW_POSTDATED     & 0x00000001 \\
199 KRB5_KDB_DISALLOW_FORWARDABLE   & 0x00000002 \\
200 KRB5_KDB_DISALLOW_TGT_BASED     & 0x00000004 \\
201 KRB5_KDB_DISALLOW_RENEWABLE     & 0x00000008 \\
202 KRB5_KDB_DISALLOW_PROXIABLE     & 0x00000010 \\
203 KRB5_KDB_DISALLOW_DUP_SKEY      & 0x00000020 \\
204 KRB5_KDB_DISALLOW_ALL_TIX       & 0x00000040 \\
205 KRB5_KDB_REQUIRES_PRE_AUTH      & 0x00000080 \\
206 KRB5_KDB_REQUIRES_HW_AUTH       & 0x00000100 \\
207 KRB5_KDB_REQUIRES_PWCHANGE      & 0x00000200 \\
208 KRB5_KDB_DISALLOW_SVR           & 0x00001000 \\
209 KRB5_KDB_PWCHANGE_SERVICE       & 0x00002000 \\
210 KRB5_KDB_SUPPORT_DESMD5         & 0x00004000 \\
211 KRB5_KDB_NEW_PRINC              & 0x00008000
212 \end{tabular}
213
214 \item[mod_name] The name of the Kerberos principal that most recently
215 modified this principal.
216
217 \item[mod_date] The time this principal was last modified, as a Kerberos
218 timestamp.
219
220 \item[kvno] The version of the principal's current key.
221
222 \item[mkvno] The version of the Kerberos Master Key in effect when
223 this principal's key was last changed.  In KADM5_API_VERSION_2, this
224 field is always zero.
225
226 \item[policy] If the POLICY bit is set in aux_attributes, the name
227 of the policy controlling this principal.
228
229 \item[aux_attributes]  A bitfield of flags for use by the
230 administration system.  Currently, the only valid flag is POLICY, and
231 it indicates whether or not the principal has a policy enforced on it.
232
233 \item[max_renewable_life] The maximum renewable lifetime of any
234 Kerberos ticket issued to or for this principal.  This field only
235 exists in KADM5_API_VERSION_2.
236
237 \item[last_success] The KDC time of the last successful AS_REQ.  This
238 is only updated if KRBCONF_KDC_MODIFIES_KDB is defined during
239 compilation of the KDC.  This field only exists in
240 KADM5_API_VERSION_2.
241
242 \item[last_failed] The KDC time of the last failed AS_REQ.  This is
243 only updated if KRBCONF_KDC_MODIFIES_KDB is defined during compilation
244 of the KDC.  This field only exists in KADM5_API_VERSION_2.
245
246 \item[fail_auth_count] The number of consecutive failed AS_REQs.  When
247 this number reaches KRB5_MAX_FAIL_COUNT, the KRB5_KDC_DISALLOW_ALL_TIX
248 is set on the principal.  This is only updated if
249 KRBCONF_KDC_MODIFIES_KDB is defined during compilation.  This field
250 only exists in KADM5_API_VERSION_2.
251
252 \item[n_tl_data] The number of elements in the \v{tl_data} linked
253 list.  This field only exists in KADM5_API_VERSION_2.
254
255 \item[n_key_data] The number of elements in the \v{key_data}
256 array. This field only exists in KADM5_API_VERSION_2.
257
258 \item[tl_data] A linked list of tagged data.  This list is a mechanism
259 by which programs can store extended information in a principal entry,
260 without having to modify the database API.  Each element is of type
261 krb5_tl_data:
262 \begin{verbatim}
263 typedef struct _krb5_tl_data {
264     struct _krb5_tl_data* tl_data_next;
265     krb5_int16            tl_data_type;         
266     krb5_int16            tl_data_length;       
267     krb5_octet          * tl_data_contents;     
268 } krb5_tl_data;
269 \end{verbatim}
270 The libkdb library defines the tagged data types
271 KRB5_TL_LAST_PWD_CHANGE, KRB5_TL_MOD_PRINC, and KRB5_TL_KADM_DATA,
272 which store the last password modification time, time and modifier of
273 last principal modification, and administration system data.  All of
274 these entries are expected by the administration system and parsed out
275 into fields of the kadm5_principal_ent_rec structure; they are also
276 left in the tl_data list.
277
278 The KADM5 API defines its own tagged data type, KRB5_TL_KADM5_E_DATA,
279 which stores the contents of the e_data field of a krb5_db_entry.  The
280 tagged data is only present if the database entry has extended data,
281 and will only ever exist while KADM5 is implemented on top of the
282 DB/DBM database mechansim.
283
284 Any additional tagged data fields found in the database will also be
285 provided, without interpretation.
286
287 \item[key_data] An array of the principal's keys.  The keys contained
288 in this array are encrypted in the Kerberos master key.  See section
289 \ref{sec:keys} for a discussion of the krb5_key_data structure.
290 \end{description}
291
292 \subsection{Policies, kadm5_policy_ent_t}
293 \label{sec:policy-fields}
294
295 If the POLICY bit is set in aux_attributes, the \v{policy} name field
296 in the kadm5_principal_ent_t structure refers to a password policy
297 entry defined in a \v{kadm5_policy_ent_t}.
298
299 \begin{verbatim}
300 typedef struct _kadm5_policy_ent_t {
301         char *policy;
302
303         u_int32 pw_min_life;
304         u_int32 pw_max_life;
305         u_int32 pw_min_length;
306         u_int32 pw_min_classes;
307         u_int32 pw_history_num;
308         u_int32 policy_refcnt;
309 } kadm5_policy_ent_rec, *kadm5_policy_ent_t;
310 \end{verbatim}
311
312 The fields of an kadm5_policy_ent_t are interpreted as follows.
313 Note that a policy's values only apply to a principal using that
314 policy.
315
316 \begin{description}
317 \item[policy] The name of this policy, as a NULL-terminated string.
318 The ASCII characters between 32 (space) and 126 (tilde), inclusive,
319 are legal.
320
321 \item[pw_min_life] The minimum password lifetime, in seconds.
322 A principal cannot change its password before pw_min_life seconds have
323 passed since last_pwd_change.
324
325 \item[pw_max_life] The default duration, in seconds, used to compute
326 pw_expiration when a principal's password is changed.
327
328 \item[pw_min_length] The minimum password length, in characters.  A
329 principal cannot set its password to anything with fewer than this
330 number of characters.  This value must be greater than zero.
331
332 \item[pw_min_classes] The minimum number of character classes in the
333 password.  This value can only be 1, 2, 3, 4, or 5.  A principal cannot
334 set its password to anything with fewer than this number of character
335 classes in it.
336
337 \item[pw_history_num] The number of past passwords that are
338 stored for the principal; the minimum value is 1 and the maximum value
339 is 10.  A principal cannot set its password to any of its previous
340 pw_history_num passwords.  The first ``previous'' password is the
341 current password; thus, a principal with a policy can never reset its
342 password to its current value.
343
344 \item[policy_refcnt]  The number of principals currently using this policy.
345 A policy cannot be deleted unless this number is zero.
346 \end{description}
347
348 \subsection{Configuration parameters}
349 \label{sec:configparams}
350
351 The KADM5 API acquires configuration information from the Kerberos
352 configuration file (\$KRB5_CONFIG or DEFAULT_PROFILE_PATH) and from
353 the KDC configuration file (\$KRB5_KDC_CONFIG or DEFAULT_KDC_PROFILE).
354 In KADM5_API_VERSION_2, some of the configuration parameters used by
355 the KADM5 API can be controlled by the caller by providing a
356 kadm5_config_params structure to kadm5_init:
357 %
358 \begin{verbatim}
359 typedef struct _kadm5_config_params {
360         u_int32 mask;
361
362         /* Client and server fields */
363         char *realm;
364         char *profile;
365         int kadmind_port;
366
367         /* client fields */
368         char *admin_server;
369
370         /* server fields */
371         char *dbname;
372         char *admin_dbname;
373         char *admin_lockfile;
374         char *acl_file;
375         char *dict_file;
376         char *admin_keytab;
377
378         /* server library (database) fields */
379         int mkey_from_kbd;
380         char *stash_file;
381         char *mkey_name;
382         krb5_enctype enctype;
383         krb5_deltat max_life;
384         krb5_deltat max_rlife;
385         krb5_timestamp expiration;
386         krb5_flags flags;
387         krb5_key_salt_tuple *keysalts;
388         krb5_int32 num_keysalts;
389 } kadm5_config_params;
390 \end{verbatim}
391 %
392 The following list describes each of the fields of the structure,
393 along with the profile relation it overrides, its mask value, its
394 default value, and whether it is valid on the client, server, or both,
395 or neither.
396 \begin{description}
397 \item[mask] No variable.  No mask value.  A bitfield specifying which
398 fields of the structure contain valid information.  A caller sets this
399 mask before calling kadm5_init_*, indicating which parameters are
400 specified.  The mask values are defined in $<$kadm5/admin.h$>$ and are
401 all prefixed with KADM5_CONFIG_; the prefix is not included in the
402 descriptions below.
403
404 \item[realm] No variable.  REALM.  Client and server.  The realm to
405 which these parameters apply, and the realm for which additional
406 parameters are to be acquired, if any.  If this field is not specified
407 in the mask, the default local realm is used.
408
409 \item[profile] Variable: profile (server only).  PROFILE.  Client and
410 server.  The Kerberos profile to use.  On the client, the default is
411 the value of the KRB5_CONFIG environment variable, or
412 DEFAULT_PROFILE_PATH if that is not set.  On the server, the value of
413 the ``profile'' variable of the KDC configuration file will be used as
414 the first default if it exists; otherwise, the default is the value of
415 the KRB5_KDC_PROFILE environment variable or DEFAULT_KDC_PROFILE.
416
417 \item[kadmind_port] Variable: kadmind_port.  KADMIND_PORT.  Client and
418 server.  The port number the kadmind server listens on.  The client
419 uses this field to determine where to connect, and the server to
420 determine where to listen.  The default is 749, which has been
421 assigned by IANA.
422
423 \item[admin_server] Variable: admin_server.  ADMIN_SERVER.  Client.
424 The host name of the admin server to which to connect.  There is no
425 default.  If the value of this field contains a colon (:), the text
426 following the colon is treated as an integer and assigned to the
427 kadmind_port field, overriding any value of the kadmind_port variable.
428
429 \item[dbname] Variable: dbname.  DBNAME.  Server.  The Kerberos
430 database name to use; the Kerberos database stores principal
431 information.  The default is DEFAULT_KDB_FILE.
432
433 \item[admin_dbname] Variable: admin_database_name.  ADBNAME.
434 Neither.  If the dbname field is set, this field is set to the value
435 of dbname followed by ``.kadm5''.
436
437 \item[admin_lockfile] Variable: admin_database_lockfile.
438 ADB_LOCKFILE.  Neither.  If the admin_dbname field is set, this field
439 is set to the value of admin_dbname followed by ``.lock''.
440
441 \item[acl_file] Variable: acl_file.  ACL_FILE.  Server.  The admin
442 server's ACL file.  The default is DEFAULT_KADM5_ACL_FILE.
443
444 \item[dict_file] Variable: admin_dict_file.  DICT_FILE.  Server.  The
445 admin server's dictionary file of passwords to disallow.  No default.
446
447 \item[admin_keytab] Variable: admin_keytab. ADMIN_KEYTAB.  Server.
448 The keytab file containing the kadmin/admin and kadmin/changepw
449 entries for the server to use.  The default is the value of the
450 KRB5_KTNAME environment variable, if defined, else
451 DEFAULT_KADM5_KEYTAB.
452
453 \item[mkey_from_keyboard] No variable. MKEY_FROM_KEYBOARD.  Server.
454 If non-zero, prompt for the master password via the tty instead of
455 using the stash file.  If this mask bit is not set, or is set and the
456 value is zero, the stash file is used.
457
458 \item[stash_file] Variable: key_stash_file.  STASH_FILE. Server.  The
459 file name containing the master key stash file.  No default; libkdb
460 will work with a NULL value.
461
462 \item[mkey_name] Variable: master_key_name.  MKEY_NAME.  Server.  The
463 name of the master principal for the realm.  No default; lbkdb will
464 work with a NULL value.
465
466 \item[enctype] Variable: master_key_type.  ENCTYPE.  Server.  The
467 encryption type of the master principal.  The default is
468 DEFAULT_KDC_ENCTYPE.
469
470 \item[max_life] Variable: max_life.  MAX_LIFE.  Maximum lifetime for
471 all tickets issued to the principal.  The default is 28800, which is 8
472 hours.
473
474 \item[max_rlife, expiration, flags] Variables: max_renewable_life,
475 default_principal_expiration, default_principal_flags.  MAX_LIFE,
476 MAX_RLIFE, EXPIRATION, FLAGS.  Server.  Default values for new
477 principals.  All default to 0.
478
479 \item[keysalts, num_keysalts] Variable: supported_enctypes.  ENCTYPES.
480 Server.  The list of supported encryption type/salt type tuples; both
481 fields must be assigned if ENCTYPES is set.  The default is a list
482 containing one enctype, DES-CBC-CRC with normal salt.
483 \end{description}
484
485 \subsection{Principal keys}
486 \label{sec:keys}
487
488 In KADM5_API_VERSION_1, all principals had a single key.  The
489 encryption method was always DES, and the salt type was determined
490 outside the API (by command-line options to the administration
491 server).
492
493 In KADM5_API_VERSION_2, principals can have multiple keys, each with
494 its own encryption type and salt.  Each time a principal's key is
495 changed with kadm5_create_principal, kadm5_chpass_principal or
496 kadm5_randkey_principal, existing key entries are removed and a key
497 entry for each encryption and salt type tuple specified in the
498 configuration parameters is added.  There is no provision for
499 specifying encryption and salt type information on a per-principal
500 basis; in a future version, this will probably be part of the admin
501 policy.  There is also presently no provision for keeping multiple key
502 versions for a single principal active in the database.
503
504 A single key is represented by a krb5_key_data:
505 %
506 \begin{verbatim}
507 typedef struct _krb5_key_data {
508         krb5_int16            key_data_ver;         /* Version */
509         krb5_int16            key_data_kvno;        /* Key Version */
510         krb5_int16            key_data_type[2];     /* Array of types */
511         krb5_int16            key_data_length[2];   /* Array of lengths */
512         krb5_octet          * key_data_contents[2]; /* Array of pointers */
513 } krb5_key_data;
514 \end{verbatim}
515 %
516 \begin{description}
517 \item[key_data_ver] The verion number of the structure.  Versions 1
518 and 2 are currently defined.  If key_data_ver is 1 then the key is
519 either a random key (not requiring a salt) or the salt is the normal
520 v5 salt which is the same as the realm and therefore doesn't need to
521 be saved in the database.
522
523 \item[key_data_kvno] The key version number of this key.
524
525 \item[key_data_type] The first element is the enctype of this key.  In
526 a version 2 structure, the second element is the salttype of this key.
527 The legal encryption types are defined in $<$krb5.h$>$.  The legal
528 salt types are defined in $<$k5-int.h$>$.
529
530 \item[key_data_length] The first element is length this key.  In a
531 version 2 structure, the second element is length of the salt for this
532 key.
533
534 \item[key_data_contents] The first element is the content of this key.
535 In a version 2 structure, the second element is the contents of the
536 salt for this key.
537 \end{description}
538
539 \subsection{Field masks}
540 \label{sec:masks}
541
542 The API functions for creating, retrieving, and modifying principals
543 and policies allow for a relevant subset of the fields of the
544 kadm5_principal_ent_t and kadm5_policy_ent_t to be specified or
545 changed.  The chosen fields are determined by a bitmask that is passed
546 to the relevant function.  Each API function has different rules for
547 which mask values can be specified, and can specify whether a given
548 mask value is mandatory, optional, or forbidden.  Mandatory fields
549 must be present and forbidden fields must not be present or an error
550 is generated.  When creating a principal or policy, optional fields
551 have a default value if they are not specified.  When modifying a
552 principal or policy, optional fields are unchanged if they are not
553 specified.  When retrieving a principal, optional fields are simply
554 not provided if they are not specified; not specifying undeeded fields
555 for retrieval may improve efficiency.  The values for forbidden fields
556 are defined in the function semantics.
557
558 The masks for principals are in table \ref{tab:princ-bits} and the
559 masks for policies are in table \ref{tab:policy-bits}.  They are
560 defined in $<$kadm5/admin.h$>$. The KADM5_ prefix has been removed
561 from the Name fields.  In the Create and Modify fields, M means
562 mandatory, F means forbidden, and O means optional.  Create fields
563 that are optional specify the default value.  The notation ``K/M
564 value'' means that the field inherits its value from the corresponding
565 field in the Kerberos master principal, for KADM5_API_VERSION_1, and
566 from the configuration parameters for KADM5_API_VERSION_2.
567
568 All masks for principals are optional for retrevial, {\it except} that
569 the KEY_DATA mask is illegal when specified by a remote client; for
570 details, see the function semantics for kadm5_get_principal.
571
572 Note that the POLICY and POLICY_CLR bits are special.  When POLICY is
573 set, the policy is assigned to the principal.  When POLICY_CLR is
574 specified, the policy is unassigned to the principal and as a result
575 no policy controls the principal.
576
577 For convenience, the mask KADM5_PRINCIPAL_NORMAL_MASK contains all of
578 the principal masks {\it except} KADM5_KEY_DATA and KADM5_TL_DATA, and
579 the mask KADM5_POLICY_NORMAL_MASK contains all of the policy masks.
580
581 \begin{table}[htbp]
582 \begin{tabular}{@{}lclll}
583 {\bf Name} & {\bf Value} & {\bf Fields Affected} & {\bf Create} & 
584         {\bf Modify} \\
585 PRINCIPAL               & 0x000001 & principal & M & F \\
586 PRINC_EXPIRE_TIME       & 0x000002 & princ_expire_time & O, K/M value & O \\
587 PW_EXPIRATION           & 0x000004 & pw_expiration & O, now+pw_max_life & O \\
588 LAST_PWD_CHANGE         & 0x000008 & last_pwd_change & F & F \\
589 ATTRIBUTES              & 0x000010 & attributes & O, 0 & O \\
590 MAX_LIFE                & 0x000020 & max_life & O, K/M value & O \\
591 MOD_TIME                & 0x000040 & mod_date & F & F \\
592 MOD_NAME                & 0x000080 & mod_name & F & F \\
593 KVNO                    & 0x000100 & kvno & O, 1 & O \\
594 MKVNO                   & 0x000200 & mkvno & F & F \\
595 AUX_ATTRIBUTES          & 0x000400 & aux_attributes & F & F \\
596 POLICY                  & 0x000800 & policy & O, none & O \\
597 POLICY_CLR              & 0x001000 & policy & F & O \\
598 MAX_RLIFE               & 0x002000 & max_renewable_life & O, K/M value & O \\
599 LAST_SUCCESS            & 0x004000 & last_success & F & F \\
600 LAST_FAILED             & 0x008000 & last_failed & F & F \\
601 FAIL_AUTH_COUNT         & 0x010000 & fail_auth_count & F & O \\
602 KEY_DATA                & 0x020000 & n_key_data, key_data & F & F \\
603 TL_DATA                 & 0x040000 & n_tl_data, tl_data & O, 0, NULL & O
604 \end{tabular}
605 \caption{Mask bits for creating, retrieving, and modifying principals.}
606 \label{tab:princ-bits}
607 \end{table}
608
609 \begin{table}[htbp]
610 \begin{tabular}{@{}lclll}
611 Name & Value & Field Affected & Create & Modify \\
612 POLICY                  & same     & policy & M & F \\
613 PW_MAX_LIFE             & 0x004000 & pw_max_life & O, 0 (infinite) & O \\
614 PW_MIN_LIFE             & 0x008000 & pw_min_life & O, 0 & O \\
615 PW_MIN_LENGTH           & 0x010000 & pw_min_length & O, 1 & O \\
616 PW_MIN_CLASSES          & 0x020000 & pw_min_classes & O, 1 & O \\
617 PW_HISTORY_NUM          & 0x040000 & pw_history_num & O, 0 & O \\
618 REF_COUNT               & 0x080000 & pw_refcnt & F & F
619 \end{tabular}
620 \caption{Mask bits for creating/modifying policies.}
621 \label{tab:policy-bits}
622 \end{table}
623
624 \section{Constants, Header Files, Libraries}
625
626 $<$kadm5/admin.h$>$ includes a number of required header files,
627 including RPC, Kerberos 5, com_err, and admin com_err
628 defines.  It contains prototypes for all kadm5 routines mentioned
629 below, as well as all Admin API data structures, type definitions and
630 defines mentioned in this document.  
631
632 Before \v{\#include}ing $<$kadm5/admin.h$>$, the programmer can
633 specify the API version number that the program will use by
634 \v{\#define}ing USE_KADM5_API_VERSION; for example, define that symbol
635 to be 1 to use KADM5_API_VERSION_1.  This will ensure that the correct
636 functional protoypes and data structures are defined.  If no version
637 symbol is defined, the most recent version supported by the header
638 files will be used.
639
640 Some of the defines and their values contained in $<$kadm5/admin.h$>$
641 include the following, whose KADM5_ prefixes have been removed.
642 Symbols that do not exist in KADM5_API_VERSION_2 do not have a KADM5_
643 prefix, but instead retain only with OVSEC_KADM_ prefix for
644 compatibility.
645 \begin{description}
646 \item[admin service principal] ADMIN_SERVICE (``kadmin/admin'')
647 \item[admin history key] HIST_PRINCIPAL (``kadmin/history'')
648 \item[change password principal] CHANGEPW_SERVICE (``kadmin/changepw'')
649 \item[server acl file path] ACLFILE (``/krb5/ovsec_adm.acl'').  In
650 KADM5_API_VERSION 2, this is controlled by configuration parameters.
651 \item[dictionary] WORDFILE (``/krb5/kadmind.dict'').    In
652 KADM5_API_VERSION 2, this is controlled by configuration parameters.
653 \end{description}
654
655 KADM5 errors are described in $<$kadm5/kadm_err.h$>$, which
656 is included by $<$kadm5/admin.h$>$.
657
658 The locations of the admin policy and principal databases, as well as
659 defines and type definitions for the databases, are defined in
660 $<$kadm5/adb.h$>$.  Some of the defines in that file are:
661 \begin{description}
662 \item[admin policy database] POLICY_DB (``/krb5/kadm5_policy.db'').    In
663 KADM5_API_VERSION 2, this is controlled by configuration parameters.
664 \item[admin principal database] PRINCIPAL_DB
665 (``/krb5/ovsec_principal.db'').  In KADM5_API_VERSION 2, this is
666 controlled by configuration parameters.
667 \end{description}
668
669 Client applications will link against libkadm5clnt.a and server
670 programs against libkadm5srv.a.  Client applications must also link
671 against: libgssapi_krb5.a, libkrb5.a, libcrypto.a, libgssrpc.a,
672 libcom_err.a, and libdyn.a.  Server applications must also link
673 against: libkdb5.a, libkrb5.a, libcrypto.a, libgssrpc.a, libcom_err.a,
674 and libdyn.a.
675
676 \section{Error Codes}
677
678 The error codes that can be returned by admin functions are listed
679 below.  Error codes indicated with a ``*'' can be returned by every
680 admin function and always have the same meaning; these codes are
681 omitted from the list presented with each function.  
682
683 The admin system guarantees that a function that returns an error code
684 has no other side effect.
685
686 The Admin system will use \v{com_err} for error codes.  Note that this
687 means \v{com_err} codes may be returned from functions that the admin
688 routines call (e.g. the kerberos library). Callers should not expect
689 that only KADM5 errors will be returned.  The Admin system error code
690 table name will be ``ovk'', and the offsets will be the same as the
691 order presented here. As mentioned above, the error table include file
692 will be $<$kadm5/kadm_err.h$>$.
693
694 Note that these error codes are also used as protocol error code
695 constants and therefore must not change between product releases.
696 Additional codes should be added at the end of the list, not in the
697 middle.  The integer value of KADM5_FAILURE is 43787520; the
698 remaining values are assigned in sequentially increasing order.
699
700 \begin{description}
701 \item[* KADM5_FAILURE] Operation failed for unspecified reason
702 \item[* KADM5_AUTH_GET] Operation requires ``get'' privilege
703 \item[* KADM5_AUTH_ADD] Operation requires ``add'' privilege
704 \item[* KADM5_AUTH_MODIFY] Operation requires ``modify'' privilege
705 \item[* KADM5_AUTH_DELETE] Operation requires ``delete'' privilege
706 \item[* KADM5_AUTH_INSUFFICIENT] Insufficient authorization for
707 operation
708 \item[* KADM5_BAD_DB] Database inconsistency detected
709 \item[KADM5_DUP] Principal or policy already exists
710 \item[KADM5_RPC_ERROR] Communication failure with server
711 \item[KADM5_NO_SRV] No administration server found for realm
712 \item[KADM5_BAD_HIST_KEY] Password history principal key version
713 mismatch
714 \item[KADM5_NOT_INIT] Connection to server not initialized
715 \item[KADM5_UNK_PRINC]  Principal does not exist
716 \item[KADM5_UNK_POLICY] Policy does not exist
717 \item[KADM5_BAD_MASK] Invalid field mask for operation
718 \item[KADM5_BAD_CLASS] Invalid number of character classes
719 \item[KADM5_BAD_LENGTH] Invalid password length
720 \item[KADM5_BAD_POLICY] Illegal policy name
721 \item[KADM5_BAD_PRINCIPAL] Illegal principal name.
722 \item[KADM5_BAD_AUX_ATTR] Invalid auxillary attributes
723 \item[KADM5_BAD_HISTORY] Invalid password history count
724 \item[KADM5_BAD_MIN_PASS_LIFE] Password minimum life is greater
725 then password maximum life
726 \item[KADM5_PASS_Q_TOOSHORT] Password is too short
727 \item[KADM5_PASS_Q_CLASS] Password does not contain enough
728 character classes
729 \item[KADM5_PASS_Q_DICT] Password is in the password dictionary
730 \item[KADM5_PASS_REUSE] Cannot resuse password
731 \item[KADM5_PASS_TOOSOON] Current password's minimum life has not
732 expired
733 \item[KADM5_POLICY_REF] Policy is in use
734 \item[KADM5_INIT] Connection to server already initialized
735 \item[KADM5_BAD_PASSWORD] Incorrect password
736 \item[KADM5_PROTECT_PRINCIPAL] Cannot change protected principal
737 \item[* KADM5_BAD_SERVER_HANDLE] Programmer error!  Bad Admin server handle
738 \item[* KADM5_BAD_STRUCT_VERSION] Programmer error!  Bad API structure version
739 \item[* KADM5_OLD_STRUCT_VERSION] API structure version specified by application is no longer supported (to fix, recompile application against current Admin API header files and libraries)
740 \item[* KADM5_NEW_STRUCT_VERSION] API structure version specified by application is unknown to libraries (to fix, obtain current Admin API header files and libraries and recompile application)
741 \item[* KADM5_BAD_API_VERSION] Programmer error!  Bad API version
742 \item[* KADM5_OLD_LIB_API_VERSION] API version specified by application is no longer supported by libraries (to fix, update application to adhere to current API version and recompile)
743 \item[* KADM5_OLD_SERVER_API_VERSION] API version specified by application is no longer supported by server (to fix, update application to adhere to current API version and recompile)
744 \item[* KADM5_NEW_LIB_API_VERSION] API version specified by application is unknown to libraries (to fix, obtain current Admin API header files and libraries and recompile application)
745 \item[* KADM5_NEW_SERVER_API_VERSION] API version specified by
746 application is unknown to server (to fix, obtain and install newest
747 Admin Server)
748 \item[KADM5_SECURE_PRINC_MISSING] Database error! Required principal missing
749 \item[KADM5_NO_RENAME_SALT] The salt type of the specified principal
750 does not support renaming
751 \item[KADM5_BAD_CLIENT_PARAMS] Illegal configuration parameter for
752 remote KADM5 client
753 \item[KADM5_BAD_SERVER_PARAMS] Illegal configuration parameter for
754 local KADM5 client.
755 \item[KADM5_AUTH_LIST] Operation requires ``list'' privilege
756 \item[KADM5_AUTH_CHANGEPW] Operation requires ``change-password'' privilege
757 \end{description}
758
759 \section{Authentication and Authorization}
760 \label{sec:auth}
761
762 Two Kerberos principals exist for use in communicating with the Admin
763 system: kadmin/admin and kadmin/changepw.  Both principals
764 have the KRB5_KDB_DISALLOW_TGT_BASED bit set in their attributes so
765 that service tickets for them can only be acquired via a
766 password-based (AS_REQ) request.  Additionally, kadmin/changepw
767 has the KRB5_KDB_PWCHANGE_SERVICE bit set so that a principal with an
768 expired password can still obtain a service ticket for it.
769
770 The Admin system accepts requests that are authenticated to either
771 service principal, but the sets of operations that can be performed by
772 a request authenticated to each service are different.  In particular,
773 only the functions chpass_principal, randkey_principal, get_principal,
774 and get_policy can be performed by a request authenticated to the
775 kadmin/changepw service.  The function semantics descriptions below
776 give the precise details.
777
778 Each Admin API operation authenticated to the kadmin/admin service
779 requires a specific authorization to run.  This version uses a simple
780 named privilege system with the following names and meanings:
781
782 \begin{description}
783 \item[Get] Able to examine the attributes (NOT key data) of principals
784 and policies. 
785 \item[Add] Able to add principals and policies.
786 \item[Modify] Able to modify attributes of existing principals and
787 policies; this does not include changing passwords.
788 \item[Delete] Able to remove principals and policies.
789 \item[List] Able to retrieve a list of principals and policies.
790 \item[Changepw] Able to change the password of principals.
791 \end{description}
792
793 Privileges are specified via an external configuration file on the
794 Kerberos master server.
795
796 Table \ref{tab:func-overview} summarizes the authorization
797 requirements of each function.  Additionally, each API function
798 description identifies the privilege required to perform it.  The
799 Authorization checks only happen if you are using the RPC mechanism.
800 If you are using the server-side API functions locally on the admin
801 server, the only authorization check is if you can access the
802 approporiate local files.
803
804 \section{Functions}
805
806 \subsection{Overview}
807
808 The functions provided by the Admin API, and the authorization they
809 require, are listed in the table \ref{tab:func-overview}.  The
810 ``kadm5_'' prefix has been removed from each function name.
811
812 The function semantics in the following sections omit details that are
813 the same for every function.
814
815 \begin{itemize}
816 \item The effects of every function are atomic.
817
818 \item Every function performs an authorization check and returns
819 the appropriate KADM5_AUTH_* error code if the caller does not
820 have the required privilege.  No other information or error code is
821 ever returned to an unauthorized user.
822
823 \item Every function checks its arguments for NULL pointers or other
824 obviously invalid values, and returns EINVAL if any are detected.
825
826 \item Any function that performs a policy check uses the policy named
827 in the principal's policy field.  If the POLICY bit is not set in the
828 principal's aux_attributes field, however, the principal has no
829 policy, so the policy check is not performed.
830
831 \item Unless otherwise specified, all functions return KADM5_OK.
832 \end{itemize}
833
834 \begin{table}[htbp]
835 \caption{Summary of functions and required authorization.}
836 \label{tab:func-overview}
837 \begin{tabular}{@{}llp{3.24in}}
838 \\
839 {\bf Function Name} & {\bf Authorization} & {\bf Operation} \\
840
841 init & none & Open a connection with the kadm5 library.  OBSOLETE
842 but still provided---use init_with_password instead. \\
843 init_with_password & none & Open a connection with the kadm5
844 library using a password to obtain initial credentials. \\
845 init_with_skey & none & Open a connection with the kadm5 library
846 using the keytab entry to obtain initial credentials. \\
847 destroy & none & Close the connection with the kadm5 library. \\
848 flush & none & Flush all database changes to disk; no-op when called
849 remotely. \\
850 create_principal & add & Create a new principal. \\
851 delete_principal & delete & Delete a principal. \\
852 modify_principal & modify & Modify the attributes of an existing
853         principal (not password). \\
854 rename_principal & add and delete & Rename a principal. \\
855 get_principal & get\footnotemark & Retrieve a principal. \\
856 get_principals & list & Retrieve some or all principal names. \\
857 chpass_principal & changepw\footnotemark[\thefootnote] &
858          Change a principal's password. \\
859 chpass_principal_util & changepw\footnotemark[\thefootnote] & Utility wrapper around chpass_principal. \\
860 randkey_principal & changepw\footnotemark[\thefootnote] &
861         Randomize a principal's key. \\
862 decrypt_key & none & Decrypt a principal key. \\
863 create_policy & add & Create a new policy. \\
864 delete_policy & delete & Delete a policy. \\
865 modify_policy & modify & Modify the attributes of a policy. \\
866 get_policy & get & Retrieve a policy. \\
867 get_policies & list & Retrieve some or all policy names. \\
868 free_principal_ent & none & Free the memory associated with an
869                 kadm5_principal_ent_t. \\
870 free_policy_ent & none & Free the memory associated with an
871                 kadm5_policy_ent_t. \\
872 get_privs & none & Return the caller's admin server privileges.
873 \end{tabular}
874 \end{table}
875 \footnotetext[\thefootnote]{These functions also allow a principal to
876 perform the operation on itself; see the function's semantics for
877 details.}
878
879 \subsection{kadm5_init_*}
880
881 In KADM5_API_VERSION 1:
882
883 \begin{verbatim}
884 kadm5_ret_t kadm5_init_with_password(char *client_name, char *pass,
885                                  char *service_name, char *realm,
886                                  unsigned long struct_version,
887                                  unsigned long api_version,
888                                  void **server_handle)
889
890 kadm5_ret_t kadm5_init_with_skey(char *client_name, char *keytab,
891                                  char *service_name, char *realm,
892                                  unsigned long struct_version,
893                                  unsigned long api_version,
894                                  void **server_handle)
895
896 kadm5_ret_t kadm5_init(char *client_name, char *pass,
897                                  char *service_name, char *realm,
898                                  unsigned long struct_version,
899                                  unsigned long api_version,
900                                  void **server_handle)
901 \end{verbatim}
902
903 In KADM5_API_VERSION 2:
904
905 \begin{verbatim}
906 kadm5_ret_t kadm5_init_with_password(char *client_name, char *pass,
907                                  char *service_name,
908                                  kadm5_config_params *realm_params,
909                                  unsigned long struct_version,
910                                  unsigned long api_version,
911                                  void **server_handle)
912
913 kadm5_ret_t kadm5_init_with_skey(char *client_name, char *keytab,
914                                  char *service_name,
915                                  kadm5_config_params *realm_params,
916                                  unsigned long struct_version,
917                                  unsigned long api_version,
918                                  void **server_handle)
919
920 kadm5_ret_t kadm5_init(char *client_name, char *pass,
921                                  char *service_name,
922                                  kadm5_config_params *realm_params,
923                                  unsigned long struct_version,
924                                  unsigned long api_version,
925                                  void **server_handle)
926
927 kadm5_ret_t kadm5_init_with_creds(char *client_name,
928                                   krb5_ccache ccache,
929                                   char *service_name,
930                                   kadm5_config_params *params,
931                                   krb5_ui_4 struct_version,
932                                   krb5_ui_4 api_version,
933                                   void **server_handle)
934 \end{verbatim}
935
936 AUTHORIZATION REQUIRED: none
937
938 NOTE: kadm5_init is an obsolete function provided for backwards
939 compatibility.  It is identical to kadm5_init_with_password.
940
941 These three functions open a connection to the kadm5 library and
942 initialize any neccessary state information.  They behave differently
943 when called from local and remote clients.  
944
945 In KADM5_API_VERSION_2, these functions take a kadm5_config_params
946 structure instead of a realm name as an argument.  The semantics are
947 similar: if a NULL pointer is passed for the realm_params argument,
948 the default realm and default parameters for that realm, as specified
949 in the krb5 configuration file (e.g. /etc/krb5.conf) are used.  If a
950 realm_params structure is provided, the fields that are set override
951 the default values.  If a parameter is specified to the local or
952 remote libraries that does not apply to that side, an error code
953 (KADM5_BAD_CLIENT_PARAMS or KADM5_BAD_SERVER_PARAMS) is returned.  See
954 section \ref{sec:configparams} for a discussion of configuration
955 parameters.
956
957 For remote clients, the semantics are:
958
959 \begin{enumerate}
960 \item Initializes all the com_err error tables used by the Admin
961 system.
962
963 \item Acquires configuration parameters.  In KADM5_API_VERSION_1, all
964 the defaults specified in the configuration file are used, according
965 to the realm.  In KADM5_API_VERSION_2, the values in params_in are
966 merged with the default values.  If an illegal mask value is
967 specified, KADM5_BAD_CLIENT_PARAMS is returned.
968
969 \item Acquires a Kerberos ticket for the specified service.
970
971 \begin{enumerate}
972 \item The ticket's client is client_name, which can be any valid
973 Kerberos principal.  If client_name does not include a realm, the
974 default realm of the local host is used
975 \item The ticket's service is service_name@realm.  service_name must
976 be one of the constants KADM5_ADMIN_SERVICE or
977 KADM5_CHANGEPW_SERVICE.
978 \item If realm is NULL, client_name's realm is used.
979
980 \item For init_with_password, an initial ticket is acquired and
981 decoded with the password pass, which must be client_name's password.
982 If pass is NULL or an empty string, the user is prompted (via the tty)
983 for a password.
984
985 \item For init_with_skey, an initial ticket is acquired and decoded
986 with client_name's key obtained from the specified keytab.  If keytab
987 is NULL or an empty string the default keytab is used.
988
989 \item For init_with_creds, ccache must be an open credential cache
990 that already has a ticket for the specified client and server.
991 Alternatively, if a site chooses to disable the DISALLOW_TGT_BASED
992 flag on the admin and changepw principals, the ccache can contain a
993 ticket-granting ticket for client_name.
994 \end{enumerate}
995
996 \item Creates a GSS-API authenticated connection to the Admin server,
997 using the just-acquired Kerberos ticket.
998
999 \item Verifies that the struct_version and api_version specified by
1000 the caller are valid and known to the library.
1001
1002 \item Sends the specified api_version to the server.
1003
1004 \item Upon successful completion, fills in server_handle with a handle
1005 for this connection, to be used in all subsequent API calls.
1006 \end{enumerate}
1007
1008 The caller should always specify KADM5_STRUCT_VERSION for the
1009 struct_version argument, a valid and supported API version constant
1010 for the api_version argument (currently, KADM5_API_VERSION_1 or
1011 KADM5_API_VERSION_2), and a valid pointer in which the server handle
1012 will be stored.
1013
1014 If any kadm5_init_* is invoked locally its semantics are:
1015
1016 \begin{enumerate}
1017 \item Initializes all the com_err error tables used by the Admin
1018 system.
1019
1020 \item Acquires configuration parameters.  In KADM5_API_VERSION_1, all
1021 the defaults specified in the configuration file are used, according
1022 to the realm.  In KADM5_API_VERSION_2, the values in params_in are
1023 merged with the default values.  If an illegal mask value is
1024 specified, KADM5_BAD_SERVER_PARAMS is returned.
1025
1026 \item Initializes direct access to the KDC database.  In
1027 KADM5_API_VERISON_1, if pass (or keytab) is NULL or an empty string,
1028 reads the master password from the stash file; otherwise, the non-NULL
1029 password is ignored and the user is prompted for it via the tty.  In
1030 KADM5_API_VERSION_2, if the MKEY_FROM_KEYBOARD parameter mask is set
1031 and the value is non-zero, reads the master password from the user via
1032 the tty; otherwise, the master key is read from the stash file.
1033 Calling init_with_skey or init_with_creds with the MKEY_FROM_KEYBOARD
1034 mask set with a non-zero field is illegal, and calling them without
1035 the mask set is exactly like calling init_with_password.
1036
1037 \item Initializes the dictionary (if present) for dictionary checks.
1038
1039 \item Parses client_name as a Kerberos principal.  client_name should
1040 usually be specified as the name of the program.
1041
1042 \item Verifies that the struct_version and api_version specified by
1043 the caller are valid.
1044
1045 \item Fills in server_handle with a handle containing all state
1046 information (version numbers and client name) for this ``connection.''
1047 \end{enumerate}
1048 The service_name argument is not used.
1049
1050 RETURN CODES: 
1051
1052 \begin{description}
1053 \item[KADM5_NO_SRV] No Admin server can be found for the
1054 specified realm.
1055
1056 \item[KADM5_RPC_ERROR] The RPC connection to the server cannot be
1057 initiated.
1058
1059 \item[KADM5_BAD_PASSWORD] Incorrect password.
1060
1061 \item[KADM5_SECURE_PRINC_MISSING] The principal
1062 KADM5_ADMIN_SERVICE or KADM5_CHANGEPW_SERVICE does not
1063 exist.  This is a special-case replacement return code for ``Server
1064 not found in database'' for these required principals.
1065
1066 \item[KADM5_BAD_CLIENT_PARAMS] A field in the parameters mask was
1067 specified to the remote client library that is not legal for remote
1068 clients.
1069
1070 \item[KADM5_BAD_SERVER_PARAMS] A field in the parameters mask was
1071 specified to the local client library that is not legal for local
1072 clients.
1073 \end{description}
1074
1075 \subsection{kadm5_flush}
1076
1077 \begin{verbatim}
1078 kadm5_ret_t kadm5_flush(void *server_handle)
1079 \end{verbatim}
1080
1081 AUTHORIZATION REQUIRED: none
1082
1083 Flush all changes to the Kerberos databases, leaving the connection to
1084 the Admin API open.  This function behaves differently when called by
1085 local and remote clients.
1086
1087 For local clients, the function closes and reopens the Kerberos
1088 database with krb5_db_fini() and krb5_db_init(), and closes and
1089 reopens the Admin policy database with adb_policy_close() and
1090 adb_policy_open().  Although it is unlikely, any other these functions
1091 could return errors; in that case, this function calls
1092 kadm5_destroy and returns the error code.  Therefore, if
1093 kadm5_flush does not return KADM5_OK, the connection to the
1094 Admin server has been terminated and, in principle, the databases
1095 might be corrupt.
1096
1097 For remote clients, the function is a no-op.
1098
1099 \subsection{kadm5_destroy}
1100
1101 \begin{verbatim}
1102 kadm5_ret_t kadm5_destroy(void *server_handle)
1103 \end{verbatim}
1104
1105 AUTHORIZATION REQUIRED: none
1106
1107 Close the connection to the Admin server and releases all related
1108 resources.  This function behaves differently when called by local and
1109 remote clients.
1110
1111 For remote clients, the semantics are:
1112
1113 \begin{enumerate}
1114 \item Destroy the temporary credential cache created by
1115 kadm5_init.
1116
1117 \item Tear down the GSS-API context negotiated with the server.
1118
1119 \item Close the RPC connection.
1120
1121 \item Free storage space associated with server_handle, after erasing
1122 its magic number so it won't be mistaken for a valid handle by the
1123 library later.
1124 \end{enumerate}
1125
1126 For local clients, this function just frees the storage space
1127 associated with server_handle after erasing its magic number.
1128
1129 RETURN CODES:
1130
1131 \subsection{kadm5_create_principal}
1132
1133 \begin{verbatim}
1134 kadm5_ret_t
1135 kadm5_create_principal(void *server_handle,
1136                             kadm5_principal_ent_t princ, u_int32 mask,
1137                             char *pw);
1138 \end{verbatim}
1139
1140 AUTHORIZATION REQUIRED: add
1141
1142 \begin{enumerate}
1143
1144 \item Return KADM5_BAD_MASK if the mask is invalid.
1145 \item If the named principal exists, return KADM5_DUP.
1146 \item If the POLICY bit is set and the named policy does not exist,
1147 return KADM5_UNK_POLICY.
1148 \item If KADM5_POLICY bit is set in aux_attributes check to see if
1149 the password does not meets quality standards, return the appropriate
1150 KADM5_PASS_Q_* error code if it fails.
1151 \item Store the principal, set the key; see section \ref{sec:keys}.
1152 \item If the POLICY bit is set, increment the named policy's reference
1153 count by one.
1154
1155 \item Set the pw_expiration field.
1156 \begin{enumerate}
1157 \item If the POLICY bit is not set, then
1158 \begin{enumerate}
1159 \item if the PW_EXPIRATION bit is set, set pw_expiration to the given
1160 value, else
1161 \item set pw_expiration to never.
1162 \end{enumerate}
1163 \item Otherwise, if the PW_EXPIRATION bit is set, set pw_expiration to
1164 the sooner of the given value and now + pw_max_life.
1165 \item Otherwise, set pw_expiration to now + pw_max_life.
1166 \end{enumerate}
1167
1168 \item Set mod_date to now and set mod_name to caller.
1169 \item Set last_pwd_change to now.
1170 \end{enumerate}
1171
1172 RETURN CODES:
1173
1174 \begin{description}
1175 \item[KADM5_BAD_MASK] The field mask is invalid for a create
1176 operation.
1177 \item[KADM5_DUP] Principal already exists.
1178 \item[KADM5_UNK_POLICY] Policy named in entry does not exist.
1179 \item[KADM5_PASS_Q_*] Specified password does not meet policy
1180 standards.
1181 \end{description}
1182
1183 \subsection{kadm5_delete_principal}
1184
1185 \begin{verbatim}
1186 kadm5_ret_t
1187 kadm5_delete_principal(void *server_handle, krb5_principal princ);
1188 \end{verbatim}
1189
1190 AUTHORIZATION REQUIRED: delete 
1191
1192 \begin{enumerate}
1193 \item Return KADM5_UNK_PRINC if the principal does not exist.
1194 \item If the POLICY bit is set in aux_attributes, decrement the named
1195 policy's reference count by one.
1196 \item Delete principal.
1197 \end{enumerate}
1198
1199 RETURN CODES: 
1200
1201 \begin{description}
1202 \item[KADM5_UNK_PRINC] Principal does not exist.
1203 \end{description}
1204
1205 \subsection{kadm5_modify_principal}
1206
1207 \begin{verbatim}
1208 kadm5_ret_t
1209 kadm5_modify_principal(void *server_handle,
1210                             kadm5_principal_ent_t princ, u_int32 mask);
1211 \end{verbatim}
1212
1213 Modify the attributes of the principal named in
1214 kadm5_principal_ent_t. This does not allow the principal to be
1215 renamed or for its password to be changed.
1216
1217 AUTHORIZATION REQUIRED: modify
1218
1219 Although a principal's pw_expiration is usually computed based on its
1220 policy and the time at which it changes its password, this function
1221 also allows it to be specified explicitly.  This allows an
1222 administrator, for example, to create a principal and assign it to a
1223 policy with a pw_max_life of one month, but to declare that the new
1224 principal must change its password away from its initial value
1225 sometime within the first week.
1226
1227 \begin{enumerate}
1228 \item Return KADM5_UNK_PRINC if the principal does not exist.
1229 \item Return KADM5_BAD_MASK if the mask is invalid.
1230 \item If POLICY bit is set but the new policy does not exist, return
1231 KADM5_UNK_POLICY.
1232 \item If either the POLICY or POLICY_CLR bits are set, update the
1233 corresponding bits in aux_attributes.
1234
1235 \item Update policy reference counts.
1236 \begin{enumerate}
1237 \item If the POLICY bit is set, then increment policy count on new
1238 policy.
1239 \item If the POLICY or POLICY_CLR bit is set, and the POLICY bit in
1240 aux_attributes is set, decrement policy count on old policy.
1241 \end{enumerate}
1242
1243 \item Set pw_expiration according to the new policy.
1244 \begin{enumerate}
1245 \item If the POLICY bit is not set in aux_attributes, then
1246 \begin{enumerate}
1247 \item if the PW_EXPIRATION bit is set, set pw_expiration to the given
1248 value, else
1249 \item set pw_expiration to never.
1250 \end{enumerate}
1251 \item Otherwise, if the PW_EXPIRATION bit is set, set pw_expiration to
1252 the sooner of the given value and last_pwd_change + pw_max_life.
1253 \item Otherwise, set pw_expiration to last_pwd_change + pw_max_life.
1254 \end{enumerate}
1255
1256 \item Update the fields specified in the mask.
1257 \item Update mod_name field to caller and mod_date to now.
1258 \end{enumerate}
1259
1260 RETURN CODES:
1261
1262 \begin{description}
1263 \item[KADM5_UNK_PRINC] Entry does not exist.
1264 \item[KADM5_BAD_MASK] The mask is not valid for a modify
1265 operation.
1266 \item[KADM5_UNK_POLICY] The POLICY bit is set but the new
1267 policy does not exist.
1268 \end{description}
1269
1270 \subsection{kadm5_rename_principal}
1271
1272 \begin{verbatim}
1273 kadm5_ret_t
1274 kadm5_rename_principal(void *server_handle, krb5_principal source,
1275                             krb5_principal target);
1276 \end{verbatim}
1277
1278 AUTHORIZATION REQUIRED: add and delete
1279
1280 \begin{enumerate}
1281 \item Check to see if source principal exists, if not return
1282 KADM5_UNK_PRINC error. 
1283 \item Check to see if target exists, if so return KADM5_DUP error.
1284 \item Create the new principal named target, then delete the old
1285 principal named source.  All of target's fields will be the same as
1286 source's fields, except that mod_name and mod_date will be updated to
1287 reflect the current caller and time.
1288 \end{enumerate}
1289
1290 Note that since the principal name may have been used as the salt for
1291 the principal's key, renaming the principal may render the principal's
1292 current password useless; with the new salt, the key generated by
1293 string-to-key on the password will suddenly be different.  Therefore,
1294 an application that renames a principal must also require the user to
1295 specify a new password for the principal (and administrators should
1296 notify the affected party).
1297
1298 Note also that, by the same argument, renaming a principal will
1299 invalidate that principal's password history information; since the
1300 salt will be different, a user will be able to select a previous
1301 password without error.
1302
1303 RETURN CODES: 
1304
1305 \begin{description}
1306 \item[KADM5_UNK_PRINC] Source principal does not exist.
1307 \item[KADM5_DUP] Target principal already exist.
1308 \end{description}
1309
1310 \subsection{kadm5_chpass_principal}
1311
1312 \begin{verbatim}
1313 kadm5_ret_t
1314 kadm5_chpass_principal(void *server_handle, krb5_principal princ,
1315                             char *pw);
1316 \end{verbatim}
1317
1318 AUTHORIZATION REQUIRED: changepw, or the calling principal being the
1319 same as the princ argument.  If the request is authenticated to the
1320 kadmin/changepw service, the changepw privilege is disregarded.
1321
1322 Change a principal's password.   See section \ref{sec:keys} for a
1323 description of how the keys are determined.
1324
1325 This function enforces password policy and dictionary checks.  If the new
1326 password specified is in the password dictionary, and the policy bit is set
1327 KADM5_PASS_DICT is returned.  If the principal's POLICY bit is set in
1328 aux_attributes, compliance with each of the named policy fields is verified
1329 and an appropriate error code is returned if verification fails.
1330
1331 Note that the policy checks are only be performed if the POLICY bit is
1332 set in the principal's aux_attributes field.
1333
1334 \begin{enumerate}
1335 \item Make sure principal exists, if not return KADM5_UNK_PRINC error.
1336 \item If caller does not have modify privilege, (now - last_pwd_change) $<$
1337 pw_min_life, and the KRB5_KDB_REQUIRES_PWCHANGE bit is not set in the
1338 principal's attributes, return KADM5_PASS_TOOSOON.
1339 \item If the principal your are trying to change is kadmin/history
1340 return KADM5_PROTECT_PRINCIPAL.
1341 \item If the password does not meet the quality
1342 standards, return the appropriate KADM5_PASS_Q_* error code.
1343 \item Convert password to key; see section \ref{sec:keys}.
1344 \item If the new key is in the principal's password history, return
1345 KADM5_PASS_REUSE.
1346 \item Store old key in history.
1347 \item Update principal to have new key.
1348 \item Increment principal's key version number by one.
1349 \item If the POLICY bit is set, set pw_expiration to now +
1350 max_pw_life.  If the POLICY bit is not set, set pw_expiration to
1351 never.
1352 \item If the KRB5_KDB_REQUIRES_PWCHANGE bit is set in the principal's
1353 attributes, clear it.
1354 \item Update last_pwd_change and mod_date to now, update mod_name to
1355 caller.
1356 \end{enumerate}
1357
1358 RETURN CODES:
1359
1360 \begin{description}
1361 \item[KADM5_UNK_PRINC] Principal does not exist.
1362 \item[KADM5_PASS_Q_*] Requested password does not meet quality
1363 standards. 
1364 \item[KADM5_PASS_REUSE] Requested password is in user's
1365 password history. 
1366 \item[KADM5_PASS_TOOSOON] Current password has not reached minimum life
1367 \item[KADM5_PROTECT_PRINCIPAL] Cannot change the password of a special principal
1368 \end{description}
1369
1370
1371 \subsection{kadm5_chpass_principal_util}
1372
1373 \begin{verbatim}
1374 kadm5_ret_t
1375 kadm5_chpass_principal_util(void *server_handle, krb5_principal princ,
1376                                  char *new_pw, char **pw_ret,
1377                                  char *msg_ret);
1378 \end{verbatim}
1379
1380 AUTHORIZATION REQUIRED: changepw, or the calling principal being the
1381 same as the princ argument.  If the request is authenticated to the
1382 kadmin/changepw service, the changepw privilege is disregarded.
1383
1384 This function is a wrapper around kadm5_chpass_principal. It can
1385 read a new password from a user, change a principal's password, and
1386 return detailed error messages.  msg_ret should point to a char buffer
1387 in the caller's space of sufficient length for the error messages
1388 described below. 1024 bytes is recommended.  It will also return the
1389 new password to the caller if pw_ret is non-NULL.
1390
1391 \begin{enumerate}
1392 \item If new_pw is NULL, this routine will prompt the user for the new
1393 password (using the strings specified by KADM5_PW_FIRST_PROMPT and
1394 KADM5_PW_SECOND_PROMPT) and read (without echoing) the password input.
1395 Since it is likely that this will simply call krb5_read_password only
1396 terminal-based applications will make use of the password reading
1397 functionality. If the passwords don't match the string ``New passwords do
1398 not match - password not changed.'' will be copied into msg_ret, and the
1399 error code KRB5_LIBOS_BADPWDMATCH will be returned.  For other errors that
1400 ocurr while reading the new password, copy the string ``<com_err message$>$
1401 occurred while trying to read new password.'' followed by a blank line and
1402 the string specified by CHPASS_UTIL_PASSWORD_NOT_CHANGED into msg_ret and
1403 return the error code returned by krb5_read_password.
1404
1405 \item If pw_ret is non-NULL, and the password was prompted, set *pw_ret to
1406 point to a static buffer containing the password.  If pw_ret is non-NULL
1407 and the password was supplied, set *pw_ret to the supplied password.
1408
1409 \item Call kadm5_chpass_principal with princ, and new_pw.
1410
1411 \item If successful copy the string specified by CHPASS_UTIL_PASSWORD_CHANGED
1412 into msg_ret and return zero.
1413
1414 \item For a policy related failure copy the appropriate message (from below) 
1415 followed by a newline and ``Password not changed.'' into msg_ret
1416 filling in the parameters from the principal's policy information. If
1417 the policy information cannot be obtained copy the generic message if
1418 one is specified below. Return the error code from
1419 kadm5_chpass_principal.
1420
1421 Detailed messages:
1422 \begin{description}
1423
1424 \item[PASS_Q_TOO_SHORT]
1425 New password is too short. Please choose a
1426 password which is more than $<$pw-min-len$>$ characters.
1427
1428 \item[PASS_Q_TOO_SHORT - generic]
1429 New password is too short. Please choose a longer password.
1430
1431 \item[PASS_REUSE]
1432 New password was used previously. Please choose a
1433 different password.
1434
1435 \item[PASS_Q_CLASS]
1436 New password does not have enough character classes. Classes include
1437 lower class letters, upper case letters, digits, punctuation and all
1438 other characters.  Please choose a password with at least
1439 $<$min-classes$>$ character classes.
1440
1441 \item[PASS_Q_CLASS - generic]
1442 New password does not have enough character classes. Classes include
1443 lower class letters, upper case letters, digits, punctuation and all
1444 other characters. 
1445
1446 \item[PASS_Q_DICT] 
1447 New password was found in a dictionary of possible passwords and
1448 therefore may be easily guessed.  Please choose another password. See
1449 the kpasswd man page for help in choosing a good password.
1450
1451 \item[PASS_TOOSOON]
1452 Password cannot be changed because it was changed too recently. Please
1453 wait until $<$last-pw-change+pw-min-life$>$ before you change it. If you
1454 need to change your password before then, contact your system
1455 security administrator.
1456
1457 \item[PASS_TOOSOON - generic]
1458 Password cannot be changed because it was changed too recently. If you
1459 need to change your now please contact your system security
1460 administrator.
1461 \end{description}
1462
1463 \item For other errors copy the string ``$<$com_err message$>$
1464 occurred while trying to change password.'' following by a blank line
1465 and ``Password not changed.'' into msg_ret. Return the error code
1466 returned by kadm5_chpass_principal.
1467 \end{enumerate}
1468
1469
1470 RETURN CODES:
1471
1472 \begin{description}
1473 \item[KRB5_LIBOS_BADPWDMATCH] Typed new passwords did not match.
1474 \item[KADM5_UNK_PRINC] Principal does not exist.
1475 \item[KADM5_PASS_Q_*] Requested password does not meet quality
1476 standards. 
1477 \item[KADM5_PASS_REUSE] Requested password is in user's
1478 password history. 
1479 \item[KADM5_PASS_TOOSOON] Current password has not reached minimum
1480 life. 
1481 \end{description}
1482
1483 \subsection{kadm5_randkey_principal}
1484
1485 In KADM5_API_VERSION_1:
1486
1487 \begin{verbatim}
1488 kadm5_ret_t
1489 kadm5_randkey_principal(void *server_handle, krb5_principal princ,
1490                              krb5_keyblock **new_key)
1491 \end{verbatim}
1492
1493 In KADM5_API_VERSION_2:
1494
1495 \begin{verbatim}
1496 kadm5_ret_t
1497 kadm5_randkey_principal(void *server_handle, krb5_principal princ,
1498                         krb5_keyblock **new_keys, int *n_keys)
1499 \end{verbatim}
1500
1501 AUTHORIZATION REQUIRED: changepw, or the calling principal being the
1502 same as the princ argument.  If the request is authenticated to the
1503 kadmin/changepw service, the changepw privilege is disregarded.
1504
1505 Generate and assign a new random key to the named principal, and
1506 return the generated key in allocated storage.  In
1507 KADM5_API_VERSION_2, multiple keys may be generated and returned as an
1508 array, and n_new_keys is filled in with the number of keys generated.
1509 See section \ref{sec:keys} for a description of how the keys are
1510 chosen.  In KADM5_API_VERSION_1, the caller must free the returned
1511 krb5_keyblock * with krb5_free_keyblock.  In KADM5_API_VERSION_2, the
1512 caller must free each returned keyblock with krb5_free_keyblock.
1513
1514 If the principal's POLICY bit is set in aux_attributes and the caller does
1515 not have modify privilege , compliance with the password minimum life
1516 specified by the policy is verified and an appropriate error code is returned
1517 if verification fails. 
1518
1519 \begin{enumerate}
1520 \item If the principal does not exist, return KADM5_UNK_PRINC.
1521 \item If caller does not have modify privilege, (now - last_pwd_change) $<$
1522 pw_min_life, and the KRB5_KDB_REQUIRES_PWCHANGE bit is not set in the
1523 principal's attributes, return KADM5_PASS_TOOSOON.
1524 \item If the principal you are trying to change is kadmin/history return
1525 KADM5_PROTECT_PRINCIPAL.
1526 \item Store old key in history.
1527 \item Update principal to have new key.
1528 \item Increment principal's key version number by one.
1529 \item If the POLICY bit in aux_attributes is set, set pw_expiration to
1530 now + max_pw_life.
1531 \item If the KRB5_KDC_REQUIRES_PWCHANGE bit is set in the principal's
1532 attributes, clear it.
1533 \item Update last_pwd_change and mod_date to now, update mod_name to
1534 caller.
1535 \end{enumerate}
1536
1537 RETURN CODES:
1538
1539 \begin{description}
1540 \item[KADM5_UNK_PRINC] Principal does not exist.
1541 \item[KADM5_PASS_TOOSOON] The minimum lifetime for the current
1542 key has not expired.
1543 \item[KADM5_PROTECT_PRINCIPAL] Cannot change the password of a special
1544 principal
1545 \end{description}
1546
1547 This function can also be used as part of a sequence to create a new
1548 principal with a random key.  The steps to perform the operation
1549 securely are
1550
1551 \begin{enumerate}
1552 \item Create the principal with kadm5_create_principal with a
1553 random password string and with the KRB5_KDB_DISALLOW_ALL_TIX bit set
1554 in the attributes field.
1555
1556 \item Randomize the principal's key with kadm5_randkey_principal.
1557
1558 \item Call kadm5_modify_principal to reset the
1559 KRB5_KDB_DISALLOW_ALL_TIX bit in the attributes field.
1560 \end{enumerate}
1561
1562 The three steps are necessary to ensure secure creation.  Since an
1563 attacker might be able to guess the initial password assigned by the
1564 client program, the principal must be disabled until the key can be
1565 truly randomized.
1566
1567 \subsection{kadm5_get_principal}
1568
1569 In KADM5_API_VERSION_1:
1570
1571 \begin{verbatim}
1572 kadm5_ret_t
1573 kadm5_get_principal(void *server_handle, krb5_principal princ, 
1574                          kadm5_principal_ent_t *ent);  
1575 \end{verbatim}
1576
1577 In KADM5_API_VERSION_2:
1578
1579 \begin{verbatim}
1580 kadm5_ret_t
1581 kadm5_get_principal(void *server_handle, krb5_principal princ, 
1582                          kadm5_principal_ent_t ent, u_int32 mask);  
1583 \end{verbatim}
1584
1585 AUTHORIZATION REQUIRED: get, or the calling principal being the same
1586 as the princ argument.  If the request is authenticated to the
1587 kadmin/changepw service, the get privilege is disregarded.
1588
1589 In KADM5_API_VERSION_1, return all of the principal's attributes in
1590 allocated memory; if an error is returned entry is set to NULL.  In
1591 KADM5_API_VERSION_2, fill in the fields of the principal structure
1592 specified in the mask; memory for the structure is not allocated.
1593 Typically, a caller will specify the mask KADM5_PRINCIPAL_NORMAL_MASK,
1594 which includes all the fields {\it except} key_data and tl_data to
1595 improve time and memory efficiency.  A caller that wants key_data and
1596 tl_data can bitwise-OR those masks onto NORMAL_MASK.
1597
1598 The caller must free the returned entry with kadm5_free_principal_ent.
1599
1600
1601 The function behaves differently for local and remote clients.  For
1602 remote clients, the KEY_DATA mask is illegal and results in a
1603 KADM5_BAD_MASK error.
1604
1605 RETURN CODES:
1606
1607 \begin{description}
1608 \item[KADM5_UNK_PRINC] Principal does not exist.
1609 \item[KADM5_BAD_MASK] The mask is not valid for a get operation.
1610
1611 \end{description}
1612
1613 \subsection{kadm5_decyrpt_key}
1614
1615 \begin{verbatim}
1616 kadm5_ret_t kadm5_decrypt_key(void *server_handle,
1617                               kadm5_principal_ent_t entry, krb5_int32
1618                               ktype, krb5_int32 stype, krb5_int32
1619                               kvno, krb5_keyblock *keyblock,
1620                               krb5_keysalt *keysalt, int *kvnop)
1621 \end{verbatim}
1622
1623 AUTHORIZATION REQUIRED: none, local function
1624
1625 Searches a principal's key_data array to find a key with the specified
1626 enctype, salt type, and kvno, and decrypts the key into keyblock and
1627 keysalt if found.  entry must have been returned by
1628 kadm5_get_principal with at least the KADM5_KEY_DATA mask set.
1629 Returns ENOENT if the key cannot be found, EINVAL if the key_data
1630 array is empty (as it always is in an RPC client).
1631
1632 If ktype or stype is -1, it is ignored for the search.  If kvno is -1,
1633 ktype and stype are ignored and the key with the max kvno is returned.
1634 If kvno is 0, only the key with the max kvno is returned and only if
1635 it matches the ktype and stype; otherwise, ENOENT is returned.
1636
1637 \subsection{kadm5_get_principals}
1638
1639 \begin{verbatim}
1640 kadm5_ret_t
1641 kadm5_get_principals(void *server_handle, char *exp,
1642                           char ***princs, int *count)
1643 \end{verbatim}
1644
1645 Retrieves the list of principal names.  
1646
1647 AUTHORIZATION REQUIRED: list
1648
1649 If \v{exp} is NULL, all principal names are retrieved; otherwise,
1650 principal names that match the expression exp are retrieved.
1651 \v{princs} is filled in with a pointer to a NULL-terminated array of
1652 strings, and \v{count} is filled in with the number of principal names
1653 in the array.  \v{princs} must be freed with a call to
1654 \v{kadm5_free_name_list}.
1655
1656 All characters in the expression match themselves except ``?'' which
1657 matches any single character, ``*'' which matches any number of
1658 consecutive characters, and ``[chars]'' which matches any single
1659 character of ``chars''. Any character which follows a ``$\backslash$''
1660 matches itself exactly, and a ``$\backslash$'' cannot be the last
1661 character in the string.
1662
1663 \subsection{kadm5_create_policy}
1664
1665 \begin{verbatim}
1666 kadm5_ret_t
1667 kadm5_create_policy(void *server_handle,
1668                          kadm5_policy_ent_t policy, u_int32 mask); 
1669 \end{verbatim}
1670
1671 Create a new policy.
1672
1673 AUTHORIZATION REQUIRED: add
1674
1675 \begin{enumerate}
1676 \item Check to see if mask is valid, if not return KADM5_BAD_MASK error.
1677 \item Return KADM5_BAD_POLICY if the policy name contains illegal
1678 characters.
1679
1680 \item Check to see if the policy already exists, if so return
1681 KADM5_DUP error. 
1682 \item If the PW_MIN_CLASSES bit is set and pw_min_classes is not 1, 2,
1683 3, 4, or 5, return KADM5_BAD_CLASS.
1684 \item Create a new policy setting the appropriate fields determined
1685 by the mask.
1686 \end{enumerate}
1687
1688 RETURN CODES:
1689
1690 \begin{description}
1691 \item[KADM5_DUP] Policy already exists
1692 \item[KADM5_BAD_MASK] The mask is not valid for a create
1693 operation.
1694 \item[KADM5_BAD_CLASS] The specified number of character classes
1695 is invalid.
1696 \item[KADM5_BAD_POLICY] The policy name contains illegal characters.
1697 \end{description}
1698
1699 \subsection{kadm5_delete_policy}
1700
1701 \begin{verbatim}
1702 kadm5_ret_t
1703 kadm5_delete_policy(void *server_handle, char *policy);
1704 \end{verbatim}
1705
1706 Deletes a policy.
1707
1708 AUTHORIZATION REQUIRED: delete
1709
1710 \begin{enumerate}
1711 \item Return KADM5_BAD_POLICY if the policy name contains illegal
1712 characters.
1713 \item Return KADM5_UNK_POLICY if the named policy does not exist.
1714 \item Return KADM5_POLICY_REF if the named policy's refcnt is not 0.
1715 \item Delete policy.
1716 \end{enumerate}
1717
1718 RETURN CODES:
1719
1720 \begin{description}
1721 \item[KADM5_BAD_POLICY] The policy name contains illegal characters.
1722 \item[KADM5_UNK_POLICY] Policy does not exist.
1723 \item[KADM5_POLICY_REF] Policy is being referenced. 
1724 \end{description}
1725
1726 \subsection{kadm5_modify_policy}
1727
1728 \begin{verbatim}
1729 kadm5_ret_t
1730 kadm5_modify_policy(void *server_handle,
1731                          kadm5_policy_ent_t policy, u_int32 mask);
1732 \end{verbatim}
1733
1734 Modify an existing policy.  Note that modifying a policy has no affect
1735 on a principal using the policy until the next time the principal's
1736 password is changed.
1737
1738 AUTHORIZATION REQUIRED: modify
1739
1740 \begin{enumerate}
1741 \item Return KADM5_BAD_POLICY if the policy name contains illegal
1742 characters.
1743 \item Check to see if mask is legal, if not return KADM5_BAD_MASK error.
1744 \item Check to see if policy exists, if not return
1745 KADM5_UNK_POLICY error.
1746 \item If the PW_MIN_CLASSES bit is set and pw_min_classes is not 1, 2,
1747 3, 4, or 5, return KADM5_BAD_CLASS.
1748 \item Update the fields specified in the mask.
1749 \end{enumerate}
1750
1751 RETURN CODES: 
1752
1753 \begin{description}
1754 \item[KADM5_BAD_POLICY] The policy name contains illegal characters.
1755 \item[KADM5_UNK_POLICY] Policy not found.
1756 \item[KADM5_BAD_MASK] The mask is not valid for a modify
1757 operation.
1758 \item[KADM5_BAD_CLASS] The specified number of character classes
1759 is invalid.
1760 \end{description}
1761
1762 \subsection{kadm5_get_policy}
1763
1764 In KADM5_API_VERSION_1:
1765
1766 \begin{verbatim}
1767 kadm5_ret_t
1768 kadm5_get_policy(void *server_handle, char *policy, kadm5_policy_ent_t *ent); 
1769 \end{verbatim}
1770
1771 In KADM5_API_VERSION_2:
1772
1773 \begin{verbatim}
1774 kadm5_ret_t
1775 kadm5_get_policy(void *server_handle, char *policy, kadm5_policy_ent_t ent); 
1776 \end{verbatim}
1777
1778 AUTHORIZATION REQUIRED: get, or the calling principal's policy being
1779 the same as the policy argument.  If the request is authenticated to
1780 the kadmin/changepw service, the get privilege is disregarded.
1781
1782 In KADM5_API_VERSION_1, return the policy's attributes in allocated
1783 memory; if an error is returned entry is set to NULL.  In
1784 KADM5_API_VERSION_2, fill in fields of the policy structure allocated
1785 by the caller.  The caller must free the returned entry with
1786 kadm5_free_policy_ent
1787
1788 RETURN CODES: 
1789
1790 \begin{description}
1791 \item[KADM5_BAD_POLICY] The policy name contains illegal characters.
1792 \item[KADM5_UNK_POLICY] Policy not found.
1793 \end{description}
1794
1795 \subsection{kadm5_get_policies}
1796
1797 \begin{verbatim}
1798 kadm5_ret_t
1799 kadm5_get_policies(void *server_handle, char *exp,
1800                           char ***pols, int *count)
1801 \end{verbatim}
1802
1803 Retrieves the list of principal names.  
1804
1805 AUTHORIZATION REQUIRED: list
1806
1807 If \v{exp} is NULL, all principal names are retrieved; otherwise,
1808 principal names that match the expression exp are retrieved.  \v{pols}
1809 is filled in with a pointer to a NULL-terminated array of strings, and
1810 \v{count} is filled in with the number of principal names in the
1811 array.  \v{pols} must be freed with a call to
1812 \v{kadm5_free_name_list}.
1813
1814 All characters in the expression match themselves except ``?'' which
1815 matches any single character, ``*'' which matches any number of
1816 consecutive characters, and ``[chars]'' which matches any single
1817 character of ``chars''. Any character which follows a ``$\backslash$''
1818 matches itself exactly, and a ``$\backslash$'' cannot be the last
1819 character in the string.
1820
1821 \subsection{kadm5_free_principal_ent, _policy_ent}
1822
1823 \begin{verbatim}
1824 void kadm5_free_principal_ent(void *server_handle,
1825                                    kadm5_principal_ent_t princ);
1826 \end{verbatim}
1827
1828 In KADM5_API_VERSION_1, free the structure and contents allocated by a
1829 call to kadm5_get_principal.  In KADM5_API_VERSION_2, free the
1830 contents allocated by a call to kadm5_get_principal.
1831
1832 AUTHORIZATION REQUIRED: none (local operation)
1833
1834 \begin{verbatim}
1835 void kadm5_free_policy_ent(kadm5_policy_ent_t policy);
1836 \end{verbatim}
1837
1838 Free memory that was allocated by a call to kadm5_get_policy.  If
1839 the argument is NULL, the function returns succesfully.
1840
1841 AUTHORIZATION REQUIRED: none (local operation)
1842
1843 \subsection{kadm5_free_name_list}
1844
1845 \begin{verbatim}
1846 void kadm5_free_name_list(void *server_handle,
1847                                char **names, int *count);
1848 \end{verbatim}
1849
1850 Free the memory that was allocated by kadm5_get_principals or
1851 kadm5_get_policies.  names and count must be a matched pair of
1852 values returned from one of those two functions.
1853
1854 \subsection{kadm5_free_key_data}
1855
1856 \begin{verbatim}
1857 void kadm5_free_key_data(void *server_handle,
1858                          krb5_int16 *n_key_data, krb5_key_data *key_data)
1859 \end{verbatim}
1860
1861 Free the memory that was allocated by kadm5_randkey_principal.
1862 n_key_data and key_data must be a matched pair of values returned from
1863 that function.
1864
1865 \subsection{kadm5_get_privs}
1866
1867 \begin{verbatim}
1868 kadm5_ret_t
1869 kadm5_get_privs(void *server_handle, u_int32 *privs);
1870 \end{verbatim}
1871
1872 Return the caller's admin server privileges in the integer pointed to
1873 by the argument.  The Admin API does not define any way for a
1874 principal's privileges to be set.  Note that this function will
1875 probably be removed or drastically changed in future versions of this
1876 system.
1877
1878 The returned value is a bitmask indicating the caller's privileges:
1879
1880 \begin{tabular}{llr}
1881 {\bf Privilege} & {\bf Symbol} & {\bf Value} \\
1882 Get & KADM5_PRIV_GET & 0x01 \\
1883 Add & KADM5_PRIV_ADD & 0x02 \\
1884 Modify & KADM5_PRIV_MODIFY & 0x04 \\
1885 Delete & KADM5_PRIV_DELETE & 0x08 \\
1886 List & KADM5_PRIV_LIST & 0x10 \\
1887 Changepw & KADM5_PRIV_CPW & 0x20
1888 \end{tabular}
1889
1890 There is no guarantee that a caller will have a privilege indicated by
1891 this function for any length of time or for any particular target;
1892 applications using this function must still be prepared to handle all
1893 possible KADM5_AUTH_* error codes.
1894
1895 In the initial MIT Kerberos version of the admin server, permissions
1896 depend both on the caller and the target; this function returns a
1897 bitmask representing all privileges the caller can possibly have for
1898 any possible target.
1899
1900 \end{document}