-Thu Mar 2 18:00:00 1995 Keith Vetter (keithv@fusion.com)
+Tue Mar 7 13:35:21 1995 Keith Vetter (keithv@fusion.com)
- * ustime.c: added another include for the pc for prototyping.
- * localaddr.c: used the NEED_SOCKETS mechanism for getting winsock.h.
+ * *.c: ported all the c files except an_to_ln, kuserok, and
+ sendto_kdc which have windows stubs.
+ * Makefile.in: reflects above changes.
Wed Mar 1 17:30:00 1995 Keith Vetter (keithv@fusion.com)
LDFLAGS = -g
##DOSBUILDTOP = ..\..\..
-##DOSLIBNAME=..\libkrb5.lib
+##DOSLIBNAME=..\krb5.lib
##DOS!include $(BUILDTOP)\config\windows.in
OBJS= \
$(srcdir)/write_msg.c
all:: $(OBJS)
+
*/
#include "k5-int.h"
-
+#ifndef _MSDOS /* Not yet for Windows */
#ifndef min
#define min(a,b) ((a) > (b) ? (b) : (a))
#endif /* min */
}
return retval;
}
+#endif
#include "k5-int.h"
#include <stdio.h>
-char *krb5_cc_default_name(context)
+char * INTERFACE
+krb5_cc_default_name(context)
krb5_context context;
{
char *name = getenv(KRB5_ENV_CCNAME);
if (name_buf == 0)
name_buf = malloc (35);
+#ifdef MSDOS_FILESYSTEM
+ strcpy (name_buf, "FILE:\\krb5cc");
+#else
sprintf(name_buf, "FILE:/tmp/krb5cc_%d", getuid());
+#endif
name = name_buf;
}
return name;
char *krb5_override_default_realm = 0;
-krb5_error_code
+krb5_error_code INTERFACE
krb5_get_default_realm(context, lrealm)
krb5_context context;
char **lrealm;
Frees the storage taken by a realm list returned by krb5_get_local_realm.
*/
-krb5_error_code
+krb5_error_code INTERFACE
krb5_free_host_realm(context, realmlist)
krb5_context context;
char * const *realmlist;
Frees the storage taken by a host list returned by krb5_get_krbhst.
*/
-krb5_error_code
+krb5_error_code INTERFACE
krb5_free_krbhst(context, hostlist)
krb5_context context;
char * const *hostlist;
* 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
+krb5_error_code INTERFACE
krb5_make_full_ipaddr(context, adr, port, outaddr)
krb5_context context;
krb5_int32 adr;
#include "k5-int.h"
#include "os-proto.h"
-krb5_error_code
+krb5_error_code INTERFACE
krb5_gen_portaddr(context, addr, ptr, outaddr)
krb5_context context;
const krb5_address *addr;
* a replay cache tag string.
*/
+#define NEED_SOCKETS
#include "k5-int.h"
#include "os-proto.h"
#ifdef KRB5_USE_INET
#include <sys/types.h>
+#ifndef _WINSOCKAPI_
#include <netinet/in.h>
#include <arpa/inet.h>
#endif
+#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_gen_replay_name(context, address, uniq, string)
krb5_context context;
const krb5_address *address;
extern char *krb5_config_file; /* extern so can be set at
load/runtime */
-krb5_error_code
+krb5_error_code INTERFACE
krb5_get_krbhst(context, realm, hostlist)
krb5_context context;
const krb5_data *realm;
continue; /* no match */
/* +1 to get beyond trailing space */
- if (strlen(filebuf) < realm->length + 1) {
+ if (strlen(filebuf) < (size_t) realm->length + 1) {
/* no hostname on config line */
retval = KRB5_CONFIG_BADFORMAT;
break;
{
time_t accum;
-#define assert_time(cnd) if(!(cnd)) return -1
+#define assert_time(cnd) if(!(cnd)) return (time_t) -1
assert_time(t->tm_year>=70);
assert_time(t->tm_year<=138);
* host names should be in the usual form (e.g. FOO.BAR.BAZ)
*/
+#define NEED_SOCKETS
#include "k5-int.h"
#include <ctype.h>
#include <stdio.h>
+#ifdef USE_STRING_H
+#include <string.h>
+#else
+#include <strings.h>
+#endif
/* for old Unixes and friends ... */
#ifndef MAXHOSTNAMELEN
extern char *krb5_trans_file;
-krb5_error_code
+krb5_error_code INTERFACE
krb5_get_host_realm(context, host, realmsp)
krb5_context context;
const char *host;
#include "k5-int.h"
-krb5_error_code
+krb5_error_code INTERFACE
krb5_os_init_context(ctx)
krb5_context ctx;
{
return 0;
}
-void
+void INTERFACE
krb5_os_free_context(ctx)
krb5_context ctx;
{
static char *VersionID = "@(#)krbfileio.c 2 - 08/22/91";
#endif
+#define NEED_LOWLEVEL_IO /* Need open(), etc. */
+
#include "k5-int.h"
+#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
+#endif
#include <sys/types.h>
#ifdef NEED_SYS_FCNTL_H
#include <sys/fcntl.h>
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#ifdef apollo
# define OPEN_MODE_NOT_TRUSTWORTHY
#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_create_secure_file(context, pathname)
krb5_context context;
const char * pathname;
/*
* Create the file with access restricted to the owner
*/
- fd = open(pathname, O_RDWR | O_CREAT | O_EXCL, 0600);
+ fd = open(pathname, O_RDWR | O_CREAT | O_EXCL | O_BINARY, 0600);
#ifdef OPEN_MODE_NOT_TRUSTWORTHY
/*
}
}
-krb5_error_code
+krb5_error_code INTERFACE
krb5_sync_disk_file(context, fp)
krb5_context context;
FILE *fp;
{
fflush(fp);
+#ifndef MSDOS_FILESYSTEM
if (fsync(fileno(fp))) {
return errno;
}
+#endif
return 0;
}
extern char *krb5_defkeyname;
-krb5_error_code
+krb5_error_code INTERFACE
krb5_kt_default_name(context, name, namesize)
krb5_context context;
char *name;
int namesize;
{
strncpy(name, krb5_defkeyname, namesize);
- if (namesize < strlen(krb5_defkeyname))
+ if ((size_t) namesize < strlen(krb5_defkeyname))
return KRB5_CONFIG_NOTENUFSPACE;
else
return 0;
*/
#include "k5-int.h"
+#ifndef _MSDOS /* Not yet for Windows */
#include <stdio.h>
#include <pwd.h>
fclose(fp);
return(isok);
}
+#endif
* get socket addresses for KDC.
*/
+#define NEED_SOCKETS
#include "k5-int.h"
#include <stdio.h>
#include <sys/types.h>
+#ifndef _WINSOCKAPI_
#include <sys/socket.h>
#ifdef KRB5_USE_INET
#include <netinet/in.h>
#endif
+#endif
+#ifndef _WINSOCKAPI_
#include <netdb.h>
+#endif
#include "os-proto.h"
#ifdef KRB5_USE_INET
* returns count of number of addresses found
*/
-krb5_error_code
+krb5_error_code INTERFACE
krb5_locate_kdc(context, realm, addr_pp, naddrs)
krb5_context context;
const krb5_data *realm;
int *naddrs;
{
char **hostlist;
- int code;
+ krb5_error_code code;
int i, j, out, count;
struct sockaddr *addr_p;
struct sockaddr_in *sin_p;
* libos: krb5_lock_file routine
*/
+#ifndef _MSDOS
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#endif
return 0;
}
+#else /* MSDOS */
+
+#include "k5-int.h"
+
+krb5_error_code INTERFACE
+krb5_lock_file(context, filep, pathname, mode)
+ krb5_context context;
+ FILE *filep;
+ char *pathname;
+ int mode;
+{
+ return 0;
+}
+#endif
*
*/
+#define NEED_LOWLEVEL_IO
#include "k5-int.h"
/*
* XXX must not use non-blocking I/O
*/
-int
+int INTERFACE
krb5_net_read(context, fd, buf, len)
krb5_context context;
int fd;
*
*/
+#define NEED_LOWLEVEL_IO
#include "k5-int.h"
/*
* XXX must not use non-blocking I/O
*/
-int
+int INTERFACE
krb5_net_write(context, fd, buf, len)
krb5_context context;
int fd;
#define KRB5_LIBOS_INT_PROTO__
#ifdef SOCK_DGRAM /* XXX hack... */
-krb5_error_code krb5_locate_kdc
+krb5_error_code INTERFACE krb5_locate_kdc
PROTOTYPE((krb5_context,
const krb5_data *,
struct sockaddr **,
#endif
#ifdef KRB5_USE_INET
-krb5_error_code krb5_unpack_full_ipaddr
+krb5_error_code INTERFACE krb5_unpack_full_ipaddr
PROTOTYPE((krb5_context,
const krb5_address *,
krb5_int32 *,
krb5_int16 *));
#ifdef NARROW_PROTOTYPES
-krb5_error_code krb5_make_full_ipaddr
+krb5_error_code INTERFACE krb5_make_full_ipaddr
PROTOTYPE((krb5_context,
krb5_int32,
krb5_int16,
krb5_address **));
#else
-krb5_error_code krb5_make_full_ipaddr
+krb5_error_code INTERFACE krb5_make_full_ipaddr
PROTOTYPE((krb5_context,
krb5_int32,
int, /* unsigned short promotes to signed
* Take an ADDRPORT address and split into IP addr & port.
*/
+#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
+krb5_error_code INTERFACE
krb5_unpack_full_ipaddr(context, inaddr, adr, port)
krb5_context context;
const krb5_address *inaddr;
unsigned short smushport;
register krb5_octet *marshal;
krb5_addrtype temptype;
- krb5_int32 templength;
+ krb5_ui_4 templength;
if (inaddr->addrtype != ADDRTYPE_ADDRPORT)
return KRB5_PROG_ATYPE_NOSUPP;
* Write a message to the network
*/
+#define NEED_SOCKETS
#include "k5-int.h"
#include <errno.h>
+#ifndef _WINSOCKAPI_
#include <netinet/in.h>
+#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_read_message(context, fdp, inbuf)
krb5_context context;
krb5_pointer fdp;
krb5_data *inbuf;
{
- krb5_int32 len, len2;
+ krb5_int32 len;
+ int len2, ilen;
char *buf = NULL;
int fd = *( (int *) fdp);
if ((len2 = krb5_net_read(context, fd, (char *)&len, 4)) != 4)
return((len2 < 0) ? errno : ECONNABORTED);
- inbuf->length = len = ntohl(len);
- if (len) {
+ len = ntohl(len);
+
+ if ((len & VALID_UINT_BITS) != len) /* Overflow size_t??? */
+ return ENOMEM;
+
+ inbuf->length = ilen = (int) len;
+ if (ilen) {
/*
* We may want to include a sanity check here someday....
*/
- if (!(buf = malloc(len))) {
+ if (!(buf = malloc(ilen))) {
return(ENOMEM);
}
- if ((len2 = krb5_net_read(context, fd, buf, len)) != len) {
+ if ((len2 = krb5_net_read(context, fd, buf, ilen)) != ilen) {
krb5_xfree(buf);
return((len2 < 0) ? errno : ECONNABORTED);
}
*/
#include "k5-int.h"
+#ifndef _MSDOS
#include <stdio.h>
#include <errno.h>
#include <signal.h>
return 0;
}
+#else /* MSDOS */
+/* Don't expect to be called, just define it for sanity and the linker.
+*/
+
+krb5_error_code INTERFACE
+krb5_read_password(context, prompt, prompt2, return_pwd, size_return)
+ krb5_context context;
+ char *prompt;
+ char *prompt2;
+ char *return_pwd;
+ int *size_return;
+{
+ *size_return = 0;
+ return 0;
+}
+#endif /* !MSDOS */
extern char *krb5_trans_file;
-krb5_error_code
+krb5_error_code INTERFACE
krb5_get_realm_domain(context, realm, domain)
krb5_context context;
const char *realm;
*/
#include "k5-int.h"
+#ifndef _MSDOS /* Not yet for Windows */
#include <sys/types.h>
#include <sys/socket.h>
}
return retval;
}
+#endif
* form.
*/
+#define NEED_SOCKETS
#include "k5-int.h"
+#ifndef _WINSOCKAPI_
#include <netdb.h>
+#endif
#include <ctype.h>
+#ifdef HAVE_SYS_PARAM_H
#include <sys/param.h>
+#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_sname_to_principal(context, hostname, sname, type, ret_princ)
krb5_context context;
const char * hostname;
#define timetype long
#endif
+#ifndef HAVE_ERRNO
extern int errno;
+#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_timeofday(context, timeret)
krb5_context context;
register krb5_int32 *timeret;
#include <stdio.h>
#include "k5-int.h"
-krb5_error_code
+krb5_error_code INTERFACE
krb5_unlock_file(context, filep, pathname)
krb5_context context;
FILE *filep;
* convenience sendauth/recvauth functions
*/
+#define NEED_SOCKETS
#include "k5-int.h"
#include <errno.h>
+#ifndef _WINSOCKAPI_
#include <netinet/in.h>
+#endif
-krb5_error_code
+krb5_error_code INTERFACE
krb5_write_message(context, fdp, outbuf)
krb5_context context;
krb5_pointer fdp;