From 31bfb7a834cd0b5f7bfdaf6433960ef79b45fb20 Mon Sep 17 00:00:00 2001 From: Alexandra Ellwood Date: Thu, 6 Mar 2003 21:16:52 +0000 Subject: [PATCH] * c_ustime.c: Removed Mac OS 9 code. * ccdefname.c: Conditionalize on USE_CCAPI and not TARGET_OS_MAC so Darwin builds work. * init_os_ctx.c: Modified to use DEFAULT_SECURE_PROFILE_PATH and DEFAULT_PROFILE_PATH for KfM homedir-relative config files. * read_pwd.c: Cast to remove const warnings. * timeofday.c: Do the same thing on the Mac as on Unix git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15259 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/os/ChangeLog | 14 +++++ src/lib/krb5/os/c_ustime.c | 104 +--------------------------------- src/lib/krb5/os/ccdefname.c | 6 +- src/lib/krb5/os/init_os_ctx.c | 14 +++-- src/lib/krb5/os/read_pwd.c | 4 +- src/lib/krb5/os/timeofday.c | 10 ---- 6 files changed, 29 insertions(+), 123 deletions(-) diff --git a/src/lib/krb5/os/ChangeLog b/src/lib/krb5/os/ChangeLog index 9149d05b2..51638d9e4 100644 --- a/src/lib/krb5/os/ChangeLog +++ b/src/lib/krb5/os/ChangeLog @@ -1,3 +1,17 @@ +2003-03-06 Alexandra Ellwood + + * c_ustime.c: Removed Mac OS 9 code. + + * ccdefname.c: Conditionalize on USE_CCAPI and not TARGET_OS_MAC + so Darwin builds work. + + * init_os_ctx.c: Modified to use DEFAULT_SECURE_PROFILE_PATH and + DEFAULT_PROFILE_PATH for KfM homedir-relative config files. + + * read_pwd.c: Cast to remove const warnings. + + * timeofday.c: Do the same thing on the Mac as on Unix. + 2003-03-04 Sam Hartman * sendto_kdc.c (service_tcp_fd): Don't call shutdown on end of write because some implementations cannot deal with half-closed TCP sockets. diff --git a/src/lib/krb5/os/c_ustime.c b/src/lib/krb5/os/c_ustime.c index e099f6a8c..4a049649f 100644 --- a/src/lib/krb5/os/c_ustime.c +++ b/src/lib/krb5/os/c_ustime.c @@ -30,109 +30,7 @@ #define NEED_SOCKETS #include "k5-int.h" -#ifdef macintosh - -/* We're a Macintosh -- do Mac time things. */ - -/* - * This code is derived from kerberos/src/lib/des/mac_time.c from - * the Cygnus Support release of Kerberos V4: - * - * mac_time.c - * (Originally time_stuff.c) - * Copyright 1989 by the Massachusetts Institute of Technology. - * Macintosh ooperating system interface for Kerberos. - */ - -#include -#include /* Defines MachineLocation, used by getTimeZoneOffset */ -#include /* Defines BitTst(), called by getTimeZoneOffset() */ -#include /* Defines GetDateTime */ -#include /* Nanosecond timing */ -#include /* Check for presence of UpTime */ -#include /* 64-bit integer math */ -#include /* Mac time -> UNIX time conversion */ - -/* Mac Cincludes */ -#include -#include - -static krb5_int32 last_sec = 0, last_usec = 0; - -/* - * The Unix epoch is 1/1/70, the Mac epoch is 1/1/04. - * - * 70 - 4 = 66 year differential - * - * Thus the offset is: - * - * (66 yrs) * (365 days/yr) * (24 hours/day) * (60 mins/hour) * (60 secs/min) - * plus - * (17 leap days) * (24 hours/day) * (60 mins/hour) * (60 secs/min) - * - * Don't forget the offset from GMT. - */ - -/* returns the offset in hours between the mac local time and the GMT */ -/* unsigned krb5_int32 */ -krb5_int32 -getTimeZoneOffset() -{ - MachineLocation macLocation; - long gmtDelta; - - macLocation.u.gmtDelta=0L; - ReadLocation(&macLocation); - gmtDelta=macLocation.u.gmtDelta & 0x00FFFFFF; - if (BitTst((void *)&gmtDelta,23L)) - gmtDelta |= 0xFF000000; - gmtDelta /= 3600L; - return(gmtDelta); -} - -/* Returns the GMT in seconds (and fake microseconds) using the Unix epoch */ - -krb5_error_code -krb5_crypto_us_timeofday(seconds, microseconds) - krb5_int32 *seconds, *microseconds; -{ - krb5_int32 sec, usec; - time_t the_time; - - GetDateTime (&sec); - usec = 0; - - /* Fix secs to UNIX epoch */ - - mac_time_to_unix_time (&sec); - - /* Make sure that we are _not_ repeating */ - - if (sec < last_sec) { /* Seconds should be at least equal to last seconds */ - sec = last_sec; - } - - if (sec == last_sec) { /* Same seconds as last time? */ - if (usec <= last_usec) { /* Yep, microseconds must be bigger than last time*/ - usec = last_usec + 1; - } - - if (usec >= 1000000) { /* handle 1e6 wraparound */ - sec++; - usec = 0; - } - } - - last_sec = sec; /* Remember for next time */ - last_usec = usec; - - *seconds = sec; - *microseconds = usec; /* Return the values */ - - return 0; -} - -#elif defined(_WIN32) +#if defined(_WIN32) /* Microsoft Windows NT and 95 (32bit) */ /* This one works for WOW (Windows on Windows, ntvdm on Win-NT) */ diff --git a/src/lib/krb5/os/ccdefname.c b/src/lib/krb5/os/ccdefname.c index 743145d75..e77bcfef9 100644 --- a/src/lib/krb5/os/ccdefname.c +++ b/src/lib/krb5/os/ccdefname.c @@ -31,8 +31,8 @@ #include "k5-int.h" #include -#if TARGET_OS_MAC -#include +#if defined(USE_CCAPI) +#include #endif #if defined(_WIN32) @@ -186,7 +186,7 @@ static krb5_error_code get_from_os(char *name_buf, int name_size) } #endif -#if TARGET_OS_MAC +#if defined(USE_CCAPI) static krb5_error_code get_from_os(char *name_buf, int name_size) { diff --git a/src/lib/krb5/os/init_os_ctx.c b/src/lib/krb5/os/init_os_ctx.c index 793a8f2c0..eb2321d42 100644 --- a/src/lib/krb5/os/init_os_ctx.c +++ b/src/lib/krb5/os/init_os_ctx.c @@ -167,7 +167,6 @@ get_from_registry( static void free_filespecs(profile_filespec_t *files) { -#if !TARGET_OS_MAC char **cp; if (files == 0) @@ -175,11 +174,12 @@ free_filespecs(profile_filespec_t *files) for (cp = files; *cp; cp++) free(*cp); -#endif free(files); } -static krb5_error_code +/* This function is needed by KfM's KerberosPreferences API + * because it needs to be able to specify "secure" */ +krb5_error_code os_get_default_config_files(profile_filespec_t **pfiles, krb5_boolean secure) { profile_filespec_t* files; @@ -234,8 +234,12 @@ os_get_default_config_files(profile_filespec_t **pfiles, krb5_boolean secure) unsigned int ent_len; const char *s, *t; - if (!secure) filepath = getenv("KRB5_CONFIG"); - if (!filepath) filepath = DEFAULT_PROFILE_PATH; + if (secure) { + filepath = DEFAULT_SECURE_PROFILE_PATH; + } else { + filepath = getenv("KRB5_CONFIG"); + if (!filepath) filepath = DEFAULT_PROFILE_PATH; + } /* count the distinct filename components */ for(s = filepath, n_entries = 1; *s; s++) { diff --git a/src/lib/krb5/os/read_pwd.c b/src/lib/krb5/os/read_pwd.c index 73a3670f1..9023b8e98 100644 --- a/src/lib/krb5/os/read_pwd.c +++ b/src/lib/krb5/os/read_pwd.c @@ -48,7 +48,7 @@ krb5_read_password(krb5_context context, const char *prompt, const char *prompt2 krb5_error_code retval; reply_data.length = *size_return; /* NB: size_return is also an input */ reply_data.data = return_pwd; - k5prompt.prompt = (const char *) prompt; + k5prompt.prompt = (char *)prompt; k5prompt.hidden = 1; k5prompt.reply = &reply_data; retval = krb5_prompter_posix(NULL, @@ -58,7 +58,7 @@ krb5_read_password(krb5_context context, const char *prompt, const char *prompt2 krb5_data verify_data; verify_data.data = malloc(*size_return); verify_data.length = *size_return; - k5prompt.prompt = (const char *) prompt2; + k5prompt.prompt = (char *)prompt2; k5prompt.reply = &verify_data; if (!verify_data.data) return ENOMEM; diff --git a/src/lib/krb5/os/timeofday.c b/src/lib/krb5/os/timeofday.c index fb3b92756..55dfe9b78 100644 --- a/src/lib/krb5/os/timeofday.c +++ b/src/lib/krb5/os/timeofday.c @@ -42,17 +42,7 @@ krb5_timeofday(krb5_context context, register krb5_int32 *timeret) *timeret = os_ctx->time_offset; return 0; } -#if TARGET_OS_MAC -{ - krb5_int32 usecs; - krb5_error_code kret; - - if (kret = krb5_crypto_us_timeofday((krb5_int32 *)&tval, &usecs)) - return kret; -} -#else tval = time(0); -#endif if (tval == (time_t) -1) return (krb5_error_code) errno; if (os_ctx->os_flags & KRB5_OS_TOFFSET_VALID) -- 2.26.2