+Tue Mar 21 19:14:49 1995 Keith Vetter (keithv@fusion.com)
+
+ * fcc_destroy.c: open file on the PC in binary mode, worked around
+ the unixism of working with deleted files.
+ * fcc_genn.c: open file on the PC in binary mode.
+ * fcc_init.c: uninitialized variable on the PC.
+ * fcc_maybe.c: open file on the PC in binary mode.
+ * fcc_read.c: a real clever one-line piece of code to turn 4 bytes
+ into a 32 bit integer fails miserbly on 16 bit machines. Fixed.
+ * fcc_ops.c: added hooks to notify programs when the ccache changes.
+ For windows, the code is taken from the K4 release, for other
+ platforms it does nothing.
+ * fcc_destroy.c, fcc_genn.c, fcc_init.c, fcc_store.c: added calls to
+ the hook described for fcc_ops.c.
+
Fri Mar 17 19:23:09 1995 John Gilmore (gnu at toad.com)
* Makefile.in (LDFLAGS): Eliminate, duplicates config/pre.in.
if (OPENCLOSE(id)) {
- ret = open(((krb5_fcc_data *) id->data)->filename, O_RDWR, 0);
+ ret = open(((krb5_fcc_data *) id->data)->filename, O_RDWR | O_BINARY, 0);
if (ret < 0) {
kret = krb5_fcc_interpret(context, errno);
goto cleanup;
else
lseek(((krb5_fcc_data *) id->data)->fd, 0, SEEK_SET);
+#ifdef MSDOS_FILESYSTEM
+/* "disgusting bit of UNIX trivia" - that's how the writers of NFS describe
+** the ability of UNIX to still write to a file which has been unlinked.
+** Naturally, the PC can't do this. As a result, we have to delete the file
+** after we wipe it clean but that throws off all the error handling code.
+** So we have do the work ourselves.
+*/
+ ret = fstat(((krb5_fcc_data *) id->data)->fd, &buf);
+ if (ret == -1) {
+ kret = krb5_fcc_interpret(context, errno);
+ size = 0; /* Nothing to wipe clean */
+ } else
+ size = (unsigned long) buf.st_size;
+
+ memset(zeros, 0, BUFSIZ);
+ while (size > 0) {
+ wlen = (int) ((size > BUFSIZ) ? BUFSIZ : size); /* How much to write */
+ i = write(((krb5_fcc_data *) id->data)->fd, zeros, wlen);
+ if (i < 0) {
+ kret = krb5_fcc_interpret(context, errno);
+ /* Don't jump to cleanup--we still want to delete the file. */
+ break;
+ }
+ size -= i; /* We've read this much */
+ }
+
+ ret = unlink(((krb5_fcc_data *) id->data)->filename);
+ if (ret < 0) {
+ kret = krb5_fcc_interpret(context, errno);
+ if (OPENCLOSE(id)) {
+ (void) close(((krb5_fcc_data *)id->data)->fd);
+ ((krb5_fcc_data *) id->data)->fd = -1;
+ kret = ret;
+ }
+ goto cleanup;
+ }
+
+#else /* MSDOS_FILESYSTEM */
+
ret = unlink(((krb5_fcc_data *) id->data)->filename);
if (ret < 0) {
kret = krb5_fcc_interpret(context, errno);
/* XXX This may not be legal XXX */
size = (unsigned long) buf.st_size;
-
memset(zeros, 0, BUFSIZ);
for (i=0; i < size / BUFSIZ; i++)
if (write(((krb5_fcc_data *) id->data)->fd, zeros, BUFSIZ) < 0) {
if (ret)
kret = krb5_fcc_interpret(context, errno);
+#endif /* MSDOS_FILESYSTEM */
+
cleanup:
krb5_xfree(((krb5_fcc_data *) id->data)->filename);
krb5_xfree(id->data);
krb5_xfree(id);
+ krb5_change_cache ();
return kret;
}
/* Make sure the file name is reserved */
ret = open(((krb5_fcc_data *) lid->data)->filename,
- O_CREAT | O_EXCL | O_WRONLY, 0);
+ O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0);
if (ret == -1) {
retcode = krb5_fcc_interpret(context, errno);
goto err_out;
}
*id = lid;
+
+ krb5_change_cache ();
return KRB5_OK;
}
krb5_principal princ;
{
krb5_error_code kret = 0;
- int reti;
+ int reti = 0;
MAYBE_OPEN(context, id, FCC_OPEN_AND_ERASE);
krb5_fcc_store_principal(context, id, princ);
MAYBE_CLOSE(context, id, kret);
+ krb5_change_cache ();
return kret;
}
break;
}
- fd = open (data->filename, open_flag, 0600);
+ fd = open (data->filename, open_flag | O_BINARY, 0600);
if (fd == -1)
return krb5_fcc_interpret (context, errno);
* This file contains the structure krb5_fcc_ops.
*/
-
-
+#define NEED_WINDOWS
#include "fcc.h"
krb5_cc_ops krb5_fcc_ops = {
krb5_fcc_set_flags,
};
+#ifdef _WINDOWS
+
+/*
+ * krb5_change_cache should be called after the cache changes.
+ * A notification message is is posted out to all top level
+ * windows so that they may recheck the cache based on the
+ * changes made. We register a unique message type with which
+ * we'll communicate to all other processes.
+ */
+
+void
+krb5_change_cache (int send) {
+
+ SendMessage(HWND_BROADCAST, krb5_get_notification_message(), 0, 0);
+}
+unsigned int INTERFACE
+krb5_get_notification_message (void) {
+ static unsigned int message = 0;
-
+ if (message == 0)
+ message = RegisterWindowMessage(WM_KERBEROS5_CHANGED);
+ return message;
+}
+#else /* _WINDOWS */
+void INTERFACE
+krb5_change_cache ()
+{
+ return;
+}
+unsigned int INTERFACE
+krb5_get_notification_message () {
+ return 0;
+}
+#endif /* _WINDOWS */
krb5_fcc_data *data = (krb5_fcc_data *)id->data;
krb5_error_code retval;
unsigned char buf[4];
+ krb5_int32 val;
if ((data->version == KRB5_FCC_FVNO_1) ||
(data->version == KRB5_FCC_FVNO_2))
retval = krb5_fcc_read(context, id, buf, 4);
if (retval)
return retval;
- *i = (((((buf[0] << 8) + buf[1]) << 8 ) + buf[2]) << 8) + buf[3];
+ val = buf[0];
+ val = (val << 8) | buf[1];
+ val = (val << 8) | buf[2];
+ val = (val << 8) | buf[3];
+ *i = val;
return 0;
}
}
lose:
MAYBE_CLOSE(context, id, ret);
+ krb5_change_cache ();
return ret;
#undef TCHECK
}