+
+Tue Apr 25 21:58:23 1995 Chris Procenzano (proven@mit.edu)
+
+ * Makefile.in : Added source files mk_faddr.c and genaddrs.c.
+ * mk_faddr.c (krb5_mk_fulladdr()): Makes a full address from
+ a struct sockaddr_in.
+ * genaddrs.c (krb5_auth_con_genaddrs()) : Generate a full address
+ from the active file descriptor and place it in the
+ auth_context for the calls mk_safe(), mk_priv(), mk_safe(),
+ rd_cred(), rd_priv(), and rd_safe().
+ * gen_rname.c (krb5_gen_replay_name()) : Fixed to take any type of
+ krb5_address and generate a rcache name.
+ * os-proto.h (krb5_make_full_ipaddr()) : Removed prototype.
+
Tue Apr 25 04:50:13 1995 Chris Procenzano (proven@mit.edu)
* locate_kdc.c (krb5_locate_kdc()): Pass a NUL terminated realm
full_ipadr.$(OBJEXT) \
get_krbhst.$(OBJEXT) \
gen_port.$(OBJEXT) \
+ genaddrs.$(OBJEXT) \
gen_rname.$(OBJEXT) \
gmt_mktime.$(OBJEXT) \
hst_realm.$(OBJEXT) \
krbfileio.$(OBJEXT) \
ktdefname.$(OBJEXT) \
kuserok.$(OBJEXT) \
+ mk_faddr.$(OBJEXT) \
localaddr.$(OBJEXT) \
locate_kdc.$(OBJEXT) \
lock_file.$(OBJEXT) \
$(srcdir)/full_ipadr.c \
$(srcdir)/get_krbhst.c \
$(srcdir)/gen_port.c \
+ $(srcdir)/genaddrs.c \
$(srcdir)/gen_rname.c \
$(srcdir)/gmt_mktime.c \
$(srcdir)/hst_realm.c \
$(srcdir)/krbfileio.c \
$(srcdir)/ktdefname.c \
$(srcdir)/kuserok.c \
+ $(srcdir)/mk_faddr.c \
$(srcdir)/localaddr.c \
$(srcdir)/locate_kdc.c \
$(srcdir)/lock_file.c \
krb5_error_code
krb5_gen_replay_name(context, address, uniq, string)
- krb5_context context;
- const krb5_address *address;
- const char *uniq;
- char **string;
+ krb5_context context;
+ const krb5_address * address;
+ const char * uniq;
+ char ** string;
{
-#ifdef KRB5_USE_INET
- krb5_int16 port;
- krb5_int32 addr;
- register krb5_error_code retval;
- register char *tmp, *tmp2;
- struct in_addr inaddr;
+ char * tmp;
+ int i;
- if (retval = krb5_unpack_full_ipaddr(context, address, &addr, &port))
- return retval;
- inaddr.s_addr = addr;
-
- tmp = inet_ntoa(inaddr);
- tmp2 = malloc(strlen(uniq)+strlen(tmp)+1+1+5); /* 1 for NUL,
- 1 for ,,
- 5 for digits (65535 is max) */
- if (!tmp2)
+ if ((*string = malloc(strlen(uniq) + (address->length * 2) + 1)) == NULL)
return ENOMEM;
- (void) sprintf(tmp2, "%s%s,%u",uniq,tmp,ntohs(port));
- *string = tmp2;
+
+ sprintf(*string, "%s", uniq);
+ tmp = (*string) + strlen(uniq);
+ for (i = 0; i < address->length; i++) {
+ sprintf(tmp, "%.2x", address->contents[i] & 0xff);
+ tmp += 2;
+ }
return 0;
-#else
- return KRB5_PROG_ATYPE_NOSUPP;
-#endif
}
--- /dev/null
+/*
+ * lib/krb5/os/genaddrs.c
+ *
+ * Copyright 1995 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ *
+ * Take an IP addr & port and generate a full IP address.
+ */
+
+#define NEED_SOCKETS
+#include "k5-int.h"
+#include "os-proto.h"
+
+#ifndef _WINSOCKAPI_
+#include <netinet/in.h>
+#endif
+
+krb5_error_code INTERFACE
+krb5_auth_con_genaddrs(context, auth_context, fd, flags)
+ krb5_context context;
+ krb5_auth_context * auth_context;
+ int fd, flags;
+{
+ krb5_error_code retval;
+ krb5_address * laddr;
+ krb5_address * raddr;
+
+#ifdef KRB5_USE_INET
+ struct sockaddr_in saddr;
+ krb5_address lcaddr;
+ krb5_address rcaddr;
+ int ssize;
+
+ ssize = sizeof(struct sockaddr);
+ if ((flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) ||
+ (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_ADDR)) {
+ if (retval = getsockname(fd, &saddr, &ssize))
+ return retval;
+
+ if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR) {
+ if (retval = krb5_make_fulladdr(context, &saddr, &lcaddr))
+ return retval;
+ } else {
+ lcaddr.contents = (krb5_octet *)&saddr.sin_addr;
+ lcaddr.length = sizeof(saddr.sin_addr);
+ lcaddr.addrtype = ADDRTYPE_INET;
+ }
+ laddr = &lcaddr;
+ } else {
+ laddr = NULL;
+ }
+
+ if ((flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) ||
+ (flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_ADDR)) {
+ if (retval = getpeername(fd, &saddr, &ssize))
+ return retval;
+
+ if (flags & KRB5_AUTH_CONTEXT_GENERATE_REMOTE_FULL_ADDR) {
+ if (retval = krb5_make_fulladdr(context, &saddr, &rcaddr)) {
+ if (flags & KRB5_AUTH_CONTEXT_GENERATE_LOCAL_FULL_ADDR)
+ krb5_xfree(laddr->contents);
+ return retval;
+ }
+ } else {
+ rcaddr.contents = (krb5_octet *)&saddr.sin_addr;
+ rcaddr.length = sizeof(saddr.sin_addr);
+ rcaddr.addrtype = ADDRTYPE_INET;
+ }
+ raddr = &rcaddr;
+ } else {
+ raddr = NULL;
+ }
+
+ return (krb5_auth_con_setaddrs(context, auth_context, laddr, raddr));
+#else
+ return KRB5_PROG_ATYPE_NOSUPP;
+#endif
+}
--- /dev/null
+/*
+ * lib/krb5/os/full_ipadr.c
+ *
+ * Copyright 1995 by the Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ *
+ * Take an IP addr & port and generate a full IP address.
+ */
+
+#define NEED_SOCKETS
+#include "k5-int.h"
+
+#ifdef KRB5_USE_INET
+
+#include "os-proto.h"
+#ifndef _WINSOCKAPI_
+#include <netinet/in.h>
+#endif
+
+krb5_error_code INTERFACE
+krb5_make_fulladdr(context, saddr, kaddr)
+ krb5_context context;
+ struct sockaddr_in * saddr;
+ krb5_address * kaddr;
+{
+ krb5_int32 smushaddr = (krb5_int32)saddr->sin_addr.s_addr; /* net order */
+ krb5_int16 smushport = (krb5_int16)saddr->sin_port; /* ditto */
+ register krb5_octet * marshal;
+ krb5_int32 tmp32;
+ krb5_int16 tmp16;
+
+ kaddr->addrtype = ADDRTYPE_ADDRPORT;
+ kaddr->length = sizeof(saddr->sin_addr) + sizeof(saddr->sin_port) +
+ (4 * sizeof(krb5_int32));
+
+ if (!(kaddr->contents = (krb5_octet *)malloc(kaddr->length)))
+ return ENOMEM;
+
+ marshal = kaddr->contents;
+
+ tmp16 = ADDRTYPE_INET;
+ *marshal++ = 0x00;
+ *marshal++ = 0x00;
+ *marshal++ = tmp16 & 0xff;
+ *marshal++ = (tmp16 >> 8) & 0xff;
+
+ tmp32 = sizeof(smushaddr);
+ *marshal++ = tmp32 & 0xff;
+ *marshal++ = (tmp32 >> 8) & 0xff;
+ *marshal++ = (tmp32 >> 16) & 0xff;
+ *marshal++ = (tmp32 >> 24) & 0xff;
+
+ (void) memcpy((char *)marshal, (char *)&smushaddr, sizeof(smushaddr));
+ marshal += sizeof(smushaddr);
+
+ tmp16 = ADDRTYPE_IPPORT;
+ *marshal++ = 0x00;
+ *marshal++ = 0x00;
+ *marshal++ = tmp16 & 0xff;
+ *marshal++ = (tmp16 >> 8) & 0xff;
+
+ tmp32 = sizeof(smushport);
+ *marshal++ = tmp32 & 0xff;
+ *marshal++ = (tmp32 >> 8) & 0xff;
+ *marshal++ = (tmp32 >> 16) & 0xff;
+ *marshal++ = (tmp32 >> 24) & 0xff;
+
+ (void) memcpy((char *)marshal, (char *)&smushport, sizeof(smushport));
+ marshal += sizeof(smushport);
+
+ return 0;
+}
+#endif
krb5_int32 *,
krb5_int16 *));
-#ifdef NARROW_PROTOTYPES
-krb5_error_code krb5_make_full_ipaddr
- PROTOTYPE((krb5_context,
- krb5_int32,
- krb5_int16,
- krb5_address **));
-#else
krb5_error_code krb5_make_full_ipaddr
PROTOTYPE((krb5_context,
krb5_int32,
int, /* unsigned short promotes to signed
int */
krb5_address **));
-#endif /* NARROW_PROTOTYPES */
#endif /* KRB5_USE_INET */
#endif /* KRB5_LIBOS_INT_PROTO__ */