25 #include "dbus-internals.h" 
   26 #include "dbus-server-unix.h" 
   27 #include "dbus-server-socket.h" 
   28 #include "dbus-server-launchd.h" 
   29 #include "dbus-transport-unix.h" 
   30 #include "dbus-connection-internal.h" 
   31 #include "dbus-sysdeps-unix.h" 
   32 #include "dbus-string.h" 
   53 DBusServerListenResult
 
   64   if (strcmp (method, 
"unix") == 0)
 
   71       int mutually_exclusive_modes = 0;
 
   73       mutually_exclusive_modes = (path != 
NULL) + (tmpdir != 
NULL) +
 
   76       if (mutually_exclusive_modes < 1)
 
   79                                 "path or tmpdir or abstract or runtime or dir",
 
   81           return DBUS_SERVER_LISTEN_BAD_ADDRESS;
 
   84       if (mutually_exclusive_modes > 1)
 
   87                                 "cannot specify two of \"path\", \"tmpdir\", \"abstract\", \"runtime\" and \"dir\" at the same time");
 
   88           return DBUS_SERVER_LISTEN_BAD_ADDRESS;
 
   95           const char *runtimedir;
 
   97           if (strcmp (runtime, 
"yes") != 0)
 
  100                   "if given, the only value allowed for \"runtime\" is \"yes\"");
 
  101               return DBUS_SERVER_LISTEN_BAD_ADDRESS;
 
  106           if (runtimedir == 
NULL)
 
  110               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  117               _DBUS_SET_OOM (error);
 
  118               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  125               _DBUS_SET_OOM (error);
 
  126               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  133               _dbus_string_get_const_data (&full_path),
 
  138       else if (tmpdir != 
NULL || dir != 
NULL)
 
  159               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  166               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  174               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  181               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  190               return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  209       if (*server_p != 
NULL)
 
  211           _DBUS_ASSERT_ERROR_IS_CLEAR(error);
 
  212           return DBUS_SERVER_LISTEN_OK;
 
  216           _DBUS_ASSERT_ERROR_IS_SET(error);
 
  217           return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  220   else if (strcmp (method, 
"systemd") == 0)
 
  229           _DBUS_ASSERT_ERROR_IS_SET (error);
 
  230           return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  236       for (i = 0; i < n; i++)
 
  248       if (*server_p == 
NULL)
 
  254       return DBUS_SERVER_LISTEN_OK;
 
  257       _DBUS_SET_OOM (error);
 
  259       for (i = 0; i < n; i++)
 
  266       return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  268 #ifdef DBUS_ENABLE_LAUNCHD 
  269   else if (strcmp (method, 
"launchd") == 0)
 
  272       if (launchd_env_var == 
NULL)
 
  275           return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  279       if (*server_p != 
NULL)
 
  281           _DBUS_ASSERT_ERROR_IS_CLEAR(error);
 
  282           return DBUS_SERVER_LISTEN_OK;
 
  286           _DBUS_ASSERT_ERROR_IS_SET(error);
 
  287           return DBUS_SERVER_LISTEN_DID_NOT_CONNECT;
 
  296       _DBUS_ASSERT_ERROR_IS_CLEAR(error);
 
  297       return DBUS_SERVER_LISTEN_NOT_HANDLED;
 
  320   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
 
  346       if (path_copy == 
NULL)
 
  355   if (listen_fd.fd < 0)
 
  357       _DBUS_ASSERT_ERROR_IS_SET (error);
 
  367   if (path_copy != 
NULL)
 
  
DBusServer * _dbus_server_new_for_socket(DBusSocket *fds, int n_fds, const DBusString *address, DBusNonceFile *noncefile, DBusError *error)
Creates a new server listening on the given file descriptor.
dbus_bool_t _dbus_append_address_from_socket(DBusSocket fd, DBusString *address, DBusError *error)
Read the address from the socket and append it to the string.
dbus_bool_t _dbus_concat_dir_and_file(DBusString *dir, const DBusString *next_component)
Appends the given filename to the given directory.
void _dbus_string_free(DBusString *str)
Frees a string created by _dbus_string_init().
void _dbus_server_socket_own_filename(DBusServer *server, char *filename)
This is a bad hack since it's really unix domain socket specific.
int _dbus_listen_systemd_sockets(DBusSocket **fds, DBusError *error)
Acquires one or more sockets passed in from systemd.
DBusServerListenResult _dbus_server_listen_platform_specific(DBusAddressEntry *entry, DBusServer **server_p, DBusError *error)
Tries to interpret the address entry in a platform-specific way, creating a platform-specific server ...
const char * dbus_address_entry_get_method(DBusAddressEntry *entry)
Returns the method string of an address entry.
int _dbus_listen_unix_socket(const char *path, dbus_bool_t abstract, DBusError *error)
Creates a socket and binds it to the given path, then listens on the socket.
dbus_bool_t _dbus_string_init(DBusString *str)
Initializes a string.
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
dbus_bool_t _dbus_generate_random_ascii(DBusString *str, int n_bytes, DBusError *error)
Generates the given number of random bytes, where the bytes are chosen from the alphanumeric ASCII su...
Internals of DBusAddressEntry.
#define DBUS_ERROR_NO_MEMORY
There was not enough memory to complete an operation.
void _dbus_set_bad_address(DBusError *error, const char *address_problem_type, const char *address_problem_field, const char *address_problem_other)
Sets DBUS_ERROR_BAD_ADDRESS.
const char * dbus_address_entry_get_value(DBusAddressEntry *entry, const char *key)
Returns a value from a key of an entry.
dbus_bool_t _dbus_close_socket(DBusSocket fd, DBusError *error)
Closes a socket.
dbus_bool_t _dbus_address_append_escaped(DBusString *escaped, const DBusString *unescaped)
Appends an escaped version of one string to another string, using the D-Bus address escaping mechanis...
char * _dbus_strdup(const char *str)
Duplicates a string.
const char * _dbus_getenv(const char *varname)
Wrapper for getenv().
DBusServer * _dbus_server_new_for_domain_socket(const char *path, dbus_bool_t abstract, DBusError *error)
Creates a new server listening on the given Unix domain socket.
Object representing an exception.
void dbus_set_error(DBusError *error, const char *name, const char *format,...)
Assigns an error name and message to a DBusError.
DBusServer * _dbus_server_new_for_launchd(const char *launchd_env_var, DBusError *error)
Creates a new server from launchd.
void _dbus_string_init_const(DBusString *str, const char *value)
Initializes a constant string.
#define DBUS_ERROR_NOT_SUPPORTED
Requested operation isn't supported (like ENOSYS on UNIX).
dbus_bool_t _dbus_string_append(DBusString *str, const char *buffer)
Appends a nul-terminated C-style string to a DBusString.
dbus_uint32_t dbus_bool_t