implemented krb5_kt_add_entry, krb5_kt_store_principal,

krb5_kt_store_keyblock


git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@1577 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Assar Westerlund
1997-04-13 22:16:00 +00:00
parent 76d99e22f3
commit d15ce8ea38

View File

@@ -79,7 +79,37 @@ krb5_kt_add_entry(krb5_context context,
krb5_keytab id,
krb5_keytab_entry *entry)
{
abort ();
int ret;
int fd;
krb5_storage *sp;
fd = open (id->filename, O_APPEND);
if (fd < 0) {
fd = open (id->filename, O_WRONLY | O_CREAT, 0600);
if (fd < 0)
return -1;
sp = krb5_storage_from_fd(fd);
ret = krb5_store_int16 (sp, 0x0502);
if (ret) return ret;
} else {
sp = krb5_storage_from_fd(fd);
}
ret = krb5_store_int32 (sp, 4711); /* XXX */
if (ret) return ret;
ret = krb5_kt_store_principal (sp, entry->principal);
if (ret) return ret;
ret = krb5_store_int32 (sp, entry->principal->type);
if (ret) return ret;
ret = krb5_store_int32 (sp, time(NULL));
if (ret) return ret;
ret = krb5_store_int8 (sp, entry->vno);
if (ret) return ret;
ret = krb5_kt_store_keyblock (sp, &entry->keyblock);
if (ret) return ret;
krb5_storage_free (sp);
close (fd);
return 0;
}
krb5_error_code
@@ -197,6 +227,24 @@ krb5_kt_ret_data(krb5_storage *sp,
return 0;
}
static krb5_error_code
krb5_kt_store_principal(krb5_storage *sp,
krb5_principal princ)
{
int i;
int ret;
ret = krb5_store_int16 (sp, princ->ncomp);
if (ret) return ret;
ret = krb5_kt_store_data (sp, princ->realm);
if (ret) return ret;
for (i = 0; i < princ->ncomp; i++) {
ret = krb5_kt_store_data (sp, princ->comp[i]);
if (ret) return ret;
}
return 0;
}
static krb5_error_code
krb5_kt_ret_principal(krb5_storage *sp,
krb5_principal *princ)
@@ -242,6 +290,19 @@ krb5_kt_ret_keyblock(krb5_storage *sp, krb5_keyblock *p)
return ret;
}
static krb5_error_code
krb5_kt_store_keyblock (krb5_storage *sp,
krb5_keyblock *p)
{
int ret;
ret = krb5_store_int16(sp, p->keytype);
if (ret) return ret;
ret = krb5_kt_store_data(sp, p->contents);
if (ret) return ret;
return 0;
}
krb5_error_code
krb5_kt_next_entry(krb5_context context,
krb5_keytab id,