+Wed Aug 16 02:45:19 1995 Chris Provenzano <proven@mit.edu>
+
+ * scc_maybe.c: Pass fds to krb5_lock_file() and krb5_unlock_file()
+
Tue Jul 11 19:22:17 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
* scc-proto.h: Add prototype for krb5_scc_read.
memset (data->stdio_buffer, 0, sizeof (data->stdio_buffer));
if (ret == EOF) {
int errsave = errno;
- (void) krb5_unlock_file(context, data->file, data->filename);
+ (void) krb5_unlock_file(context, fileno(data->file));
(void) fclose (data->file);
data->file = 0;
return krb5_scc_interpret (context, errsave);
}
- retval = krb5_unlock_file(context, data->file, data->filename);
+ retval = krb5_unlock_file(context, fileno(data->file));
ret = fclose (data->file);
data->file = 0;
if (retval)
data = (krb5_scc_data *) id->data;
if (data->file) {
/* Don't know what state it's in; shut down and start anew. */
- (void) krb5_unlock_file(context, data->file, data->filename);
+ (void) krb5_unlock_file(context, fileno(data->file));
(void) fclose (data->file);
data->file = 0;
}
#endif
switch (mode) {
case SCC_OPEN_RDONLY:
- if ((retval = krb5_lock_file(context, f, data->filename, KRB5_LOCKMODE_SHARED))) {
+ if ((retval = krb5_lock_file(context,fileno(f),KRB5_LOCKMODE_SHARED))){
(void) fclose(f);
return retval;
}
break;
case SCC_OPEN_RDWR:
case SCC_OPEN_AND_ERASE:
- if ((retval = krb5_lock_file(context, f, data->filename,
+ if ((retval = krb5_lock_file(context, fileno(f),
KRB5_LOCKMODE_EXCLUSIVE))) {
(void) fclose(f);
return retval;
data->version = krb5_scc_default_format;
if (!fwrite((char *)fvno_bytes, sizeof(fvno_bytes), 1, f)) {
errsave = errno;
- (void) krb5_unlock_file(context, f, data->filename);
+ (void) krb5_unlock_file(context, fileno(f));
(void) fclose(f);
return krb5_scc_interpret(context, errsave);
}
} else {
/* verify a valid version number is there */
if (!fread((char *)fvno_bytes, sizeof(fvno_bytes), 1, f)) {
- (void) krb5_unlock_file(context, f, data->filename);
+ (void) krb5_unlock_file(context, fileno(f));
(void) fclose(f);
return KRB5_CCACHE_BADVNO;
}
if ((data->version != KRB5_SCC_FVNO_1) &&
(data->version != KRB5_SCC_FVNO_2) &&
(data->version != KRB5_SCC_FVNO_3)) {
- (void) krb5_unlock_file(context, f, data->filename);
+ (void) krb5_unlock_file(context, fileno(f));
(void) fclose(f);
return KRB5_CCACHE_BADVNO;
}
+Wed Aug 16 02:45:19 1995 Chris Provenzano <proven@mit.edu>
+
+ * ktf_util.c: Pass fds to krb5_lock_file() and krb5_unlock_file()
+
Tue Aug 15 01:34:57 1995 Tom Yu <tlyu@dragons-lair.MIT.EDU>
* ktf_util.c: return KRB5_KEYTAB_BADVNO instead of -1
} else /* some other error */
return errno;
}
- if ((kerror = krb5_lock_file(context, KTFILEP(id), KTFILENAME(id),
- mode))) {
+ if ((kerror = krb5_lock_file(context, fileno(KTFILEP(id)), mode))) {
(void) fclose(KTFILEP(id));
KTFILEP(id) = 0;
return kerror;
KTVERSION(id) = krb5_kt_default_vno;
if (!xfwrite(&kt_vno, sizeof(kt_vno), 1, KTFILEP(id))) {
kerror = errno;
- (void) krb5_unlock_file(context, KTFILEP(id), KTFILENAME(id));
+ (void) krb5_unlock_file(context, fileno(KTFILEP(id)));
(void) fclose(KTFILEP(id));
return kerror;
}
/* gotta verify it instead... */
if (!xfread(&kt_vno, sizeof(kt_vno), 1, KTFILEP(id))) {
kerror = errno;
- (void) krb5_unlock_file(context, KTFILEP(id), KTFILENAME(id));
+ (void) krb5_unlock_file(context, fileno(KTFILEP(id)));
(void) fclose(KTFILEP(id));
return kerror;
}
kt_vno = KTVERSION(id) = ntohs(kt_vno);
if ((kt_vno != KRB5_KT_VNO) &&
(kt_vno != KRB5_KT_VNO_1)) {
- (void) krb5_unlock_file(context, KTFILEP(id), KTFILENAME(id));
+ (void) krb5_unlock_file(context, fileno(KTFILEP(id)));
(void) fclose(KTFILEP(id));
return KRB5_KEYTAB_BADVNO;
}
if (!KTFILEP(id))
return 0;
- kerror = krb5_unlock_file(context, KTFILEP(id), KTFILENAME(id));
+ kerror = krb5_unlock_file(context, fileno(KTFILEP(id)));
(void) fclose(KTFILEP(id));
KTFILEP(id) = 0;
return kerror;
+Wed Aug 16 02:45:19 1995 Chris Provenzano <proven@mit.edu>
+
+ * kprop.c, kpropd.c: Pass fds to krb5_lock_file() and krb5_unlock_file()
Fri Jul 7 16:34:36 EDT 1995 Paul Park (pjpark@mit.edu)
* Makefile.in - Remove all explicit library handling and LDFLAGS.
krb5_free_ap_rep_enc_part(context, rep_result);
}
-FILE * dbfp;
char * dbpathname;
/*
* Open the Kerberos database dump file. Takes care of locking it
data_fn);
exit(1);
}
- if ((dbfp = fopen(dbpathname, "r")) == 0) {
+ if ((fd = open(dbpathname, O_RDONLY)) < 0) {
com_err(progname, errno, "while trying to open %s",
dbpathname);
exit(1);
}
- err = krb5_lock_file(context, dbfp, dbpathname,
+ err = krb5_lock_file(context, fd,
KRB5_LOCKMODE_SHARED|KRB5_LOCKMODE_DONTBLOCK);
if (err == EAGAIN || err == EWOULDBLOCK || errno == EACCES) {
com_err(progname, 0, "database locked");
com_err(progname, err, "while trying to lock '%s'", dbpathname);
exit(1);
}
- fd = fileno(dbfp);
if (fstat(fd, &stbuf)) {
com_err(progname, errno, "while trying to stat %s",
data_fn);
int fd;
{
int err;
- if (fd != fileno(dbfp)) {
- com_err(progname, 0, "bad fd passed to close_database");
- exit(1);
- }
- err = krb5_lock_file(context, dbfp, dbpathname, KRB5_LOCKMODE_UNLOCK);
- if (err)
+ if (err = krb5_lock_file(context, fd, KRB5_LOCKMODE_UNLOCK));
com_err(progname, err, "while unlocking database '%s'", dbpathname);
free(dbpathname);
- (void) fclose(dbfp);
+ (void)close(fd);
return;
}
int on = 1, fromlen;
struct hostent *hp;
krb5_error_code retval;
- FILE *lock_fp;
+ int lock_fd;
int omask;
fromlen = sizeof (from);
exit(1);
}
omask = umask(077);
- lock_fp = fopen(temp_file_name, "a");
+ lock_fd = fopen(temp_file_name, O_RDONLY);
(void) umask(omask);
- retval = krb5_lock_file(kpropd_context, lock_fp, temp_file_name,
+ retval = krb5_lock_file(kpropd_context, lock_fd,
KRB5_LOCKMODE_EXCLUSIVE|KRB5_LOCKMODE_DONTBLOCK);
if (retval) {
com_err(progname, retval, "while trying to lock '%s'",
exit(1);
}
load_database(kpropd_context, kdb5_edit, file);
- retval = krb5_lock_file(kpropd_context, lock_fp, temp_file_name,
- KRB5_LOCKMODE_UNLOCK);
+ retval = krb5_lock_file(kpropd_context, lock_fd, KRB5_LOCKMODE_UNLOCK);
if (retval) {
com_err(progname, retval, "while unlocking '%s'", temp_file_name);
exit(1);
}
- (void) fclose(lock_fp);
+ (void)close(lock_fd);
exit(0);
}