2 Copyright (C) 1989 by the Massachusetts Institute of Technology
4 Export of this software from the United States of America is assumed
5 to require a specific license from the United States Government.
6 It is the responsibility of any person or organization contemplating
7 export to obtain such a license before exporting.
9 WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
10 distribute this software and its documentation for any purpose and
11 without fee is hereby granted, provided that the above copyright
12 notice appear in all copies and that both that copyright notice and
13 this permission notice appear in supporting documentation, and that
14 the name of M.I.T. not be used in advertising or publicity pertaining
15 to distribution of the software without specific, written prior
16 permission. M.I.T. makes no representations about the suitability of
17 this software for any purpose. It is provided "as is" without express
23 * Support functions for Kerberos administration server & clients
28 this holds the support routines for the kerberos administration server
30 error: prints out a kadm error message, returns
31 fatal: prints out a kadm fatal error message, exits
32 prin_vals: prints out data associated with a Principal in the vals
36 #include "kadm_locl.h"
38 RCSID("$Id: kadm_supp.c,v 1.14 1999/09/16 20:41:46 assar Exp $");
41 time2str(char *buf, size_t len, time_t t)
43 strftime(buf, len, "%Y-%m-%d %H:%M:%S", localtime(&t));
48 recieves : a vals structure
51 prin_vals(Kadm_vals *vals)
54 if(IS_FIELD(KADM_NAME, vals->fields) && IS_FIELD(KADM_INST, vals->fields))
55 printf("%20s: %s\n", "Principal",
56 krb_unparse_name_long(vals->name, vals->instance, NULL));
58 printf("Dump of funny entry:\n");
59 if(IS_FIELD(KADM_NAME, vals->fields))
60 printf("%20s: %s\n", "Name", vals->name);
61 if(IS_FIELD(KADM_INST, vals->fields))
62 printf("%20s: %s\n", "Instance", vals->instance);
64 if(IS_FIELD(KADM_MAXLIFE, vals->fields))
65 printf("%20s: %d (%s)\n", "Max ticket life",
67 krb_life_to_atime(vals->max_life));
68 if(IS_FIELD(KADM_EXPDATE, vals->fields)) {
69 time2str(date, sizeof(date), vals->exp_date);
70 printf("%20s: %s\n", "Expiration date", date);
72 if(IS_FIELD(KADM_ATTR, vals->fields))
73 printf("%20s: %d\n", "Attributes",
75 if(IS_FIELD(KADM_DESKEY, vals->fields))
76 printf("%20s: %#lx %#lx\n", "Key",
77 (unsigned long)vals->key_low,
78 (unsigned long)vals->key_high);
81 if (IS_FIELD(KADM_MODDATE,vals->fields)) {
82 time2str(date, sizeof(date), vals->mod_date);
83 printf("%20s: %s\n", "Modification date", date);
85 if (IS_FIELD(KADM_MODNAME,vals->fields) &&
86 IS_FIELD(KADM_MODINST,vals->fields))
87 printf("%20s: %s\n", "Modifier",
88 krb_unparse_name_long(vals->mod_name, vals->mod_instance, NULL));
89 if (IS_FIELD(KADM_KVNO,vals->fields))
90 printf("%20s: %d\n", "Key version", vals->key_version);
94 printf("Info in Database for %s.%s:\n", vals->name, vals->instance);
95 printf(" Max Life: %d (%s) Exp Date: %s\n",
97 krb_life_to_atime(vals->max_life),
98 asctime(k_localtime(&vals->exp_date)));
99 printf(" Attribs: %.2x key: %#lx %#lx\n",
101 (unsigned long)vals->key_low,
102 (unsigned long)vals->key_high);
106 /* kadm_prin_to_vals takes a fields arguments, a Kadm_vals and a Principal,
107 it copies the fields in Principal specified by fields into Kadm_vals,
108 i.e from old to new */
111 kadm_prin_to_vals(u_char *fields, Kadm_vals *new, Principal *old)
113 memset(new, 0, sizeof(*new));
114 if (IS_FIELD(KADM_NAME,fields)) {
115 strlcpy(new->name, old->name, ANAME_SZ);
116 SET_FIELD(KADM_NAME, new->fields);
118 if (IS_FIELD(KADM_INST,fields)) {
119 strlcpy(new->instance, old->instance, INST_SZ);
120 SET_FIELD(KADM_INST, new->fields);
122 if (IS_FIELD(KADM_EXPDATE,fields)) {
123 new->exp_date = old->exp_date;
124 SET_FIELD(KADM_EXPDATE, new->fields);
126 if (IS_FIELD(KADM_ATTR,fields)) {
127 new->attributes = old->attributes;
128 SET_FIELD(KADM_ATTR, new->fields);
130 if (IS_FIELD(KADM_MAXLIFE,fields)) {
131 new->max_life = old->max_life;
132 SET_FIELD(KADM_MAXLIFE, new->fields);
134 if (IS_FIELD(KADM_DESKEY,fields)) {
135 new->key_low = old->key_low;
136 new->key_high = old->key_high;
137 SET_FIELD(KADM_DESKEY, new->fields);
140 if (IS_FIELD(KADM_MODDATE,fields)) {
141 new->mod_date = old->mod_date;
142 SET_FIELD(KADM_MODDATE, new->fields);
144 if (IS_FIELD(KADM_MODNAME,fields)) {
145 strlcpy(new->mod_name, old->mod_name, ANAME_SZ);
146 SET_FIELD(KADM_MODNAME, new->fields);
148 if (IS_FIELD(KADM_MODINST,fields)) {
149 strlcpy(new->mod_instance, old->mod_instance, ANAME_SZ);
150 SET_FIELD(KADM_MODINST, new->fields);
152 if (IS_FIELD(KADM_KVNO,fields)) {
153 new->key_version = old->key_version;
154 SET_FIELD(KADM_KVNO, new->fields);
160 kadm_vals_to_prin(u_char *fields, Principal *new, Kadm_vals *old)
163 memset(new, 0, sizeof(*new));
164 if (IS_FIELD(KADM_NAME,fields))
165 strlcpy(new->name, old->name, ANAME_SZ);
166 if (IS_FIELD(KADM_INST,fields))
167 strlcpy(new->instance, old->instance, INST_SZ);
168 if (IS_FIELD(KADM_EXPDATE,fields))
169 new->exp_date = old->exp_date;
170 if (IS_FIELD(KADM_ATTR,fields))
171 new->attributes = old->attributes;
172 if (IS_FIELD(KADM_MAXLIFE,fields))
173 new->max_life = old->max_life;
174 if (IS_FIELD(KADM_DESKEY,fields)) {
175 new->key_low = old->key_low;
176 new->key_high = old->key_high;
179 if (IS_FIELD(KADM_MODDATE,fields))
180 new->mod_date = old->mod_date;
181 if (IS_FIELD(KADM_MODNAME,fields))
182 strlcpy(new->mod_name, old->mod_name, ANAME_SZ);
183 if (IS_FIELD(KADM_MODINST,fields))
184 strlcpy(new->mod_instance, old->mod_instance, ANAME_SZ);
185 if (IS_FIELD(KADM_KVNO,fields))
186 new->key_version = old->key_version;