that can be changed. (Filename is fixed after
initialization.) */
k5_mutex_t lock;
- /* Grab this one before trying to get an advisory lock on the disk
- file, since the facility is per-process, not per-thread. */
- k5_mutex_t disk_file_lock;
- int file_is_locked;
int file;
krb5_flags flags;
int mode; /* needed for locking code */
return KRB5_FCC_INTERNAL;
retval = krb5_unlock_file(context, data->file);
- k5_mutex_unlock(&data->disk_file_lock);
ret = close (data->file);
- data->file_is_locked = 0;
data->file = NO_FILE;
if (retval)
return retval;
if (data->file != NO_FILE) {
/* Don't know what state it's in; shut down and start anew. */
- if (data->file_is_locked) {
- (void) krb5_unlock_file(context, data->file);
- k5_mutex_unlock(&data->disk_file_lock);
- data->file_is_locked = 0;
- }
+ (void) krb5_unlock_file(context, data->file);
(void) close (data->file);
data->file = NO_FILE;
}
lock_flag = KRB5_LOCKMODE_SHARED;
else
lock_flag = KRB5_LOCKMODE_EXCLUSIVE;
- retval = k5_mutex_lock(&data->disk_file_lock);
- if (retval) {
- close(f);
- return retval;
- }
if ((retval = krb5_lock_file(context, f, lock_flag))) {
- k5_mutex_unlock(&data->disk_file_lock);
(void) close(f);
return retval;
}
- data->file_is_locked = 1;
if (mode == FCC_OPEN_AND_ERASE) {
/* write the version number */
if (retval) {
data->file = -1;
(void) krb5_unlock_file(context, f);
- (void) k5_mutex_unlock(&data->disk_file_lock);
- data->file_is_locked = 0;
(void) close(f);
}
return retval;
*fccsp = (*fccsp)->next;
free(temp);
k5_mutex_unlock(&krb5int_cc_file_mutex);
+ k5_mutex_assert_unlocked(&data->lock);
free(data->filename);
zap(data->buf, sizeof(data->buf));
if (data->file >= 0) {
krb5_fcc_close_file(context, data);
k5_mutex_unlock(&data->lock);
}
- k5_mutex_assert_unlocked(&data->lock);
k5_mutex_destroy(&data->lock);
- k5_mutex_destroy(&data->disk_file_lock);
free(data);
} else
k5_mutex_unlock(&krb5int_cc_file_mutex);
free(data);
return kret;
}
- kret = k5_mutex_init(&data->disk_file_lock);
- if (kret) {
- k5_mutex_unlock(&krb5int_cc_file_mutex);
- k5_mutex_unlock(&data->lock);
- k5_mutex_destroy(&data->lock);
- free(data->filename);
- free(data);
- return kret;
- }
/* data->version,mode filled in for real later */
data->version = data->mode = 0;
- data->file_is_locked = 0;
data->flags = KRB5_TC_OPENCLOSE;
data->file = -1;
data->valid_bytes = 0;
setptr = malloc(sizeof(struct fcc_set));
if (setptr == NULL) {
k5_mutex_unlock(&krb5int_cc_file_mutex);
- k5_mutex_destroy(&data->disk_file_lock);
k5_mutex_destroy(&data->lock);
free(data->filename);
free(data);
retcode = k5_mutex_init(&data->lock);
if (retcode)
goto err_out;
- retcode = k5_mutex_init(&data->disk_file_lock);
- if (retcode) {
- k5_mutex_destroy(&data->lock);
- goto err_out;
- }
- data->file_is_locked = 0;
/* Set up the filename */
strcpy(((krb5_fcc_data *) lid->data)->filename, scratch);
/* XXX This should check for illegal combinations, if any.. */
if (flags & KRB5_TC_OPENCLOSE) {
/* asking to turn on OPENCLOSE mode */
- if (!OPENCLOSE(id))
+ if (!OPENCLOSE(id)
+ /* XXX Is this test necessary? */
+ && ((krb5_fcc_data *) id->data)->file != NO_FILE)
(void) krb5_fcc_close_file (context, ((krb5_fcc_data *) id->data));
} else {
/* asking to turn off OPENCLOSE mode, meaning it must be