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 * Kerberos administration server-side subroutines
26 #include "kadm_locl.h"
28 RCSID("$Id: kadm_server.c,v 1.9 1997/05/02 10:29:08 joda Exp $");
31 kadm_ser_cpw - the server side of the change_password routine
32 recieves : KTEXT, {key}
33 returns : CKSUM, RETCODE
34 acl : caller can change only own password
36 Replaces the password (i.e. des key) of the caller with that specified in key.
37 Returns no actual data from the master server, since this is called by a user
40 kadm_ser_cpw(u_char *dat, int len, AUTH_DAT *ad, u_char **datout, int *outlen)
42 u_int32_t keylow, keyhigh;
47 char pword[MAX_KPW_LEN];
50 /* take key off the stream, and change the database */
52 if ((status = stv_long(dat, &keyhigh, 0, len)) < 0)
53 return(KADM_LENGTH_ERROR);
55 if ((status = stv_long(dat, &keylow, stvlen, len)) < 0)
56 return(KADM_LENGTH_ERROR);
59 if((status = stv_string(dat, pword, stvlen, sizeof(pword), len))<0)
62 keylow = ntohl(keylow);
63 keyhigh = ntohl(keyhigh);
64 memcpy(((char *)newkey) + 4, &keyhigh, 4);
65 memcpy(newkey, &keylow, 4);
67 strings[0] = ad->pname;
68 strings[1] = ad->pinst;
69 strings[2] = ad->prealm;
71 status = kadm_pw_check(pword, &newkey, &pw_msg, strings);
73 memset(pword, 0, sizeof(pword));
76 if(status != KADM_SUCCESS){
78 *outlen=vts_string(pw_msg, datout, 0);
84 return(kadm_change(ad->pname, ad->pinst, ad->prealm, newkey));
89 kadm_ser_add - the server side of the add_entry routine
90 recieves : KTEXT, {values}
91 returns : CKSUM, RETCODE, {values}
92 acl : su, sms (as alloc)
94 Adds and entry containing values to the database
95 returns the values of the entry, so if you leave certain fields blank you will
96 be able to determine the default values they are set to
99 kadm_ser_add(u_char *dat, int len, AUTH_DAT *ad, u_char **datout, int *outlen)
101 Kadm_vals values, retvals;
104 if ((status = stream_to_vals(dat, &values, len)) < 0)
105 return(KADM_LENGTH_ERROR);
106 if ((status = kadm_add_entry(ad->pname, ad->pinst, ad->prealm,
107 &values, &retvals)) == KADM_DATA) {
108 *outlen = vals_to_stream(&retvals,datout);
117 kadm_ser_mod - the server side of the mod_entry routine
118 recieves : KTEXT, {values, values}
119 returns : CKSUM, RETCODE, {values}
120 acl : su, sms (as register or dealloc)
122 Modifies all entries corresponding to the first values so they match the
124 returns the values for the changed entries
127 kadm_ser_mod(u_char *dat, int len, AUTH_DAT *ad, u_char **datout, int *outlen)
129 Kadm_vals vals1, vals2, retvals;
133 if ((wh = stream_to_vals(dat, &vals1, len)) < 0)
134 return KADM_LENGTH_ERROR;
135 if ((status = stream_to_vals(dat+wh,&vals2, len-wh)) < 0)
136 return KADM_LENGTH_ERROR;
137 if ((status = kadm_mod_entry(ad->pname, ad->pinst, ad->prealm, &vals1,
138 &vals2, &retvals)) == KADM_DATA) {
139 *outlen = vals_to_stream(&retvals,datout);
148 kadm_ser_delete(u_char *dat, int len, AUTH_DAT *ad,
149 u_char **datout, int *outlen)
155 if((wh = stream_to_vals(dat, &values, len)) < 0)
156 return KADM_LENGTH_ERROR;
158 return KADM_LENGTH_ERROR;
159 status = kadm_delete_entry(ad->pname, ad->pinst, ad->prealm,
167 recieves : KTEXT, {values, flags}
168 returns : CKSUM, RETCODE, {count, values, values, values}
171 gets the fields requested by flags from all entries matching values
172 returns this data for each matching recipient, after a count of how many such
176 kadm_ser_get(u_char *dat, int len, AUTH_DAT *ad, u_char **datout, int *outlen)
178 Kadm_vals values, retvals;
183 if ((wh = stream_to_vals(dat, &values, len)) < 0)
184 return KADM_LENGTH_ERROR;
185 if (wh + FLDSZ > len)
186 return KADM_LENGTH_ERROR;
187 for (loop=FLDSZ-1; loop>=0; loop--)
188 fl[loop] = dat[wh++];
189 if ((status = kadm_get_entry(ad->pname, ad->pinst, ad->prealm,
190 &values, fl, &retvals)) == KADM_DATA) {
191 *outlen = vals_to_stream(&retvals,datout);