UNIX-specific internal API
[D-Bus secret internal implementation details]

Internal system-dependent API available on UNIX only. More...

Data Structures

struct  DBusUserInfo
 Information about a UNIX user. More...
struct  DBusGroupInfo
 Information about a UNIX group. More...

Typedefs

typedef DBusUserInfo DBusUserInfo
 Information about a UNIX user.
typedef DBusGroupInfo DBusGroupInfo
 Information about a UNIX group.

Functions

dbus_bool_t _dbus_close (int fd, DBusError *error)
 Closes a file descriptor.
int _dbus_read (int fd, DBusString *buffer, int count)
 Thin wrapper around the read() system call that appends the data it reads to the DBusString buffer.
int _dbus_write (int fd, const DBusString *buffer, int start, int len)
 Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for you.
int _dbus_write_two (int fd, const DBusString *buffer1, int start1, int len1, const DBusString *buffer2, int start2, int len2)
 Like _dbus_write() but will use writev() if possible to write both buffers in sequence.
dbus_bool_t _dbus_open_unix_socket (int *fd, DBusError *error)
 Opens a UNIX domain socket (as in the socket() call).
int _dbus_connect_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error)
 Creates a socket and connects it to the UNIX domain socket at the given path.
int _dbus_listen_unix_socket (const char *path, dbus_bool_t abstract, DBusError *error)
 Creates a socket and binds it to the given path, then listens on the socket.
dbus_bool_t _dbus_read_credentials (int client_fd, DBusCredentials *credentials, DBusError *error)
dbus_bool_t _dbus_send_credentials (int server_fd, DBusError *error)
dbus_bool_t _dbus_user_info_fill (DBusUserInfo *info, const DBusString *username, DBusError *error)
 Gets user info for the given username.
dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
 Gets user info for the given user ID.
void _dbus_user_info_free (DBusUserInfo *info)
 Frees the members of info (but not info itself).
dbus_bool_t _dbus_group_info_fill (DBusGroupInfo *info, const DBusString *groupname, DBusError *error)
 Initializes the given DBusGroupInfo struct with information about the given group name.
dbus_bool_t _dbus_group_info_fill_gid (DBusGroupInfo *info, dbus_gid_t gid, DBusError *error)
 Initializes the given DBusGroupInfo struct with information about the given group ID.
void _dbus_group_info_free (DBusGroupInfo *info)
 Frees the members of info (but not info itself).
dbus_uid_t _dbus_getuid (void)
 Gets our UID.
dbus_uid_t _dbus_geteuid (void)
 Gets our effective UID.
dbus_gid_t _dbus_getgid (void)
dbus_bool_t _dbus_parse_uid (const DBusString *uid_str, dbus_uid_t *uid)
 Gets a UID from a UID string.

Detailed Description

Internal system-dependent API available on UNIX only.


Function Documentation

dbus_bool_t _dbus_close ( int  fd,
DBusError error 
)

Closes a file descriptor.

Parameters:
fd the file descriptor
error error object
Returns:
FALSE if error set

Definition at line 2628 of file dbus-sysdeps-unix.c.

References _dbus_error_from_errno(), dbus_set_error(), FALSE, and TRUE.

Referenced by _dbus_close_socket(), _dbus_command_for_pid(), _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_create_file_exclusively(), _dbus_file_get_contents(), _dbus_full_duplex_pipe(), _dbus_generate_random_bytes(), _dbus_listen_tcp_socket(), _dbus_listen_unix_socket(), _dbus_pipe_close(), and _dbus_string_save_to_file().

int _dbus_connect_unix_socket ( const char *  path,
dbus_bool_t  abstract,
DBusError error 
)

Creates a socket and connects it to the UNIX domain socket at the given path.

The connection fd is returned, and is set up as nonblocking.

Uses abstract sockets instead of filesystem-linked sockets if requested (it's possible only on Linux; see "man 7 unix" on Linux). On non-Linux abstract socket usage always fails.

Parameters:
path the path to UNIX domain socket
abstract TRUE to use abstract namespace
error return location for error code
Returns:
connection file descriptor or -1 on error

Definition at line 483 of file dbus-sysdeps-unix.c.

References _dbus_close(), _dbus_error_from_errno(), _dbus_open_unix_socket(), _DBUS_ZERO, DBUS_ERROR_BAD_ADDRESS, DBUS_ERROR_NOT_SUPPORTED, dbus_set_error(), and NULL.

Referenced by _dbus_transport_new_for_domain_socket().

dbus_uid_t _dbus_geteuid ( void   ) 

Gets our effective UID.

Returns:
process effective UID

Definition at line 1772 of file dbus-sysdeps-unix.c.

Referenced by _dbus_append_user_from_current_process(), _dbus_change_to_daemon_user(), _dbus_credentials_add_from_current_process(), and _dbus_unix_user_is_process_owner().

dbus_uid_t _dbus_getuid ( void   ) 

Gets our UID.

Returns:
process UID

Definition at line 1763 of file dbus-sysdeps-unix.c.

dbus_bool_t _dbus_group_info_fill ( DBusGroupInfo info,
const DBusString groupname,
DBusError error 
)

Initializes the given DBusGroupInfo struct with information about the given group name.

Parameters:
info the group info struct
groupname name of group
error the error return
Returns:
FALSE if error is set

Definition at line 967 of file dbus-sysdeps-util-unix.c.

References DBUS_GID_UNSET.

Referenced by _dbus_user_database_lookup_group().

dbus_bool_t _dbus_group_info_fill_gid ( DBusGroupInfo info,
dbus_gid_t  gid,
DBusError error 
)

Initializes the given DBusGroupInfo struct with information about the given group ID.

Parameters:
info the group info struct
gid group ID
error the error return
Returns:
FALSE if error is set

Definition at line 986 of file dbus-sysdeps-util-unix.c.

References NULL.

Referenced by _dbus_user_database_lookup_group().

void _dbus_group_info_free ( DBusGroupInfo info  ) 

Frees the members of info (but not info itself).

Parameters:
info the group info

Definition at line 88 of file dbus-userdb.c.

References dbus_free(), and DBusGroupInfo::groupname.

Referenced by _dbus_group_info_free_allocated().

int _dbus_listen_unix_socket ( const char *  path,
dbus_bool_t  abstract,
DBusError error 
)

Creates a socket and binds it to the given path, then listens on the socket.

The socket is set to be nonblocking.

Uses abstract sockets instead of filesystem-linked sockets if requested (it's possible only on Linux; see "man 7 unix" on Linux). On non-Linux abstract socket usage always fails.

Parameters:
path the socket name
abstract TRUE to use abstract namespace
error return location for errors
Returns:
the listening file descriptor or -1 on error

Definition at line 619 of file dbus-sysdeps-unix.c.

References _dbus_close(), _dbus_error_from_errno(), _dbus_open_unix_socket(), _dbus_warn(), _DBUS_ZERO, DBUS_ERROR_BAD_ADDRESS, DBUS_ERROR_NOT_SUPPORTED, dbus_set_error(), NULL, and TRUE.

Referenced by _dbus_server_new_for_domain_socket().

dbus_bool_t _dbus_open_unix_socket ( int *  fd,
DBusError error 
)

Opens a UNIX domain socket (as in the socket() call).

Does not bind the socket.

Parameters:
fd return location for socket descriptor
error return location for an error
Returns:
FALSE if error is set

Definition at line 128 of file dbus-sysdeps-unix.c.

Referenced by _dbus_connect_unix_socket(), and _dbus_listen_unix_socket().

dbus_bool_t _dbus_parse_uid ( const DBusString uid_str,
dbus_uid_t uid 
)

Gets a UID from a UID string.

Parameters:
uid_str the UID in string form
uid UID to fill in
Returns:
TRUE if successfully filled in UID

Definition at line 1797 of file dbus-sysdeps-unix.c.

References _dbus_string_parse_int(), FALSE, and TRUE.

int _dbus_read ( int  fd,
DBusString buffer,
int  count 
)

Thin wrapper around the read() system call that appends the data it reads to the DBusString buffer.

It appends up to the given count, and returns the same value and same errno as read(). The only exception is that _dbus_read() handles EINTR for you. Also, _dbus_read() can return ENOMEM, even though regular UNIX read doesn't.

Unlike _dbus_read_socket(), _dbus_read() is not available on Windows.

Parameters:
fd the file descriptor to read from
buffer the buffer to append data to
count the amount of data to read
Returns:
the number of bytes read or -1

Definition at line 280 of file dbus-sysdeps-unix.c.

References _dbus_assert, _dbus_string_get_data_len(), _dbus_string_lengthen(), _dbus_string_set_length(), and _dbus_verbose_bytes_of_string().

Referenced by _dbus_command_for_pid(), _dbus_file_get_contents(), _dbus_generate_random_bytes(), _dbus_get_autolaunch_address(), and _dbus_read_socket().

dbus_bool_t _dbus_user_info_fill ( DBusUserInfo info,
const DBusString username,
DBusError error 
)

Gets user info for the given username.

Parameters:
info user info object to initialize
username the username
error error return
Returns:
TRUE on success

Definition at line 1680 of file dbus-sysdeps-unix.c.

References DBUS_UID_UNSET.

Referenced by _dbus_user_database_lookup().

dbus_bool_t _dbus_user_info_fill_uid ( DBusUserInfo info,
dbus_uid_t  uid,
DBusError error 
)

Gets user info for the given user ID.

Parameters:
info user info object to initialize
uid the user ID
error error return
Returns:
TRUE on success

Definition at line 1697 of file dbus-sysdeps-unix.c.

References NULL.

Referenced by _dbus_user_database_lookup().

void _dbus_user_info_free ( DBusUserInfo info  ) 

Frees the members of info (but not info itself).

Parameters:
info the user info struct

Definition at line 75 of file dbus-userdb.c.

References dbus_free(), DBusUserInfo::group_ids, DBusUserInfo::homedir, and DBusUserInfo::username.

Referenced by _dbus_user_info_free_allocated().

int _dbus_write ( int  fd,
const DBusString buffer,
int  start,
int  len 
)

Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for you.

Parameters:
fd the file descriptor to write
buffer the buffer to write data from
start the first byte in the buffer to write
len the number of bytes to try to write
Returns:
the number of bytes written or -1 on error

Definition at line 340 of file dbus-sysdeps-unix.c.

References _dbus_verbose_bytes_of_string().

Referenced by _dbus_pipe_write(), _dbus_string_save_to_file(), _dbus_write_socket(), and _dbus_write_two().

int _dbus_write_two ( int  fd,
const DBusString buffer1,
int  start1,
int  len1,
const DBusString buffer2,
int  start2,
int  len2 
)

Like _dbus_write() but will use writev() if possible to write both buffers in sequence.

The return value is the number of bytes written in the first buffer, plus the number written in the second. If the first buffer is written successfully and an error occurs writing the second, the number of bytes in the first is returned (i.e. the error is ignored), on systems that don't have writev. Handles EINTR for you. The second buffer may be NULL.

Parameters:
fd the file descriptor
buffer1 first buffer
start1 first byte to write in first buffer
len1 number of bytes to write from first buffer
buffer2 second buffer, or NULL
start2 first byte to write in second buffer
len2 number of bytes to write in second buffer
Returns:
total bytes written from both buffers, or -1 on error

Definition at line 386 of file dbus-sysdeps-unix.c.

References _dbus_assert, _dbus_write(), and NULL.

Referenced by _dbus_write_socket_two().


Generated on Tue Feb 24 16:40:41 2009 for D-Bus by  doxygen 1.5.1