[2184] in Kerberos_V5_Development

home help back first fref pref prev next nref lref last post

replay cache I/O perm error in win32 port

daemon@ATHENA.MIT.EDU (Tom Sanfilippo)
Sun Jan 26 17:19:43 1997

Date: Sun, 26 Jan 1997 17:18:06 -0500
To: krbdev@MIT.EDU
From: Tom Sanfilippo <sanfilip@osf.org>

There is a problem with the krb5-win32-alpha1 which
causes a replay cache I/O perm error for a server if
there are more than 30 tickets in the replay cache and
all of them are older than 5 minutes.  To fix it I added
a patch in lib\krb5\rcache\rc_io.c.  The problem stems
from a difference between rename() in the Microsoft C
Runtime and on UNIX.  On UNIX rename() deletes the
target file if it previously exists.  On Win32 the
function fails instead.  This leads into a rat's nest
of other assumptions on the handling of file handles
on Win32.  Basically, the MIT sources assume you can
manipulate files via their links, while standard the
Win32 runtime library does not.  I'm not sure of a
way aroung this without pulling in some replacement
functions for rename(), etc.  I think I've seen such
a beast somewhere so I'll look into it.  For now the
code below seems to work as a temporary work-around.

*** rc_io.c	Sun Jan 26 08:03:44 1997
--- rc_io.c.orig	Wed Jun 12 03:16:09 1996
***************
*** 245,265 ****
      krb5_rc_iostuff *new;
      krb5_rc_iostuff *old;
  {
- #if defined(_MSDOS) || defined(_WIN32)
-  char *fn = NULL;
-  GETDIR;
-  close(new->fd);
-  unlink(new->fn);
-  close(old->fd);
-  if (rename(old->fn,new->fn) == -1) /* MUST be atomic! */
-    return KRB5_RC_IO_UNKNOWN;
-  if (!(fn = malloc(strlen(new->fn) - dirlen + 1)))
-    return KRB5_RC_IO_MALLOC;
-  strcpy(fn, new->fn + dirlen);
-  krb5_rc_io_close(context, new);
-  krb5_rc_io_open(context, new, fn);
-  free(fn);
- #else
   if (rename(old->fn,new->fn) == -1) /* MUST be atomic! */
     return KRB5_RC_IO_UNKNOWN;
   (void) krb5_rc_io_close(context, new);
--- 245,250 ----
***************
*** 271,277 ****
   new->fd = fcntl(old->fd, F_DUPFD);
  #else
   new->fd = dup(old->fd);
- #endif
  #endif
   return 0;
  }
--- 256,261 ----

Tom Sanfilippo
OSF Research Institute


home help back first fref pref prev next nref lref last post