summaryrefslogtreecommitdiffstats
path: root/src/lib/krb5/ccache/stdio
diff options
context:
space:
mode:
authorTheodore Tso <tytso@mit.edu>1997-11-11 01:45:42 +0000
committerTheodore Tso <tytso@mit.edu>1997-11-11 01:45:42 +0000
commitf9ec66d08b60dd5b39980f6fb433f15ff3a9ad26 (patch)
tree48004f81cde5b2fa6fbd05b1d01ad44ad805dbd1 /src/lib/krb5/ccache/stdio
parent0c2085fe0efdd894058e45e7e8f030eb25c3766c (diff)
downloadkrb5-f9ec66d08b60dd5b39980f6fb433f15ff3a9ad26.tar.gz
krb5-f9ec66d08b60dd5b39980f6fb433f15ff3a9ad26.tar.xz
krb5-f9ec66d08b60dd5b39980f6fb433f15ff3a9ad26.zip
scc_maybe.c: Added kludge for the Macintosh, since fopen() doesn't set
errno, although open() does. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@10272 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/lib/krb5/ccache/stdio')
-rw-r--r--src/lib/krb5/ccache/stdio/ChangeLog5
-rw-r--r--src/lib/krb5/ccache/stdio/scc_maybe.c44
2 files changed, 47 insertions, 2 deletions
diff --git a/src/lib/krb5/ccache/stdio/ChangeLog b/src/lib/krb5/ccache/stdio/ChangeLog
index 4e4aba9ecc..f8351fb8d5 100644
--- a/src/lib/krb5/ccache/stdio/ChangeLog
+++ b/src/lib/krb5/ccache/stdio/ChangeLog
@@ -1,3 +1,8 @@
+Wed Oct 29 15:57:31 1997 Theodore Y. Ts'o <tytso@mit.edu>
+
+ * scc_maybe.c: Added kludge for the Macintosh, since fopen()
+ doesn't set errno, although open() does.
+
Thu Sep 25 21:04:47 1997 Tom Yu <tlyu@mit.edu>
* scc_maybe.c (krb5_scc_open_file): Replace HAS_SETVBUF with
diff --git a/src/lib/krb5/ccache/stdio/scc_maybe.c b/src/lib/krb5/ccache/stdio/scc_maybe.c
index 1f93922d4d..5b3544c345 100644
--- a/src/lib/krb5/ccache/stdio/scc_maybe.c
+++ b/src/lib/krb5/ccache/stdio/scc_maybe.c
@@ -29,6 +29,44 @@
#include "scc.h"
#include "k5-int.h"
+#ifdef _MACINTOSH
+/*
+ * Kludge for the Macintosh, since fopen doesn't set errno, but open
+ * does...
+ */
+static FILE *my_fopen(char *path, char *mode)
+{
+ int fd, open_flags;
+ FILE *f;
+
+ f = fopen(path, mode);
+ if (f)
+ return f;
+ /*
+ * OK, fopen failed; let's try to figure out why....
+ */
+ if (strchr(mode, '+'))
+ open_flags = O_RDWR;
+ else if (strchr(mode, 'w') || strchr(mode, 'a'))
+ open_flags = O_WRONLY;
+ else
+ open_flags = O_RDONLY;
+ if (strchr(mode, 'a'))
+ open_flags |= O_APPEND;
+
+ fd = open(path, open_flags);
+ if (fd == -1)
+ return NULL;
+ /*
+ * fopen failed, but open succeeded? W*E*I*R*D.....
+ */
+ close(fd);
+ errno = KRB5_CC_IO;
+
+ return NULL;
+}
+#endif
+
krb5_error_code
krb5_scc_close_file (context, id)
krb5_context context;
@@ -77,7 +115,6 @@ krb5_scc_open_file (context, id, mode)
krb5_os_context os_ctx = (krb5_os_context) context->os_context;
krb5_scc_data *data = (krb5_scc_data *) id->data;
char fvno_bytes[2]; /* In nework byte order */
- krb5_ui_2 scc_vno;
krb5_ui_2 scc_tag;
krb5_ui_2 scc_taglen;
krb5_ui_2 scc_hlen;
@@ -125,7 +162,11 @@ krb5_scc_open_file (context, id, mode)
}
#endif
+#ifdef _MACINTOSH
+ f = my_fopen (data->filename, open_flag);
+#else
f = fopen (data->filename, open_flag);
+#endif
if (!f)
return krb5_scc_interpret (context, errno);
#ifdef HAVE_SETVBUF
@@ -151,7 +192,6 @@ krb5_scc_open_file (context, id, mode)
}
if (mode == SCC_OPEN_AND_ERASE) {
/* write the version number */
- int errsave;
data->file = f;
data->version = context->scc_default_format;