2 * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 #include "kadmin_locl.h"
36 RCSID("$Id: mod.c,v 1.11 2002/12/03 14:12:30 joda Exp $");
38 static int parse_args (krb5_context context
, kadm5_principal_ent_t ent
,
39 int argc
, char **argv
, int *optind
, char *name
,
43 parse_args(krb5_context context
, kadm5_principal_ent_t ent
,
44 int argc
, char **argv
, int *optind
, char *name
,
47 char *attr_str
= NULL
;
48 char *max_life_str
= NULL
;
49 char *max_rlife_str
= NULL
;
50 char *expiration_str
= NULL
;
51 char *pw_expiration_str
= NULL
;
55 struct getargs args
[] = {
56 {"attributes", 'a', arg_string
, NULL
, "Attributies",
58 {"max-ticket-life", 0, arg_string
, NULL
, "max ticket lifetime",
60 {"max-renewable-life", 0, arg_string
, NULL
,
61 "max renewable lifetime", "lifetime" },
62 {"expiration-time", 0, arg_string
,
63 NULL
, "Expiration time", "time"},
64 {"pw-expiration-time", 0, arg_string
,
65 NULL
, "Password expiration time", "time"},
66 {"kvno", 0, arg_integer
,
67 NULL
, "Key version number", "number"},
71 args
[i
++].value
= &attr_str
;
72 args
[i
++].value
= &max_life_str
;
73 args
[i
++].value
= &max_rlife_str
;
74 args
[i
++].value
= &expiration_str
;
75 args
[i
++].value
= &pw_expiration_str
;
76 args
[i
++].value
= &new_kvno
;
78 *optind
= 0; /* XXX */
80 if(getarg(args
, sizeof(args
) / sizeof(args
[0]),
83 sizeof(args
) / sizeof(args
[0]),
89 ret
= set_entry(context
, ent
, mask
, max_life_str
, max_rlife_str
,
90 expiration_str
, pw_expiration_str
, attr_str
);
102 mod_entry(int argc
, char **argv
)
104 kadm5_principal_ent_rec princ
;
107 krb5_principal princ_ent
= NULL
;
110 memset (&princ
, 0, sizeof(princ
));
112 ret
= parse_args (context
, &princ
, argc
, argv
,
113 &optind
, "mod", &mask
);
121 printf ("Usage: mod [options] principal\n");
125 krb5_parse_name(context
, argv
[0], &princ_ent
);
128 memset(&princ
, 0, sizeof(princ
));
129 ret
= kadm5_get_principal(kadm_handle
, princ_ent
, &princ
,
130 KADM5_PRINCIPAL
| KADM5_ATTRIBUTES
|
131 KADM5_MAX_LIFE
| KADM5_MAX_RLIFE
|
132 KADM5_PRINC_EXPIRE_TIME
|
133 KADM5_PW_EXPIRATION
);
134 krb5_free_principal (context
, princ_ent
);
136 printf ("no such principal: %s\n", argv
[0]);
139 if(edit_entry(&princ
, &mask
, NULL
, 0))
142 princ
.principal
= princ_ent
;
145 ret
= kadm5_modify_principal(kadm_handle
, &princ
, mask
);
147 krb5_warn(context
, ret
, "kadm5_modify_principal");
149 kadm5_free_principal_ent(kadm_handle
, &princ
);