TCHECK(kret);
kret = krb5_fcc_read_addrs(id, &creds->addresses);
TCHECK(kret);
+ kret = krb5_fcc_read_authdata(id, &creds->authdata);
+ TCHECK(kret);
kret = krb5_fcc_read_data(id, &creds->ticket);
TCHECK(kret);
kret = krb5_fcc_read_data(id, &creds->second_ticket);
xfree(creds->second_ticket.data);
if (creds->addresses)
krb5_free_address(creds->addresses);
+ if (creds->authdata)
+ krb5_free_authdata(creds->authdata);
}
return kret;
}
{
return krb5_fcc_read(id, (krb5_pointer) f, sizeof(krb5_flags));
}
+
+krb5_error_code
+krb5_fcc_read_authdata(id, a)
+ krb5_ccache id;
+ krb5_authdata ***a;
+{
+ krb5_error_code kret;
+ krb5_int32 length;
+ int i;
+
+ *a = 0;
+
+ /* Read the number of components */
+ kret = krb5_fcc_read_int32(id, &length);
+ CHECK(kret);
+
+ if (length == 0)
+ return KRB5_OK;
+
+ /* Make *a able to hold length pointers to krb5_authdata structs
+ * Add one extra for a null-terminated list
+ */
+ *a = (krb5_authdata **) calloc(length+1, sizeof(krb5_authdata *));
+ if (*a == NULL)
+ return KRB5_CC_NOMEM;
+
+ for (i=0; i < length; i++) {
+ (*a)[i] = (krb5_authdata *) malloc(sizeof(krb5_authdata));
+ if ((*a)[i] == NULL) {
+ krb5_free_authdata(*a);
+ return KRB5_CC_NOMEM;
+ }
+ kret = krb5_fcc_read_authdatum(id, (*a)[i]);
+ CHECK(kret);
+ }
+
+ return KRB5_OK;
+ errout:
+ if (*a)
+ krb5_free_authdata(*a);
+ return kret;
+}
+
+krb5_error_code
+krb5_fcc_read_authdatum(id, a)
+ krb5_ccache id;
+ krb5_authdata *a;
+{
+ krb5_error_code kret;
+ int ret;
+
+ a->contents = NULL;
+
+ kret = krb5_fcc_read_ui_2(id, &a->ad_type);
+ CHECK(kret);
+ kret = krb5_fcc_read_int(id, &a->length);
+ CHECK(kret);
+
+ a->contents = (krb5_octet *) malloc(a->length);
+ if (a->contents == NULL)
+ return KRB5_CC_NOMEM;
+ ret = read(((krb5_fcc_data *) id->data)->fd, (char *)a->contents,
+ (a->length)*sizeof(krb5_octet));
+ if (ret == -1) {
+ xfree(a->contents);
+ return krb5_fcc_interpret(errno);
+ }
+ if (ret != (a->length)*sizeof(krb5_octet)) {
+ xfree(a->contents);
+ return KRB5_CC_END;
+ }
+ return KRB5_OK;
+ errout:
+ if (a->contents)
+ xfree(a->contents);
+ return kret;
+
+}
static krb5_boolean standard_fields_match
PROTOTYPE((const krb5_creds *,
const krb5_creds *));
+
+static krb5_boolean authdata_match
+ PROTOTYPE ((krb5_authdata * const *, krb5_authdata * const *));
+
/*
* Effects:
* Searches the file cred cache is for a credential matching mcreds,
times_match_exact(&mcreds->times, &fetchcreds.times))
&&
(! set(KRB5_TC_MATCH_TIMES) ||
- times_match(&mcreds->times, &fetchcreds.times)))
+ times_match(&mcreds->times, &fetchcreds.times))
+ &&
+ ( ! set(KRB5_TC_MATCH_AUTHDATA) ||
+ authdata_match(mcreds->authdata, fetchcreds.authdata)))
{
krb5_fcc_end_seq_get(id, &cursor);
*creds = fetchcreds;
return (krb5_principal_compare(mcreds->client,creds->client) &&
krb5_principal_compare(mcreds->server,creds->server));
}
+
+static krb5_boolean
+authdata_match(mdata, data)
+ register krb5_authdata * const *mdata, * const *data;
+{
+ register const krb5_authdata *mdatap, *datap;
+
+ if (mdata == data)
+ return TRUE;
+
+ if (mdata == NULL)
+ return *data == NULL;
+
+ if (data == NULL)
+ return *mdata == NULL;
+
+ while ((mdatap = *mdata) && (datap = *data)) {
+ if ((mdatap->ad_type != datap->ad_type) ||
+ (mdatap->length != datap->length) ||
+ (bcmp ((char *)mdatap->contents,
+ (char *)datap->contents, mdatap->length) != 0))
+ return FALSE;
+ mdata++;
+ data++;
+ }
+ return (*mdata == NULL) && (*data == NULL);
+}
{
return krb5_fcc_write(id, (char *) f, sizeof(krb5_flags));
}
+
+krb5_error_code
+krb5_fcc_store_authdata(id, a)
+ krb5_ccache id;
+ krb5_authdata **a;
+{
+ krb5_error_code ret;
+ krb5_authdata **temp;
+ krb5_int32 i, length=0;
+
+ if (a != NULL) {
+ for (temp=a; *temp; temp++)
+ length++;
+ }
+
+ ret = krb5_fcc_store_int32(id, &length);
+ CHECK(ret);
+ for (i=0; i<length; i++) {
+ ret = krb5_fcc_store_authdatum (id, a[i]);
+ CHECK(ret);
+ }
+ return KRB5_OK;
+}
+
+krb5_error_code
+krb5_fcc_store_authdatum (id, a)
+ krb5_ccache id;
+ krb5_authdata *a;
+{
+ krb5_error_code ret;
+ ret = krb5_fcc_store_ui_2(id, &a->ad_type);
+ CHECK(ret);
+ ret = krb5_fcc_store_int32(id, &a->length);
+ CHECK(ret);
+ return krb5_fcc_write(id, a->contents, a->length);
+}