struct inst_info *inst;
};
+static int is_valid_service_requestor(pid_t pid, const char *pkgname)
+{
+ char pid_pkgname[pathconf("/", _PC_PATH_MAX)];
+ char *caller_pkgname;
+ char *widget_pkgname;
+ int ret;
+
+ if (aul_app_get_pkgname_bypid(pid, pid_pkgname, sizeof(pid_pkgname)) != AUL_R_OK) {
+ ret = widget_mgr_is_valid_requestor(pid);
+ if (ret == 0) {
+ ErrPrint("pid[%d] is not authroized package\n", pid);
+ }
+ return ret;
+ }
+
+ caller_pkgname = package_get_pkgid(pid_pkgname);
+ if (!caller_pkgname) {
+ ErrPrint("Caller pkgname is not valid\n");
+ return 0;
+ }
+
+ widget_pkgname = package_get_pkgid(pkgname);
+ if (!widget_pkgname) {
+ ErrPrint("Widget pkgname is not valid\n");
+ return 0;
+ }
+
+ ret = strcmp(caller_pkgname, widget_pkgname);
+ DbgFree(caller_pkgname);
+ DbgFree(widget_pkgname);
+
+ return ret == 0;
+}
+
/**
* Returns widget Id from provider Id
*/
return NULL;
}
+ if (is_valid_service_requestor(pid, widget_id)) {
+ ErrPrint("Invalid service requestor: %d %s\n", pid, widget_id);
+ return NULL;
+ }
+
inst = package_find_instance_by_id(widget_id, inst_id);
if (!inst) {
result = packet_create_reply(packet, "is", WIDGET_ERROR_NOT_EXIST, "?");
return NULL;
}
+ if (is_valid_service_requestor(pid, widget_id) == 0) {
+ ErrPrint("Invalid requestor: %d %s\n", pid, widget_id);
+ return NULL;
+ }
+
pkg = package_find(widget_id);
if (!pkg) {
result = packet_create_reply(packet, "iis", WIDGET_ERROR_NOT_EXIST, 0, NULL);
}
DbgPrint("Register monitor target for [%s]\n", widget_id);
+ if (!widget_id) {
+ /**
+ * @TODO
+ * Only the authorized requstor can listens all widget's lifecycle event.
+ WIDGET_CONF_MONITOR_PACKAGE required
+ */
+ if (widget_mgr_is_valid_requestor(pid) == 0) {
+ ErrPrint("All widget's lifecycle event listener is not registered\n");
+ goto out;
+ }
+ } else {
+ if (is_valid_service_requestor(pid, widget_id) == 0) {
+ goto out;
+ }
+ }
if (monitor_find_client_by_pid(widget_id, pid)) {
ErrPrint("Already registered: [%s], %d\n", widget_id, pid);
goto out;
}
+ if (is_valid_service_requestor(pid, pkgname) == 0) {
+ ErrPrint("Invalid requestor: %d (%s)\n", pid, pkgname);
+ ret = WIDGET_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
if (!strlen(id)) {
struct pkg_info *pkg;
goto out;
}
+ if (is_valid_service_requestor(pid, pkgname) == 0) {
+ ErrPrint("Requestor is not valid\n");
+ ret = WIDGET_ERROR_PERMISSION_DENIED;
+ goto out;
+ }
+
widget_id = package_widget_pkgname(pkgname);
if (!widget_id) {
ErrPrint("Invalid package %s\n", pkgname);
static int disconnected_cb(int handle, void *data)
{
- printf("Disconnected\n");
- ecore_main_loop_quit();
+ if (s_info.fd == handle) {
+ printf("Disconnected\n");
+ ecore_main_loop_quit();
+ } else {
+ printf("Disconnected: %d <> %d\n", s_info.fd, handle);
+ }
return 0;
}
{
struct packet *packet;
+ if (s_info.fd != -EINVAL && s_info.fd != handle) {
+ printf("Connected: %d <> %d\n", s_info.fd, handle);
+ return 0;
+ }
+
printf("Connected\n");
packet = packet_create("widget_mgr_hello", "d", 0.0f);