5 * Copyright 1991 by the Massachusetts Institute of Technology.
8 * Export of this software from the United States of America may
9 * require a specific license from the United States Government.
10 * It is the responsibility of any person or organization contemplating
11 * export to obtain such a license before exporting.
13 * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
14 * distribute this software and its documentation for any purpose and
15 * without fee is hereby granted, provided that the above copyright
16 * notice appear in all copies and that both that copyright notice and
17 * this permission notice appear in supporting documentation, and that
18 * the name of M.I.T. not be used in advertising or publicity pertaining
19 * to distribution of the software without specific, written prior
20 * permission. M.I.T. makes no representations about the suitability of
21 * this software for any purpose. It is provided "as is" without express
22 * or implied warranty.
25 * Allocate & prepare a default replay cache for a server.
28 #if !defined(lint) && !defined(SABER)
29 static char rcsid_srv_rcache_c[] =
31 #endif /* !lint & !SABER */
33 #include <krb5/krb5.h>
34 #include <krb5/ext-proto.h>
37 krb5_get_server_rcache(piece, rcptr)
38 const krb5_data *piece;
41 krb5_rcache rcache = 0;
44 extern krb5_deltat krb5_clockskew;
45 krb5_error_code retval;
48 rcache = (krb5_rcache) malloc(sizeof(*rcache));
52 retval = krb5_rc_resolve_type(&rcache, "dfl");
53 if (retval) goto cleanup;
55 len = piece->length + 3 + 1;
56 for (i = 0; i <= piece->length; i++) {
57 if (piece->data[i] == '\\')
59 else if (!isgraph(piece->data[i]))
62 cachename = malloc(len);
67 strcpy(cachename, "rc_");
69 for (i = 0; i < piece->length; i++) {
70 if (piece->data[i] == '\\') {
71 cachename[p++] = '\\';
72 cachename[p++] = '\\';
75 if (!isgraph(piece->data[i])) {
76 sprintf(tmp, "%03o", piece->data[i]);
77 cachename[p++] = '\\';
78 cachename[p++] = tmp[0];
79 cachename[p++] = tmp[1];
80 cachename[p++] = tmp[2];
82 cachename[p++] = piece->data[i];
85 if (retval = krb5_rc_resolve(rcache, cachename))
89 * First try to recover the replay cache; if that doesn't work,
92 if (krb5_rc_recover(rcache)) {
93 if (retval = krb5_rc_initialize(rcache, krb5_clockskew)) {
94 krb5_rc_close(rcache);
107 krb5_xfree(cachename);