Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

keyring class
[D-BUS internal implementation details]

DBusKeyring data structure. More...

Functions

DBusKeyring * _dbus_keyring_ref (DBusKeyring *keyring)
 Increments reference count of the keyring. More...

void _dbus_keyring_unref (DBusKeyring *keyring)
 Decrements refcount and finalizes if it reaches zero. More...

DBusKeyring * _dbus_keyring_new_homedir (const DBusString *username, const DBusString *context, DBusError *error)
 Creates a new keyring that lives in the ~/.dbus-keyrings directory of the given user. More...

dbus_bool_t _dbus_keyring_validate_context (const DBusString *context)
 Checks whether the context is a valid context. More...

int _dbus_keyring_get_best_key (DBusKeyring *keyring, DBusError *error)
 Gets a recent key to use for authentication. More...

dbus_bool_t _dbus_keyring_is_for_user (DBusKeyring *keyring, const DBusString *username)
 Checks whether the keyring is for the given username. More...

dbus_bool_t _dbus_keyring_get_hex_key (DBusKeyring *keyring, int key_id, DBusString *hex_key)
 Gets the hex-encoded secret key for the given ID. More...


Detailed Description

DBusKeyring data structure.

Types and functions related to DBusKeyring. DBusKeyring is intended to manage cookies used to authenticate clients to servers. This is essentially the "verify that client can read the user's homedir" authentication mechanism. Both client and server must have access to the homedir.

The secret keys are not kept in locked memory, and are written to a file in the user's homedir. However they are transient (only used by a single server instance for a fixed period of time, then discarded). Also, the keys are not sent over the wire.

Todo:
there's a memory leak on some codepath in here, I saw it once when running make check - probably some specific initial cookies present in the cookie file, then depending on what we do with them.

Function Documentation

int _dbus_keyring_get_best_key DBusKeyring   keyring,
DBusError   error
 

Gets a recent key to use for authentication.

If no recent key exists, creates one. Returns the key ID. If a key can't be written to the keyring file so no recent key can be created, returns -1. All valid keys are > 0.

Parameters:
keyring  the keyring
error  error on failure
Returns:
key ID to use for auth, or -1 on failure

Definition at line 967 of file dbus-keyring.c.

References DBusKey::id.

dbus_bool_t _dbus_keyring_get_hex_key DBusKeyring   keyring,
int    key_id,
DBusString   hex_key
 

Gets the hex-encoded secret key for the given ID.

Returns FALSE if not enough memory. Returns TRUE but empty key on any other error such as unknown key ID.

Parameters:
keyring  the keyring
key_id  the key ID
hex_key  string to append hex-encoded key to
Returns:
TRUE if we had enough memory

Definition at line 1025 of file dbus-keyring.c.

References keys, n_keys, and DBusKey::secret.

dbus_bool_t _dbus_keyring_is_for_user DBusKeyring   keyring,
const DBusString   username
 

Checks whether the keyring is for the given username.

Parameters:
keyring  the keyring
username  the username to check
Returns:
TRUE if the keyring belongs to the given user

Definition at line 1006 of file dbus-keyring.c.

References username.

DBusKeyring* _dbus_keyring_new_homedir const DBusString   username,
const DBusString   context,
DBusError   error
 

Creates a new keyring that lives in the ~/.dbus-keyrings directory of the given user.

If the username is NULL, uses the user owning the current process.

Parameters:
username  username to get keyring for, or NULL
context  which keyring to get
error  return location for errors
Returns:
the keyring or NULL on error

Definition at line 711 of file dbus-keyring.c.

References directory, filename, filename_lock, DBusError::message, and username.

DBusKeyring* _dbus_keyring_ref DBusKeyring   keyring
 

Increments reference count of the keyring.

Parameters:
keyring  the keyring
Returns:
the keyring

Definition at line 671 of file dbus-keyring.c.

References refcount.

void _dbus_keyring_unref DBusKeyring   keyring
 

Decrements refcount and finalizes if it reaches zero.

Parameters:
keyring  the keyring

Definition at line 685 of file dbus-keyring.c.

References directory, filename, filename_lock, keys, n_keys, refcount, and username.

dbus_bool_t _dbus_keyring_validate_context const DBusString   context
 

Checks whether the context is a valid context.

Contexts that might cause confusion when used in filenames are not allowed (contexts can't start with a dot or contain dir separators).

Todo:
this is the most inefficient implementation imaginable.
Parameters:
context  the context
Returns:
TRUE if valid

Definition at line 871 of file dbus-keyring.c.


Generated on Wed Jun 9 05:01:28 2004 for D-BUS by doxygen1.2.15