Main Page   Modules   Data Structures   File List   Data Fields   Related Pages  

Utilities and portability
[D-BUS internal implementation details]

Utility functions (_dbus_assert(), _dbus_warn(), etc.). More...

Data Structures

struct  DBusBabysitter
 Babysitter implementation details. More...

struct  DBusDirIter
 Internals of directory iterator. More...


Defines

#define _dbus_assert(condition)   _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__)
 Aborts with an error message if the condition is false. More...

#define _dbus_assert_not_reached(explanation)   _dbus_real_assert_not_reached (explanation, __FILE__, __LINE__)
 Aborts with an error message if called. More...

#define _DBUS_N_ELEMENTS(array)   ((int) (sizeof ((array)) / sizeof ((array)[0])))
 Computes the number of elements in a fixed-size array using sizeof(). More...

#define _DBUS_POINTER_TO_INT(pointer)   ((long)(pointer))
 Safely casts a void* to an integer; should only be used on void* that actually contain integers, for example one created with _DBUS_INT_TO_POINTER. More...

#define _DBUS_INT_TO_POINTER(integer)   ((void*)((long)(integer)))
 Safely stuffs an integer into a pointer, to be extracted later with _DBUS_POINTER_TO_INT. More...

#define _DBUS_ZERO(object)   (memset (&(object), '\0', sizeof ((object))))
 Sets all bits in an object to zero. More...

#define _DBUS_INT_MIN   (-_DBUS_INT_MAX - 1)
 Minimum value of type "int".

#define _DBUS_INT_MAX   2147483647
 Maximum value of type "int".

#define _DBUS_LOCK_NAME(name)   _dbus_lock_##name
 Expands to name of a global lock variable.

#define _DBUS_DEFINE_GLOBAL_LOCK(name)   DBusMutex *_dbus_lock_##name
 Defines a global lock variable with the given name. More...

#define _DBUS_DECLARE_GLOBAL_LOCK(name)   extern DBusMutex *_dbus_lock_##name
 Expands to declaration of a global lock defined with _DBUS_DEFINE_GLOBAL_LOCK. More...

#define _DBUS_LOCK(name)   dbus_mutex_lock (_dbus_lock_##name)
 Locks a global lock.

#define _DBUS_UNLOCK(name)   dbus_mutex_unlock (_dbus_lock_##name)
 Unlocks a global lock.

#define LIVE_CHILDREN(sitter)   ((sitter)->socket_to_babysitter >= 0 || (sitter)->error_pipe_from_child >= 0)
 Macro returns TRUE if the babysitter still has live sockets open to the babysitter child or the grandchild.

#define READ_END   0
 Helps remember which end of the pipe is which.

#define WRITE_END   1
 Helps remember which end of the pipe is which.

#define _DBUS_MAX_SUN_PATH_LENGTH   99
 Maximum length of the path to a UNIX domain socket, sockaddr_un::sun_path member. More...

#define NANOSECONDS_PER_SECOND   1000000000
 nanoseconds in a second.

#define MICROSECONDS_PER_SECOND   1000000
 microseconds in a second.

#define MILLISECONDS_PER_SECOND   1000
 milliseconds in a second.

#define NANOSECONDS_PER_MILLISECOND   1000000
 nanoseconds in a millisecond.

#define MICROSECONDS_PER_MILLISECOND   1000
 microseconds in a millisecond.


Typedefs

typedef void(* DBusForeachFunction )(void *element, void *data)
 Used to iterate over each item in a collection, such as a DBusList.


Enumerations

enum  ReadStatus { READ_STATUS_OK, READ_STATUS_ERROR, READ_STATUS_EOF }
 Enumeration for status of a read(). More...

enum  { CHILD_EXITED, CHILD_FORK_FAILED, CHILD_EXEC_FAILED, CHILD_PID }

Functions

void _dbus_warn (const char *format,...)
 Prints a warning message to stderr. More...

void _dbus_verbose_real (const char *format,...)
 Prints a warning message to stderr if the user has enabled verbose mode. More...

void _dbus_verbose_reset_real (void)
 Reinitializes the verbose logging code, used as a hack in dbus-spawn.c so that a child process re-reads its pid.

char * _dbus_strdup (const char *str)
 Duplicates a string. More...

void * _dbus_memdup (const void *mem, size_t n_bytes)
 Duplicates a block of memory. More...

char ** _dbus_dup_string_array (const char **array)
 Duplicates a string array. More...

dbus_bool_t _dbus_string_array_contains (const char **array, const char *str)
 Checks whether a string array contains the given string. More...

const char * _dbus_type_to_string (int type)
 Returns a string describing the given type. More...

const char * _dbus_header_field_to_string (int header_field)
 Returns a string describing the given name. More...

void _dbus_real_assert (dbus_bool_t condition, const char *condition_text, const char *file, int line)
 Internals of _dbus_assert(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size. More...

void _dbus_real_assert_not_reached (const char *explanation, const char *file, int line)
 Internals of _dbus_assert_not_reached(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size. More...

dbus_bool_t _dbus_test_oom_handling (const char *description, DBusTestMemoryFunction func, void *data)
 Tests how well the given function responds to out-of-memory situations. More...

DBusBabysitter_dbus_babysitter_ref (DBusBabysitter *sitter)
 Increment the reference count on the babysitter object. More...

void _dbus_babysitter_unref (DBusBabysitter *sitter)
 Decrement the reference count on the babysitter object. More...

void _dbus_babysitter_kill_child (DBusBabysitter *sitter)
 Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawned grandchild. More...

dbus_bool_t _dbus_babysitter_get_child_exited (DBusBabysitter *sitter)
 Checks whether the child has exited, without blocking. More...

void _dbus_babysitter_set_child_exit_error (DBusBabysitter *sitter, DBusError *error)
 Sets the DBusError with an explanation of why the spawned child process exited (on a signal, or whatever). More...

dbus_bool_t _dbus_babysitter_set_watch_functions (DBusBabysitter *sitter, DBusAddWatchFunction add_function, DBusRemoveWatchFunction remove_function, DBusWatchToggledFunction toggled_function, void *data, DBusFreeFunction free_data_function)
 Sets watch functions to notify us when the babysitter object needs to read/write file descriptors. More...

dbus_bool_t _dbus_spawn_async_with_babysitter (DBusBabysitter **sitter_p, char **argv, DBusSpawnChildSetupFunc child_setup, void *user_data, DBusError *error)
 Spawns a new process. More...

void _dbus_abort (void)
 Aborts the program with SIGABRT (dumping core).

dbus_bool_t _dbus_setenv (const char *varname, const char *value)
 Wrapper for setenv(). More...

const char * _dbus_getenv (const char *varname)
 Wrapper for getenv(). More...

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. More...

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. More...

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. More...

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. More...

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. More...

int _dbus_connect_tcp_socket (const char *host, dbus_uint32_t port, DBusError *error)
 Creates a socket and connects to a socket at the given host and port. More...

int _dbus_listen_tcp_socket (const char *host, dbus_uint32_t port, DBusError *error)
 Creates a socket and binds it to the given path, then listens on the socket. More...

dbus_bool_t _dbus_read_credentials_unix_socket (int client_fd, DBusCredentials *credentials, DBusError *error)
 Reads a single byte which must be nul (an error occurs otherwise), and reads unix credentials if available. More...

dbus_bool_t _dbus_send_credentials_unix_socket (int server_fd, DBusError *error)
 Sends a single nul byte with our UNIX credentials as ancillary data. More...

int _dbus_accept (int listen_fd)
 Accepts a connection on a listening socket. More...

dbus_bool_t _dbus_user_info_fill (DBusUserInfo *info, const DBusString *username, DBusError *error)
 Gets user info for the given username. More...

dbus_bool_t _dbus_user_info_fill_uid (DBusUserInfo *info, dbus_uid_t uid, DBusError *error)
 Gets user info for the given user ID. More...

void _dbus_user_info_free (DBusUserInfo *info)
 Frees the members of info (but not info itself). More...

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. More...

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. More...

void _dbus_group_info_free (DBusGroupInfo *info)
 Frees the members of info (but not info itself). More...

void _dbus_credentials_clear (DBusCredentials *credentials)
 Sets fields in DBusCredentials to DBUS_PID_UNSET, DBUS_UID_UNSET, DBUS_GID_UNSET. More...

void _dbus_credentials_from_current_process (DBusCredentials *credentials)
 Gets the credentials of the current process. More...

dbus_bool_t _dbus_credentials_match (const DBusCredentials *expected_credentials, const DBusCredentials *provided_credentials)
 Checks whether the provided_credentials are allowed to log in as the expected_credentials. More...

unsigned long _dbus_getpid (void)
 Gets our process ID. More...

dbus_uid_t _dbus_getuid (void)
 Gets our UID. More...

dbus_gid_t _dbus_getgid (void)
 Gets our GID. More...

dbus_int32_t _dbus_atomic_inc (DBusAtomic *atomic)
 Atomically increments an integer. More...

dbus_int32_t _dbus_atomic_dec (DBusAtomic *atomic)
 Atomically decrement an integer. More...

int _dbus_poll (DBusPollFD *fds, int n_fds, int timeout_milliseconds)
 Wrapper for poll(). More...

void _dbus_sleep_milliseconds (int milliseconds)
 Sleeps the given number of milliseconds. More...

void _dbus_get_current_time (long *tv_sec, long *tv_usec)
 Get current time, as in gettimeofday(). More...

dbus_bool_t _dbus_file_get_contents (DBusString *str, const DBusString *filename, DBusError *error)
 Appends the contents of the given file to the string, returning error code. More...

dbus_bool_t _dbus_string_save_to_file (const DBusString *str, const DBusString *filename, DBusError *error)
 Writes a string out to a file. More...

dbus_bool_t _dbus_create_file_exclusively (const DBusString *filename, DBusError *error)
 Creates the given file, failing if the file already exists. More...

dbus_bool_t _dbus_delete_file (const DBusString *filename, DBusError *error)
 Deletes the given file. More...

dbus_bool_t _dbus_create_directory (const DBusString *filename, DBusError *error)
 Creates a directory; succeeds if the directory is created or already existed. More...

dbus_bool_t _dbus_delete_directory (const DBusString *filename, DBusError *error)
 Removes a directory; Directory must be empty. More...

dbus_bool_t _dbus_concat_dir_and_file (DBusString *dir, const DBusString *next_component)
 Appends the given filename to the given directory. More...

dbus_bool_t _dbus_string_get_dirname (const DBusString *filename, DBusString *dirname)
 Get the directory name from a complete filename. More...

dbus_bool_t _dbus_path_is_absolute (const DBusString *filename)
 Checks whether the filename is an absolute path. More...

DBusDirIter_dbus_directory_open (const DBusString *filename, DBusError *error)
 Open a directory to iterate over. More...

dbus_bool_t _dbus_directory_get_next_file (DBusDirIter *iter, DBusString *filename, DBusError *error)
 Get next file in the directory. More...

void _dbus_directory_close (DBusDirIter *iter)
 Closes a directory iteration.

dbus_bool_t _dbus_generate_random_bytes (DBusString *str, int n_bytes)
 Generates the given number of random bytes, using the best mechanism we can come up with. More...

dbus_bool_t _dbus_generate_random_ascii (DBusString *str, int n_bytes)
 Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII subset. More...

const char * _dbus_strerror (int error_number)
 A wrapper around strerror() because some platforms may be lame and not have strerror(). More...

void _dbus_disable_sigpipe (void)
 signal (SIGPIPE, SIG_IGN);.

void _dbus_fd_set_close_on_exec (int fd)
 Sets the file descriptor to be close on exec. More...

const char * _dbus_error_from_errno (int error_number)
 Converts a UNIX errno into a DBusError name. More...

void _dbus_exit (int code)
 Exit the process, returning the given value. More...

dbus_bool_t _dbus_stat (const DBusString *filename, DBusStat *statbuf, DBusError *error)
 stat() wrapper. More...

dbus_bool_t _dbus_full_duplex_pipe (int *fd1, int *fd2, dbus_bool_t blocking, DBusError *error)
 Creates a full-duplex pipe (as in socketpair()). More...

dbus_bool_t _dbus_close (int fd, DBusError *error)
 Closes a file descriptor. More...

dbus_bool_t _dbus_set_fd_nonblocking (int fd, DBusError *error)
 Sets a file descriptor to be nonblocking. More...

void _dbus_print_backtrace (void)
 On GNU libc systems, print a crude backtrace to the verbose log. More...

dbus_bool_t _dbus_become_daemon (const DBusString *pidfile, DBusError *error)
 Does the chdir, fork, setsid, etc. More...

dbus_bool_t _dbus_write_pid_file (const DBusString *filename, unsigned long pid, DBusError *error)
 Creates a file containing the process ID. More...

dbus_bool_t _dbus_change_identity (dbus_uid_t uid, dbus_gid_t gid, DBusError *error)
 Changes the user and group the bus is running as. More...

void _dbus_set_signal_handler (int sig, DBusSignalHandler handler)
 Installs a UNIX signal handler. More...

dbus_bool_t _dbus_sysdeps_test (void)
 Unit test for dbus-sysdeps.c. More...

void _dbus_user_database_lock_system (void)
 Locks global system user database.

void _dbus_user_database_unlock_system (void)
 Unlocks global system user database.

DBusUserDatabase_dbus_user_database_get_system (void)
 Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system()). More...

dbus_bool_t _dbus_username_from_current_process (const DBusString **username)
 Gets username of user owning current process. More...

dbus_bool_t _dbus_homedir_from_current_process (const DBusString **homedir)
 Gets homedir of user owning current process. More...

dbus_bool_t _dbus_get_user_id (const DBusString *username, dbus_uid_t *uid)
 Gets user ID given username. More...

dbus_bool_t _dbus_get_group_id (const DBusString *groupname, dbus_gid_t *gid)
 Gets group ID given groupname. More...

dbus_bool_t _dbus_homedir_from_username (const DBusString *username, DBusString *homedir)
 Gets the home directory for the given user. More...

dbus_bool_t _dbus_uid_from_string (const DBusString *uid_str, dbus_uid_t *uid)
 Gets a UID from a UID string. More...

dbus_bool_t _dbus_credentials_from_username (const DBusString *username, DBusCredentials *credentials)
 Gets the credentials corresponding to the given username. More...

dbus_bool_t _dbus_credentials_from_uid (dbus_uid_t uid, DBusCredentials *credentials)
 Gets the credentials corresponding to the given UID. More...

DBusUserDatabase_dbus_user_database_new (void)
 Creates a new user database object used to look up and cache user information. More...

DBusUserDatabase_dbus_user_database_ref (DBusUserDatabase *db)
 Increments refcount of user database. More...

void _dbus_user_database_unref (DBusUserDatabase *db)
 Decrements refcount of user database. More...

dbus_bool_t _dbus_user_database_get_groups (DBusUserDatabase *db, dbus_uid_t uid, dbus_gid_t **group_ids, int *n_group_ids, DBusError *error)
 Gets all groups for a particular user. More...

dbus_bool_t _dbus_user_database_get_uid (DBusUserDatabase *db, dbus_uid_t uid, const DBusUserInfo **info, DBusError *error)
 Gets the user information for the given UID, returned user info should not be freed. More...

dbus_bool_t _dbus_user_database_get_gid (DBusUserDatabase *db, dbus_gid_t gid, const DBusGroupInfo **info, DBusError *error)
 Gets the user information for the given GID, returned group info should not be freed. More...

dbus_bool_t _dbus_user_database_get_username (DBusUserDatabase *db, const DBusString *username, const DBusUserInfo **info, DBusError *error)
 Gets the user information for the given username. More...

dbus_bool_t _dbus_user_database_get_groupname (DBusUserDatabase *db, const DBusString *groupname, const DBusGroupInfo **info, DBusError *error)
 Gets the user information for the given group name, returned group info should not be freed. More...


Variables

const char _dbus_no_memory_message [] = "Not enough memory"
 Fixed "out of memory" error message, just to avoid making up a different string every time and wasting space.

const char _dbus_return_if_fail_warning_format []
 String used in _dbus_return_if_fail macro. More...


Detailed Description

Utility functions (_dbus_assert(), _dbus_warn(), etc.).


Define Documentation

#define _dbus_assert condition       _dbus_real_assert ((condition) != 0, #condition, __FILE__, __LINE__)
 

Aborts with an error message if the condition is false.

Parameters:
condition  condition which must be true.

Definition at line 104 of file dbus-internals.h.

#define _dbus_assert_not_reached explanation       _dbus_real_assert_not_reached (explanation, __FILE__, __LINE__)
 

Aborts with an error message if called.

The given explanation will be printed.

Parameters:
explanation  explanation of what happened if the code was reached.

Definition at line 114 of file dbus-internals.h.

#define _DBUS_DECLARE_GLOBAL_LOCK name       extern DBusMutex *_dbus_lock_##name
 

Expands to declaration of a global lock defined with _DBUS_DEFINE_GLOBAL_LOCK.

The lock must be added to the list to initialize in dbus_threads_init().

Definition at line 254 of file dbus-internals.h.

#define _DBUS_DEFINE_GLOBAL_LOCK name       DBusMutex *_dbus_lock_##name
 

Defines a global lock variable with the given name.

The lock must be added to the list to initialize in dbus_threads_init().

Definition at line 255 of file dbus-internals.h.

#define _DBUS_INT_TO_POINTER integer       ((void*)((long)(integer)))
 

Safely stuffs an integer into a pointer, to be extracted later with _DBUS_POINTER_TO_INT.

Only guaranteed to preserve 32 bits.

Parameters:
integer  the integer to stuff into a pointer.

Definition at line 143 of file dbus-internals.h.

#define _DBUS_MAX_SUN_PATH_LENGTH   99
 

Maximum length of the path to a UNIX domain socket, sockaddr_un::sun_path member.

POSIX requires that all systems support at least 100 bytes here, including the nul termination. We use 99 for the max value to allow for the nul.

We could probably also do sizeof (addr.sun_path) but this way we are the same on all platforms which is probably a good idea.

#define _DBUS_N_ELEMENTS array       ((int) (sizeof ((array)) / sizeof ((array)[0])))
 

Computes the number of elements in a fixed-size array using sizeof().

Parameters:
array  the array to count elements in.

Definition at line 140 of file dbus-internals.h.

#define _DBUS_POINTER_TO_INT pointer       ((long)(pointer))
 

Safely casts a void* to an integer; should only be used on void* that actually contain integers, for example one created with _DBUS_INT_TO_POINTER.

Only guaranteed to preserve 32 bits. (i.e. it's used to store 32-bit ints in pointers, but can't be used to store 64-bit pointers in ints.)

Parameters:
pointer  pointer to extract an integer from.

Definition at line 142 of file dbus-internals.h.

#define _DBUS_ZERO object       (memset (&(object), '\0', sizeof ((object))))
 

Sets all bits in an object to zero.

Parameters:
object  the object to be zeroed.

Definition at line 145 of file dbus-internals.h.


Enumeration Type Documentation

enum ReadStatus
 

Enumeration for status of a read().

Enumeration values:
READ_STATUS_OK  Read succeeded.
READ_STATUS_ERROR  Some kind of error.
READ_STATUS_EOF  EOF returned.

Definition at line 49 of file dbus-spawn.c.


Function Documentation

int _dbus_accept int    listen_fd
 

Accepts a connection on a listening socket.

Handles EINTR for you.

Parameters:
listen_fd  the listen file descriptor
Returns:
the connection fd of the client, or -1 on error

Definition at line 948 of file dbus-sysdeps.c.

dbus_int32_t _dbus_atomic_dec DBusAtomic   atomic
 

Atomically decrement an integer.

Parameters:
atomic  pointer to the integer to decrement
Returns:
the value before decrementing
Todo:
implement arch-specific faster atomic ops

Definition at line 1897 of file dbus-sysdeps.c.

References DBusAtomic::value.

dbus_int32_t _dbus_atomic_inc DBusAtomic   atomic
 

Atomically increments an integer.

Parameters:
atomic  pointer to the integer to increment
Returns:
the value before incrementing
Todo:
implement arch-specific faster atomic ops

Definition at line 1874 of file dbus-sysdeps.c.

References DBusAtomic::value.

dbus_bool_t _dbus_babysitter_get_child_exited DBusBabysitter   sitter
 

Checks whether the child has exited, without blocking.

Parameters:
sitter  the babysitter

Definition at line 586 of file dbus-spawn.c.

References DBusBabysitter::socket_to_babysitter.

void _dbus_babysitter_kill_child DBusBabysitter   sitter
 

Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawned grandchild.

Parameters:
sitter  the babysitter object

Definition at line 564 of file dbus-spawn.c.

References DBusBabysitter::grandchild_pid.

DBusBabysitter* _dbus_babysitter_ref DBusBabysitter   sitter
 

Increment the reference count on the babysitter object.

Parameters:
sitter  the babysitter
Returns:
the babysitter

Definition at line 241 of file dbus-spawn.c.

References DBusBabysitter::refcount.

void _dbus_babysitter_set_child_exit_error DBusBabysitter   sitter,
DBusError   error
 

Sets the DBusError with an explanation of why the spawned child process exited (on a signal, or whatever).

If the child process has not exited, does nothing (error will remain unset).

Parameters:
sitter  the babysitter
error  an error to fill in

Definition at line 608 of file dbus-spawn.c.

References DBusBabysitter::errnum, DBusBabysitter::executable, DBusBabysitter::have_child_status, DBusBabysitter::have_exec_errnum, DBusBabysitter::have_fork_errnum, and DBusBabysitter::status.

dbus_bool_t _dbus_babysitter_set_watch_functions DBusBabysitter   sitter,
DBusAddWatchFunction    add_function,
DBusRemoveWatchFunction    remove_function,
DBusWatchToggledFunction    toggled_function,
void *    data,
DBusFreeFunction    free_data_function
 

Sets watch functions to notify us when the babysitter object needs to read/write file descriptors.

Parameters:
sitter  the babysitter
add_function  function to begin monitoring a new descriptor.
remove_function  function to stop monitoring a descriptor.
toggled_function  function to notify when the watch is enabled/disabled
data  data to pass to add_function and remove_function.
free_data_function  function to be called to free the data.
Returns:
FALSE on failure (no memory)

Definition at line 666 of file dbus-spawn.c.

References DBusBabysitter::watches.

void _dbus_babysitter_unref DBusBabysitter   sitter
 

Decrement the reference count on the babysitter object.

Parameters:
sitter  the babysitter

Definition at line 257 of file dbus-spawn.c.

References DBusBabysitter::error_pipe_from_child, DBusBabysitter::error_watch, DBusBabysitter::executable, DBusBabysitter::refcount, DBusBabysitter::sitter_pid, DBusBabysitter::sitter_watch, DBusBabysitter::socket_to_babysitter, DBusBabysitter::status, and DBusBabysitter::watches.

dbus_bool_t _dbus_become_daemon const DBusString   pidfile,
DBusError   error
 

Does the chdir, fork, setsid, etc.

to become a daemon process.

Parameters:
pidfile  NULL, or pidfile to create
error  return location for errors
Returns:
FALSE on failure

Definition at line 3136 of file dbus-sysdeps.c.

dbus_bool_t _dbus_change_identity dbus_uid_t    uid,
dbus_gid_t    gid,
DBusError   error
 

Changes the user and group the bus is running as.

Parameters:
uid  the new user ID
gid  the new group ID
error  return location for errors
Returns:
FALSE on failure

Definition at line 3279 of file dbus-sysdeps.c.

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 3038 of file dbus-sysdeps.c.

dbus_bool_t _dbus_concat_dir_and_file DBusString   dir,
const DBusString   next_component
 

Appends the given filename to the given directory.

Todo:
it might be cute to collapse multiple '/' such as "foo//" concat "//bar"
Parameters:
dir  the directory name
next_component  the filename
Returns:
TRUE on success

Definition at line 2455 of file dbus-sysdeps.c.

int _dbus_connect_tcp_socket const char *    host,
dbus_uint32_t    port,
DBusError   error
 

Creates a socket and connects to a socket at the given host and port.

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

Parameters:
host  the host name to connect to
port  the prot to connect to
error  return location for error code
Returns:
connection file descriptor or -1 on error

Definition at line 591 of file dbus-sysdeps.c.

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 391 of file dbus-sysdeps.c.

dbus_bool_t _dbus_create_directory const DBusString   filename,
DBusError   error
 

Creates a directory; succeeds if the directory is created or already existed.

Parameters:
filename  directory filename
error  initialized error object
Returns:
TRUE on success

Definition at line 2393 of file dbus-sysdeps.c.

dbus_bool_t _dbus_create_file_exclusively const DBusString   filename,
DBusError   error
 

Creates the given file, failing if the file already exists.

Parameters:
filename  the filename
error  error location
Returns:
TRUE if we created the file and it didn't exist

Definition at line 2320 of file dbus-sysdeps.c.

void _dbus_credentials_clear DBusCredentials   credentials
 

Sets fields in DBusCredentials to DBUS_PID_UNSET, DBUS_UID_UNSET, DBUS_GID_UNSET.

Parameters:
credentials  the credentials object to fill in

Definition at line 1767 of file dbus-sysdeps.c.

References DBusCredentials::gid, DBusCredentials::pid, and DBusCredentials::uid.

void _dbus_credentials_from_current_process DBusCredentials   credentials
 

Gets the credentials of the current process.

Parameters:
credentials  credentials to fill in.

Definition at line 1780 of file dbus-sysdeps.c.

References DBusCredentials::gid, DBusCredentials::pid, and DBusCredentials::uid.

dbus_bool_t _dbus_credentials_from_uid dbus_uid_t    uid,
DBusCredentials   credentials
 

Gets the credentials corresponding to the given UID.

Parameters:
uid  the UID
credentials  credentials to fill in
Returns:
TRUE if the UID existed and we got some credentials

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

References DBusCredentials::gid, DBusCredentials::pid, DBusUserInfo::primary_gid, DBusUserInfo::uid, and DBusCredentials::uid.

dbus_bool_t _dbus_credentials_from_username const DBusString   username,
DBusCredentials   credentials
 

Gets the credentials corresponding to the given username.

Parameters:
username  the username
credentials  credentials to fill in
Returns:
TRUE if the username existed and we got some credentials

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

References DBusCredentials::gid, DBusCredentials::pid, DBusUserInfo::primary_gid, DBusCredentials::uid, and DBusUserInfo::uid.

dbus_bool_t _dbus_credentials_match const DBusCredentials   expected_credentials,
const DBusCredentials   provided_credentials
 

Checks whether the provided_credentials are allowed to log in as the expected_credentials.

Parameters:
expected_credentials  credentials we're trying to log in as
provided_credentials  credentials we have
Returns:
TRUE if we can log in

Definition at line 1804 of file dbus-sysdeps.c.

References DBusCredentials::uid.

dbus_bool_t _dbus_delete_directory const DBusString   filename,
DBusError   error
 

Removes a directory; Directory must be empty.

Parameters:
filename  directory filename
error  initialized error object
Returns:
TRUE on success

Definition at line 2424 of file dbus-sysdeps.c.

dbus_bool_t _dbus_delete_file const DBusString   filename,
DBusError   error
 

Deletes the given file.

Parameters:
filename  the filename
error  error location
Returns:
TRUE if unlink() succeeded

Definition at line 2364 of file dbus-sysdeps.c.

dbus_bool_t _dbus_directory_get_next_file DBusDirIter   iter,
DBusString   filename,
DBusError   error
 

Get next file in the directory.

Will not return "." or ".." on UNIX. If an error occurs, the contents of "filename" are undefined. The error is never set if the function succeeds.

Todo:
for thread safety, I think we have to use readdir_r(). (GLib has the same issue, should file a bug.)
Parameters:
iter  the iterator
filename  string to be set to the next file in the dir
error  return location for error
Returns:
TRUE if filename was filled in with a new filename

Definition at line 2612 of file dbus-sysdeps.c.

References DBusDirIter::d.

DBusDirIter* _dbus_directory_open const DBusString   filename,
DBusError   error
 

Open a directory to iterate over.

Parameters:
filename  the directory name
error  exception return object or NULL
Returns:
new iterator, or NULL on error

Definition at line 2564 of file dbus-sysdeps.c.

References DBusDirIter::d.

char** _dbus_dup_string_array const char **    array
 

Duplicates a string array.

Result may be freed with dbus_free_string_array(). Returns NULL if memory allocation fails. If the array to be duplicated is NULL, returns NULL.

Parameters:
array  array to duplicate.
Returns:
newly-allocated copy.

Definition at line 302 of file dbus-internals.c.

const char* _dbus_error_from_errno int    error_number
 

Converts a UNIX errno into a DBusError name.

Todo:
should cover more errnos, specifically those from open().
Parameters:
error_number  the errno.
Returns:
an error name

Definition at line 2839 of file dbus-sysdeps.c.

void _dbus_exit int    code
 

Exit the process, returning the given value.

Parameters:
code  the exit code

Definition at line 2933 of file dbus-sysdeps.c.

void _dbus_fd_set_close_on_exec int    fd
 

Sets the file descriptor to be close on exec.

Should be called for all file descriptors in D-BUS code.

Parameters:
fd  the file descriptor

Definition at line 2815 of file dbus-sysdeps.c.

dbus_bool_t _dbus_file_get_contents DBusString   str,
const DBusString   filename,
DBusError   error
 

Appends the contents of the given file to the string, returning error code.

At the moment, won't open a file more than a megabyte in size.

Parameters:
str  the string to append to
filename  filename to load
error  place to set an error
Returns:
FALSE if error was set

Definition at line 2078 of file dbus-sysdeps.c.

dbus_bool_t _dbus_full_duplex_pipe int *    fd1,
int *    fd2,
dbus_bool_t    blocking,
DBusError   error
 

Creates a full-duplex pipe (as in socketpair()).

Sets both ends of the pipe nonblocking.

Parameters:
fd1  return location for one end
fd2  return location for the other end
blocking  TRUE if pipe should be blocking
error  error return
Returns:
FALSE on failure (if error is set)

Definition at line 2988 of file dbus-sysdeps.c.

dbus_bool_t _dbus_generate_random_ascii DBusString   str,
int    n_bytes
 

Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII subset.

Parameters:
str  the string
n_bytes  the number of random ASCII bytes to append to string
Returns:
TRUE on success, FALSE if no memory or other failure

Definition at line 2751 of file dbus-sysdeps.c.

dbus_bool_t _dbus_generate_random_bytes DBusString   str,
int    n_bytes
 

Generates the given number of random bytes, using the best mechanism we can come up with.

Parameters:
str  the string
n_bytes  the number of random bytes to append to string
Returns:
TRUE on success, FALSE if no memory

Definition at line 2707 of file dbus-sysdeps.c.

void _dbus_get_current_time long *    tv_sec,
long *    tv_usec
 

Get current time, as in gettimeofday().

Parameters:
tv_sec  return location for number of seconds
tv_usec  return location for number of microseconds (thousandths)

Definition at line 2054 of file dbus-sysdeps.c.

dbus_bool_t _dbus_get_group_id const DBusString   groupname,
dbus_gid_t *    gid
 

Gets group ID given groupname.

Parameters:
groupname  the groupname
gid  return location for GID
Returns:
TRUE if group name existed and we got the GID

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

References DBusGroupInfo::gid.

dbus_bool_t _dbus_get_user_id const DBusString   username,
dbus_uid_t *    uid
 

Gets user ID given username.

Parameters:
username  the username
uid  return location for UID
Returns:
TRUE if username existed and we got the UID

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

References DBusCredentials::uid.

const char* _dbus_getenv const char *    varname
 

Wrapper for getenv().

Parameters:
varname  name of environment variable
Returns:
value of environment variable or NULL if unset

Definition at line 169 of file dbus-sysdeps.c.

dbus_gid_t _dbus_getgid void   
 

Gets our GID.

Returns:
process GID

Definition at line 1842 of file dbus-sysdeps.c.

unsigned long _dbus_getpid void   
 

Gets our process ID.

Returns:
process ID

Definition at line 1824 of file dbus-sysdeps.c.

dbus_uid_t _dbus_getuid void   
 

Gets our UID.

Returns:
process UID

Definition at line 1833 of file dbus-sysdeps.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 1723 of file dbus-sysdeps.c.

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 1742 of file dbus-sysdeps.c.

void _dbus_group_info_free DBusGroupInfo   info
 

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

Parameters:
info  the group info

Definition at line 1755 of file dbus-sysdeps.c.

References DBusGroupInfo::groupname.

const char* _dbus_header_field_to_string int    header_field
 

Returns a string describing the given name.

Parameters:
header_field  the field to describe
Returns:
a constant string describing the field

Definition at line 401 of file dbus-internals.c.

dbus_bool_t _dbus_homedir_from_current_process const DBusString **    homedir
 

Gets homedir of user owning current process.

The returned string is valid until dbus_shutdown() is called.

Parameters:
homedir  place to store pointer to homedir
Returns:
FALSE if no memory

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

dbus_bool_t _dbus_homedir_from_username const DBusString   username,
DBusString   homedir
 

Gets the home directory for the given user.

Parameters:
username  the username
homedir  string to append home directory to
Returns:
TRUE if user existed and we appended their homedir

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

References DBusUserInfo::homedir.

int _dbus_listen_tcp_socket const char *    host,
dbus_uint32_t    port,
DBusError   error
 

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

The socket is set to be nonblocking.

Parameters:
host  the host name to listen on
port  the prot to listen on
error  return location for errors
Returns:
the listening file descriptor or -1 on error

Definition at line 669 of file dbus-sysdeps.c.

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 481 of file dbus-sysdeps.c.

void* _dbus_memdup const void *    mem,
size_t    n_bytes
 

Duplicates a block of memory.

Returns NULL on failure.

Parameters:
mem  memory to copy
n_bytes  number of bytes to copy
Returns:
the copy

Definition at line 279 of file dbus-internals.c.

dbus_bool_t _dbus_path_is_absolute const DBusString   filename
 

Checks whether the filename is an absolute path.

Parameters:
filename  the filename
Returns:
TRUE if an absolute path

Definition at line 2539 of file dbus-sysdeps.c.

int _dbus_poll DBusPollFD   fds,
int    n_fds,
int    timeout_milliseconds
 

Wrapper for poll().

Parameters:
fds  the file descriptors to poll
n_fds  number of descriptors in the array
timeout_milliseconds  timeout or -1 for infinite
Returns:
numbers of fds with revents, or <0 on error

Definition at line 1921 of file dbus-sysdeps.c.

References DBusPollFD::events, DBusPollFD::fd, and DBusPollFD::revents.

void _dbus_print_backtrace void   
 

On GNU libc systems, print a crude backtrace to the verbose log.

On other systems, print "no backtrace support"

Definition at line 3103 of file dbus-sysdeps.c.

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. _dbus_read() can return ENOMEM, even though regular UNIX read doesn't.

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 188 of file dbus-sysdeps.c.

dbus_bool_t _dbus_read_credentials_unix_socket int    client_fd,
DBusCredentials   credentials,
DBusError   error
 

Reads a single byte which must be nul (an error occurs otherwise), and reads unix credentials if available.

Fills in pid/uid/gid with -1 if no credentials are available. Return value indicates whether a byte was read, not whether we got valid credentials. On some systems, such as Linux, reading/writing the byte isn't actually required, but we do it anyway just to avoid multiple codepaths.

Fails if no byte is available, so you must select() first.

The point of the byte is that on some systems we have to use sendmsg()/recvmsg() to transmit credentials.

Parameters:
client_fd  the client file descriptor
credentials  struct to fill with credentials of client
error  location to store error code
Returns:
TRUE on success

Definition at line 790 of file dbus-sysdeps.c.

References DBusCredentials::gid, DBusCredentials::pid, and DBusCredentials::uid.

void _dbus_real_assert dbus_bool_t    condition,
const char *    condition_text,
const char *    file,
int    line
 

Internals of _dbus_assert(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size.

Parameters:
condition  TRUE if assertion succeeded
condition_text  condition as a string
file  file the assertion is in
line  line the assertion is in

Definition at line 446 of file dbus-internals.c.

void _dbus_real_assert_not_reached const char *    explanation,
const char *    file,
int    line
 

Internals of _dbus_assert_not_reached(); it's a function rather than a macro with the inline code so that the assertion failure blocks don't show up in test suite coverage, and to shrink code size.

Parameters:
explanation  what was reached that shouldn't have been
file  file the assertion is in
line  line the assertion is in

Definition at line 470 of file dbus-internals.c.

dbus_bool_t _dbus_send_credentials_unix_socket int    server_fd,
DBusError   error
 

Sends a single nul byte with our UNIX credentials as ancillary data.

Returns TRUE if the data was successfully written. On systems that don't support sending credentials, just writes a byte, doesn't send any credentials. On some systems, such as Linux, reading/writing the byte isn't actually required, but we do it anyway just to avoid multiple codepaths.

Fails if no byte can be written, so you must select() first.

The point of the byte is that on some systems we have to use sendmsg()/recvmsg() to transmit credentials.

Parameters:
server_fd  file descriptor for connection to server
error  return location for error code
Returns:
TRUE if the byte was sent

Definition at line 929 of file dbus-sysdeps.c.

dbus_bool_t _dbus_set_fd_nonblocking int    fd,
DBusError   error
 

Sets a file descriptor to be nonblocking.

Parameters:
fd  the file descriptor.
error  address of error location.
Returns:
TRUE on success.

Definition at line 3065 of file dbus-sysdeps.c.

void _dbus_set_signal_handler int    sig,
DBusSignalHandler    handler
 

Installs a UNIX signal handler.

Parameters:
sig  the signal to handle
handler  the handler

Definition at line 3311 of file dbus-sysdeps.c.

dbus_bool_t _dbus_setenv const char *    varname,
const char *    value
 

Wrapper for setenv().

If the value is NULL, unsets the environment variable.

Todo:
if someone can verify it's safe, we could avoid the memleak when doing an unset.
Parameters:
varname  name of environment variable
value  value of environment variable
Returns:
TRUE on success.

Definition at line 101 of file dbus-sysdeps.c.

void _dbus_sleep_milliseconds int    milliseconds
 

Sleeps the given number of milliseconds.

Parameters:
milliseconds  number of milliseconds

Definition at line 2027 of file dbus-sysdeps.c.

dbus_bool_t _dbus_spawn_async_with_babysitter DBusBabysitter **    sitter_p,
char **    argv,
DBusSpawnChildSetupFunc    child_setup,
void *    user_data,
DBusError   error
 

Spawns a new process.

The executable name and argv[0] are the same, both are provided in argv[0]. The child_setup function is passed the given user_data and is run in the child just before calling exec().

Also creates a "babysitter" which tracks the status of the child process, advising the parent if the child exits. If the spawn fails, no babysitter is created. If sitter_p is NULL, no babysitter is kept.

Parameters:
sitter_p  return location for babysitter or NULL
argv  the executable and arguments
child_setup  function to call in child pre-exec()
user_data  user data for setup function
error  error object to be filled in if function fails
Returns:
TRUE on success, FALSE if error is filled in

Definition at line 998 of file dbus-spawn.c.

References DBusBabysitter::error_pipe_from_child, DBusBabysitter::error_watch, DBusBabysitter::executable, DBusBabysitter::sitter_pid, DBusBabysitter::sitter_watch, DBusBabysitter::socket_to_babysitter, and DBusBabysitter::watches.

dbus_bool_t _dbus_stat const DBusString   filename,
DBusStat   statbuf,
DBusError   error
 

stat() wrapper.

Parameters:
filename  the filename to stat
statbuf  the stat info to fill in
error  return location for error
Returns:
FALSE if error was set

Definition at line 2947 of file dbus-sysdeps.c.

References DBusStat::atime, DBusStat::ctime, DBusStat::gid, DBusStat::mode, DBusStat::mtime, DBusStat::nlink, DBusStat::size, and DBusStat::uid.

char* _dbus_strdup const char *    str
 

Duplicates a string.

Result must be freed with dbus_free(). Returns NULL if memory allocation fails. If the string to be duplicated is NULL, returns NULL.

Parameters:
str  string to duplicate.
Returns:
newly-allocated copy.

Definition at line 251 of file dbus-internals.c.

const char* _dbus_strerror int    error_number
 

A wrapper around strerror() because some platforms may be lame and not have strerror().

Parameters:
error_number  errno.
Returns:
error description.

Definition at line 2787 of file dbus-sysdeps.c.

dbus_bool_t _dbus_string_array_contains const char **    array,
const char *    str
 

Checks whether a string array contains the given string.

Parameters:
array  array to search.
str  string to look for
Returns:
TRUE if array contains string

Definition at line 342 of file dbus-internals.c.

dbus_bool_t _dbus_string_get_dirname const DBusString   filename,
DBusString   dirname
 

Get the directory name from a complete filename.

Parameters:
filename  the filename
dirname  string to append directory name to
Returns:
FALSE if no memory

Definition at line 2491 of file dbus-sysdeps.c.

dbus_bool_t _dbus_string_save_to_file const DBusString   str,
const DBusString   filename,
DBusError   error
 

Writes a string out to a file.

If the file exists, it will be atomically overwritten by the new data.

Parameters:
str  the string to write out
filename  the file to save string to
error  error to be filled in on failure
Returns:
FALSE on failure

Definition at line 2184 of file dbus-sysdeps.c.

dbus_bool_t _dbus_sysdeps_test void   
 

Unit test for dbus-sysdeps.c.

Returns:
TRUE on success.

Definition at line 3375 of file dbus-sysdeps.c.

dbus_bool_t _dbus_test_oom_handling const char *    description,
DBusTestMemoryFunction    func,
void *    data
 

Tests how well the given function responds to out-of-memory situations.

Calls the function repeatedly, failing a different call to malloc() each time. If the function ever returns FALSE, the test fails. The function should return TRUE whenever something valid (such as returning an error, or succeeding) occurs, and FALSE if it gets confused in some way.

Parameters:
description  description of the test used in verbose output
func  function to call
data  data to pass to function
Returns:
TRUE if the function never returns FALSE

Definition at line 522 of file dbus-internals.c.

const char* _dbus_type_to_string int    type
 

Returns a string describing the given type.

Parameters:
type  the type to describe
Returns:
a constant string describing the type

Definition at line 365 of file dbus-internals.c.

dbus_bool_t _dbus_uid_from_string 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 482 of file dbus-userdb.c.

dbus_bool_t _dbus_user_database_get_gid DBusUserDatabase   db,
dbus_gid_t    gid,
const DBusGroupInfo **    info,
DBusError   error
 

Gets the user information for the given GID, returned group info should not be freed.

Parameters:
db  user database
gid  the group ID
info  return location for const ref to group info
error  error location
Returns:
FALSE if error is set

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

dbus_bool_t _dbus_user_database_get_groupname DBusUserDatabase   db,
const DBusString   groupname,
const DBusGroupInfo **    info,
DBusError   error
 

Gets the user information for the given group name, returned group info should not be freed.

Parameters:
db  user database
groupname  the group name
info  return location for const ref to group info
error  error location
Returns:
FALSE if error is set

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

dbus_bool_t _dbus_user_database_get_groups DBusUserDatabase   db,
dbus_uid_t    uid,
dbus_gid_t **    group_ids,
int *    n_group_ids,
DBusError   error
 

Gets all groups for a particular user.

Returns FALSE if no memory, or user isn't known, but always initializes group_ids to a NULL array. Sets error to the reason for returning FALSE.

Parameters:
db  the user database object
uid  the user ID
group_ids  return location for array of group IDs
n_group_ids  return location for length of returned array
error  return location for error
Returns:
TRUE on success

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

References DBusUserInfo::group_ids, and DBusUserInfo::n_group_ids.

DBusUserDatabase* _dbus_user_database_get_system void   
 

Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system()).

Returns:
the database or NULL if no memory

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

dbus_bool_t _dbus_user_database_get_uid DBusUserDatabase   db,
dbus_uid_t    uid,
const DBusUserInfo **    info,
DBusError   error
 

Gets the user information for the given UID, returned user info should not be freed.

Parameters:
db  user database
uid  the user ID
info  return location for const ref to user info
error  error location
Returns:
FALSE if error is set

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

dbus_bool_t _dbus_user_database_get_username DBusUserDatabase   db,
const DBusString   username,
const DBusUserInfo **    info,
DBusError   error
 

Gets the user information for the given username.

Parameters:
db  user database
username  the user name
info  return location for const ref to user info
error  error location
Returns:
FALSE if error is set

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

DBusUserDatabase* _dbus_user_database_new void   
 

Creates a new user database object used to look up and cache user information.

Returns:
new database, or NULL on out of memory

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

References DBusUserDatabase::groups, DBusUserDatabase::groups_by_name, DBusUserDatabase::refcount, DBusUserDatabase::users, and DBusUserDatabase::users_by_name.

DBusUserDatabase* _dbus_user_database_ref DBusUserDatabase   db
 

Increments refcount of user database.

Parameters:
db  the database
Returns:
the database

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

References DBusUserDatabase::refcount.

void _dbus_user_database_unref DBusUserDatabase   db
 

Decrements refcount of user database.

Parameters:
db  the database

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

References DBusUserDatabase::groups, DBusUserDatabase::groups_by_name, DBusUserDatabase::refcount, DBusUserDatabase::users, and DBusUserDatabase::users_by_name.

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 1579 of file dbus-sysdeps.c.

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 1596 of file dbus-sysdeps.c.

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 1610 of file dbus-sysdeps.c.

References DBusUserInfo::group_ids, DBusUserInfo::homedir, and DBusUserInfo::username.

dbus_bool_t _dbus_username_from_current_process const DBusString **    username
 

Gets username of user owning current process.

The returned string is valid until dbus_shutdown() is called.

Parameters:
username  place to store pointer to username
Returns:
FALSE if no memory

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

void _dbus_verbose_real const char *    format,
...   
 

Prints a warning message to stderr if the user has enabled verbose mode.

This is the real function implementation, use _dbus_verbose() macro in code.

Parameters:
format  printf-style format string.

Definition at line 188 of file dbus-internals.c.

void _dbus_warn const char *    format,
...   
 

Prints a warning message to stderr.

Parameters:
format  printf-style format string.

Definition at line 166 of file dbus-internals.c.

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 248 of file dbus-sysdeps.c.

dbus_bool_t _dbus_write_pid_file const DBusString   filename,
unsigned long    pid,
DBusError   error
 

Creates a file containing the process ID.

Parameters:
filename  the filename to write to
pid  our process ID
error  return location for errors
Returns:
FALSE on failure

Definition at line 3223 of file dbus-sysdeps.c.

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 294 of file dbus-sysdeps.c.


Variable Documentation

const char _dbus_return_if_fail_warning_format[]
 

Initial value:

"%lu: arguments to %s() were incorrect, assertion \"%s\" failed in file %s line %d.\n"
"This is normally a bug in some application using the D-BUS library.\n"
String used in _dbus_return_if_fail macro.

Definition at line 428 of file dbus-internals.c.


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