(fkt_remove_entry): make this work

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@5443 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Johan Danielsson
1999-02-27 21:38:32 +00:00
parent 1e6e688c0e
commit 8acb8d2589

View File

@@ -562,10 +562,12 @@ fkt_start_seq_get(krb5_context context,
} }
static krb5_error_code static krb5_error_code
fkt_next_entry(krb5_context context, fkt_next_entry_int(krb5_context context,
krb5_keytab id, krb5_keytab id,
krb5_keytab_entry *entry, krb5_keytab_entry *entry,
krb5_kt_cursor *cursor) krb5_kt_cursor *cursor,
off_t *start,
off_t *end)
{ {
u_int32_t len; u_int32_t len;
u_int32_t timestamp; u_int32_t timestamp;
@@ -582,6 +584,7 @@ loop:
cursor->offset += 4 + -tmp32; cursor->offset += 4 + -tmp32;
goto loop; goto loop;
} }
if(start) *start = cursor->offset;
len = tmp32; len = tmp32;
cursor->offset += 4 + len; cursor->offset += 4 + len;
ret = krb5_kt_ret_principal (cursor->sp, &entry->principal); ret = krb5_kt_ret_principal (cursor->sp, &entry->principal);
@@ -605,10 +608,20 @@ loop:
/* backwards compatibility with Heimdal <= 0.0n */ /* backwards compatibility with Heimdal <= 0.0n */
if(len == 4711) if(len == 4711)
cursor->offset = cursor->sp->seek(cursor->sp, 0, SEEK_CUR); cursor->offset = cursor->sp->seek(cursor->sp, 0, SEEK_CUR);
if(end) *end = cursor->offset;
return 0; return 0;
} }
static krb5_error_code
fkt_next_entry(krb5_context context,
krb5_keytab id,
krb5_keytab_entry *entry,
krb5_kt_cursor *cursor)
{
return fkt_next_entry_int(context, id, entry, cursor, NULL, NULL);
}
static krb5_error_code static krb5_error_code
fkt_end_seq_get(krb5_context context, fkt_end_seq_get(krb5_context context,
krb5_keytab id, krb5_keytab id,
@@ -679,14 +692,13 @@ fkt_remove_entry(krb5_context context,
int found = 0; int found = 0;
fkt_start_seq_get_int(context, id, O_RDWR | O_BINARY, &cursor); fkt_start_seq_get_int(context, id, O_RDWR | O_BINARY, &cursor);
pos_start = cursor.offset; while(fkt_next_entry_int(context, id, &e, &cursor,
while(krb5_kt_next_entry(context, id, &e, &cursor) == 0) { &pos_start, &pos_end) == 0) {
if(kt_compare(context, &e, entry->principal, if(kt_compare(context, &e, entry->principal,
entry->vno, entry->keyblock.keytype)) { entry->vno, entry->keyblock.keytype)) {
int32_t len; int32_t len;
unsigned char buf[128]; unsigned char buf[128];
found = 1; found = 1;
pos_end = cursor.offset;
cursor.sp->seek(cursor.sp, pos_start, SEEK_SET); cursor.sp->seek(cursor.sp, pos_start, SEEK_SET);
krb5_ret_int32(cursor.sp, &len); krb5_ret_int32(cursor.sp, &len);
cursor.sp->seek(cursor.sp, pos_start, SEEK_SET); cursor.sp->seek(cursor.sp, pos_start, SEEK_SET);
@@ -698,9 +710,7 @@ fkt_remove_entry(krb5_context context,
cursor.sp->store(cursor.sp, buf, min(len, sizeof(buf))); cursor.sp->store(cursor.sp, buf, min(len, sizeof(buf)));
len -= min(len, sizeof(buf)); len -= min(len, sizeof(buf));
} }
break;
} }
pos_start = cursor.offset;
} }
krb5_kt_end_seq_get(context, id, &cursor); krb5_kt_end_seq_get(context, id, &cursor);
if (!found) if (!found)