#ifdef __cplusplus
extern "C" {
#endif
-
+
#include <kim/kim_types.h>
-
+
/*!
* \addtogroup kim_types_reference
* @{
* This value determines what type of user interface is displayed.
* See \ref kim_options_custom_prompt_callback for more information.
*/
-typedef uint32_t kim_prompt_type_t;
+typedef uint32_t kim_prompt_type;
enum kim_prompt_type_enum {
kim_prompt_type_password = 0,
* The prompt callback used to display a prompt to the user.
* See \ref kim_options_custom_prompt_callback for more information.
*/
-typedef kim_error_code (*kim_prompt_callback_t) (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply);
+typedef kim_error_code (*kim_prompt_callback) (kim_options *io_options,
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply);
/*!
* The default prompt callback.
* See \ref kim_options_custom_prompt_callback for more information.
*/
kim_error_code kim_prompt_callback_default (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply);
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply);
/*!
* The graphical prompt callback.
* See \ref kim_options_custom_prompt_callback for more information.
*/
kim_error_code kim_prompt_callback_gui (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply);
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply);
/*!
* The command line prompt callback.
* See \ref kim_options_custom_prompt_callback for more information.
*/
kim_error_code kim_prompt_callback_cli (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply);
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply);
/*!
* The prompt callback which always returns an error.
* See \ref kim_options_custom_prompt_callback for more information.
*/
kim_error_code kim_prompt_callback_none (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply);
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply);
/*! @} */
* \brief Copy options.
*/
kim_error kim_options_copy (kim_options *out_options,
- kim_options in_options);
+ kim_options in_options);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_prompt_callback()
*/
kim_error kim_options_set_prompt_callback (kim_options io_options,
- kim_prompt_callback_t in_prompt_callback);
+ kim_prompt_callback in_prompt_callback);
/*!
* \param in_options an options object.
* \sa kim_options_set_prompt_callback()
*/
kim_error kim_options_get_prompt_callback (kim_options in_options,
- kim_prompt_callback_t *out_prompt_callback);
+ kim_prompt_callback *out_prompt_callback);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_data()
*/
kim_error kim_options_set_data (kim_options io_options,
- const void *in_data);
+ const void *in_data);
/*!
* \param in_options an options object.
* \sa kim_options_set_data()
*/
kim_error kim_options_get_data (kim_options in_options,
- const void **out_data);
+ const void **out_data);
/*!
* \param io_options an options object to modify.
* NULL (no response is set by default)
* \sa kim_options_get_prompt_response()
*/
-kim_error kim_options_set_prompt_response (kim_options io_options,
- kim_prompt_type_t in_prompt_type,
- void *in_response);
+kim_error kim_options_set_prompt_response (kim_options io_options,
+ kim_prompt_type in_prompt_type,
+ void *in_response);
/*!
* \param in_options an options object.
* \sa kim_options_set_prompt_response()
*/
kim_error kim_options_get_prompt_response (kim_options in_options,
- kim_prompt_type_t in_prompt_type,
- void **out_response);
+ kim_prompt_type in_prompt_type,
+ void **out_response);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_start_time(), kim_credential_validate(), kim_ccache_validate(), kim_identity_validate()
*/
kim_error kim_options_set_start_time (kim_options io_options,
- kim_time in_start_time);
+ kim_time in_start_time);
/*!
* \param in_options an options object.
* \sa kim_options_set_start_time(), kim_credential_validate(), kim_ccache_validate(), kim_identity_validate()
*/
kim_error kim_options_get_start_time (kim_options in_options,
- kim_time *out_start_time);
+ kim_time *out_start_time);
/*!
* \param io_options an options object to modify.
* Read from the user's preferences and the Kerberos configuration. 10 hours if unspecified.
*/
kim_error kim_options_set_lifetime (kim_options io_options,
- kim_lifetime in_lifetime);
+ kim_lifetime in_lifetime);
/*!
* \param in_options an options object.
* \sa kim_options_set_lifetime()
*/
kim_error kim_options_get_lifetime (kim_options in_options,
- kim_lifetime *out_lifetime);
+ kim_lifetime *out_lifetime);
/*!
-* \param io_options an options object to modify.
+ * \param io_options an options object to modify.
* \param in_renewable a boolean value indicating whether or not to request a renewable
* credential.
* \return On success, #KIM_NO_ERROR. On failure, an error object representing the failure.
* \sa kim_options_get_renewable()
*/
kim_error kim_options_set_renewable (kim_options io_options,
- kim_boolean in_renewable);
+ kim_boolean in_renewable);
/*!
-* \param in_options an options object.
+ * \param in_options an options object.
* \param out_renewable on exit, a boolean value indicating whether or \a in_options will
* request a renewable credential.
* \return On success, #KIM_NO_ERROR. On failure, an error object representing the failure.
* \sa kim_options_set_renewable()
*/
kim_error kim_options_get_renewable (kim_options in_options,
- kim_boolean *out_renewable);
+ kim_boolean *out_renewable);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_renewal_lifetime(), kim_identity_renew(), kim_credential_renew(), kim_ccache_renew()
*/
kim_error kim_options_set_renewal_lifetime (kim_options io_options,
- kim_lifetime in_renewal_lifetime);
+ kim_lifetime in_renewal_lifetime);
/*!
* \param in_options an options object.
* \sa kim_options_set_renewal_lifetime(), kim_identity_renew(), kim_credential_renew(), kim_ccache_renew()
*/
kim_error kim_options_get_renewal_lifetime (kim_options in_options,
- kim_lifetime *out_renewal_lifetime);
+ kim_lifetime *out_renewal_lifetime);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_forwardable()
*/
kim_error kim_options_set_forwardable (kim_options io_options,
- kim_boolean in_forwardable);
+ kim_boolean in_forwardable);
/*!
* \param in_options an options object.
* \sa kim_options_set_forwardable()
*/
kim_error kim_options_get_forwardable (kim_options in_options,
- kim_boolean *out_forwardable);
+ kim_boolean *out_forwardable);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_proxiable()
*/
kim_error kim_options_set_proxiable (kim_options io_options,
- kim_boolean in_proxiable);
+ kim_boolean in_proxiable);
/*!
* \param in_options an options object.
* \sa kim_options_set_proxiable()
*/
kim_error kim_options_get_proxiable (kim_options in_options,
- kim_boolean *out_proxiable);
+ kim_boolean *out_proxiable);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_addressless()
*/
kim_error kim_options_set_addressless (kim_options io_options,
- kim_boolean in_addressless);
+ kim_boolean in_addressless);
/*!
* \param in_options an options object.
* \sa kim_options_set_addressless()
*/
kim_error kim_options_get_addressless (kim_options in_options,
- kim_boolean *out_addressless);
+ kim_boolean *out_addressless);
/*!
* \param io_options an options object to modify.
* \sa kim_options_get_service_name()
*/
kim_error kim_options_set_service_name (kim_options io_options,
- kim_string in_service_name);
+ kim_string in_service_name);
/*!
* \param in_options an options object.
* \sa kim_options_set_service_name()
*/
kim_error kim_options_get_service_name (kim_options in_options,
- kim_string *out_service_name);
+ kim_string *out_service_name);
/*!
* \param io_options the options object to be freed. Set to NULL on exit.
}
if (!err) {
- err = krb5_error (krb5_init_context (&ccache_iterator->context));
+ err = krb5_error (NULL, krb5_init_context (&ccache_iterator->context));
}
if (!err) {
- err = krb5_error (krb5_cccol_cursor_new (ccache_iterator->context,
+ err = krb5_error (ccache_iterator->context,
+ krb5_cccol_cursor_new (ccache_iterator->context,
&ccache_iterator->cursor));
}
-
+
if (!err) {
*out_ccache_iterator = ccache_iterator;
ccache_iterator = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_iterator_next (kim_ccache_iterator in_ccache_iterator,
- kim_ccache *out_ccache)
+ kim_ccache *out_ccache)
{
kim_error err = KIM_NO_ERROR;
krb5_ccache ccache = NULL;
krb5_error_code terr = krb5_cccol_cursor_next (in_ccache_iterator->context,
in_ccache_iterator->cursor,
&ccache);
-
+
if (!terr) {
err = kim_ccache_create_from_krb5_ccache (out_ccache,
in_ccache_iterator->context,
*out_ccache = NULL; /* no more ccaches */
} else {
- err = krb5_error (terr);
+ err = krb5_error (in_ccache_iterator->context, terr);
}
}
/* ------------------------------------------------------------------------ */
static kim_error kim_ccache_create_resolve_name (kim_string *out_resolve_name,
- kim_string in_name,
- kim_string in_type)
+ kim_string in_name,
+ kim_string in_type)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
static kim_boolean kim_ccache_k5ccaches_are_equal (krb5_context in_context,
- krb5_ccache in_ccache,
- krb5_context in_compare_to_context,
- krb5_ccache io_compare_to_ccache)
+ krb5_ccache in_ccache,
+ krb5_context in_compare_to_context,
+ krb5_ccache io_compare_to_ccache)
{
kim_boolean equal = FALSE;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_new (kim_ccache *out_ccache,
- kim_identity in_client_identity,
- kim_options in_options)
+ kim_identity in_client_identity,
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
if (!err) {
err = kim_credential_get_client_identity (credential, &client_identity);
}
-
+
if (!err) {
err = kim_credential_store (credential, client_identity, out_ccache);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_new_if_needed (kim_ccache *out_ccache,
- kim_identity in_client_identity,
- kim_options in_options)
+ kim_identity in_client_identity,
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_from_client_identity (kim_ccache *out_ccache,
- kim_identity in_client_identity)
+ kim_identity in_client_identity)
{
kim_error err = KIM_NO_ERROR;
kim_ccache_iterator iterator = NULL;
err = kim_error_create_from_code (KIM_NO_SUCH_PRINCIPAL_ECODE,
string);
}
-
+
kim_string_free (&string);
}
*out_ccache = ccache;
ccache = NULL;
}
-
+
kim_identity_free (&identity);
kim_ccache_free (&ccache);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_from_keytab (kim_ccache *out_ccache,
- kim_identity in_identity,
- kim_options in_options,
- kim_string in_keytab)
+ kim_identity in_identity,
+ kim_options in_options,
+ kim_string in_keytab)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
}
if (!err) {
- err = krb5_error (krb5_init_context (&ccache->context));
+ err = krb5_error (NULL, krb5_init_context (&ccache->context));
}
-
+
if (!err) {
- err = krb5_error (krb5_cc_default (ccache->context, &ccache->ccache));
+ err = krb5_error (ccache->context,
+ krb5_cc_default (ccache->context, &ccache->ccache));
}
-
+
if (!err) {
*out_ccache = ccache;
ccache = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_from_display_name (kim_ccache *out_ccache,
- kim_string in_display_name)
+ kim_string in_display_name)
{
kim_error err = KIM_NO_ERROR;
kim_ccache ccache = NULL;
}
if (!err) {
- err = krb5_error (krb5_init_context (&ccache->context));
+ err = krb5_error (NULL, krb5_init_context (&ccache->context));
}
if (!err) {
- err = krb5_error (krb5_cc_resolve (ccache->context, in_display_name,
+ err = krb5_error (ccache->context,
+ krb5_cc_resolve (ccache->context, in_display_name,
&ccache->ccache));
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_from_type_and_name (kim_ccache *out_ccache,
- kim_string in_type,
- kim_string in_name)
+ kim_string in_type,
+ kim_string in_name)
{
kim_error err = KIM_NO_ERROR;
kim_string resolve_name = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_create_from_krb5_ccache (kim_ccache *out_ccache,
- krb5_context in_krb5_context,
- krb5_ccache in_krb5_ccache)
+ krb5_context in_krb5_context,
+ krb5_ccache in_krb5_ccache)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_copy (kim_ccache *out_ccache,
- kim_ccache in_ccache)
+ kim_ccache in_ccache)
{
kim_error err = KIM_NO_ERROR;
kim_string name = NULL;
if (!err) {
err = kim_ccache_get_name (in_ccache, &name);
}
-
+
if (!err) {
err = kim_ccache_get_type (in_ccache, &type);
}
kim_string_free (&name);
kim_string_free (&type);
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_compare (kim_ccache in_ccache,
- kim_ccache in_compare_to_ccache,
- kim_boolean *out_equal)
+ kim_ccache in_compare_to_ccache,
+ kim_boolean *out_equal)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_krb5_ccache (kim_ccache in_ccache,
- krb5_context in_krb5_context,
- krb5_ccache *out_krb5_ccache)
+ krb5_context in_krb5_context,
+ krb5_ccache *out_krb5_ccache)
{
kim_error err = KIM_NO_ERROR;
kim_string resolve_name = NULL;
}
if (!err) {
- err = krb5_error (krb5_cc_resolve (in_krb5_context, resolve_name,
+ err = krb5_error (in_krb5_context,
+ krb5_cc_resolve (in_krb5_context, resolve_name,
out_krb5_ccache));
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_type (kim_ccache in_ccache,
- kim_string *out_type)
+ kim_string *out_type)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_name (kim_ccache in_ccache,
- kim_string *out_name)
+ kim_string *out_name)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_display_name (kim_ccache in_ccache,
- kim_string *out_display_name)
+ kim_string *out_display_name)
{
kim_error err = KIM_NO_ERROR;
if (!err) {
kim_string type = krb5_cc_get_type (in_ccache->context,
- in_ccache->ccache);
+ in_ccache->ccache);
kim_string name = krb5_cc_get_name (in_ccache->context,
- in_ccache->ccache);
-
+ in_ccache->ccache);
+
err = kim_ccache_create_resolve_name (out_display_name, type, name);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_client_identity (kim_ccache in_ccache,
- kim_identity *out_client_identity)
+ kim_identity *out_client_identity)
{
kim_error err = KIM_NO_ERROR;
krb5_principal principal = NULL;
if (!err && !out_client_identity) { err = param_error (2, "out_client_identity", "NULL"); }
if (!err) {
- err = krb5_error (krb5_cc_get_principal (in_ccache->context,
+ err = krb5_error (in_ccache->context,
+ krb5_cc_get_principal (in_ccache->context,
in_ccache->ccache,
&principal));
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_valid_credential (kim_ccache in_ccache,
- kim_credential *out_credential)
+ kim_credential *out_credential)
{
kim_error err = KIM_NO_ERROR;
kim_credential_iterator iterator = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_start_time (kim_ccache in_ccache,
- kim_time *out_start_time)
+ kim_time *out_start_time)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_expiration_time (kim_ccache in_ccache,
- kim_time *out_expiration_time)
+ kim_time *out_expiration_time)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_get_renewal_expiration_time (kim_ccache in_ccache,
- kim_time *out_renewal_expiration_time)
+ kim_time *out_renewal_expiration_time)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
krb5_ccache environment_ccache = NULL;
krb5_principal client_principal = NULL;
- err = krb5_error (krb5_cc_resolve (io_ccache->context,
+ err = krb5_error (io_ccache->context,
+ krb5_cc_resolve (io_ccache->context,
environment_ccache_name,
&environment_ccache));
/* KRB5CCNAME is set and does not point to this ccache.
* Move the creds and make this kim_ccache_t object refer to that ccache. */
- err = krb5_error (krb5_cc_get_principal (io_ccache->context,
+ err = krb5_error (io_ccache->context,
+ krb5_cc_get_principal (io_ccache->context,
io_ccache->ccache,
&client_principal));
-
+
if (!err) {
- err = krb5_error (krb5_cc_initialize (io_ccache->context,
+ err = krb5_error (io_ccache->context,
+ krb5_cc_initialize (io_ccache->context,
environment_ccache,
client_principal));
}
if (!err) {
- err = krb5_error (krb5_cc_copy_creds (io_ccache->context,
+ err = krb5_error (io_ccache->context,
+ krb5_cc_copy_creds (io_ccache->context,
io_ccache->ccache,
environment_ccache));
}
err = kim_error_create_from_code (KIM_CANT_BECOME_DEFAULT_ECODE,
display_name);
}
-
+
kim_string_free (&display_name);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_verify (kim_ccache in_ccache,
- kim_identity in_service_identity,
- kim_string in_keytab,
- kim_boolean in_fail_if_no_service_key)
+ kim_identity in_service_identity,
+ kim_string in_keytab,
+ kim_boolean in_fail_if_no_service_key)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
-
+
if (!err && !in_ccache) { err = param_error (1, "in_ccache", "NULL"); }
if (!err) {
}
kim_credential_free (&credential);
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_renew (kim_ccache in_ccache,
- kim_options in_options)
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_ccache_validate (kim_ccache in_ccache,
- kim_options in_options)
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
kim_error err = KIM_NO_ERROR;
if (io_ccache && *io_ccache) {
- err = krb5_error (krb5_cc_destroy ((*io_ccache)->context,
+ err = krb5_error ((*io_ccache)->context,
+ krb5_cc_destroy ((*io_ccache)->context,
(*io_ccache)->ccache));
if (!err) {
#include <kim/kim.h>
kim_error kim_ccache_create_from_display_name (kim_ccache *out_ccache,
- kim_string in_display_name);
+ kim_string in_display_name);
kim_error kim_ccache_compare (kim_ccache in_ccache,
- kim_ccache in_compare_to_ccache,
- kim_boolean *out_equal);
+ kim_ccache in_compare_to_ccache,
+ kim_boolean *out_equal);
#endif /* KIM_CCACHE_PRIVATE_H */
}
if (!err) {
- err = krb5_error (krb5_init_context (&credential_iterator->context));
+ err = krb5_error (NULL, krb5_init_context (&credential_iterator->context));
}
if (!err) {
}
if (!err) {
- err = krb5_error (krb5_cc_start_seq_get (credential_iterator->context,
+ err = krb5_error (credential_iterator->context,
+ krb5_cc_start_seq_get (credential_iterator->context,
credential_iterator->ccache,
&credential_iterator->cursor));
}
*out_credential = NULL; /* no more ccaches */
} else {
- err = krb5_error (terr);
+ err = krb5_error (in_credential_iterator->context, terr);
}
}
}
if (!err) {
- err = krb5_error (krb5_init_context (&credential->context));
+ err = krb5_error (NULL, krb5_init_context (&credential->context));
}
if (!err) {
}
if (!err) {
- err = krb5_error (krb5_init_context (&credential->context));
+ err = krb5_error (NULL, krb5_init_context (&credential->context));
}
if (!err) {
}
if (!err) {
- err = kim_options_get_init_cred_options (options, credential->context,
+ err = kim_options_get_init_cred_options (options,
+ credential->context,
&init_cred_options);
}
if (!err) {
if (in_keytab) {
- err = krb5_error (krb5_kt_resolve (credential->context, in_keytab, &keytab));
+ err = krb5_error (credential->context,
+ krb5_kt_resolve (credential->context,
+ in_keytab, &keytab));
} else {
- err = krb5_error (krb5_kt_default (credential->context, &keytab));
+ err = krb5_error (credential->context,
+ krb5_kt_default (credential->context, &keytab));
}
}
if (!err) {
if (in_identity) {
- err = kim_identity_get_krb5_principal (in_identity, credential->context, &principal);
+ err = kim_identity_get_krb5_principal (in_identity,
+ credential->context,
+ &principal);
} else {
krb5_kt_cursor cursor = NULL;
krb5_keytab_entry entry;
kim_boolean entry_allocated = FALSE;
- err = krb5_error (krb5_kt_start_seq_get (credential->context, keytab, &cursor));
+ err = krb5_error (credential->context,
+ krb5_kt_start_seq_get (credential->context,
+ keytab,
+ &cursor));
if (!err) {
- err = krb5_error (krb5_kt_next_entry (credential->context, keytab, &entry, &cursor));
+ err = krb5_error (credential->context,
+ krb5_kt_next_entry (credential->context,
+ keytab,
+ &entry,
+ &cursor));
entry_allocated = (err == KIM_NO_ERROR); /* remember to free later */
}
if (!err) {
- err = krb5_error (krb5_copy_principal (credential->context, entry.principal, &principal));
+ err = krb5_error (credential->context,
+ krb5_copy_principal (credential->context,
+ entry.principal,
+ &principal));
}
if (entry_allocated) { krb5_free_keytab_entry_contents (credential->context, &entry); }
}
if (!err) {
- err = krb5_error (krb5_get_init_creds_keytab (credential->context, &creds, principal, keytab,
- start_time, (char *) service_name, init_cred_options));
+ err = krb5_error (credential->context,
+ krb5_get_init_creds_keytab (credential->context,
+ &creds,
+ principal,
+ keytab,
+ start_time,
+ (char *) service_name,
+ init_cred_options));
if (!err) { free_creds = TRUE; }
}
if (!err) {
- err = krb5_error (krb5_copy_creds (credential->context, &creds, &credential->creds));
+ err = krb5_error (credential->context,
+ krb5_copy_creds (credential->context,
+ &creds,
+ &credential->creds));
}
if (!err) {
/* ------------------------------------------------------------------------ */
kim_error kim_credential_create_from_krb5_creds (kim_credential *out_credential,
- krb5_context in_krb5_context,
- krb5_creds *in_krb5_creds)
+ krb5_context in_krb5_context,
+ krb5_creds *in_krb5_creds)
{
kim_error err = KIM_NO_ERROR;
kim_credential credential = NULL;
}
if (!err) {
- err = krb5_error (krb5_init_context (&credential->context));
+ err = krb5_error (NULL, krb5_init_context (&credential->context));
}
if (!err) {
- err = krb5_error (krb5_copy_creds (credential->context, in_krb5_creds, &credential->creds));
+ err = krb5_error (credential->context,
+ krb5_copy_creds (credential->context,
+ in_krb5_creds,
+ &credential->creds));
}
if (!err) {
}
if (!err) {
- err = krb5_error (krb5_init_context (&credential->context));
+ err = krb5_error (NULL, krb5_init_context (&credential->context));
}
if (!err) {
- err = krb5_error (krb5_copy_creds (credential->context, in_credential->creds, &credential->creds));
+ err = krb5_error (credential->context,
+ krb5_copy_creds (credential->context,
+ in_credential->creds,
+ &credential->creds));
}
if (!err) {
/* ------------------------------------------------------------------------ */
kim_error kim_credential_get_krb5_creds (kim_credential in_credential,
- krb5_context in_krb5_context,
- krb5_creds **out_krb5_creds)
+ krb5_context in_krb5_context,
+ krb5_creds **out_krb5_creds)
{
kim_error err = KIM_NO_ERROR;
if (!err && !out_krb5_creds ) { err = param_error (3, "out_krb5_creds", "NULL"); }
if (!err) {
- err = krb5_error (krb5_copy_creds (in_krb5_context, in_credential->creds, out_krb5_creds));
+ err = krb5_error (in_krb5_context,
+ krb5_copy_creds (in_krb5_context,
+ in_credential->creds,
+ out_krb5_creds));
}
return check_error (err);
if (!err) {
krb5_int32 usec;
- err = krb5_error (krb5_us_timeofday (in_credential->context, &now, &usec));
+ err = krb5_error (in_credential->context,
+ krb5_us_timeofday (in_credential->context,
+ &now, &usec));
}
if (!err) {
} else if (in_credential->creds->addresses) { /* ticket contains addresses */
krb5_address **laddresses = NULL;
- krb5_error_code code = krb5_os_localaddr (in_credential->context, &laddresses);
+ krb5_error_code code = krb5_os_localaddr (in_credential->context,
+ &laddresses);
if (!code) { laddresses = NULL; }
if (laddresses) { /* assume valid if the local host has no addresses */
kim_boolean found_match = FALSE;
kim_count i = 0;
- for (i = 0; in_credential->creds->addresses[0]; i++) {
- if (krb5_address_search (in_credential->context,
- in_credential->creds->addresses[i], laddresses)) {
+ for (i = 0; in_credential->creds->addresses[i]; i++) {
+ if (!krb5_address_search (in_credential->context,
+ in_credential->creds->addresses[i],
+ laddresses)) {
found_match = TRUE;
break;
}
}
}
- if (laddresses) { krb5_free_addresses (in_credential->context, laddresses); }
+ if (laddresses) { krb5_free_addresses (in_credential->context,
+ laddresses); }
}
}
if (!err && !in_client_identity) { err = param_error (2, "in_client_identity", "NULL"); }
if (!err) {
- err = krb5_error (krb5_init_context (&context));
+ err = krb5_error (NULL, krb5_init_context (&context));
}
if (!err) {
char *environment_ccache = getenv ("KRB5CCNAME");
if (environment_ccache) {
- err = krb5_error (krb5_cc_resolve (context, environment_ccache, &k5ccache));
+ err = krb5_error (context,
+ krb5_cc_resolve (context, environment_ccache,
+ &k5ccache));
} else {
kim_ccache ccache = NULL;
- err = kim_ccache_create_from_client_identity (&ccache, in_client_identity);
+ err = kim_ccache_create_from_client_identity (&ccache,
+ in_client_identity);
if (!err) {
err = kim_ccache_get_krb5_ccache (ccache, context, &k5ccache);
} else if (kim_error_get_code (err) == KIM_NO_SUCH_PRINCIPAL_ECODE) {
/* Nothing to replace, toss error and create a new ccache */
kim_error_free (&err);
- err = krb5_error (krb5_cc_new_unique (context, "API", NULL, &k5ccache));
+ err = krb5_error (context,
+ krb5_cc_new_unique (context, "API", NULL,
+ &k5ccache));
if (!err) { destroy_ccache_on_error = TRUE; }
}
}
if (!err) {
- err = krb5_error (krb5_cc_initialize (in_credential->context,
+ err = krb5_error (in_credential->context,
+ krb5_cc_initialize (in_credential->context,
k5ccache, client_principal));
}
if (!err) {
- err = krb5_error (krb5_cc_store_cred (in_credential->context,
+ err = krb5_error (in_credential->context,
+ krb5_cc_store_cred (in_credential->context,
k5ccache, in_credential->creds));
}
if (!err && !in_credential) { err = param_error (1, "in_credential", "NULL"); }
if (!err) {
- err = krb5_error (krb5_init_secure_context (&scontext));
+ err = krb5_error (NULL, krb5_init_secure_context (&scontext));
}
if (!err && in_service_identity) {
}
if (in_keytab) {
- err = krb5_error (krb5_kt_resolve (scontext, in_keytab, &keytab));
+ err = krb5_error (scontext,
+ krb5_kt_resolve (scontext, in_keytab, &keytab));
}
if (!err) {
krb5_verify_init_creds_opt_init (&options);
krb5_verify_init_creds_opt_set_ap_req_nofail (&options, in_fail_if_no_service_key);
- err = krb5_error (krb5_verify_init_creds (scontext, in_credential->creds,
+ err = krb5_error (scontext,
+ krb5_verify_init_creds (scontext, in_credential->creds,
service_principal,
keytab,
NULL /* don't store creds in ccache */,
}
if (!err) {
- err = krb5_error (krb5_cc_new_unique ((*io_credential)->context,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_new_unique ((*io_credential)->context,
"MEMORY", NULL,
&ccache));
}
if (!err) {
- err = krb5_error (krb5_cc_initialize ((*io_credential)->context, ccache,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_initialize ((*io_credential)->context, ccache,
(*io_credential)->creds->client));
}
if (!err) {
- err = krb5_error (krb5_cc_store_cred ((*io_credential)->context, ccache,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_store_cred ((*io_credential)->context, ccache,
(*io_credential)->creds));
}
krb5_creds *renewed_creds = NULL;
kim_boolean free_creds = 0;
- err = krb5_error (krb5_get_renewed_creds ((*io_credential)->context,
+ err = krb5_error ((*io_credential)->context,
+ krb5_get_renewed_creds ((*io_credential)->context,
&creds, (*io_credential)->creds->client,
ccache, (char *) service_name));
if (!err) { free_creds = 1; }
if (!err) {
- err = krb5_error (krb5_copy_creds ((*io_credential)->context, &creds, &renewed_creds));
+ err = krb5_error ((*io_credential)->context,
+ krb5_copy_creds ((*io_credential)->context,
+ &creds, &renewed_creds));
}
if (!err) {
}
if (!err) {
- err = krb5_error (krb5_cc_new_unique ((*io_credential)->context,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_new_unique ((*io_credential)->context,
"MEMORY", NULL,
&ccache));
}
if (!err) {
- err = krb5_error (krb5_cc_initialize ((*io_credential)->context, ccache,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_initialize ((*io_credential)->context, ccache,
(*io_credential)->creds->client));
}
if (!err) {
- err = krb5_error (krb5_cc_store_cred ((*io_credential)->context, ccache,
+ err = krb5_error ((*io_credential)->context,
+ krb5_cc_store_cred ((*io_credential)->context, ccache,
(*io_credential)->creds));
}
krb5_creds *validated_creds = NULL;
kim_boolean free_creds = 0;
- err = krb5_error (krb5_get_validated_creds ((*io_credential)->context,
- &creds, (*io_credential)->creds->client,
- ccache, (char *) service_name));
+ err = krb5_error ((*io_credential)->context,
+ krb5_get_validated_creds ((*io_credential)->context,
+ &creds,
+ (*io_credential)->creds->client,
+ ccache,
+ (char *) service_name));
if (!err) { free_creds = 1; }
if (!err) {
- err = krb5_error (krb5_copy_creds ((*io_credential)->context, &creds, &validated_creds));
+ err = krb5_error ((*io_credential)->context,
+ krb5_copy_creds ((*io_credential)->context,
+ &creds, &validated_creds));
}
if (!err) {
/* ------------------------------------------------------------------------ */
-static inline kim_error kim_error_allocate (kim_error *out_error)
+static inline kim_error kim_error_allocate (kim_error *out_error,
+ kim_error_code in_code)
{
kim_error err = KIM_NO_ERROR;
kim_error error = NULL;
+ /* short circuit out of memory errors so we don't loop */
+ switch (in_code) {
+ case 0:
+ return KIM_NO_ERROR;
+
+ case KIM_OUT_OF_MEMORY_ECODE:
+ case ENOMEM:
+ case KRB5_CC_NOMEM:
+ case ccErrNoMem:
+ // case klMemFullErr:
+ // case memFullErr:
+ return kim_no_memory_error;
+ }
+
if (!err) {
error = malloc (sizeof (*error));
if (!error) {
}
if (!err) {
+ error->code = in_code;
+
*out_error = error;
error = NULL;
}
return check_error (err);
}
+/* ------------------------------------------------------------------------ */
+
+static kim_boolean kim_error_is_builtin (kim_error in_error)
+{
+ return (in_error == KIM_NO_ERROR ||
+ in_error == kim_no_memory_error);
+}
+
#pragma mark -- Helper Functions --
-/* These helper functions exist so we get type checking on the most common errors */
+/* These helper functions exist so we get type checking on common errors */
/* ------------------------------------------------------------------------ */
kim_error _kim_error_create_for_param (kim_string in_function,
- unsigned int in_argument_position,
- kim_string in_argument_name,
- kim_string in_invalid_value)
+ unsigned int in_argument_position,
+ kim_string in_argument_name,
+ kim_string in_invalid_value)
{
return kim_error_create_from_code (KIM_PARAMETER_ECODE,
in_function,
/* ------------------------------------------------------------------------ */
kim_error kim_error_create_from_code (kim_error_code in_code,
- ...)
+ ...)
{
kim_error err = KIM_NO_ERROR;
va_list args;
/* ------------------------------------------------------------------------ */
kim_error kim_error_create_from_code_va (kim_error_code in_code,
- va_list in_args)
+ va_list in_args)
{
kim_error err = KIM_NO_ERROR;
kim_error error = KIM_NO_ERROR;
- kim_string message = NULL;
- /* short circuit out of memory errors so we don't loop */
- switch (in_code) {
- case 0:
- return KIM_NO_ERROR;
-
- case KIM_OUT_OF_MEMORY_ECODE:
- case ENOMEM:
- case KRB5_CC_NOMEM:
- case ccErrNoMem:
-// case klMemFullErr:
-// case memFullErr:
- err = kim_no_memory_error;
- break;
+ if (!err) {
+ err = kim_error_allocate (&error, in_code);
+ }
+
+ if (!err && !kim_error_is_builtin (error)) {
+ err = kim_string_create_from_format_va_retcode (&error->message,
+ error_message (in_code),
+ in_args);
}
if (!err) {
- err = kim_string_create_from_format_va_retcode (&message, error_message (in_code), in_args);
+ err = error;
+ error = NULL; /* take ownership */
}
+ kim_error_free (&error);
+
+ return err;
+}
+
+
+/* ------------------------------------------------------------------------ */
+
+kim_error kim_error_create_from_krb5_error (krb5_context in_context,
+ krb5_error_code in_code)
+{
+ kim_error err = KIM_NO_ERROR;
+ kim_error error = KIM_NO_ERROR;
+
if (!err) {
- err = kim_error_allocate (&error);
+ err = kim_error_allocate (&error, in_code);
+ }
+
+ if (!err && !kim_error_is_builtin (error)) {
+ const char *message = krb5_get_error_message (in_context, in_code);
+
+ err = kim_string_copy (&error->message, message);
+
+ if (message) { krb5_free_error_message (in_context, message); }
}
if (!err) {
- error->code = in_code;
- error->message = message;
- message = NULL; /* take ownership */
-
err = error;
error = NULL; /* take ownership */
}
kim_error_free (&error);
- kim_string_free (&message);
return err;
}
-
+
/* ------------------------------------------------------------------------ */
kim_error kim_error_copy (kim_error *out_error,
- kim_error in_error)
+ kim_error in_error)
{
kim_error err = KIM_NO_ERROR;
kim_error error = KIM_NO_ERROR;
if (!err && !in_error ) { err = param_error (2, "in_error", "NULL"); }
if (!err) {
- if (in_error == kim_no_memory_error) {
- error = kim_no_memory_error;
+ if (kim_error_is_builtin (in_error)) {
+ error = in_error;
} else {
- err = kim_error_allocate (&error);
+ err = kim_error_allocate (&error, in_error->code);
- if (!err) {
- error->code = in_error->code;
- if (in_error->message) {
- err = kim_string_copy (&error->message, in_error->message);
- }
- }
+ if (!err && in_error->message) {
+ err = kim_string_copy (&error->message, in_error->message);
+ }
}
}
return in_error->message;
} else {
- /* Note that kim_no_memory_error will get here because its string is NULL */
+ /* Note: kim_no_memory_error will get here because its string is NULL */
return error_message (in_error->code);
}
}
void kim_error_free (kim_error *io_error)
{
if (io_error && *io_error) {
- if (*io_error != kim_no_memory_error) {
+ if (kim_error_is_builtin (*io_error)) {
kim_string_free (&(*io_error)->message);
- free (*io_error);
+ free (*io_error);
*io_error = KIM_NO_ERROR;
}
}
/* ------------------------------------------------------------------------ */
kim_error _check_error (kim_error in_err,
- kim_string in_function,
- kim_string in_file,
- int in_line)
+ kim_string in_function,
+ kim_string in_file,
+ int in_line)
{
if (in_err) {
kim_error_code code = kim_error_get_code (in_err);
#include <kim/kim.h>
kim_error _kim_error_create_for_param (kim_string in_function,
- unsigned int in_argument_position,
- kim_string in_argument_name,
- kim_string in_invalid_value);
-#define param_error(pos, name, value) _kim_error_create_for_param(__FUNCTION__, \
- pos, name, value)
+ unsigned int in_argument_position,
+ kim_string in_argument_name,
+ kim_string in_invalid_value);
+#define param_error(pos, name, value) _kim_error_create_for_param(__FUNCTION__,\
+ pos, name, \
+ value)
kim_error kim_error_create_from_code (kim_error_code in_code,
...);
kim_error kim_error_create_from_code_va (kim_error_code in_code,
va_list args);
+kim_error kim_error_create_from_krb5_error (krb5_context in_context,
+ krb5_error_code in_code);
-#define ccapi_error(code) kim_error_create_from_code(code)
-#define krb5_error(code) kim_error_create_from_code(code)
-#define gss_error(code) kim_error_create_from_code(code)
-#define os_error(code) kim_error_create_from_code(code)
+#define krb5_error(context,code) kim_error_create_from_krb5_error(context, code)
+#define ccapi_error(code) kim_error_create_from_code(code)
+#define os_error(code) kim_error_create_from_code(code)
kim_error _check_error (kim_error in_err,
- kim_string in_function,
- kim_string in_file,
- int in_line);
+ kim_string in_function,
+ kim_string in_file,
+ int in_line);
#define check_error(err) _check_error(err, __FUNCTION__, __FILE__, __LINE__)
#endif /* KIM_ERROR_PRIVATE_H */
/* ------------------------------------------------------------------------ */
kim_error kim_identity_create_from_string (kim_identity *out_identity,
- kim_string in_string)
+ kim_string in_string)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
if (!err && !in_string ) { err = param_error (2, "in_string", "NULL"); }
-
+
if (!err) {
err = kim_identity_allocate (&identity);
}
if (!err) {
- err = krb5_error (krb5_init_context (&identity->context));
+ err = krb5_error (NULL, krb5_init_context (&identity->context));
}
if (!err) {
if (code == KRB5_PARSE_MALFORMED) {
err = kim_error_create_from_code (KIM_BAD_PRINCIPAL_STRING_ECODE, in_string);
} else if (code) {
- err = krb5_error (code);
+ err = krb5_error (identity->context, code);
}
}
/* ------------------------------------------------------------------------ */
kim_error kim_identity_create_from_components (kim_identity *out_identity,
- kim_string in_realm,
- kim_string in_1st_component,
- ...)
+ kim_string in_realm,
+ kim_string in_1st_component,
+ ...)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
}
if (!err) {
- err = krb5_error (krb5_init_context (&identity->context));
+ err = krb5_error (NULL, krb5_init_context (&identity->context));
}
-
+
if (!err) {
va_list args;
kim_count component_count = 1;
-
+
va_start (args, in_1st_component);
while (va_arg (args, kim_string)) { component_count++; }
va_end (args);
if (!err) {
va_list args;
krb5_int32 i;
-
+
krb5_princ_set_realm_length (context, &principal_data, strlen (in_realm));
krb5_princ_set_realm_data (context, &principal_data, (char *) in_realm);
}
va_end (args);
}
-
+
if (!err) {
/* make a copy that has actually been allocated by the krb5
* library so krb5_free_principal can be called on it */
- err = krb5_error (krb5_copy_principal (identity->context, &principal_data, &identity->principal));
+ err = krb5_error (identity->context,
+ krb5_copy_principal (identity->context,
+ &principal_data,
+ &identity->principal));
}
if (!err) {
/* ------------------------------------------------------------------------ */
-kim_error kim_identity_create_from_krb5_principal (kim_identity *out_identity,
- krb5_context in_krb5_context,
- krb5_principal in_krb5_principal)
+kim_error kim_identity_create_from_krb5_principal (kim_identity *out_identity,
+ krb5_context in_krb5_context,
+ krb5_principal in_krb5_principal)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
}
if (!err) {
- err = krb5_error (krb5_init_context (&identity->context));
+ err = krb5_error (NULL, krb5_init_context (&identity->context));
}
-
+
if (!err) {
- err = krb5_error (krb5_copy_principal (identity->context, in_krb5_principal,
+ err = krb5_error (identity->context,
+ krb5_copy_principal (identity->context,
+ in_krb5_principal,
&identity->principal));
}
/* ------------------------------------------------------------------------ */
kim_error kim_identity_copy (kim_identity *out_identity,
- kim_identity in_identity)
+ kim_identity in_identity)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = KIM_IDENTITY_ANY;
if (!err && !out_identity) { err = param_error (1, "out_identity", "NULL"); }
-
+
if (!err && in_identity != KIM_IDENTITY_ANY) {
err = kim_identity_allocate (&identity);
if (!err) {
- err = krb5_error (krb5_init_context (&identity->context));
+ err = krb5_error (NULL, krb5_init_context (&identity->context));
}
if (!err) {
- err = krb5_error (krb5_copy_principal (identity->context, in_identity->principal,
+ err = krb5_error (identity->context,
+ krb5_copy_principal (identity->context,
+ in_identity->principal,
&identity->principal));
}
}
-
+
if (!err) {
*out_identity = identity;
identity = NULL;
}
-
+
kim_identity_free (&identity);
return check_error (err);
/* ------------------------------------------------------------------------ */
kim_error kim_identity_compare (kim_identity in_identity,
- kim_identity in_compare_to_identity,
- kim_comparison *out_comparison)
+ kim_identity in_compare_to_identity,
+ kim_comparison *out_comparison)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_string (kim_identity in_identity,
- kim_string *out_string)
+ kim_string *out_string)
{
kim_error err = KIM_NO_ERROR;
char *unparsed_name = NULL;
if (!err && !out_string ) { err = param_error (2, "out_string", "NULL"); }
if (!err) {
- err = krb5_error (krb5_unparse_name (in_identity->context,
+ err = krb5_error (in_identity->context,
+ krb5_unparse_name (in_identity->context,
in_identity->principal,
&unparsed_name));
}
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_display_string (kim_identity in_identity,
- kim_string *out_display_string)
+ kim_string *out_display_string)
{
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_realm (kim_identity in_identity,
- kim_string *out_realm_string)
+ kim_string *out_realm_string)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_number_of_components (kim_identity in_identity,
- kim_count *out_number_of_components)
+ kim_count *out_number_of_components)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_component_at_index (kim_identity in_identity,
- kim_count in_index,
- kim_string *out_component_string)
+ kim_count in_index,
+ kim_string *out_component_string)
{
kim_error err = KIM_NO_ERROR;
krb5_data *component = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_identity_get_krb5_principal (kim_identity in_identity,
- krb5_context in_krb5_context,
- krb5_principal *out_krb5_principal)
+kim_error kim_identity_get_krb5_principal (kim_identity in_identity,
+ krb5_context in_krb5_context,
+ krb5_principal *out_krb5_principal)
{
kim_error err = KIM_NO_ERROR;
if (!err && !out_krb5_principal) { err = param_error (3, "out_krb5_principal", "NULL"); }
if (!err) {
- err = krb5_error (krb5_copy_principal (in_identity->context,
+ err = krb5_error (in_identity->context,
+ krb5_copy_principal (in_identity->context,
in_identity->principal,
out_krb5_principal));
}
/* ------------------------------------------------------------------------ */
kim_error kim_identity_get_gss_name (kim_identity in_identity,
- gss_name_t *out_gss_name)
+ gss_name_t *out_gss_name)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_is_tgt_service (kim_identity in_identity,
- kim_boolean *out_is_tgt_service)
+ kim_boolean *out_is_tgt_service)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_change_password (kim_identity in_identity,
- kim_options in_options)
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_identity_change_password_to_password (kim_identity in_identity,
- kim_options in_options,
- kim_string in_new_password)
+ kim_options in_options,
+ kim_string in_new_password)
{
kim_error err = KIM_NO_ERROR;
{
if (io_identity && *io_identity) {
kim_identity identity = *io_identity;
-
+
if (identity->context) {
if (identity->principal) {
krb5_free_principal (identity->context, identity->principal);
kim_error kim_os_identity_create_for_username (kim_identity *out_identity);
kim_error kim_identity_is_tgt_service (kim_identity in_identity,
- kim_boolean *out_is_tgt_service);
+ kim_boolean *out_is_tgt_service);
#endif /* KIM_IDENTITY_PRIVATE_H */
/* ------------------------------------------------------------------------ */
struct kim_options_opaque {
- kim_prompt_callback_t prompt_callback;
+ kim_prompt_callback prompt_callback;
const void *prompt_callback_data;
#warning add prompt responses here
kim_time start_time;
};
struct kim_options_opaque kim_options_initializer = {
- NULL, NULL,
- 0,
- kim_default_lifetime,
- kim_default_renewable,
- kim_default_renewal_lifetime,
- kim_default_forwardable,
- kim_default_proxiable,
- kim_default_addressless,
- NULL };
+NULL, NULL,
+0,
+kim_default_lifetime,
+kim_default_renewable,
+kim_default_renewal_lifetime,
+kim_default_forwardable,
+kim_default_proxiable,
+kim_default_addressless,
+NULL };
/* ------------------------------------------------------------------------ */
if (!err) {
err = kim_options_allocate (&options);
}
-
+
if (!err) {
*out_options = options;
options = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_options_copy (kim_options *out_options,
- kim_options in_options)
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
if (!err && !out_options) { err = param_error (1, "out_options", "NULL"); }
if (!err && !in_options ) { err = param_error (2, "in_options", "NULL"); }
-
+
if (!err) {
err = kim_options_allocate (&options);
}
}
kim_options_free (&options);
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_prompt_callback (kim_options io_options,
- kim_prompt_callback_t in_prompt_callback)
+ kim_prompt_callback in_prompt_callback)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_prompt_callback (kim_options in_options,
- kim_prompt_callback_t *out_prompt_callback)
+ kim_prompt_callback *out_prompt_callback)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_data (kim_options io_options,
- const void *in_data)
+ const void *in_data)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_data (kim_options in_options,
- const void **out_data)
+ const void **out_data)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
-kim_error kim_options_set_prompt_response (kim_options io_options,
- kim_prompt_type_t in_prompt_type,
- void *in_response)
+kim_error kim_options_set_prompt_response (kim_options io_options,
+ kim_prompt_type in_prompt_type,
+ void *in_response)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_prompt_response (kim_options in_options,
- kim_prompt_type_t in_prompt_type,
- void **out_response)
+ kim_prompt_type in_prompt_type,
+ void **out_response)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_start_time (kim_options io_options,
- kim_time in_start_time)
+ kim_time in_start_time)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_start_time (kim_options in_options,
- kim_time *out_start_time)
+ kim_time *out_start_time)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_lifetime (kim_options io_options,
- kim_lifetime in_lifetime)
+ kim_lifetime in_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_lifetime (kim_options in_options,
- kim_lifetime *out_lifetime)
+ kim_lifetime *out_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_renewable (kim_options io_options,
- kim_boolean in_renewable)
+ kim_boolean in_renewable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_renewable (kim_options in_options,
- kim_boolean *out_renewable)
+ kim_boolean *out_renewable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_renewal_lifetime (kim_options io_options,
- kim_lifetime in_renewal_lifetime)
+ kim_lifetime in_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_renewal_lifetime (kim_options in_options,
- kim_lifetime *out_renewal_lifetime)
+ kim_lifetime *out_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_forwardable (kim_options io_options,
- kim_boolean in_forwardable)
+ kim_boolean in_forwardable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_forwardable (kim_options in_options,
- kim_boolean *out_forwardable)
+ kim_boolean *out_forwardable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_proxiable (kim_options io_options,
- kim_boolean in_proxiable)
+ kim_boolean in_proxiable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_proxiable (kim_options in_options,
- kim_boolean *out_proxiable)
+ kim_boolean *out_proxiable)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_addressless (kim_options io_options,
- kim_boolean in_addressless)
+ kim_boolean in_addressless)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_addressless (kim_options in_options,
- kim_boolean *out_addressless)
+ kim_boolean *out_addressless)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_options_set_service_name (kim_options io_options,
- kim_string in_service_name)
+ kim_string in_service_name)
{
kim_error err = KIM_NO_ERROR;
kim_string service_name = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_options_get_service_name (kim_options in_options,
- kim_string *out_service_name)
+ kim_string *out_service_name)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
-kim_error kim_options_get_init_cred_options (kim_options in_options,
- krb5_context in_context,
- krb5_get_init_creds_opt **out_init_cred_options)
+kim_error kim_options_get_init_cred_options (kim_options in_options,
+ krb5_context in_context,
+ krb5_get_init_creds_opt **out_init_cred_options)
{
kim_error err = KIM_NO_ERROR;
krb5_get_init_creds_opt *init_cred_options;
if (!err && !out_init_cred_options) { err = param_error (3, "out_init_cred_options", "NULL"); }
if (!err && !in_options->addressless) {
- err = krb5_error (krb5_os_localaddr (in_context, &addresses));
+ err = krb5_error (in_context,
+ krb5_os_localaddr (in_context, &addresses));
}
-
+
if (!err) {
krb5_get_init_creds_opt_alloc (in_context, &init_cred_options);
krb5_get_init_creds_opt_set_tkt_life (init_cred_options, in_options->lifetime);
krb5_get_init_creds_opt_set_forwardable (init_cred_options, in_options->forwardable);
krb5_get_init_creds_opt_set_proxiable (init_cred_options, in_options->proxiable);
krb5_get_init_creds_opt_set_address_list (init_cred_options, addresses);
-
+
*out_init_cred_options = init_cred_options;
init_cred_options = NULL;
addresses = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_options_free_init_cred_options (krb5_context in_context,
- krb5_get_init_creds_opt **io_init_cred_options)
+kim_error kim_options_free_init_cred_options (krb5_context in_context,
+ krb5_get_init_creds_opt **io_init_cred_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error_code kim_prompt_callback_default (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply)
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply)
{
kim_error err = KIM_NO_ERROR;
kim_error_code code = KIM_NO_ERROR_ECODE;
/* ------------------------------------------------------------------------ */
kim_error_code kim_prompt_callback_gui (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply)
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply)
{
kim_error err = KIM_NO_ERROR;
kim_error_code code = KIM_NO_ERROR_ECODE;
/* ------------------------------------------------------------------------ */
kim_error_code kim_prompt_callback_cli (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply)
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply)
{
kim_error err = KIM_NO_ERROR;
kim_error_code code = KIM_NO_ERROR_ECODE;
/* ------------------------------------------------------------------------ */
kim_error_code kim_prompt_callback_none (kim_options *io_options,
- kim_prompt_type_t in_type,
- kim_string in_title,
- kim_string in_message,
- kim_string in_description,
- void **out_reply)
+ kim_prompt_type in_type,
+ kim_string in_title,
+ kim_string in_message,
+ kim_string in_description,
+ void **out_reply)
{
return KIM_USER_CANCELED_ECODE;
}
kim_error kim_options_create_from_defaults (kim_options *out_options);
-kim_error kim_options_get_init_cred_options (kim_options in_options,
- krb5_context in_context,
- krb5_get_init_creds_opt **out_init_cred_options);
+kim_error kim_options_get_init_cred_options (kim_options in_options,
+ krb5_context in_context,
+ krb5_get_init_creds_opt **out_init_cred_options);
-kim_error kim_options_free_init_cred_options (krb5_context in_context,
- krb5_get_init_creds_opt **io_init_cred_options);
+kim_error kim_options_free_init_cred_options (krb5_context in_context,
+ krb5_get_init_creds_opt **io_init_cred_options);
#endif /* KIM_OPTIONS_PRIVATE_H */
#include "kim_private.h"
#pragma mark -- KIM Favorite Realms --
-
+
struct kim_favorite_identities_opaque {
kim_count count;
kim_identity *identities;
/* ------------------------------------------------------------------------ */
static inline kim_error kim_favorite_identities_resize (kim_favorite_identities io_favorite_identities,
- kim_count in_new_count)
+ kim_count in_new_count)
{
kim_error err = KIM_NO_ERROR;
if (!err && io_favorite_identities->count != in_new_count) {
kim_identity *identities = NULL;
-
+
if (in_new_count == 0) {
if (io_favorite_identities->identities) {
free (io_favorite_identities->identities);
}
kim_favorite_identities_free (&favorite_identities);
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_favorite_identities_copy (kim_favorite_identities *out_favorite_identities,
- kim_favorite_identities in_favorite_identities)
+ kim_favorite_identities in_favorite_identities)
{
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_favorite_identities_get_number_of_identities (kim_favorite_identities in_favorite_identities,
- kim_count *out_number_of_identities)
+ kim_count *out_number_of_identities)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_favorite_identities_get_identity_at_index (kim_favorite_identities in_favorite_identities,
- kim_count in_index,
- kim_identity *out_identity)
+ kim_count in_index,
+ kim_identity *out_identity)
{
kim_error err = KIM_NO_ERROR;
if (!err) {
err = kim_identity_copy (out_identity, in_favorite_identities->identities[in_index]);
}
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_favorite_identities_add_identity (kim_favorite_identities io_favorite_identities,
- kim_identity in_identity)
+ kim_identity in_identity)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_favorite_identities_remove_identity (kim_favorite_identities io_favorite_identities,
- kim_identity in_identity)
+ kim_identity in_identity)
{
kim_error err = KIM_NO_ERROR;
kim_boolean found = FALSE;
io_favorite_identities->count = 0;
io_favorite_identities->identities = NULL;
}
-
+
return check_error (err);
}
};
struct kim_preferences_opaque kim_preferences_initializer = {
- NULL,
- FALSE,
- kim_default_remember_options,
- FALSE,
- kim_default_client_identity,
- FALSE,
- kim_default_remember_client_identity,
- FALSE,
- kim_default_minimum_lifetime,
- kim_default_maximum_lifetime,
- FALSE,
- kim_default_minimum_renewal_lifetime,
- kim_default_maximum_renewal_lifetime,
- FALSE,
- NULL,
- FALSE
+NULL,
+FALSE,
+kim_default_remember_options,
+FALSE,
+kim_default_client_identity,
+FALSE,
+kim_default_remember_client_identity,
+FALSE,
+kim_default_minimum_lifetime,
+kim_default_maximum_lifetime,
+FALSE,
+kim_default_minimum_renewal_lifetime,
+kim_default_maximum_renewal_lifetime,
+FALSE,
+NULL,
+FALSE
};
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_copy (kim_preferences *out_preferences,
- kim_preferences in_preferences)
+ kim_preferences in_preferences)
{
kim_error err = KIM_NO_ERROR;
kim_preferences preferences = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_options (kim_preferences io_preferences,
- kim_options in_options)
+ kim_options in_options)
{
kim_error err = KIM_NO_ERROR;
kim_options options = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_options (kim_preferences in_preferences,
- kim_options *out_options)
+ kim_options *out_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_remember_options (kim_preferences io_preferences,
- kim_boolean in_remember_options)
+ kim_boolean in_remember_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_remember_options (kim_preferences in_preferences,
- kim_boolean *out_remember_options)
+ kim_boolean *out_remember_options)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_client_identity (kim_preferences io_preferences,
- kim_identity in_client_identity)
+ kim_identity in_client_identity)
{
kim_error err = KIM_NO_ERROR;
kim_identity identity = KIM_IDENTITY_ANY;
if (!err && !io_preferences ) { err = param_error (1, "io_preferences", "NULL"); }
/* in_client_identity may be KIM_IDENTITY_ANY */
-
+
if (!err && in_client_identity) {
err = kim_identity_copy (&identity, in_client_identity);
}
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_client_identity (kim_preferences in_preferences,
- kim_identity *out_client_identity)
+ kim_identity *out_client_identity)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_remember_client_identity (kim_preferences io_preferences,
- kim_boolean in_remember_client_identity)
+ kim_boolean in_remember_client_identity)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_remember_client_identity (kim_preferences in_preferences,
- kim_boolean *out_remember_client_identity)
+ kim_boolean *out_remember_client_identity)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_minimum_lifetime (kim_preferences io_preferences,
- kim_lifetime in_minimum_lifetime)
+ kim_lifetime in_minimum_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_minimum_lifetime (kim_preferences in_preferences,
- kim_lifetime *out_minimum_lifetime)
+ kim_lifetime *out_minimum_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_maximum_lifetime (kim_preferences io_preferences,
- kim_lifetime in_maximum_lifetime)
+ kim_lifetime in_maximum_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_maximum_lifetime (kim_preferences in_preferences,
- kim_lifetime *out_maximum_lifetime)
+ kim_lifetime *out_maximum_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_minimum_renewal_lifetime (kim_preferences io_preferences,
- kim_lifetime in_minimum_renewal_lifetime)
+ kim_lifetime in_minimum_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_minimum_renewal_lifetime (kim_preferences in_preferences,
- kim_lifetime *out_minimum_renewal_lifetime)
+ kim_lifetime *out_minimum_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_set_maximum_renewal_lifetime (kim_preferences io_preferences,
- kim_lifetime in_maximum_renewal_lifetime)
+ kim_lifetime in_maximum_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
kim_error kim_preferences_get_maximum_renewal_lifetime (kim_preferences in_preferences,
- kim_lifetime *out_maximum_renewal_lifetime)
+ kim_lifetime *out_maximum_renewal_lifetime)
{
kim_error err = KIM_NO_ERROR;
/* ------------------------------------------------------------------------ */
-kim_error kim_preferences_set_favorite_identities (kim_preferences io_preferences,
- kim_favorite_identities in_favorite_identities)
+kim_error kim_preferences_set_favorite_identities (kim_preferences io_preferences,
+ kim_favorite_identities in_favorite_identities)
{
kim_error err = KIM_NO_ERROR;
kim_favorite_identities favorite_identities = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_preferences_get_favorite_identities (kim_preferences in_preferences,
- kim_favorite_identities *out_favorite_identities)
+kim_error kim_preferences_get_favorite_identities (kim_preferences in_preferences,
+ kim_favorite_identities *out_favorite_identities)
{
kim_error err = KIM_NO_ERROR;
kim_preference_key_maximum_lifetime,
kim_preference_key_minimum_renewal_lifetime,
kim_preference_key_maximum_renewal_lifetime
-} kim_preference_key_t;
+} kim_preference_key;
#define kim_default_lifetime 10*60*60
#define kim_default_renewable TRUE
#define kim_default_maximum_renewal_lifetime 7*24*60*60
-kim_error kim_os_preferences_get_identity_for_key (kim_preference_key_t in_key,
- kim_identity in_hardcoded_default,
- kim_identity *out_identity);
+kim_error kim_os_preferences_get_identity_for_key (kim_preference_key in_key,
+ kim_identity in_hardcoded_default,
+ kim_identity *out_identity);
-kim_error kim_os_preferences_set_identity_for_key (kim_preference_key_t in_key,
- kim_identity in_identity);
+kim_error kim_os_preferences_set_identity_for_key (kim_preference_key in_key,
+ kim_identity in_identity);
-kim_error kim_os_preferences_get_favorite_identities_for_key (kim_preference_key_t in_key,
- kim_favorite_identities in_hardcoded_default,
- kim_favorite_identities *out_favorite_identities);
+kim_error kim_os_preferences_get_favorite_identities_for_key (kim_preference_key in_key,
+ kim_favorite_identities in_hardcoded_default,
+ kim_favorite_identities *out_favorite_identities);
-kim_error kim_os_preferences_set_favorite_identities_for_key (kim_preference_key_t in_key,
- kim_favorite_identities in_favorite_identities);
+kim_error kim_os_preferences_set_favorite_identities_for_key (kim_preference_key in_key,
+ kim_favorite_identities in_favorite_identities);
-kim_error kim_os_preferences_get_time_for_key (kim_preference_key_t in_key,
- kim_time in_hardcoded_default,
- kim_time *out_time);
+kim_error kim_os_preferences_get_time_for_key (kim_preference_key in_key,
+ kim_time in_hardcoded_default,
+ kim_time *out_time);
-kim_error kim_os_preferences_set_time_for_key (kim_preference_key_t in_key,
- kim_time in_time);
+kim_error kim_os_preferences_set_time_for_key (kim_preference_key in_key,
+ kim_time in_time);
-kim_error kim_os_preferences_get_lifetime_for_key (kim_preference_key_t in_key,
- kim_lifetime in_hardcoded_default,
- kim_lifetime *out_lifetime);
+kim_error kim_os_preferences_get_lifetime_for_key (kim_preference_key in_key,
+ kim_lifetime in_hardcoded_default,
+ kim_lifetime *out_lifetime);
-kim_error kim_os_preferences_set_lifetime_for_key (kim_preference_key_t in_key,
- kim_lifetime in_lifetime);
+kim_error kim_os_preferences_set_lifetime_for_key (kim_preference_key in_key,
+ kim_lifetime in_lifetime);
-kim_error kim_os_preferences_get_boolean_for_key (kim_preference_key_t in_key,
- kim_boolean in_hardcoded_default,
- kim_boolean *out_boolean);
+kim_error kim_os_preferences_get_boolean_for_key (kim_preference_key in_key,
+ kim_boolean in_hardcoded_default,
+ kim_boolean *out_boolean);
-kim_error kim_os_preferences_set_boolean_for_key (kim_preference_key_t in_key,
- kim_boolean in_boolean);
+kim_error kim_os_preferences_set_boolean_for_key (kim_preference_key in_key,
+ kim_boolean in_boolean);
#endif /* KIM_PREFERENCES_PRIVATE_H */
} kim_selection_hints_preference_strings;
-kim_error kim_selection_hints_get_preference_strings (kim_selection_hints in_selection_hints,
- kim_selection_hints_preference_strings *io_preference_strings);
+kim_error kim_selection_hints_get_preference_strings (kim_selection_hints in_selection_hints,
+ kim_selection_hints_preference_strings *io_preference_strings);
kim_error kim_os_selection_hints_lookup_identity (kim_selection_hints in_selection_hints,
- kim_identity *out_identity);
+ kim_identity *out_identity);
kim_error kim_os_selection_hints_remember_identity (kim_selection_hints in_selection_hints,
- kim_identity in_identity);
+ kim_identity in_identity);
kim_error kim_os_selection_hints_forget_identity (kim_selection_hints in_selection_hints);
#include "kim_private.h"
-/* ------------------------------------------------------------------------ */
-
-static inline kim_error kim_string_allocate (kim_string *out_string,
- kim_count in_length)
-{
- kim_error err = KIM_NO_ERROR;
- kim_string string = NULL;
-
- if (!err && !out_string) { err = param_error (1, "out_string", "NULL"); }
-
- if (!err) {
- string = calloc (in_length, sizeof (char *));
- if (!string) { err = os_error (errno); }
- }
-
- if (!err) {
- *out_string = string;
- string = NULL;
- }
-
- kim_string_free (&string);
-
- return check_error (err);
-}
-
/* ------------------------------------------------------------------------ */
kim_error kim_string_create_from_format (kim_string *out_string,
kim_error kim_string_create_from_format_va_retcode (kim_string *out_string,
kim_string in_format,
- va_list in_args)
+ va_list in_args)
{
kim_error err = KIM_NO_ERROR;
kim_error kim_string_create_from_format_va (kim_string *out_string,
kim_string in_format,
- va_list in_args)
+ va_list in_args)
{
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
if (!err && !in_format ) { err = param_error (2, "in_format", "NULL"); }
if (!err) {
- err = kim_string_create_from_format_va_retcode (&string, in_format, in_args);
+ err = kim_string_create_from_format_va_retcode (&string,
+ in_format,
+ in_args);
}
if (!err) {
/* ------------------------------------------------------------------------ */
kim_error kim_string_create_from_buffer (kim_string *out_string,
- const char *in_buffer,
+ const char *in_buffer,
kim_count in_length)
{
kim_error err = KIM_NO_ERROR;
if (!err && !in_buffer ) { err = param_error (2, "in_buffer", "NULL"); }
if (!err) {
- err = kim_string_allocate (&string, in_length + 1);
+ string = calloc (in_length + 1, sizeof (char *));
+ if (!string) { err = os_error (ENOMEM); }
}
if (!err) {
if (!err && !in_string ) { err = param_error (2, "in_string", "NULL"); }
if (!err) {
- err = kim_string_allocate (&string, strlen (in_string) + 1);
+ string = calloc (strlen (in_string) + 1, sizeof (char *));
+ if (!string) { err = os_error (ENOMEM); }
}
if (!err) {
kim_string in_compare_to_string,
kim_comparison *out_comparison)
{
- return kim_os_string_compare (in_string, in_compare_to_string, out_comparison);
+ return kim_os_string_compare (in_string,
+ in_compare_to_string,
+ out_comparison);
}
/* ------------------------------------------------------------------------ */
kim_error kim_string_create_from_format (kim_string *out_string,
- kim_string in_format,
- ...);
+ kim_string in_format,
+ ...);
kim_error kim_string_create_from_format_va_retcode (kim_string *out_string,
- kim_string in_format,
- va_list in_args);
+ kim_string in_format,
+ va_list in_args);
kim_error kim_string_create_from_format_va (kim_string *out_string,
- kim_string in_format,
- va_list in_args);
+ kim_string in_format,
+ va_list in_args);
kim_error kim_string_create_from_buffer (kim_string *out_string,
- const char *in_buffer,
- kim_count in_length);
+ const char *in_buffer,
+ kim_count in_length);
kim_error kim_string_prepend (kim_string *io_string,
- kim_string in_prefix);
+ kim_string in_prefix);
kim_error kim_string_append (kim_string *io_string,
- kim_string in_suffix);
+ kim_string in_suffix);
/* OS-specific because it should use UTF8-safe sorting where possible */
kim_error kim_os_string_compare (kim_string in_string,
- kim_string in_compare_to_string,
- kim_comparison *out_comparison);
+ kim_string in_compare_to_string,
+ kim_comparison *out_comparison);
#endif /* KIM_STRING_PRIVATE_H */
/* ------------------------------------------------------------------------ */
-static kim_error kim_os_preferences_cfstring_for_key (kim_preference_key_t in_key,
- CFStringRef *out_kim_string_key,
- CFStringRef *out_kll_string_key)
+static kim_error kim_os_preferences_cfstring_for_key (kim_preference_key in_key,
+ CFStringRef *out_kim_string_key,
+ CFStringRef *out_kll_string_key)
{
kim_error err = KIM_NO_ERROR;
-
+
if (!err && !out_kim_string_key) { err = param_error (2, "out_kim_string_key", "NULL"); }
if (!err && !out_kll_string_key) { err = param_error (3, "out_kll_string_key", "NULL"); }
-
+
if (!err) {
if (in_key == kim_preference_key_lifetime) {
*out_kim_string_key = CFSTR ("CredentialLifetime");
/* ------------------------------------------------------------------------ */
-static kim_error kim_os_preferences_get_value (kim_preference_key_t in_key,
- CFTypeID in_type,
- CFPropertyListRef *out_value)
+static kim_error kim_os_preferences_get_value (kim_preference_key in_key,
+ CFTypeID in_type,
+ CFPropertyListRef *out_value)
{
kim_error err = KIM_NO_ERROR;
if (!err) {
kim_count u, f, h;
-
+
if (!kim_library_allow_home_directory_access()) {
users[0] = kCFPreferencesAnyUser;
users[1] = NULL;
}
if (value) { CFRelease (value); }
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
-static kim_error kim_os_preferences_set_value (kim_preference_key_t in_key,
- CFPropertyListRef in_value)
+static kim_error kim_os_preferences_set_value (kim_preference_key in_key,
+ CFPropertyListRef in_value)
{
kim_error err = KIM_NO_ERROR;
CFStringRef kim_key = NULL;
CFStringRef kll_key = NULL;
-
+
if (!err && !in_value) { err = param_error (2, "in_value", "NULL"); }
if (!err) {
kim_boolean homedir_ok = kim_library_allow_home_directory_access();
CFStringRef user = homedir_ok ? kCFPreferencesCurrentUser : kCFPreferencesAnyUser;
CFStringRef host = homedir_ok ? kCFPreferencesAnyHost : kCFPreferencesCurrentHost;
-
+
CFPreferencesSetValue (kim_key, in_value, KIM_PREFERENCES_FILE, user, host);
if (!CFPreferencesSynchronize (KIM_PREFERENCES_FILE, user, host)) {
err = kim_error_create_from_code (KIM_PREFERENCES_WRITE_ECODE);
}
}
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_get_identity_for_key (kim_preference_key_t in_key,
- kim_identity in_hardcoded_default,
- kim_identity *out_identity)
+kim_error kim_os_preferences_get_identity_for_key (kim_preference_key in_key,
+ kim_identity in_hardcoded_default,
+ kim_identity *out_identity)
{
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_set_identity_for_key (kim_preference_key_t in_key,
- kim_identity in_identity)
+kim_error kim_os_preferences_set_identity_for_key (kim_preference_key in_key,
+ kim_identity in_identity)
{
kim_error err = KIM_NO_ERROR;
CFStringRef value = NULL;
if (!err) {
err = kim_os_preferences_set_value (in_key, value);
}
-
+
if (value) { CFRelease (value); }
kim_string_free (&string);
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_get_favorite_identities_for_key (kim_preference_key_t in_key,
- kim_favorite_identities in_hardcoded_default,
- kim_favorite_identities *out_favorite_identities)
+kim_error kim_os_preferences_get_favorite_identities_for_key (kim_preference_key in_key,
+ kim_favorite_identities in_hardcoded_default,
+ kim_favorite_identities *out_favorite_identities)
{
kim_error err = KIM_NO_ERROR;
CFArrayRef value = NULL;
if (!err) {
if (!value || CFArrayGetCount (value) < 1) {
err = kim_favorite_identities_copy (out_favorite_identities, in_hardcoded_default);
-
+
} else {
kim_favorite_identities favorite_identities = NULL;
CFIndex count = CFArrayGetCount (value);
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_set_favorite_identities_for_key (kim_preference_key_t in_key,
- kim_favorite_identities in_favorite_identities)
+kim_error kim_os_preferences_set_favorite_identities_for_key (kim_preference_key in_key,
+ kim_favorite_identities in_favorite_identities)
{
kim_error err = KIM_NO_ERROR;
kim_count count = 0;
if (!err) {
err = kim_favorite_identities_get_number_of_identities (in_favorite_identities, &count);
}
-
+
if (!err) {
value = CFArrayCreateMutable (kCFAllocatorDefault, count, &kCFTypeArrayCallBacks);
if (!value) { err = os_error (ENOMEM); }
if (!err) {
err = kim_identity_get_string (identity, &string);
}
-
+
if (!err) {
err = kim_os_string_get_cfstring (string, &cfstring);
}
if (!err) {
err = kim_os_preferences_set_value (in_key, value);
}
-
+
if (value) { CFRelease (value); }
return check_error (err);
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_get_time_for_key (kim_preference_key_t in_key,
- kim_time in_hardcoded_default,
- kim_time *out_time)
+kim_error kim_os_preferences_get_time_for_key (kim_preference_key in_key,
+ kim_time in_hardcoded_default,
+ kim_time *out_time)
{
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_set_time_for_key (kim_preference_key_t in_key,
- kim_time in_time)
+kim_error kim_os_preferences_set_time_for_key (kim_preference_key in_key,
+ kim_time in_time)
{
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_get_lifetime_for_key (kim_preference_key_t in_key,
- kim_lifetime in_hardcoded_default,
- kim_lifetime *out_lifetime)
+kim_error kim_os_preferences_get_lifetime_for_key (kim_preference_key in_key,
+ kim_lifetime in_hardcoded_default,
+ kim_lifetime *out_lifetime)
{
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_set_lifetime_for_key (kim_preference_key_t in_key,
- kim_lifetime in_lifetime)
+kim_error kim_os_preferences_set_lifetime_for_key (kim_preference_key in_key,
+ kim_lifetime in_lifetime)
{
kim_error err = KIM_NO_ERROR;
CFNumberRef value = NULL;
}
if (value) { CFRelease (value); }
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_get_boolean_for_key (kim_preference_key_t in_key,
- kim_boolean in_hardcoded_default,
- kim_boolean *out_boolean)
+kim_error kim_os_preferences_get_boolean_for_key (kim_preference_key in_key,
+ kim_boolean in_hardcoded_default,
+ kim_boolean *out_boolean)
{
kim_error err = KIM_NO_ERROR;
CFBooleanRef value = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_preferences_set_boolean_for_key (kim_preference_key_t in_key,
- kim_boolean in_boolean)
+kim_error kim_os_preferences_set_boolean_for_key (kim_preference_key in_key,
+ kim_boolean in_boolean)
{
kim_error err = KIM_NO_ERROR;
CFBooleanRef value = in_boolean ? kCFBooleanTrue : kCFBooleanFalse;
CFStringRef kim_os_string_get_cfstring_for_key (kim_string in_key_string);
kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
- CFStringRef in_cfstring);
+ CFStringRef in_cfstring);
kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string);
+ kim_string in_key_string);
kim_error kim_os_string_get_cfstring (kim_string in_string,
- CFStringRef *out_cfstring);
+ CFStringRef *out_cfstring);
kim_error kim_os_string_compare_to_cfstring (kim_string in_string,
- CFStringRef in_compare_to_cfstring,
- kim_comparison *out_comparison);
+ CFStringRef in_compare_to_cfstring,
+ kim_comparison *out_comparison);
#endif /* KIM_PRIVATE_H */
}
if (value) { CFRelease (value); }
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
static kim_error kim_os_selection_hints_create_dictionary (kim_selection_hints in_selection_hints,
- kim_identity in_identity,
- CFDictionaryRef *out_hints_dictionary)
+ kim_identity in_identity,
+ CFDictionaryRef *out_hints_dictionary)
{
kim_error err = KIM_NO_ERROR;
kim_selection_hints_preference_strings preference_strings = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
if (!err) {
err = kim_identity_get_string (in_identity, &identity_string);
}
-
+
if (!err) {
keys[i] = KIM_APPLICATION_ID_HINT;
err = kim_os_string_get_cfstring (preference_strings.application_identifier, &values[i]);
keys[++i] = KIM_IDENTITY_HINT;
err = kim_os_string_get_cfstring (identity_string, &values[i]);
}
-
+
if (!err && preference_strings.service_identity) {
keys[++i] = KIM_SERVICE_IDENTITY_HINT;
err = kim_os_string_get_cfstring (preference_strings.service_identity, &values[i]);
/* ------------------------------------------------------------------------ */
-static kim_boolean kim_os_selection_hints_compare_hint (kim_string in_string,
- CFStringRef in_value)
+static kim_boolean kim_os_selection_hints_compare_hint (kim_string in_string,
+ CFStringRef in_value)
{
kim_boolean equal = 0;
kim_comparison comparison;
kim_error err = kim_os_string_compare_to_cfstring (in_string, in_value,
- &comparison);
+ &comparison);
if (!err && kim_comparison_is_equal_to (comparison)) {
equal = 1;
kim_debug_printf ("%s: Malformed string in hints dictionary.", __FUNCTION__);
}
}
-
+
return equal;
}
/* ------------------------------------------------------------------------ */
static kim_error kim_os_selection_hints_compare_to_dictionary (kim_selection_hints in_selection_hints,
- CFDictionaryRef in_hints_dictionary,
- kim_boolean *out_hints_equal)
+ CFDictionaryRef in_hints_dictionary,
+ kim_boolean *out_hints_equal)
{
kim_error err = KIM_NO_ERROR;
kim_selection_hints_preference_strings preference_strings = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
/* ------------------------------------------------------------------------ */
static kim_error kim_os_selection_hints_get_dictionary_identity (CFDictionaryRef in_dictionary,
- kim_identity *out_identity)
+ kim_identity *out_identity)
{
kim_error err = KIM_NO_ERROR;
CFStringRef identity_cfstr = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_os_selection_hints_lookup_identity (kim_selection_hints in_selection_hints,
- kim_identity *out_identity)
+ kim_identity *out_identity)
{
kim_error err = KIM_NO_ERROR;
CFArrayRef hints_array = NULL;
err = kim_os_selection_hints_compare_to_dictionary (in_selection_hints,
dictionary,
&found);
- }
-
+ }
+
if (!err && found) {
found_dictionary = dictionary;
}
}
-
+
if (!err && found) {
err = kim_os_selection_hints_get_dictionary_identity (found_dictionary,
out_identity);
}
if (hints_array) { CFRelease (hints_array); }
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_os_selection_hints_remember_identity (kim_selection_hints in_selection_hints,
- kim_identity in_identity)
+ kim_identity in_identity)
{
kim_error err = KIM_NO_ERROR;
CFArrayRef old_hints_array = NULL;
if (!err) {
err = kim_os_selection_hints_get_selection_hints_array (&old_hints_array);
}
-
+
if (!err) {
if (old_hints_array) {
new_hints_array = CFArrayCreateMutableCopy (kCFAllocatorDefault, 0,
err = kim_os_selection_hints_get_dictionary_identity (dictionary,
&identity);
-
+
if (!err) {
err = kim_identity_compare (in_identity, identity, &comparison);
}
err = kim_os_selection_hints_create_dictionary (in_selection_hints,
in_identity,
&new_hint_dictionary);
-
+
if (!err) {
CFArrayInsertValueAtIndex (new_hints_array, 0, new_hint_dictionary);
hints_array_changed = 1;
}
-
+
if (new_hint_dictionary) { CFRelease (new_hint_dictionary); }
}
if (new_hints_array ) { CFRelease (new_hints_array); }
if (old_hints_array ) { CFRelease (old_hints_array); }
-
+
return check_error (err);
}
CFMutableArrayRef new_hints_array = NULL;
CFIndex count = 0;
CFIndex i = 0;
-
+
if (!err && !in_selection_hints) { err = param_error (1, "in_selection_hints", "NULL"); }
if (!err) {
old_hints_array);
if (!new_hints_array) { err = os_error (ENOMEM); }
}
-
+
if (!err) {
count = CFArrayGetCount (new_hints_array);
}
}
if (new_hints_array) { CFRelease (new_hints_array); }
-
+
return check_error (err);
}
if (in_key_string) {
key = CFStringCreateWithCString (kCFAllocatorDefault, in_key_string, kCFStringEncodingASCII);
-
+
if (key) {
// Try to find the key, first searching in the framework, then in the main bundle
CFBundleRef frameworkBundle = CFBundleGetBundleWithIdentifier (CFSTR ("edu.mit.Kerberos"));
if (!value) {
CFBundleRef mainBundle = CFBundleGetMainBundle ();
-
+
if (mainBundle) {
value = kim_os_string_get_cfstring_for_key_and_dictionary (key, mainBundle);
}
/* ------------------------------------------------------------------------ */
-kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
- CFStringRef in_cfstring)
+kim_error kim_os_string_create_from_cfstring (kim_string *out_string,
+ CFStringRef in_cfstring)
{
kim_error err = KIM_NO_ERROR;
kim_string string = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_os_string_create_for_key (kim_string *out_string,
- kim_string in_key_string)
+ kim_string in_key_string)
{
kim_error err = KIM_NO_ERROR;
CFStringRef value = NULL;
/* ------------------------------------------------------------------------ */
-kim_error kim_os_string_get_cfstring (kim_string in_string,
- CFStringRef *out_cfstring)
+kim_error kim_os_string_get_cfstring (kim_string in_string,
+ CFStringRef *out_cfstring)
{
kim_error err = KIM_NO_ERROR;
CFStringRef cfstring = NULL;
/* ------------------------------------------------------------------------ */
kim_error kim_os_string_compare (kim_string in_string,
- kim_string in_compare_to_string,
- kim_comparison *out_comparison)
+ kim_string in_compare_to_string,
+ kim_comparison *out_comparison)
{
kim_error err = KIM_NO_ERROR;
CFStringRef cfstring = NULL;
if (!err) {
err = kim_os_string_get_cfstring (in_string, &cfstring);
}
-
+
if (!err) {
err = kim_os_string_get_cfstring (in_compare_to_string, &compare_to_cfstring);
}
if (cfstring ) { CFRelease (cfstring); }
if (compare_to_cfstring) { CFRelease (compare_to_cfstring); }
-
+
return check_error (err);
}
/* ------------------------------------------------------------------------ */
kim_error kim_os_string_compare_to_cfstring (kim_string in_string,
- CFStringRef in_compare_to_cfstring,
- kim_comparison *out_comparison)
+ CFStringRef in_compare_to_cfstring,
+ kim_comparison *out_comparison)
{
kim_error err = KIM_NO_ERROR;
CFStringRef cfstring = NULL;