+2003-03-06 Alexandra Ellwood <lxs@mit.edu>
+
+ * 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 <hartmans@mit.edu>
* sendto_kdc.c (service_tcp_fd): Don't call shutdown on end of write because some implementations cannot deal with half-closed TCP sockets.
#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 <ConditionalMacros.h>
-#include <script.h> /* Defines MachineLocation, used by getTimeZoneOffset */
-#include <ToolUtils.h> /* Defines BitTst(), called by getTimeZoneOffset() */
-#include <OSUtils.h> /* Defines GetDateTime */
-#include <DriverServices.h> /* Nanosecond timing */
-#include <CodeFragments.h> /* Check for presence of UpTime */
-#include <Math64.h> /* 64-bit integer math */
-#include <KerberosSupport/Utilities.h> /* Mac time -> UNIX time conversion */
-
-/* Mac Cincludes */
-#include <string.h>
-#include <stddef.h>
-
-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) */
static void
free_filespecs(profile_filespec_t *files)
{
-#if !TARGET_OS_MAC
char **cp;
if (files == 0)
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;
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++) {
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,
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;