Sync with tizen_2.3
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 6 May 2015 01:53:01 +0000 (10:53 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 6 May 2015 01:53:01 +0000 (10:53 +0900)
[model] Redwood,Kiran,B3(Wearable)
[binary_type] AP
[customer] Docomo/Orange/ATT/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: I2bbb7e2e0254905d6cc70917ca62c6b064ef8df7

data-provider-master.rule
data/device/abi.ini
data/emulator/abi.ini
include/widget-mgr.h
packaging/data-provider-master.spec
src/server.c
src/widget-mgr.c
widget-mgr/src/widget-mgr.c

index dafbe90..370a0a4 100644 (file)
@@ -31,3 +31,4 @@ data-provider-master::bin shortcut-service::db rw---- ------
 data-provider-master::bin badge::db rw---- ------
 _ data-provider-master::bin r-x--- ------
 data-provider-master::bin sdbd r----- ------
+data-provider-master::bin system::homedir rwxa-- ------
index 40407ed..048f85e 100644 (file)
@@ -12,3 +12,6 @@ package=gi2qxenosh.osp-appwidget-service
 
 [app]
 package=/APPID/
+
+[svc]
+package=org.tizen.data-provider-slave.svc
index 40407ed..048f85e 100644 (file)
@@ -12,3 +12,6 @@ package=gi2qxenosh.osp-appwidget-service
 
 [app]
 package=/APPID/
+
+[svc]
+package=org.tizen.data-provider-slave.svc
index 7061548..908fe0e 100644 (file)
@@ -32,4 +32,5 @@ extern void widget_mgr_close_fifo(struct widget_mgr *info);
 extern void widget_mgr_set_data(struct widget_mgr *info, void *data);
 extern void *widget_mgr_data(struct widget_mgr *info);
 
+extern int widget_mgr_is_valid_requestor(pid_t pid);
 /* End of a file */
index 4d9f2f2..1a03648 100644 (file)
@@ -5,7 +5,7 @@ Summary: Master service provider for widgetes
 Version: 1.1.6
 Release: 1
 Group: HomeTF/widget
-License: Flora
+License: Flora License, Version 1.1
 Source0: %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 BuildRequires: cmake, gettext-tools, smack, coreutils
index 9d4ad00..2e4606b 100644 (file)
@@ -120,6 +120,40 @@ struct deleted_item {
        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
  */
@@ -8410,6 +8444,11 @@ static struct packet *service_get_content(pid_t pid, int handle, const struct pa
                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, "?");
@@ -8435,6 +8474,11 @@ static struct packet *service_get_inst_list(pid_t pid, int handle, const struct
                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);
@@ -8511,6 +8555,21 @@ static struct packet *monitor_register(pid_t pid, int handle, const struct packe
        }
 
        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);
@@ -8566,6 +8625,12 @@ static struct packet *service_change_period(pid_t pid, int handle, const struct
                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;
 
@@ -8630,6 +8695,12 @@ static struct packet *service_update(pid_t pid, int handle, const struct packet
                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);
index bf815e9..f701ff3 100644 (file)
@@ -69,7 +69,7 @@ HAPI void widget_mgr_fini(void)
        }
 }
 
-static inline int valid_requestor(pid_t pid)
+HAPI int widget_mgr_is_valid_requestor(pid_t pid)
 {
        char cmdline[60]; /* strlen("/proc/%d/cmdline") + 30 */
        struct stat target;
@@ -106,7 +106,7 @@ HAPI struct widget_mgr *widget_mgr_create(pid_t pid, int handle)
 {
        struct widget_mgr *info;
 
-       if (!valid_requestor(pid)) {
+       if (!widget_mgr_is_valid_requestor(pid)) {
                ErrPrint("Invalid requestor\n");
                return NULL;
        }
index 80d6bd9..7622f97 100644 (file)
@@ -1999,8 +1999,12 @@ static int ret_cb(pid_t pid, int handle, const struct packet *packet, void *data
 
 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;
 }
 
@@ -2008,6 +2012,11 @@ static int connected_cb(int handle, void *data)
 {
        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);