2 * Copyright (c) 1997, 1998, 1999 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.7 1999/12/02 17:04:58 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;
54 struct getargs args[] = {
55 {"attributes", 'a', arg_string, NULL, "Attributies",
57 {"max-ticket-life", 0, arg_string, NULL, "max ticket lifetime",
59 {"max-renewable-life", 0, arg_string, NULL,
60 "max renewable lifetime", "lifetime" },
61 {"expiration-time", 0, arg_string,
62 NULL, "Expiration time", "time"},
63 {"pw-expiration-time", 0, arg_string,
64 NULL, "Password expiration time", "time"},
68 args[i++].value = &attr_str;
69 args[i++].value = &max_life_str;
70 args[i++].value = &max_rlife_str;
71 args[i++].value = &expiration_str;
72 args[i++].value = &pw_expiration_str;
74 *optind = 0; /* XXX */
76 if(getarg(args, sizeof(args) / sizeof(args[0]),
79 sizeof(args) / sizeof(args[0]),
85 ret = set_entry(context, ent, mask, max_life_str, max_rlife_str,
86 expiration_str, pw_expiration_str, attr_str);
93 mod_entry(int argc, char **argv)
95 kadm5_principal_ent_rec princ;
98 krb5_principal princ_ent = NULL;
101 memset (&princ, 0, sizeof(princ));
103 ret = parse_args (context, &princ, argc, argv,
104 &optind, "mod", &mask);
112 printf ("Usage: mod [options] principal\n");
116 krb5_parse_name(context, argv[0], &princ_ent);
119 memset(&princ, 0, sizeof(princ));
120 ret = kadm5_get_principal(kadm_handle, princ_ent, &princ,
121 KADM5_PRINCIPAL | KADM5_ATTRIBUTES |
122 KADM5_MAX_LIFE | KADM5_MAX_RLIFE |
123 KADM5_PRINC_EXPIRE_TIME |
124 KADM5_PW_EXPIRATION);
126 printf ("no such principal: %s\n", argv[0]);
127 krb5_free_principal (context, princ_ent);
130 edit_entry(&princ, &mask, NULL, 0);
133 princ.principal = princ_ent;
136 ret = kadm5_modify_principal(kadm_handle, &princ, mask);
138 krb5_warn(context, ret, "kadm5_modify_principal");
140 krb5_free_principal(context, princ_ent);
141 kadm5_free_principal_ent(kadm_handle, &princ);