Data Structures | |
struct | DBusBabysitter |
Babysitter implementation details. More... | |
struct | DBusDirIter |
Internals of directory iterator. More... | |
Defines | |
#define | _dbus_assert(condition) |
Aborts with an error message if the condition is false. | |
#define | _dbus_assert_not_reached(explanation) |
Aborts with an error message if called. | |
#define | _DBUS_N_ELEMENTS(array) ((int) (sizeof ((array)) / sizeof ((array)[0]))) |
Computes the number of elements in a fixed-size array using sizeof(). | |
#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. | |
#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. | |
#define | _DBUS_ZERO(object) (memset (&(object), '\0', sizeof ((object)))) |
Sets all bits in an object to zero. | |
#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. | |
#define | _DBUS_DECLARE_GLOBAL_LOCK(name) extern DBusMutex *_dbus_lock_##name |
Expands to declaration of a global lock defined with _DBUS_DEFINE_GLOBAL_LOCK. | |
#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. | |
#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. | |
void | _dbus_verbose_real (const char *format,...) |
Prints a warning message to stderr if the user has enabled verbose mode. | |
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. | |
void * | _dbus_memdup (const void *mem, size_t n_bytes) |
Duplicates a block of memory. | |
char ** | _dbus_dup_string_array (const char **array) |
Duplicates a string array. | |
dbus_bool_t | _dbus_string_array_contains (const char **array, const char *str) |
Checks whether a string array contains the given string. | |
const char * | _dbus_type_to_string (int type) |
Returns a string describing the given type. | |
const char * | _dbus_header_field_to_string (int header_field) |
Returns a string describing the given name. | |
void | _dbus_babysitter_ref (DBusBabysitter *sitter) |
Increment the reference count on the babysitter object. | |
void | _dbus_babysitter_unref (DBusBabysitter *sitter) |
Decrement the reference count on the babysitter object. | |
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. | |
dbus_bool_t | _dbus_babysitter_get_child_exited (DBusBabysitter *sitter) |
Checks whether the child has exited, without blocking. | |
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). | |
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. | |
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. | |
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(). | |
const char * | _dbus_getenv (const char *varname) |
Wrapper for getenv(). | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
int | _dbus_accept (int listen_fd) |
Accepts a connection on a listening socket. | |
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). | |
void | _dbus_credentials_clear (DBusCredentials *credentials) |
Sets fields in DBusCredentials to DBUS_PID_UNSET, DBUS_UID_UNSET, DBUS_GID_UNSET. | |
void | _dbus_credentials_from_current_process (DBusCredentials *credentials) |
Gets the credentials of the current process. | |
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. | |
unsigned long | _dbus_getpid (void) |
Gets our process ID. | |
dbus_uid_t | _dbus_getuid (void) |
Gets our UID. | |
dbus_gid_t | _dbus_getgid (void) |
Gets our GID. | |
dbus_int32_t | _dbus_atomic_inc (DBusAtomic *atomic) |
Atomically increments an integer. | |
dbus_int32_t | _dbus_atomic_dec (DBusAtomic *atomic) |
Atomically decrement an integer. | |
int | _dbus_poll (DBusPollFD *fds, int n_fds, int timeout_milliseconds) |
Wrapper for poll(). | |
void | _dbus_sleep_milliseconds (int milliseconds) |
Sleeps the given number of milliseconds. | |
void | _dbus_get_current_time (long *tv_sec, long *tv_usec) |
Get current time, as in gettimeofday(). | |
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. | |
dbus_bool_t | _dbus_string_save_to_file (const DBusString *str, const DBusString *filename, DBusError *error) |
Writes a string out to a file. | |
dbus_bool_t | _dbus_create_file_exclusively (const DBusString *filename, DBusError *error) |
Creates the given file, failing if the file already exists. | |
dbus_bool_t | _dbus_delete_file (const DBusString *filename, DBusError *error) |
Deletes the given file. | |
dbus_bool_t | _dbus_create_directory (const DBusString *filename, DBusError *error) |
Creates a directory; succeeds if the directory is created or already existed. | |
dbus_bool_t | _dbus_concat_dir_and_file (DBusString *dir, const DBusString *next_component) |
Appends the given filename to the given directory. | |
dbus_bool_t | _dbus_string_get_dirname (const DBusString *filename, DBusString *dirname) |
Get the directory name from a complete filename. | |
dbus_bool_t | _dbus_path_is_absolute (const DBusString *filename) |
Checks whether the filename is an absolute path. | |
DBusDirIter * | _dbus_directory_open (const DBusString *filename, DBusError *error) |
Open a directory to iterate over. | |
dbus_bool_t | _dbus_directory_get_next_file (DBusDirIter *iter, DBusString *filename, DBusError *error) |
Get next file in the directory. | |
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. | |
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. | |
const char * | _dbus_strerror (int error_number) |
A wrapper around strerror() because some platforms may be lame and not have strerror(). | |
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. | |
const char * | _dbus_error_from_errno (int error_number) |
Converts a UNIX errno into a DBusError name. | |
void | _dbus_exit (int code) |
Exit the process, returning the given value. | |
dbus_bool_t | _dbus_stat (const DBusString *filename, DBusStat *statbuf, DBusError *error) |
stat() wrapper. | |
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()). | |
dbus_bool_t | _dbus_close (int fd, DBusError *error) |
Closes a file descriptor. | |
dbus_bool_t | _dbus_set_fd_nonblocking (int fd, DBusError *error) |
Sets a file descriptor to be nonblocking. | |
void | _dbus_print_backtrace (void) |
On GNU libc systems, print a crude backtrace to the verbose log. | |
dbus_bool_t | _dbus_become_daemon (const DBusString *pidfile, DBusError *error) |
Does the chdir, fork, setsid, etc. | |
dbus_bool_t | _dbus_write_pid_file (const DBusString *filename, unsigned long pid, DBusError *error) |
Creates a file containing the process ID. | |
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. | |
void | _dbus_set_signal_handler (int sig, DBusSignalHandler handler) |
Installs a UNIX signal handler. | |
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()). | |
dbus_bool_t | _dbus_username_from_current_process (const DBusString **username) |
Gets username of user owning current process. | |
dbus_bool_t | _dbus_homedir_from_current_process (const DBusString **homedir) |
Gets homedir of user owning current process. | |
dbus_bool_t | _dbus_get_user_id (const DBusString *username, dbus_uid_t *uid) |
Gets user ID given username. | |
dbus_bool_t | _dbus_get_group_id (const DBusString *groupname, dbus_gid_t *gid) |
Gets group ID given groupname. | |
dbus_bool_t | _dbus_homedir_from_username (const DBusString *username, DBusString *homedir) |
Gets the home directory for the given user. | |
dbus_bool_t | _dbus_uid_from_string (const DBusString *uid_str, dbus_uid_t *uid) |
Gets a UID from a UID string. | |
dbus_bool_t | _dbus_credentials_from_username (const DBusString *username, DBusCredentials *credentials) |
Gets the credentials corresponding to the given username. | |
dbus_bool_t | _dbus_credentials_from_uid (dbus_uid_t uid, DBusCredentials *credentials) |
Gets the credentials corresponding to the given UID. | |
DBusUserDatabase * | _dbus_user_database_new (void) |
Creates a new user database object used to look up and cache user information. | |
void | _dbus_user_database_ref (DBusUserDatabase *db) |
Increments refcount of user database. | |
void | _dbus_user_database_unref (DBusUserDatabase *db) |
Decrements refcount of user database. | |
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. | |
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. | |
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. | |
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. | |
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. | |
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. | |
const char | _dbus_return_if_fail_warning_format [] |
String used in _dbus_return_if_fail macro. | |
const char | _dbus_no_memory_message [] |
Fixed "out of memory" error message, just to avoid making up a different string every time and wasting space. |
|
|
Aborts with an error message if called. The given explanation will be printed.
Definition at line 109 of file dbus-internals.h. Referenced by _dbus_become_daemon(), _dbus_hash_table_new(), _dbus_keyring_new_homedir(), _dbus_marshal_get_arg_end_pos(), _dbus_mem_pool_dealloc(), _dbus_spawn_async_with_babysitter(), _dbus_timeout_list_remove_timeout(), _dbus_watch_list_remove_watch(), and dbus_connection_dispatch(). |
|
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. |
|
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. |
|
Safely stuffs an integer into a pointer, to be extracted later with _DBUS_POINTER_TO_INT. Only guaranteed to preserve 32 bits.
Definition at line 143 of file dbus-internals.h. Referenced by _dbus_hash_table_insert_int(), _dbus_hash_table_lookup_int(), and _dbus_hash_table_remove_int(). |
|
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. Referenced by _dbus_connect_unix_socket(), and _dbus_listen_unix_socket(). |
|
Computes the number of elements in a fixed-size array using sizeof().
Definition at line 140 of file dbus-internals.h. Referenced by _dbus_hash_table_new(), and _dbus_string_base64_encode(). |
|
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.)
Definition at line 142 of file dbus-internals.h. Referenced by _dbus_hash_iter_get_int_key(). |
|
Sets all bits in an object to zero.
Definition at line 145 of file dbus-internals.h. Referenced by _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_listen_tcp_socket(), and _dbus_listen_unix_socket(). |
|
Enumeration for status of a read().
Definition at line 49 of file dbus-spawn.c. |
|
Accepts a connection on a listening socket. Handles EINTR for you.
Definition at line 951 of file dbus-sysdeps.c. |
|
Atomically decrement an integer.
Definition at line 1900 of file dbus-sysdeps.c. References _DBUS_LOCK, _DBUS_UNLOCK, dbus_int32_t, and DBusAtomic::value. Referenced by _dbus_connection_unref_unlocked(), dbus_connection_unref(), dbus_message_unref(), and dbus_pending_call_unref(). |
|
Atomically increments an integer.
Definition at line 1877 of file dbus-sysdeps.c. References _DBUS_LOCK, _DBUS_UNLOCK, dbus_int32_t, and DBusAtomic::value. Referenced by _dbus_connection_ref_unlocked(), dbus_connection_ref(), dbus_message_ref(), and dbus_pending_call_ref(). |
|
Checks whether the child has exited, without blocking.
Definition at line 583 of file dbus-spawn.c. References FALSE, LIVE_CHILDREN, and DBusBabysitter::socket_to_babysitter. Referenced by _dbus_babysitter_set_child_exit_error(). |
|
Blocks until the babysitter process gives us the PID of the spawned grandchild, then kills the spawned grandchild.
Definition at line 561 of file dbus-spawn.c. References DBusBabysitter::grandchild_pid, LIVE_CHILDREN, and TRUE. |
|
Increment the reference count on the babysitter object.
Definition at line 240 of file dbus-spawn.c. References _dbus_assert, NULL, and DBusBabysitter::refcount. |
|
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).
Definition at line 605 of file dbus-spawn.c. References _dbus_babysitter_get_child_exited(), _dbus_strerror(), dbus_set_error(), DBusBabysitter::errnum, DBusBabysitter::executable, DBusBabysitter::have_child_status, DBusBabysitter::have_exec_errnum, DBusBabysitter::have_fork_errnum, and DBusBabysitter::status. |
|
Sets watch functions to notify us when the babysitter object needs to read/write file descriptors.
Definition at line 663 of file dbus-spawn.c. References _dbus_watch_list_set_functions(), DBusFreeFunction, and DBusBabysitter::watches. |
|
Decrement the reference count on the babysitter object.
Definition at line 254 of file dbus-spawn.c. References _dbus_assert, _dbus_strerror(), _dbus_warn(), _dbus_watch_invalidate(), _dbus_watch_list_free(), _dbus_watch_unref(), dbus_free(), DBusBabysitter::error_pipe_from_child, DBusBabysitter::error_watch, DBusBabysitter::executable, NULL, DBusBabysitter::refcount, DBusBabysitter::sitter_pid, DBusBabysitter::sitter_watch, DBusBabysitter::socket_to_babysitter, DBusBabysitter::status, and DBusBabysitter::watches. Referenced by _dbus_spawn_async_with_babysitter(). |
|
Does the chdir, fork, setsid, etc. to become a daemon process.
Definition at line 3113 of file dbus-sysdeps.c. References _dbus_assert_not_reached, _dbus_error_from_errno(), _dbus_getenv(), _dbus_strerror(), _dbus_write_pid_file(), dbus_set_error(), FALSE, NULL, and TRUE. |
|
Changes the user and group the bus is running as.
Definition at line 3256 of file dbus-sysdeps.c. References _dbus_change_identity(), _dbus_error_from_errno(), _dbus_strerror(), dbus_set_error(), FALSE, and TRUE. Referenced by _dbus_change_identity(). |
|
Closes a file descriptor.
Definition at line 3015 of file dbus-sysdeps.c. References _dbus_error_from_errno(), dbus_set_error(), FALSE, and TRUE. Referenced by _dbus_server_new_for_domain_socket(), _dbus_transport_new_for_domain_socket(), and _dbus_transport_new_for_tcp_socket(). |
|
Appends the given filename to the given directory.
Definition at line 2432 of file dbus-sysdeps.c. References _dbus_string_append_byte(), _dbus_string_copy(), _dbus_string_get_byte(), _dbus_string_get_length(), _dbus_string_shorten(), dbus_bool_t, FALSE, and TRUE. Referenced by _dbus_keyring_new_homedir(), and dbus_server_listen(). |
|
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.
Definition at line 591 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_set_fd_nonblocking(), _dbus_strerror(), _DBUS_ZERO, dbus_set_error(), dbus_uint32_t, and NULL. Referenced by _dbus_transport_new_for_tcp_socket(). |
|
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.
Definition at line 391 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _DBUS_MAX_SUN_PATH_LENGTH, _dbus_set_fd_nonblocking(), _dbus_strerror(), _DBUS_ZERO, dbus_bool_t, and dbus_set_error(). Referenced by _dbus_transport_new_for_domain_socket(). |
|
Creates a directory; succeeds if the directory is created or already existed.
Definition at line 2398 of file dbus-sysdeps.c. References _dbus_strerror(), _dbus_string_get_const_data(), dbus_set_error(), FALSE, and TRUE. Referenced by _dbus_keyring_new_homedir(). |
|
Creates the given file, failing if the file already exists.
Definition at line 2325 of file dbus-sysdeps.c. References _dbus_strerror(), _dbus_string_get_const_data(), dbus_set_error(), FALSE, and TRUE. |
|
Sets fields in DBusCredentials to DBUS_PID_UNSET, DBUS_UID_UNSET, DBUS_GID_UNSET.
Definition at line 1770 of file dbus-sysdeps.c. References DBusCredentials::gid, DBusCredentials::pid, and DBusCredentials::uid. Referenced by _dbus_auth_get_identity(), and _dbus_read_credentials_unix_socket(). |
|
Gets the credentials of the current process.
Definition at line 1783 of file dbus-sysdeps.c. References _dbus_assert, DBusCredentials::gid, DBusCredentials::pid, and DBusCredentials::uid. Referenced by _dbus_transport_get_is_authenticated(). |
|
Gets the credentials corresponding to the given UID.
Definition at line 559 of file dbus-userdb.c. References _dbus_assert, _dbus_user_database_get_system(), _dbus_user_database_get_uid(), _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, DBusCredentials::gid, NULL, DBusCredentials::pid, DBusUserInfo::primary_gid, TRUE, DBusUserInfo::uid, and DBusCredentials::uid. |
|
Gets the credentials corresponding to the given username.
Definition at line 522 of file dbus-userdb.c. References _dbus_user_database_get_system(), _dbus_user_database_get_username(), _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, DBusCredentials::gid, NULL, DBusCredentials::pid, DBusUserInfo::primary_gid, TRUE, DBusCredentials::uid, and DBusUserInfo::uid. Referenced by _dbus_get_user_id(). |
|
Checks whether the provided_credentials are allowed to log in as the expected_credentials.
Definition at line 1807 of file dbus-sysdeps.c. References FALSE, TRUE, and DBusCredentials::uid. Referenced by _dbus_transport_get_is_authenticated(). |
|
Deletes the given file.
Definition at line 2369 of file dbus-sysdeps.c. References _dbus_strerror(), _dbus_string_get_const_data(), dbus_set_error(), FALSE, and TRUE. |
|
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.
Definition at line 2589 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), _dbus_string_append(), _dbus_string_set_length(), DBusDirIter::d, dbus_set_error(), FALSE, NULL, and TRUE. |
|
Open a directory to iterate over.
Definition at line 2541 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), _dbus_string_get_const_data(), DBusDirIter::d, dbus_new0, dbus_set_error(), and NULL. |
|
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.
Definition at line 302 of file dbus-internals.c. References _dbus_strdup(), dbus_free_string_array(), dbus_new0, and NULL. Referenced by _dbus_auth_set_mechanisms(), and dbus_server_set_auth_mechanisms(). |
|
Converts a UNIX errno into a DBusError name.
Definition at line 2816 of file dbus-sysdeps.c. Referenced by _dbus_become_daemon(), _dbus_change_identity(), _dbus_close(), _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_directory_get_next_file(), _dbus_directory_open(), _dbus_file_get_contents(), _dbus_full_duplex_pipe(), _dbus_listen_tcp_socket(), _dbus_listen_unix_socket(), _dbus_read_credentials_unix_socket(), _dbus_set_fd_nonblocking(), _dbus_stat(), _dbus_string_save_to_file(), and _dbus_write_pid_file(). |
|
Exit the process, returning the given value.
Definition at line 2910 of file dbus-sysdeps.c. Referenced by dbus_connection_dispatch(). |
|
Sets the file descriptor to be close on exec. Should be called for all file descriptors in D-BUS code.
Definition at line 2792 of file dbus-sysdeps.c. Referenced by _dbus_server_new_for_domain_socket(), _dbus_server_new_for_tcp_socket(), _dbus_spawn_async_with_babysitter(), _dbus_transport_new_for_domain_socket(), and _dbus_transport_new_for_tcp_socket(). |
|
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.
Definition at line 2083 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_read(), _dbus_strerror(), _dbus_string_get_const_data(), _dbus_string_get_length(), _dbus_string_set_length(), dbus_set_error(), FALSE, and TRUE. |
|
Creates a full-duplex pipe (as in socketpair()). Sets both ends of the pipe nonblocking.
Definition at line 2965 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_set_fd_nonblocking(), _dbus_warn(), dbus_bool_t, dbus_set_error(), FALSE, NULL, and TRUE. Referenced by _dbus_spawn_async_with_babysitter(). |
|
Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII subset.
Definition at line 2728 of file dbus-sysdeps.c. References _dbus_assert, _dbus_generate_random_bytes(), _dbus_string_get_byte(), _dbus_string_get_length(), _dbus_string_set_byte(), _dbus_string_validate_ascii(), FALSE, and TRUE. Referenced by _dbus_string_save_to_file(), and dbus_server_listen(). |
|
Generates the given number of random bytes, using the best mechanism we can come up with.
Definition at line 2684 of file dbus-sysdeps.c. References _dbus_read(), _dbus_string_get_length(), _dbus_string_set_length(), and TRUE. Referenced by _dbus_generate_random_ascii(). |
|
Get current time, as in gettimeofday().
Definition at line 2059 of file dbus-sysdeps.c. References NULL. Referenced by _dbus_connection_block_for_reply(). |
|
Gets group ID given groupname.
Definition at line 408 of file dbus-userdb.c. References _dbus_user_database_get_groupname(), _dbus_user_database_get_system(), _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, DBusGroupInfo::gid, NULL, and TRUE. |
|
Gets user ID given username.
Definition at line 384 of file dbus-userdb.c. References _dbus_credentials_from_username(), FALSE, TRUE, and DBusCredentials::uid. |
|
Wrapper for getenv().
Definition at line 169 of file dbus-sysdeps.c. Referenced by _dbus_abort(), _dbus_become_daemon(), _dbus_keyring_new_homedir(), and _dbus_verbose_real(). |
|
Gets our GID.
Definition at line 1845 of file dbus-sysdeps.c. |
|
Gets our process ID.
Definition at line 1827 of file dbus-sysdeps.c. Referenced by _dbus_verbose_real(). |
|
Gets our UID.
Definition at line 1836 of file dbus-sysdeps.c. |
|
Initializes the given DBusGroupInfo struct with information about the given group name.
Definition at line 1726 of file dbus-sysdeps.c. |
|
Initializes the given DBusGroupInfo struct with information about the given group ID.
Definition at line 1745 of file dbus-sysdeps.c. References NULL. |
|
Frees the members of info (but not info itself).
Definition at line 1758 of file dbus-sysdeps.c. References dbus_free(), and DBusGroupInfo::groupname. |
|
Returns a string describing the given name.
Definition at line 401 of file dbus-internals.c. |
|
Gets homedir of user owning current process. The returned string is valid until dbus_shutdown() is called.
Definition at line 362 of file dbus-userdb.c. References _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, and TRUE. Referenced by _dbus_keyring_new_homedir(). |
|
Gets the home directory for the given user.
Definition at line 443 of file dbus-userdb.c. References _dbus_string_append(), _dbus_user_database_get_system(), _dbus_user_database_get_username(), _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, DBusUserInfo::homedir, NULL, and TRUE. Referenced by _dbus_keyring_new_homedir(). |
|
Creates a socket and binds it to the given path, then listens on the socket. The socket is set to be nonblocking.
Definition at line 669 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_set_fd_nonblocking(), _dbus_strerror(), _DBUS_ZERO, dbus_set_error(), dbus_uint32_t, and NULL. Referenced by _dbus_server_new_for_tcp_socket(). |
|
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.
Definition at line 481 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _DBUS_MAX_SUN_PATH_LENGTH, _dbus_set_fd_nonblocking(), _dbus_strerror(), _dbus_warn(), _DBUS_ZERO, dbus_bool_t, and dbus_set_error(). Referenced by _dbus_server_new_for_domain_socket(). |
|
Duplicates a block of memory. Returns NULL on failure.
Definition at line 279 of file dbus-internals.c. References dbus_malloc(), and NULL. Referenced by _dbus_demarshal_object_path(). |
|
Checks whether the filename is an absolute path.
Definition at line 2516 of file dbus-sysdeps.c. References _dbus_string_get_byte(), _dbus_string_get_length(), and FALSE. |
|
Wrapper for poll().
Definition at line 1926 of file dbus-sysdeps.c. References _dbus_warn(), DBusPollFD::events, DBusPollFD::fd, and DBusPollFD::revents. |
|
On GNU libc systems, print a crude backtrace to the verbose log. On other systems, print "no backtrace support" Definition at line 3080 of file dbus-sysdeps.c. Referenced by _dbus_abort(). |
|
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.
Definition at line 188 of file dbus-sysdeps.c. References _dbus_assert, _dbus_string_get_data_len(), _dbus_string_get_length(), _dbus_string_lengthen(), _dbus_string_set_length(), and _dbus_verbose_bytes_of_string(). Referenced by _dbus_file_get_contents(), and _dbus_generate_random_bytes(). |
|
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.
Definition at line 793 of file dbus-sysdeps.c. References _dbus_assert, _dbus_credentials_clear(), _dbus_error_from_errno(), _dbus_strerror(), dbus_set_error(), FALSE, DBusCredentials::gid, DBusCredentials::pid, TRUE, and DBusCredentials::uid. |
|
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.
Definition at line 932 of file dbus-sysdeps.c. |
|
Sets a file descriptor to be nonblocking.
Definition at line 3042 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), dbus_set_error(), FALSE, and TRUE. Referenced by _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_full_duplex_pipe(), _dbus_listen_tcp_socket(), and _dbus_listen_unix_socket(). |
|
Installs a UNIX signal handler.
Definition at line 3288 of file dbus-sysdeps.c. |
|
Wrapper for setenv(). If the value is NULL, unsets the environment variable.
Definition at line 101 of file dbus-sysdeps.c. References _dbus_assert, FALSE, NULL, and TRUE. |
|
Sleeps the given number of milliseconds.
Definition at line 2032 of file dbus-sysdeps.c. References MICROSECONDS_PER_MILLISECOND, MILLISECONDS_PER_SECOND, and NANOSECONDS_PER_MILLISECOND. Referenced by _dbus_connection_block_for_reply(). |
|
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.
Definition at line 995 of file dbus-spawn.c. References _dbus_assert_not_reached, _dbus_babysitter_unref(), _dbus_fd_set_close_on_exec(), _dbus_full_duplex_pipe(), _dbus_strdup(), _dbus_strerror(), _dbus_watch_list_add_watch(), _dbus_watch_new(), dbus_set_error(), DBusBabysitter::error_pipe_from_child, DBusBabysitter::error_watch, DBusBabysitter::executable, FALSE, NULL, READ_END, DBusBabysitter::sitter_pid, DBusBabysitter::sitter_watch, DBusBabysitter::socket_to_babysitter, TRUE, DBusBabysitter::watches, and WRITE_END. |
|
stat() wrapper.
Definition at line 2924 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), _dbus_string_get_const_data(), DBusStat::atime, DBusStat::ctime, dbus_set_error(), FALSE, DBusStat::gid, DBusStat::mode, DBusStat::mtime, DBusStat::nlink, DBusStat::size, TRUE, and DBusStat::uid. |
|
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.
Definition at line 251 of file dbus-internals.c. References dbus_malloc(), and NULL. Referenced by _dbus_dup_string_array(), _dbus_server_new_for_domain_socket(), _dbus_spawn_async_with_babysitter(), dbus_bus_set_base_service(), and dbus_server_get_address(). |
|
A wrapper around strerror() because some platforms may be lame and not have strerror().
Definition at line 2764 of file dbus-sysdeps.c. References NULL. Referenced by _dbus_babysitter_set_child_exit_error(), _dbus_babysitter_unref(), _dbus_become_daemon(), _dbus_change_identity(), _dbus_connect_tcp_socket(), _dbus_connect_unix_socket(), _dbus_create_directory(), _dbus_create_file_exclusively(), _dbus_delete_file(), _dbus_directory_get_next_file(), _dbus_directory_open(), _dbus_file_get_contents(), _dbus_listen_tcp_socket(), _dbus_listen_unix_socket(), _dbus_read_credentials_unix_socket(), _dbus_set_fd_nonblocking(), _dbus_spawn_async_with_babysitter(), _dbus_stat(), _dbus_string_save_to_file(), and _dbus_write_pid_file(). |
|
Checks whether a string array contains the given string.
Definition at line 342 of file dbus-internals.c. |
|
Get the directory name from a complete filename.
Definition at line 2468 of file dbus-sysdeps.c. References _dbus_assert, _dbus_string_append(), _dbus_string_copy_len(), _dbus_string_find_byte_backward(), _dbus_string_get_byte(), _dbus_string_get_length(), and NULL. |
|
Writes a string out to a file. If the file exists, it will be atomically overwritten by the new data.
Definition at line 2189 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_generate_random_ascii(), _dbus_strerror(), _dbus_string_append(), _dbus_string_copy(), _dbus_string_free(), _dbus_string_get_const_data(), _dbus_string_get_length(), _dbus_string_init(), _dbus_write(), dbus_bool_t, dbus_set_error(), FALSE, NULL, and TRUE. |
|
Returns a string describing the given type.
Definition at line 365 of file dbus-internals.c. Referenced by dbus_message_iter_get_args_valist(). |
|
Gets a UID from a UID string.
Definition at line 482 of file dbus-userdb.c. References _dbus_string_get_length(), _dbus_string_parse_int(), FALSE, and TRUE. |
|
Gets the user information for the given GID, returned group info should not be freed.
Definition at line 757 of file dbus-userdb.c. References NULL. |
|
Gets the user information for the given group name, returned group info should not be freed.
Definition at line 796 of file dbus-userdb.c. References NULL. Referenced by _dbus_get_group_id(). |
|
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.
Definition at line 689 of file dbus-userdb.c. References dbus_new, dbus_set_error(), FALSE, DBusUserInfo::group_ids, DBusUserInfo::n_group_ids, NULL, and TRUE. |
|
Gets the system global user database; must be called with lock held (_dbus_user_database_lock_system()).
Definition at line 323 of file dbus-userdb.c. References _dbus_assert. Referenced by _dbus_credentials_from_uid(), _dbus_credentials_from_username(), _dbus_get_group_id(), and _dbus_homedir_from_username(). |
|
Gets the user information for the given UID, returned user info should not be freed.
Definition at line 737 of file dbus-userdb.c. References NULL. Referenced by _dbus_credentials_from_uid(). |
|
Gets the user information for the given username.
Definition at line 776 of file dbus-userdb.c. References NULL. Referenced by _dbus_credentials_from_username(), and _dbus_homedir_from_username(). |
|
Creates a new user database object used to look up and cache user information.
Definition at line 596 of file dbus-userdb.c. References _dbus_hash_table_new(), _dbus_user_database_unref(), dbus_new0, DBusUserDatabase::groups, DBusUserDatabase::groups_by_name, NULL, DBusUserDatabase::refcount, DBusUserDatabase::users, and DBusUserDatabase::users_by_name. |
|
Increments refcount of user database.
Definition at line 640 of file dbus-userdb.c. References _dbus_assert, and DBusUserDatabase::refcount. |
|
Decrements refcount of user database.
Definition at line 652 of file dbus-userdb.c. References _dbus_assert, _dbus_hash_table_unref(), dbus_free(), DBusUserDatabase::groups, DBusUserDatabase::groups_by_name, DBusUserDatabase::refcount, DBusUserDatabase::users, and DBusUserDatabase::users_by_name. Referenced by _dbus_user_database_new(). |
|
Gets user info for the given username.
Definition at line 1582 of file dbus-sysdeps.c. |
|
Gets user info for the given user ID.
Definition at line 1599 of file dbus-sysdeps.c. References NULL. |
|
Frees the members of info (but not info itself).
Definition at line 1613 of file dbus-sysdeps.c. References dbus_free(), DBusUserInfo::group_ids, DBusUserInfo::homedir, and DBusUserInfo::username. |
|
Gets username of user owning current process. The returned string is valid until dbus_shutdown() is called.
Definition at line 340 of file dbus-userdb.c. References _dbus_user_database_lock_system(), _dbus_user_database_unlock_system(), FALSE, and TRUE. Referenced by _dbus_keyring_new_homedir(). |
|
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.
Definition at line 188 of file dbus-internals.c. References _dbus_getenv(), _dbus_getpid(), dbus_bool_t, FALSE, NULL, and TRUE. |
|
Prints a warning message to stderr.
Definition at line 166 of file dbus-internals.c. Referenced by _dbus_babysitter_unref(), _dbus_full_duplex_pipe(), _dbus_keyring_new_homedir(), _dbus_listen_unix_socket(), _dbus_marshal_get_arg_end_pos(), _dbus_object_tree_register(), _dbus_object_tree_unregister_and_unlock(), _dbus_poll(), _dbus_string_steal_data_len(), _dbus_transport_handle_watch(), dbus_bus_register(), dbus_connection_dispatch(), dbus_connection_remove_filter(), dbus_message_append_args_valist(), dbus_message_iter_append_array(), dbus_message_iter_append_dict_key(), dbus_message_iter_get_args_valist(), dbus_threads_init(), and dbus_watch_handle(). |
|
Thin wrapper around the write() system call that writes a part of a DBusString and handles EINTR for you.
Definition at line 248 of file dbus-sysdeps.c. References _dbus_string_get_const_data_len(), and _dbus_verbose_bytes_of_string(). Referenced by _dbus_string_save_to_file(), and _dbus_write_two(). |
|
Creates a file containing the process ID.
Definition at line 3200 of file dbus-sysdeps.c. References _dbus_error_from_errno(), _dbus_strerror(), _dbus_string_get_const_data(), dbus_set_error(), FALSE, NULL, and TRUE. Referenced by _dbus_become_daemon(). |
|
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.
Definition at line 294 of file dbus-sysdeps.c. References _dbus_assert, _dbus_string_get_const_data_len(), _dbus_write(), and NULL. |
|
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"
Definition at line 428 of file dbus-internals.c. |