* $Source$
* $Author$
*
- * Copyright 1990 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
*
* For copying and distribution information, please see the file
* <krb5/copyright.h>.
"$Id$";
#endif /* !lint & !SABER */
-#include <krb5/copyright.h>
#include "krb425.h"
+#include <arpa/inet.h>
long
krb_rd_priv(in, in_length, sched, key, sender, receiver, msg)
krb5_data inbuf;
krb5_data out;
krb5_keyblock keyb;
- krb5_address saddr;
+ krb5_address saddr, *saddr2;
krb5_address raddr;
krb5_error_code r;
char sa[4], ra[4];
+ krb5_rcache rcache;
keyb.keytype = KEYTYPE_DES;
keyb.length = sizeof(des_cblock);
inbuf.data = (char *)in;
inbuf.length = in_length;
- if (r = krb5_rd_priv(&inbuf, &keyb, &saddr, &raddr, 0, 0, 0, &out)) {
+ if (r = krb5_gen_portaddr(&saddr, (krb5_pointer)&sender->sin_port,
+ &saddr2)) {
#ifdef EBUG
- ERROR(r)
+ ERROR(r);
+#endif
+ return(-1);
+ }
+ if (rcache = (krb5_rcache) malloc(sizeof(*rcache))) {
+ if (!(r = krb5_rc_resolve_type(&rcache, "dfl"))) {
+ char *cachename;
+ extern krb5_deltat krb5_clockskew;
+ char *insender = inet_ntoa(sender->sin_addr);
+
+ if (cachename = calloc(1, strlen(insender)+1+4+5)) {
+ /* 1 for NUL, 4 for rc_., 5 for digits of port
+ (unsigned 16bit, no greater than 65535) */
+ sprintf(cachename, "rc_%s.%u", insender,
+ ntohs(receiver->sin_port));
+
+ if (!(r = krb5_rc_resolve(rcache, cachename))) {
+ if (!((r = krb5_rc_recover(rcache)) &&
+ (r = krb5_rc_initialize(rcache,
+ krb5_clockskew)))) {
+ r = krb5_rd_priv(&inbuf, &keyb, saddr2, &raddr,
+ 0, 0, 0, rcache, &out);
+ krb5_rc_close(rcache);
+ }
+ }
+ free(cachename);
+ } else
+ r = ENOMEM;
+ }
+ xfree(rcache);
+ } else {
+ krb5_free_addr(saddr2);
+#ifdef EBUG
+ ERROR(ENOMEM);
+#endif
+ return(-1);
+ }
+ krb5_free_addr(saddr2);
+
+ if (r) {
+#ifdef EBUG
+ ERROR(r);
#endif
return(-1);
}
* $Source$
* $Author$
*
- * Copyright 1990 by the Massachusetts Institute of Technology.
+ * Copyright 1990,1991 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
*
* For copying and distribution information, please see the file
* <krb5/copyright.h>.
"$Id$";
#endif /* !lint & !SABER */
-#include <krb5/copyright.h>
#include "krb425.h"
+#include <arpa/inet.h>
long
krb_rd_safe(in, in_length, key, sender, receiver, msg)
krb5_data inbuf;
krb5_data out;
krb5_keyblock keyb;
- krb5_address saddr;
+ krb5_address saddr, *saddr2;
krb5_address raddr;
krb5_error_code r;
char sa[4], ra[4];
+ krb5_rcache rcache;
keyb.keytype = KEYTYPE_DES;
keyb.length = sizeof(des_cblock);
inbuf.data = (char *)in;
inbuf.length = in_length;
- if (r = krb5_rd_safe(&inbuf, &keyb, &saddr, &raddr, 0, 0, &out)) {
+ if (r = krb5_gen_portaddr(&saddr, (krb5_pointer)&sender->sin_port,
+ &saddr2)) {
#ifdef EBUG
- ERROR(r)
+ ERROR(r);
+#endif
+ return(-1);
+ }
+ if (rcache = (krb5_rcache) malloc(sizeof(*rcache))) {
+ if (!(r = krb5_rc_resolve_type(&rcache, "dfl"))) {
+ char *cachename;
+ extern krb5_deltat krb5_clockskew;
+ char *insender = inet_ntoa(sender->sin_addr);
+
+ if (cachename = calloc(1, strlen(insender)+1+4+5)) {
+ /* 1 for NUL, 4 for rc_., 5 for digits of port
+ (unsigned 16bit, no greater than 65535) */
+ sprintf(cachename, "rc_%s.%u", insender,
+ ntohs(receiver->sin_port));
+
+ if (!(r = krb5_rc_resolve(rcache, cachename))) {
+ if (!((r = krb5_rc_recover(rcache)) &&
+ (r = krb5_rc_initialize(rcache,
+ krb5_clockskew)))) {
+ r = krb5_rd_safe(&inbuf, &keyb, saddr2, &raddr,
+ 0, 0, rcache, &out);
+ krb5_rc_close(rcache);
+ }
+ }
+ free(cachename);
+ } else
+ r = ENOMEM;
+ }
+ xfree(rcache);
+ } else {
+ krb5_free_addr(saddr2);
+#ifdef EBUG
+ ERROR(ENOMEM);
+#endif
+ return(-1);
+ }
+ krb5_free_addr(saddr2);
+ if (r) {
+#ifdef EBUG
+ ERROR(r);
#endif
return(-1);
}