From e4521e79d7069fabfea3144da74973add29b3569 Mon Sep 17 00:00:00 2001 From: Tom Yu Date: Tue, 31 Oct 2000 00:33:00 +0000 Subject: [PATCH] * cc_stdio.c: Add a "mode" field to krb5_scc_data to keep track of what mode the file was opened in. (krb5_scc_close_file): Ignore EBADF from fflush() if the file was opened for readonly access. For some reason NetBSD's fflush() exhibits this behavior. (krb5_scc_open_file): Save the mode with which the file was opened in data->mode. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@12825 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/krb5/ccache/ChangeLog | 10 ++++++++++ src/lib/krb5/ccache/cc_stdio.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/src/lib/krb5/ccache/ChangeLog b/src/lib/krb5/ccache/ChangeLog index 8c2724ad6..75abaa032 100644 --- a/src/lib/krb5/ccache/ChangeLog +++ b/src/lib/krb5/ccache/ChangeLog @@ -1,3 +1,13 @@ +2000-10-30 Tom Yu + + * cc_stdio.c: Add a "mode" field to krb5_scc_data to keep track of + what mode the file was opened in. + (krb5_scc_close_file): Ignore EBADF from fflush() if the file was + opened for readonly access. For some reason NetBSD's fflush() + exhibits this behavior. + (krb5_scc_open_file): Save the mode with which the file was opened + in data->mode. + 2000-10-17 Ezra Peisach * cc_stdio.c, cc_file.c: Unsigned/signed int cleanup. diff --git a/src/lib/krb5/ccache/cc_stdio.c b/src/lib/krb5/ccache/cc_stdio.c index f7ea17b29..f46e5d649 100644 --- a/src/lib/krb5/ccache/cc_stdio.c +++ b/src/lib/krb5/ccache/cc_stdio.c @@ -316,6 +316,7 @@ typedef struct _krb5_scc_data { krb5_flags flags; char stdio_buffer[BUFSIZ]; int version; + int mode; } krb5_scc_data; /* An off_t can be arbitrarily complex */ @@ -1173,6 +1174,12 @@ krb5_scc_close_file (context, id) (failed) syscall */ if (ret == EOF && !errno) ret = 0; #endif + /* + * NetBSD returns EBADF on fflush of a read-only file. + */ + if (ret == EOF && errno == EBADF + && data->mode == SCC_OPEN_RDONLY) + ret = 0; memset (data->stdio_buffer, 0, sizeof (data->stdio_buffer)); if (ret == EOF) { int errsave = errno; @@ -1253,6 +1260,7 @@ krb5_scc_open_file (context, id, mode) #endif if (!f) return krb5_scc_interpret (context, errno); + data->mode = mode; #ifdef HAVE_SETVBUF setvbuf(f, data->stdio_buffer, _IOFBF, sizeof (data->stdio_buffer)); #else -- 2.26.2