static void newconnection_reply(DBusPendingCall *call, void *data) { struct audio_device *dev = data; struct gateway *gw = dev->gateway; struct hf_agent *agent = gw->agent; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; dbus_pending_call_unref(agent->call); agent->call = NULL; dbus_error_init(&derr); if (!dbus_set_error_from_message(&derr, reply)) { DBG("Agent reply: file descriptor passed successfully"); gw->rfcomm_id = g_io_add_watch(gw->rfcomm, G_IO_ERR | G_IO_HUP | G_IO_NVAL, (GIOFunc) rfcomm_disconnect_cb, dev); change_state(dev, GATEWAY_STATE_CONNECTED); goto done; } DBG("Agent reply: %s", derr.message); dbus_error_free(&derr); gateway_close(dev); done: dbus_message_unref(reply); }
static void remove_connection_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply; DBusError error; if (dbus_pending_call_get_completed(call) == FALSE) return; DBG(""); reply = dbus_pending_call_steal_reply(call); dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply) == TRUE) { /* * If the returned error is NotFound, it means that we * have actually removed the provider in vpnd already. */ if (dbus_error_has_name(&error, CONNMAN_ERROR_INTERFACE ".NotFound") == FALSE) connman_error("%s", error.message); dbus_error_free(&error); } dbus_message_unref(reply); dbus_pending_call_unref(call); }
static void newconnection_reply(DBusPendingCall *call, void *data) { struct audio_device *dev = data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; if (!dev->gateway->rfcomm) { DBG("RFCOMM disconnected from server before agent reply"); goto done; } dbus_error_init(&derr); if (!dbus_set_error_from_message(&derr, reply)) { DBG("Agent reply: file descriptor passed successfully"); change_state(dev, GATEWAY_STATE_CONNECTED); goto done; } DBG("Agent reply: %s", derr.message); dbus_error_free(&derr); gateway_close(dev); done: dbus_message_unref(reply); }
static void server_unregister_reply(DBusPendingCall *call, void *user_data) { struct connman_technology *technology = user_data; DBusError error; DBusMessage *reply; DBG(""); reply = dbus_pending_call_steal_reply(call); dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply) == TRUE) { connman_error("%s", error.message); dbus_error_free(&error); dbus_message_unref(reply); dbus_pending_call_unref(call); return; } dbus_message_unref(reply); dbus_pending_call_unref(call); connman_technology_tethering_notify(technology, FALSE); }
static void connect_reply(DBusPendingCall *call, void *user_data) { char *path = user_data; struct connman_network *network; DBusMessage *reply; DBusError error; const char *interface = NULL; int index; network = g_hash_table_lookup(bluetooth_networks, path); if (!network) return; DBG("network %p", network); reply = dbus_pending_call_steal_reply(call); dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply)) { connman_error("%s", error.message); dbus_error_free(&error); goto err; } if (!dbus_message_get_args(reply, &error, DBUS_TYPE_STRING, &interface, DBUS_TYPE_INVALID)) { if (dbus_error_is_set(&error)) { connman_error("%s", error.message); dbus_error_free(&error); } else connman_error("Wrong arguments for connect"); goto err; } if (!interface) goto err; DBG("interface %s", interface); index = connman_inet_ifindex(interface); connman_network_set_index(network, index); connman_network_set_connected(network, true); dbus_message_unref(reply); dbus_pending_call_unref(call); return; err: connman_network_set_connected(network, false); dbus_message_unref(reply); dbus_pending_call_unref(call); }
static void dbus_method_reply(DBusPendingCall *call, void *user_data) { struct dbus_callback *callback = user_data; DBusMessage *reply; DBusMessageIter iter; reply = dbus_pending_call_steal_reply(call); dbus_pending_call_unref(call); if (dbus_message_get_type(reply) == DBUS_MESSAGE_TYPE_ERROR) { DBusError err; dbus_error_init(&err); dbus_set_error_from_message(&err, reply); callback->cb(NULL, err.message, callback->user_data); dbus_error_free(&err); goto end; } dbus_message_iter_init(reply, &iter); callback->cb(&iter, NULL, callback->user_data); end: callback_ended(); free(callback); dbus_message_unref(reply); }
int rtkit_make_high_priority(DBusConnection *connection, pid_t thread, int nice_level) { DBusMessage *m = NULL, *r = NULL; dbus_uint64_t u64; dbus_int32_t s32; DBusError error; int ret; dbus_error_init(&error); if (thread == 0) thread = _gettid(); if (!(m = dbus_message_new_method_call( RTKIT_SERVICE_NAME, RTKIT_OBJECT_PATH, "org.freedesktop.RealtimeKit1", "MakeThreadHighPriority"))) { ret = -ENOMEM; goto finish; } u64 = (dbus_uint64_t) thread; s32 = (dbus_int32_t) nice_level; if (!dbus_message_append_args( m, DBUS_TYPE_UINT64, &u64, DBUS_TYPE_INT32, &s32, DBUS_TYPE_INVALID)) { ret = -ENOMEM; goto finish; } if (!(r = dbus_connection_send_with_reply_and_block(connection, m, -1, &error))) { ret = translate_error(error.name); goto finish; } if (dbus_set_error_from_message(&error, r)) { ret = translate_error(error.name); goto finish; } ret = 0; finish: if (m) dbus_message_unref(m); if (r) dbus_message_unref(r); dbus_error_free(&error); return ret; }
static void adapter_reply(DBusPendingCall *call, void *user_data) { DBusError err; DBusMessage *reply; struct callback_data *callback = user_data; struct obc_session *session = callback->session; struct pending_req *req = find_session_request(session, call); reply = dbus_pending_call_steal_reply(call); session->pending_calls = g_slist_remove(session->pending_calls, req); pending_req_finalize(req); dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) { error("manager replied with an error: %s, %s", err.name, err.message); dbus_error_free(&err); goto failed; } if (session_connect(session, callback) < 0) goto failed; goto proceed; failed: obc_session_unref(session); g_free(callback); proceed: dbus_message_unref(reply); }
static void add_record_reply(DBusPendingCall *call, void *user_data) { struct bluetooth_service *service = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError derr; uint32_t handle; dbus_error_init(&derr); if (dbus_set_error_from_message(&derr, reply)) { error("bluetooth: Replied with an error: %s, %s", derr.name, derr.message); dbus_error_free(&derr); handle = 0; } else { dbus_message_get_args(reply, NULL, DBUS_TYPE_UINT32, &handle, DBUS_TYPE_INVALID); service->handle = handle; DBG("Registered: %s, handle: 0x%x", service->driver->name, service->handle); } dbus_message_unref(reply); }
gboolean gkr_operation_handle_errors (GkrOperation *op, DBusMessage *reply) { DBusError derr = DBUS_ERROR_INIT; MateKeyringResult res; gboolean was_keyring; g_assert (op); g_assert (reply); was_keyring = op->was_keyring; op->was_keyring = FALSE; if (dbus_set_error_from_message (&derr, reply)) { if (dbus_error_has_name (&derr, ERROR_NO_SUCH_OBJECT)) { if (was_keyring) res = MATE_KEYRING_RESULT_NO_SUCH_KEYRING; else res = MATE_KEYRING_RESULT_BAD_ARGUMENTS; } else { g_message ("secret service operation failed: %s", derr.message); res = MATE_KEYRING_RESULT_IO_ERROR; } dbus_error_free (&derr); gkr_operation_complete (op, res); return TRUE; } return FALSE; }
static void onConnectSinkResult(DBusMessage *msg, void *user, void *natData) { LOGV(__FUNCTION__); char *c_path = (char *)user; DBusError err; JNIEnv *env; if (nat->vm->GetEnv((void**)&env, nat->envVer) < 0) { LOGE("%s: error finding Env for our VM\n", __FUNCTION__); return; } dbus_error_init(&err); LOGV("... path = %s", c_path); if (dbus_set_error_from_message(&err, msg)) { /* if (!strcmp(err.name, BLUEZ_DBUS_BASE_IFC ".Error.AuthenticationFailed")) */ LOGE("%s: D-Bus error: %s (%s)\n", __FUNCTION__, err.name, err.message); dbus_error_free(&err); env->CallVoidMethod(nat->me, method_onSinkDisconnected, env->NewStringUTF(c_path)); if (env->ExceptionCheck()) { LOGE("VM Exception occurred in native function %s (%s:%d)", __FUNCTION__, __FILE__, __LINE__); } } // else Java callback is triggered by signal in a2dp_event_filter free(c_path); }
static void get_managed_objects_reply(DBusPendingCall *call, void *user_data) { GDBusClient *client = user_data; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusError error; g_dbus_client_ref(client); dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply) == TRUE) { dbus_error_free(&error); goto done; } parse_managed_objects(client, reply); done: if (client->ready) client->ready(client, client->ready_data); dbus_message_unref(reply); dbus_pending_call_unref(client->get_objects_call); client->get_objects_call = NULL; g_dbus_client_unref(client); }
static void get_all_properties_reply(DBusPendingCall *call, void *user_data) { GDBusProxy *proxy = user_data; GDBusClient *client = proxy->client; DBusMessage *reply = dbus_pending_call_steal_reply(call); DBusMessageIter iter; DBusError error; dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply) == TRUE) { dbus_error_free(&error); goto done; } dbus_message_iter_init(reply, &iter); update_properties(proxy, &iter, FALSE); done: if (g_list_find(client->proxy_list, proxy) == NULL) { if (client->proxy_added) client->proxy_added(proxy, client->user_data); client->proxy_list = g_list_append(client->proxy_list, proxy); } dbus_message_unref(reply); g_dbus_client_unref(client); }
static void read_radio_states_cb(DBusPendingCall *call, void *user_data) { DBusError err; DBusMessage *reply; dbus_uint32_t radio_states; struct btd_adapter *adapter = user_data; reply = dbus_pending_call_steal_reply(call); dbus_error_init(&err); if (dbus_set_error_from_message(&err, reply)) { error("mce replied with an error: %s, %s", err.name, err.message); dbus_error_free(&err); goto done; } dbus_error_init(&err); if (dbus_message_get_args(reply, &err, DBUS_TYPE_UINT32, &radio_states, DBUS_TYPE_INVALID) == FALSE) { error("unable to parse get_radio_states reply: %s, %s", err.name, err.message); dbus_error_free(&err); goto done; } if (radio_states & MCE_RADIO_STATE_BLUETOOTH) btd_adapter_switch_online(adapter); done: dbus_message_unref(reply); }
/** Handle reply to asynchronous connman service name ownership query * * @param pc State data for asynchronous D-Bus method call * @param user_data (not used) */ static void xconnman_check_service_cb(DBusPendingCall *pc, void *user_data) { (void)user_data; DBusMessage *rsp = 0; const char *owner = 0; DBusError err = DBUS_ERROR_INIT; if( !(rsp = dbus_pending_call_steal_reply(pc)) ) goto EXIT; if( dbus_set_error_from_message(&err, rsp) || !dbus_message_get_args(rsp, &err, DBUS_TYPE_STRING, &owner, DBUS_TYPE_INVALID) ) { if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) ) { mce_log(LL_WARN, "%s: %s", err.name, err.message); } goto EXIT; } xconnman_set_runstate(owner && *owner); EXIT: if( rsp ) dbus_message_unref(rsp); dbus_error_free(&err); }
/** Handle D-Bus name owner changed signals for "org.ofono" */ static gboolean xofono_name_owner_changed_cb(DBusMessage *rsp) { const gchar *name = 0; const gchar *prev = 0; const gchar *curr = 0; DBusError err = DBUS_ERROR_INIT; if( dbus_set_error_from_message(&err, rsp) ) { mce_log(LL_ERR, "%s: %s", err.name, err.message); goto EXIT; } if( !dbus_message_get_args(rsp, &err, DBUS_TYPE_STRING, &name, DBUS_TYPE_STRING, &prev, DBUS_TYPE_STRING, &curr, DBUS_TYPE_INVALID) ) { mce_log(LL_ERR, "%s: %s", err.name, err.message); goto EXIT; } if( !name || strcmp(name, OFONO_SERVICE) ) goto EXIT; xofono_availability_set(curr && *curr != 0 ); EXIT: dbus_error_free(&err); return TRUE; }
static void pincode_reply(DBusPendingCall *call, void *user_data) { struct agent_request *req = user_data; struct agent *agent = req->agent; struct btd_adapter *adapter = agent->adapter; agent_pincode_cb cb = req->cb; DBusMessage *message; DBusError err; bdaddr_t sba; size_t len; char *pin; adapter_get_address(adapter, &sba); /* steal_reply will always return non-NULL since the callback * is only called after a reply has been received */ message = dbus_pending_call_steal_reply(call); dbus_error_init(&err); if (dbus_set_error_from_message(&err, message)) { error("Agent %s replied with an error: %s, %s", agent->path, err.name, err.message); cb(agent, &err, NULL, req->user_data); dbus_error_free(&err); goto done; } dbus_error_init(&err); if (!dbus_message_get_args(message, &err, DBUS_TYPE_STRING, &pin, DBUS_TYPE_INVALID)) { error("Wrong passkey reply signature: %s", err.message); cb(agent, &err, NULL, req->user_data); dbus_error_free(&err); goto done; } len = strlen(pin); dbus_error_init(&err); if (len > 16 || len < 1) { error("Invalid PIN length (%zu) from agent", len); dbus_set_error_const(&err, "org.bluez.Error.InvalidArgs", "Invalid passkey length"); cb(agent, &err, NULL, req->user_data); dbus_error_free(&err); goto done; } cb(agent, NULL, pin, req->user_data); done: if (message) dbus_message_unref(message); dbus_pending_call_cancel(req->call); agent->request = NULL; agent_request_free(req, TRUE); }
static dbus_bool_t client_parse_reply(DBusMessage *rsp, DBusError *err, int arg, ...) { dbus_bool_t res = 0; if( dbus_error_is_set(err) ) { // error is already set -> nop } else if( dbus_message_get_type(rsp) == DBUS_MESSAGE_TYPE_METHOD_RETURN ) { // try to parse the message va_list va; va_start(va, arg); res = dbus_message_get_args_valist (rsp, err, arg, va); va_end(va); } else if( dbus_set_error_from_message(err, rsp) ) { // it was an error message and error is now set } else { dbus_set_error(err, DBUS_ERROR_NO_REPLY, "expected %s, got %s\n", dbus_message_type_to_string(DBUS_MESSAGE_TYPE_METHOD_RETURN), dbus_message_type_to_string(dbus_message_get_type(rsp))); } return res; }
static void read_reply(DBusMessage *message, void *user_data) { DBusError error; DBusMessageIter iter, array; uint8_t *value; int len; dbus_error_init(&error); if (dbus_set_error_from_message(&error, message) == TRUE) { rl_printf("Failed to read: %s\n", error.name); dbus_error_free(&error); return; } dbus_message_iter_init(message, &iter); if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) { rl_printf("Invalid response to read\n"); return; } dbus_message_iter_recurse(&iter, &array); dbus_message_iter_get_fixed_array(&array, &value, &len); if (len < 0) { rl_printf("Unable to parse value\n"); return; } rl_hexdump(value, len); }
int bridge_request_call_dbus_json(bridge_request_t *self, DBusMessage *in_dbus) { DBusMessageIter it; DBusError err; struct json_object *result = 0; int ret = 0; if (dbus_message_get_type(in_dbus) == DBUS_MESSAGE_TYPE_ERROR) { dbus_error_init(&err); (void)dbus_set_error_from_message(&err, in_dbus); bridge_request_error(self, err.message ? err.message : err.name); dbus_error_free(&err); ret = EINVAL; goto finish; } if (dbus_message_iter_init(in_dbus, &it)) { if ((ret = bridge_request_json_params(self, &it, &result, dbus_message_iter_has_next(&it))) != 0) goto finish; } if ((ret = bridge_request_send_response(self, 0, result)) != 0) { bridge_request_error(self, "Out of memory."); } finish: if (result) json_object_put(result); dbus_message_unref(in_dbus); FCGX_Finish_r(&self->request); self->next = self->bridge->head; self->bridge->head = self; return ret; }
static bool filter_handle_message(Filter* filter, DBusMessage* msg) { switch (dbus_message_get_type(msg)) { case DBUS_MESSAGE_TYPE_METHOD_CALL: // TODO: add logging break; case DBUS_MESSAGE_TYPE_SIGNAL: break; case DBUS_MESSAGE_TYPE_ERROR: { DBusError error; dbus_error_init(&error); if (dbus_set_error_from_message(&error, msg)) { dsme_log(LOG_DEBUG, "D-Bus: %s: %s", dbus_message_get_error_name(msg), error.message); } else { dsme_log(LOG_DEBUG, "D-Bus: could not get error message"); } dbus_error_free(&error); } break; default: // IGNORE (silently ignore per D-Bus documentation) break; } return false; }
/** * thunar_dbus_client_terminate: * @error : Return location for errors or %NULL. * * Tells a running Thunar instance, connected to the D-BUS * session bus, to terminate immediately. * * Return value: %TRUE if any instance was terminated, else * %FALSE and @error is set. **/ gboolean thunar_dbus_client_terminate (GError **error) { DBusConnection *connection; DBusMessage *message; DBusMessage *result; DBusError derror; _thunar_return_val_if_fail (error == NULL || *error == NULL, FALSE); /* initialize the DBusError struct */ dbus_error_init (&derror); /* try to connect to the session bus */ connection = dbus_bus_get (DBUS_BUS_SESSION, &derror); if (G_UNLIKELY (connection == NULL)) { dbus_set_g_error (error, &derror); dbus_error_free (&derror); return FALSE; } /* generate the LaunchFiles() method (disable activation!) */ message = dbus_message_new_method_call ("org.xfce.Thunar", "/org/xfce/FileManager", "org.xfce.Thunar", "Terminate"); dbus_message_set_auto_start (message, FALSE); /* send the message and release our references on connection and message */ result = dbus_connection_send_with_reply_and_block (connection, message, -1, &derror); dbus_message_unref (message); /* check if no reply was received */ if (G_UNLIKELY (result == NULL)) { /* check if there was nothing to terminate */ if (dbus_error_has_name (&derror, DBUS_ERROR_NAME_HAS_NO_OWNER)) { dbus_error_free (&derror); return TRUE; } /* Looks like there was a real error */ dbus_set_g_error (error, &derror); dbus_error_free (&derror); return FALSE; } /* but maybe we received an error */ if (dbus_message_get_type (result) == DBUS_MESSAGE_TYPE_ERROR) { dbus_set_error_from_message (&derror, result); dbus_set_g_error (error, &derror); dbus_message_unref (result); dbus_error_free (&derror); return FALSE; } /* let's asume that it worked */ dbus_message_unref (result); return TRUE; }
/** Parse a reply message to GetNameOwner method call * * @param rsp method call reply message * * @return dbus name of the name owner, or NULL in case of errors */ static gchar * cpu_keepalive_parse_GetNameOwner_rsp(DBusMessage *rsp) { char *res = 0; DBusError err = DBUS_ERROR_INIT; char *dta = NULL; if( dbus_set_error_from_message(&err, rsp) || !dbus_message_get_args(rsp, &err, DBUS_TYPE_STRING, &dta, DBUS_TYPE_INVALID) ) { if( strcmp(err.name, DBUS_ERROR_NAME_HAS_NO_OWNER) ) { mce_log(LL_WARN, "%s: %s", err.name, err.message); } goto EXIT; } res = g_strdup(dta); EXIT: dbus_error_free(&err); return res; }
static void _libnm_glib_nm_state_cb (DBusPendingCall *pcall, void *user_data) { DBusMessage * reply; libnm_glib_ctx * ctx = (libnm_glib_ctx *) user_data; NMState nm_state; g_return_if_fail (pcall != NULL); g_return_if_fail (ctx != NULL); if (!(reply = dbus_pending_call_steal_reply (pcall))) goto out; if (dbus_message_get_type (reply) == DBUS_MESSAGE_TYPE_ERROR) { DBusError err; dbus_error_init (&err); dbus_set_error_from_message (&err, reply); fprintf (stderr, "%s: dbus returned an error.\n (%s) %s\n", __func__, err.name, err.message); dbus_error_free (&err); dbus_message_unref (reply); goto out; } if (dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &nm_state, DBUS_TYPE_INVALID)) _libnm_glib_update_state (ctx, nm_state); dbus_message_unref (reply); out: dbus_pending_call_unref (pcall); }
void onConnectSinkResult(DBusMessage *msg, void *user, void *n) { LOGV(__FUNCTION__); native_data_t *nat = (native_data_t *)n; const char *path = (const char *)user; DBusError err; dbus_error_init(&err); JNIEnv *env; nat->vm->GetEnv((void**)&env, nat->envVer); bool result = JNI_TRUE; if (dbus_set_error_from_message(&err, msg)) { LOG_AND_FREE_DBUS_ERROR(&err); result = JNI_FALSE; } LOGV("... Device Path = %s, result = %d", path, result); jstring jPath = env->NewStringUTF(path); env->CallVoidMethod(nat->me, method_onConnectSinkResult, jPath, result); env->DeleteLocalRef(jPath); free(user); }
/** Handle reply to asynchronous connman property change D-Bus method call * * @param pc State data for asynchronous D-Bus method call * @param user_data (not used) */ static void xconnman_set_property_cb(DBusPendingCall *pc, void *user_data) { (void)user_data; DBusMessage *rsp = 0; DBusError err = DBUS_ERROR_INIT; if( !(rsp = dbus_pending_call_steal_reply(pc)) ) goto EXIT; if( dbus_set_error_from_message(&err, rsp) ) { mce_log(LL_WARN, "%s: %s", err.name, err.message); goto EXIT; } /* NOTE: there is either empty or error reply message, we have * no clue whether connman actually modified the property */ mce_log(LL_DEBUG, "set property acked by connman"); /* Query properties if missing an expected property changed signal */ if( connman_verify_property_setting ) { connman_verify_property_setting = FALSE; mce_log(LL_DEBUG, "no change signal seen, querying props"); if( !xconnman_get_properties() ) mce_log(LL_WARN, "failed to query connman properties"); } EXIT: if( rsp ) dbus_message_unref(rsp); dbus_error_free(&err); }
static void disconnect_reply(DBusPendingCall *call, void *user_data) { DBusMessage *reply; DBusError error; if (dbus_pending_call_get_completed(call) == FALSE) return; DBG("user %p", user_data); reply = dbus_pending_call_steal_reply(call); dbus_error_init(&error); if (dbus_set_error_from_message(&error, reply) == TRUE) { connman_error("%s", error.message); dbus_error_free(&error); goto done; } done: dbus_message_unref(reply); dbus_pending_call_unref(call); }
static void on_get_connection_unix_process_id (DBusPendingCall *pending, gpointer user_data) { on_get_connection_unix_process_id_args *args = user_data; DBusMessage *reply = NULL; DBusError error = DBUS_ERROR_INIT; dbus_uint32_t caller_pid = 0; GkdSecretService *self; ServiceClient *client; const gchar *caller; g_return_if_fail (GKD_SECRET_IS_SERVICE (args->self)); self = args->self; /* Get the resulting process ID */ reply = dbus_pending_call_steal_reply (pending); g_return_if_fail (reply); caller = dbus_message_get_sender (args->message); g_return_if_fail (caller); client = g_hash_table_lookup (self->clients, caller); if (client == NULL) { /* An error returned from GetConnectionUnixProcessID */ if (dbus_set_error_from_message (&error, reply)) { g_message ("couldn't get the caller's unix process id: %s", error.message); caller_pid = 0; dbus_error_free (&error); /* A PID was returned from GetConnectionUnixProcessID */ } else { if (!dbus_message_get_args (reply, NULL, DBUS_TYPE_UINT32, &caller_pid, DBUS_TYPE_INVALID)) g_return_if_reached (); } /* Initialize the client object */ client = g_new0 (ServiceClient, 1); client->caller_peer = g_strdup (caller); client->caller_pid = caller_pid; if (caller_pid != 0) client->caller_exec = egg_unix_credentials_executable (caller_pid); client->app.applicationData = client; client->sessions = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, dispose_and_unref); client->prompts = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, dispose_and_unref); g_hash_table_replace (self->clients, client->caller_peer, client); /* Update default collection each time someone connects */ update_default (self, TRUE); } dbus_message_unref (reply); /* Dispatch the original message again */ service_dispatch_message (self, args->message); }
static void set_property_cb(DBusPendingCall *pending, void *user_data) { struct property_setting *set = user_data; struct connman_service *service; struct property_change *property; DBusMessage *reply; DBusError error; if (dbus_pending_call_get_completed(pending) == FALSE) return; if (set == NULL) return; service = set->data; service->call_modify[set->index] = NULL; if (service->property_set_error_cb == NULL) return; property = g_try_malloc0(sizeof(struct property_change)); if (property == NULL) return; reply = dbus_pending_call_steal_reply(pending); if (reply == NULL) return; if (dbus_set_error_from_message(&error, reply) == FALSE) goto done; printf("SetProperty Error: %s\n", error.message); dbus_error_free(&error); if (service->property_set_error_cb == NULL) goto done; property = g_try_malloc0(sizeof(struct property_change)); if (property == NULL) goto done; property->path = service->path; property->name = PROPERTY(set->index); property->error = -1; if (service->to_error[set->index] != 0) g_source_remove(service->to_error[set->index]); service->to_error[set->index] = g_timeout_add_full( G_PRIORITY_DEFAULT, 0, property_changed_or_error, property, destroy_property); done: dbus_message_unref(reply); }
static int bus_get_selinux_security_context( DBusConnection *connection, const char *name, char **scon, DBusError *error) { _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL; DBusMessageIter iter, sub; const char *bytes; char *b; int nbytes; m = dbus_message_new_method_call( DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "GetConnectionSELinuxSecurityContext"); if (!m) { dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, NULL); return -ENOMEM; } if (!dbus_message_append_args( m, DBUS_TYPE_STRING, &name, DBUS_TYPE_INVALID)) { dbus_set_error_const(error, DBUS_ERROR_NO_MEMORY, NULL); return -ENOMEM; } reply = dbus_connection_send_with_reply_and_block(connection, m, -1, error); if (!reply) return -EIO; if (dbus_set_error_from_message(error, reply)) return -EIO; if (!dbus_message_iter_init(reply, &iter)) return -EIO; if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_ARRAY) return -EIO; dbus_message_iter_recurse(&iter, &sub); dbus_message_iter_get_fixed_array(&sub, &bytes, &nbytes); b = strndup(bytes, nbytes); if (!b) return -ENOMEM; *scon = b; log_debug("GetConnectionSELinuxSecurityContext %s (pid %ld)", *scon, (long) bus_get_unix_process_id(connection, name, error)); return 0; }