#define METHOD_REQUEST "Request"
#define METHOD_RESPOND "Respond"
#define SIGNAL_LAUNCHED "Launched"
+#define METHOD_CHK_PRIV_NETWORK_GET "ChkPrivNetworkGet"
#define ARG_REQTYPE "type"
#define ARG_COOKIE "cookie"
" <arg type='s' name='" ARG_RESULT_ADD "' direction='out'/>"
" <arg type='s' name='" ARG_OUTPUT "' direction='out'/>"
" </method>"
+ " <method name='" METHOD_CHK_PRIV_NETWORK_GET "'>"
+ " <arg type='i' name='" ARG_RESULT_ERR "' direction='out'/>"
+ " </method>"
" </interface>"
"</node>";
} catch (std::bad_alloc& ba) {
_E("Memory Allocation Failed..");
g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", CONV_ERROR_INVALID_OPERATION, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
-// delete creds;
+ delete creds;
return;
} catch (int e) {
_E("Caught %d", e);
g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", CONV_ERROR_INVALID_OPERATION, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
-// delete creds;
+ delete creds;
return;
}
if (!recvRequest) {
_E("Memory allocation failed");
g_dbus_method_invocation_return_value(invocation, g_variant_new("(iss)", CONV_ERROR_INVALID_OPERATION, EMPTY_JSON_OBJECT, EMPTY_JSON_OBJECT));
+ delete creds;
return;
}
if (STR_EQ(method_name, METHOD_REQUEST))
__handle_request(conn, sender, param, invocation);
+ else if (STR_EQ(method_name, METHOD_CHK_PRIV_NETWORK_GET))
+ g_dbus_method_invocation_return_value(invocation, g_variant_new("(i)", CONV_ERROR_NONE));
else
_W("Invalid method: %s", method_name);
EXTAPI int conv_service_get_connection_state(conv_service_h handle, conv_service_connection_state_e* state)
{
IF_FAIL_RETURN_TAG(conv::util::is_feature_supported(), CONV_ERROR_NOT_SUPPORTED, _E, "Not supported");
+
+ int error = conv::dbus_client::call(METHOD_CHK_PRIV_NETWORK_GET);
+ IF_FAIL_RETURN_TAG(error == CONV_ERROR_NONE, error, _E, "Privilege checking failed (%#x)", error);
+
ASSERT_NOT_NULL(handle);
ASSERT_NOT_NULL(state);
return true;
}
+
+int conv::dbus_client::call(const char* subject)
+{
+ int ret = CONV_ERROR_NONE;
+ GError *err = NULL;
+
+ GVariant *response = g_dbus_connection_call_sync(dbus_connection, DBUS_DEST, DBUS_PATH, DBUS_IFACE,
+ subject, NULL, NULL, G_DBUS_CALL_FLAGS_NONE, DBUS_TIMEOUT, NULL, &err);
+
+ if (response) {
+ g_variant_unref(response);
+ return CONV_ERROR_NONE;
+ }
+
+ ret = CONV_ERROR_INVALID_OPERATION;
+ if (err->code == G_DBUS_ERROR_ACCESS_DENIED)
+ ret = CONV_ERROR_PERMISSION_DENIED;
+
+ HANDLE_GERROR(err);
+ return ret;
+}
int request(int type, int* req_id, const char* subject, const char* input, std::string* req_result, std::string* data_read);
int request_with_no_reply(int type, int* req_id, const char* subject, const char* input);
int register_callback(const char* subject, subject_response_cb callback);
+ int call(const char* subject);
}
} /* namespace ctx */
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
- <policy smack="System">
+ <policy user="root">
<allow own="org.tizen.d2dconv"/>
- <allow send_destination="org.tizen.d2dconv"/>
- <allow send_interface="org.tizen.d2dconv"/>
- <allow receive_sender="org.tizen.d2dconv"/>
+ <allow send_destination="org.tizen.d2dconv" send_interface="org.tizen.d2dconv" send_member="Request"/>
+ <allow send_interface="org.tizen.d2dconv" send_member="Respond"/>
</policy>
- <policy at_console="true">
- <allow send_destination="org.tizen.d2dconv"/>
- <allow receive_sender="org.tizen.d2dconv"/>
- </policy>
- <policy smack="User">
- <allow send_destination="org.tizen.d2dconv"/>
- <allow receive_sender="org.tizen.d2dconv"/>
+ <policy user="owner">
+ <allow own="org.tizen.d2dconv"/>
+ <allow send_destination="org.tizen.d2dconv" send_interface="org.tizen.d2dconv" send_member="Request"/>
+ <allow send_interface="org.tizen.d2dconv" send_member="Respond"/>
</policy>
<policy context="default">
- <allow send_destination="org.tizen.d2dconv"/>
- <allow receive_sender="org.tizen.d2dconv"/>
+ <check send_destination="org.tizen.d2dconv" send_interface="org.tizen.d2dconv"
+ send_member="ChkPrivNetworkGet" privilege="http://tizen.org/privilege/network.get"/>
</policy>
</busconfig>
-