From: Keith Vetter Date: Tue, 7 Mar 1995 23:13:03 +0000 (+0000) Subject: Port of most of the OS directory to the PC X-Git-Tag: krb5-1.0-beta5~591 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7bfcaba07af807d42dbd9322a0f76f2c47f8209e;p=krb5.git Port of most of the OS directory to the PC git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@5079 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index c829a5534..69673dcfb 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,7 +1,8 @@ -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) diff --git a/src/lib/krb5/os/Makefile.in b/src/lib/krb5/os/Makefile.in index aefffdd3d..1b47e350b 100644 --- a/src/lib/krb5/os/Makefile.in +++ b/src/lib/krb5/os/Makefile.in @@ -2,7 +2,7 @@ CFLAGS = $(CCOPTS) $(DEFS) LDFLAGS = -g ##DOSBUILDTOP = ..\..\.. -##DOSLIBNAME=..\libkrb5.lib +##DOSLIBNAME=..\krb5.lib ##DOS!include $(BUILDTOP)\config\windows.in OBJS= \ @@ -72,3 +72,4 @@ SRCS= \ $(srcdir)/write_msg.c all:: $(OBJS) + diff --git a/src/lib/krb5/os/an_to_ln.c b/src/lib/krb5/os/an_to_ln.c index a96fb4c18..da065b9dd 100644 --- a/src/lib/krb5/os/an_to_ln.c +++ b/src/lib/krb5/os/an_to_ln.c @@ -25,7 +25,7 @@ */ #include "k5-int.h" - +#ifndef _MSDOS /* Not yet for Windows */ #ifndef min #define min(a,b) ((a) > (b) ? (b) : (a)) #endif /* min */ @@ -168,3 +168,4 @@ username_an_to_ln(context, aname, lnsize, lname) } return retval; } +#endif diff --git a/src/lib/krb5/os/ccdefname.c b/src/lib/krb5/os/ccdefname.c index 3b00b6df5..79314a6b7 100644 --- a/src/lib/krb5/os/ccdefname.c +++ b/src/lib/krb5/os/ccdefname.c @@ -27,7 +27,8 @@ #include "k5-int.h" #include -char *krb5_cc_default_name(context) +char * INTERFACE +krb5_cc_default_name(context) krb5_context context; { char *name = getenv(KRB5_ENV_CCNAME); @@ -37,7 +38,11 @@ char *krb5_cc_default_name(context) 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; diff --git a/src/lib/krb5/os/def_realm.c b/src/lib/krb5/os/def_realm.c index f32061ec3..a6f4f993b 100644 --- a/src/lib/krb5/os/def_realm.c +++ b/src/lib/krb5/os/def_realm.c @@ -51,7 +51,7 @@ extern char *krb5_override_default_realm; char *krb5_override_default_realm = 0; -krb5_error_code +krb5_error_code INTERFACE krb5_get_default_realm(context, lrealm) krb5_context context; char **lrealm; diff --git a/src/lib/krb5/os/free_hstrl.c b/src/lib/krb5/os/free_hstrl.c index f112041e4..8314d44f6 100644 --- a/src/lib/krb5/os/free_hstrl.c +++ b/src/lib/krb5/os/free_hstrl.c @@ -31,7 +31,7 @@ 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; diff --git a/src/lib/krb5/os/free_krbhs.c b/src/lib/krb5/os/free_krbhs.c index 066acfcbf..8b50a74c7 100644 --- a/src/lib/krb5/os/free_krbhs.c +++ b/src/lib/krb5/os/free_krbhs.c @@ -30,7 +30,7 @@ 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; diff --git a/src/lib/krb5/os/full_ipadr.c b/src/lib/krb5/os/full_ipadr.c index d5539e454..94d99f276 100644 --- a/src/lib/krb5/os/full_ipadr.c +++ b/src/lib/krb5/os/full_ipadr.c @@ -24,14 +24,17 @@ * 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 +#endif -krb5_error_code +krb5_error_code INTERFACE krb5_make_full_ipaddr(context, adr, port, outaddr) krb5_context context; krb5_int32 adr; diff --git a/src/lib/krb5/os/gen_port.c b/src/lib/krb5/os/gen_port.c index a5eb91bca..3789759aa 100644 --- a/src/lib/krb5/os/gen_port.c +++ b/src/lib/krb5/os/gen_port.c @@ -27,7 +27,7 @@ #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; diff --git a/src/lib/krb5/os/gen_rname.c b/src/lib/krb5/os/gen_rname.c index 59bd7daca..d56bb9160 100644 --- a/src/lib/krb5/os/gen_rname.c +++ b/src/lib/krb5/os/gen_rname.c @@ -25,15 +25,18 @@ * a replay cache tag string. */ +#define NEED_SOCKETS #include "k5-int.h" #include "os-proto.h" #ifdef KRB5_USE_INET #include +#ifndef _WINSOCKAPI_ #include #include #endif +#endif -krb5_error_code +krb5_error_code INTERFACE krb5_gen_replay_name(context, address, uniq, string) krb5_context context; const krb5_address *address; diff --git a/src/lib/krb5/os/get_krbhst.c b/src/lib/krb5/os/get_krbhst.c index 2445c1bde..eeb785c0a 100644 --- a/src/lib/krb5/os/get_krbhst.c +++ b/src/lib/krb5/os/get_krbhst.c @@ -57,7 +57,7 @@ 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; @@ -91,7 +91,7 @@ krb5_get_krbhst(context, realm, hostlist) 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; diff --git a/src/lib/krb5/os/gmt_mktime.c b/src/lib/krb5/os/gmt_mktime.c index 18973e138..fac8e65f3 100644 --- a/src/lib/krb5/os/gmt_mktime.c +++ b/src/lib/krb5/os/gmt_mktime.c @@ -38,7 +38,7 @@ time_t gmt_mktime(t) { 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); diff --git a/src/lib/krb5/os/hst_realm.c b/src/lib/krb5/os/hst_realm.c index 1cbe9aead..00c46ca93 100644 --- a/src/lib/krb5/os/hst_realm.c +++ b/src/lib/krb5/os/hst_realm.c @@ -62,9 +62,15 @@ * host names should be in the usual form (e.g. FOO.BAR.BAZ) */ +#define NEED_SOCKETS #include "k5-int.h" #include #include +#ifdef USE_STRING_H +#include +#else +#include +#endif /* for old Unixes and friends ... */ #ifndef MAXHOSTNAMELEN @@ -75,7 +81,7 @@ 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; diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c index 4c92c6775..3f9599aad 100644 --- a/src/lib/krb5/os/init_os_ctx.c +++ b/src/lib/krb5/os/init_os_ctx.c @@ -25,7 +25,7 @@ #include "k5-int.h" -krb5_error_code +krb5_error_code INTERFACE krb5_os_init_context(ctx) krb5_context ctx; { @@ -45,7 +45,7 @@ krb5_os_init_context(ctx) return 0; } -void +void INTERFACE krb5_os_free_context(ctx) krb5_context ctx; { diff --git a/src/lib/krb5/os/krbfileio.c b/src/lib/krb5/os/krbfileio.c index 44521dd9b..1a54ddd7f 100644 --- a/src/lib/krb5/os/krbfileio.c +++ b/src/lib/krb5/os/krbfileio.c @@ -33,18 +33,26 @@ 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 +#endif #include #ifdef NEED_SYS_FCNTL_H #include #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; @@ -54,7 +62,7 @@ krb5_create_secure_file(context, 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 /* @@ -83,15 +91,17 @@ krb5_create_secure_file(context, pathname) } } -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; } diff --git a/src/lib/krb5/os/ktdefname.c b/src/lib/krb5/os/ktdefname.c index 2e944d0e2..3e9e13d5f 100644 --- a/src/lib/krb5/os/ktdefname.c +++ b/src/lib/krb5/os/ktdefname.c @@ -28,14 +28,14 @@ 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; diff --git a/src/lib/krb5/os/kuserok.c b/src/lib/krb5/os/kuserok.c index 900f8c0be..cefb3ce9a 100644 --- a/src/lib/krb5/os/kuserok.c +++ b/src/lib/krb5/os/kuserok.c @@ -25,6 +25,7 @@ */ #include "k5-int.h" +#ifndef _MSDOS /* Not yet for Windows */ #include #include @@ -135,3 +136,4 @@ krb5_kuserok(context, principal, luser) fclose(fp); return(isok); } +#endif diff --git a/src/lib/krb5/os/locate_kdc.c b/src/lib/krb5/os/locate_kdc.c index 99e6fdcfe..4c2d2e94a 100644 --- a/src/lib/krb5/os/locate_kdc.c +++ b/src/lib/krb5/os/locate_kdc.c @@ -24,14 +24,19 @@ * get socket addresses for KDC. */ +#define NEED_SOCKETS #include "k5-int.h" #include #include +#ifndef _WINSOCKAPI_ #include #ifdef KRB5_USE_INET #include #endif +#endif +#ifndef _WINSOCKAPI_ #include +#endif #include "os-proto.h" #ifdef KRB5_USE_INET @@ -43,7 +48,7 @@ extern char *krb5_kdc_sec_udp_portname; * 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; @@ -51,7 +56,7 @@ krb5_locate_kdc(context, realm, addr_pp, naddrs) int *naddrs; { char **hostlist; - int code; + krb5_error_code code; int i, j, out, count; struct sockaddr *addr_p; struct sockaddr_in *sin_p; diff --git a/src/lib/krb5/os/lock_file.c b/src/lib/krb5/os/lock_file.c index 86368d80e..95b086ce6 100644 --- a/src/lib/krb5/os/lock_file.c +++ b/src/lib/krb5/os/lock_file.c @@ -24,6 +24,7 @@ * libos: krb5_lock_file routine */ +#ifndef _MSDOS #if HAVE_UNISTD_H #include #endif @@ -103,3 +104,17 @@ krb5_lock_file(context, filep, pathname, mode) #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 diff --git a/src/lib/krb5/os/net_read.c b/src/lib/krb5/os/net_read.c index caa85ff78..9b28896d9 100644 --- a/src/lib/krb5/os/net_read.c +++ b/src/lib/krb5/os/net_read.c @@ -22,6 +22,7 @@ * */ +#define NEED_LOWLEVEL_IO #include "k5-int.h" /* @@ -34,7 +35,7 @@ * XXX must not use non-blocking I/O */ -int +int INTERFACE krb5_net_read(context, fd, buf, len) krb5_context context; int fd; diff --git a/src/lib/krb5/os/net_write.c b/src/lib/krb5/os/net_write.c index 9cf3bb5e7..4885a8172 100644 --- a/src/lib/krb5/os/net_write.c +++ b/src/lib/krb5/os/net_write.c @@ -22,6 +22,7 @@ * */ +#define NEED_LOWLEVEL_IO #include "k5-int.h" /* @@ -33,7 +34,7 @@ * XXX must not use non-blocking I/O */ -int +int INTERFACE krb5_net_write(context, fd, buf, len) krb5_context context; int fd; diff --git a/src/lib/krb5/os/os-proto.h b/src/lib/krb5/os/os-proto.h index f23bb6646..e5f982673 100644 --- a/src/lib/krb5/os/os-proto.h +++ b/src/lib/krb5/os/os-proto.h @@ -28,7 +28,7 @@ #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 **, @@ -36,20 +36,20 @@ krb5_error_code krb5_locate_kdc #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 diff --git a/src/lib/krb5/os/port2ip.c b/src/lib/krb5/os/port2ip.c index b6883d782..d8c5b23c1 100644 --- a/src/lib/krb5/os/port2ip.c +++ b/src/lib/krb5/os/port2ip.c @@ -24,13 +24,16 @@ * 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 +#endif -krb5_error_code +krb5_error_code INTERFACE krb5_unpack_full_ipaddr(context, inaddr, adr, port) krb5_context context; const krb5_address *inaddr; @@ -41,7 +44,7 @@ krb5_unpack_full_ipaddr(context, inaddr, adr, port) 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; diff --git a/src/lib/krb5/os/read_msg.c b/src/lib/krb5/os/read_msg.c index 2d49249dc..749dae088 100644 --- a/src/lib/krb5/os/read_msg.c +++ b/src/lib/krb5/os/read_msg.c @@ -24,31 +24,40 @@ * Write a message to the network */ +#define NEED_SOCKETS #include "k5-int.h" #include +#ifndef _WINSOCKAPI_ #include +#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); } diff --git a/src/lib/krb5/os/read_pwd.c b/src/lib/krb5/os/read_pwd.c index 3ca73fbbe..1c07c9c40 100644 --- a/src/lib/krb5/os/read_pwd.c +++ b/src/lib/krb5/os/read_pwd.c @@ -25,6 +25,7 @@ */ #include "k5-int.h" +#ifndef _MSDOS #include #include #include @@ -238,3 +239,19 @@ krb5_read_password(context, prompt, prompt2, return_pwd, size_return) 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 */ diff --git a/src/lib/krb5/os/realm_dom.c b/src/lib/krb5/os/realm_dom.c index dd146825a..4550bfbca 100644 --- a/src/lib/krb5/os/realm_dom.c +++ b/src/lib/krb5/os/realm_dom.c @@ -51,7 +51,7 @@ 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; diff --git a/src/lib/krb5/os/sendto_kdc.c b/src/lib/krb5/os/sendto_kdc.c index 24022ad6b..5b66acae4 100644 --- a/src/lib/krb5/os/sendto_kdc.c +++ b/src/lib/krb5/os/sendto_kdc.c @@ -26,6 +26,7 @@ */ #include "k5-int.h" +#ifndef _MSDOS /* Not yet for Windows */ #include #include @@ -205,3 +206,4 @@ krb5_sendto_kdc (context, message, realm, reply) } return retval; } +#endif diff --git a/src/lib/krb5/os/sn2princ.c b/src/lib/krb5/os/sn2princ.c index 97509717b..1ee37d3f9 100644 --- a/src/lib/krb5/os/sn2princ.c +++ b/src/lib/krb5/os/sn2princ.c @@ -25,12 +25,17 @@ * form. */ +#define NEED_SOCKETS #include "k5-int.h" +#ifndef _WINSOCKAPI_ #include +#endif #include +#ifdef HAVE_SYS_PARAM_H #include +#endif -krb5_error_code +krb5_error_code INTERFACE krb5_sname_to_principal(context, hostname, sname, type, ret_princ) krb5_context context; const char * hostname; diff --git a/src/lib/krb5/os/timeofday.c b/src/lib/krb5/os/timeofday.c index 5197809d3..82636efa6 100644 --- a/src/lib/krb5/os/timeofday.c +++ b/src/lib/krb5/os/timeofday.c @@ -36,9 +36,11 @@ #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; diff --git a/src/lib/krb5/os/unlck_file.c b/src/lib/krb5/os/unlck_file.c index 900073e09..3e0b3b32b 100644 --- a/src/lib/krb5/os/unlck_file.c +++ b/src/lib/krb5/os/unlck_file.c @@ -27,7 +27,7 @@ #include #include "k5-int.h" -krb5_error_code +krb5_error_code INTERFACE krb5_unlock_file(context, filep, pathname) krb5_context context; FILE *filep; diff --git a/src/lib/krb5/os/write_msg.c b/src/lib/krb5/os/write_msg.c index e9f615412..659b79bbe 100644 --- a/src/lib/krb5/os/write_msg.c +++ b/src/lib/krb5/os/write_msg.c @@ -24,11 +24,14 @@ * convenience sendauth/recvauth functions */ +#define NEED_SOCKETS #include "k5-int.h" #include +#ifndef _WINSOCKAPI_ #include +#endif -krb5_error_code +krb5_error_code INTERFACE krb5_write_message(context, fdp, outbuf) krb5_context context; krb5_pointer fdp;