return CONTACTS_ERROR_NONE;
}
+static bool __ctsvc_is_allowed_client(const char *client_label, const char *addressbook_label)
+{
+ const char *device_addressbook = "org.tizen.contacts";
+ const char *preload_contacts = "User::Pkg::org.tizen.contacts";
+ const char *user_daemon = "User";
+ const char *system_daemon = "System";
+
+ if (STRING_EQUAL == strncmp(client_label, preload_contacts, strlen(preload_contacts))
+ && STRING_EQUAL == strcmp(addressbook_label, device_addressbook)) /*preload contacts && device addressbook*/
+ return true;
+ else if ((STRING_EQUAL == strcmp(client_label, user_daemon) || STRING_EQUAL == strcmp(client_label, system_daemon))
+ && STRING_EQUAL != strcmp(addressbook_label, device_addressbook)) /*daemon && !device addressbook*/
+ return true;
+
+ return false;
+}
+
/* this function is called in mutex lock */
static void __ctsvc_set_permission_info(ctsvc_permission_info_s *info)
{
} else if (NULL == info->ipc) { /* contacts-service daemon */
wi->id = id;
wi->type = CTSVC_TYPE_PERMISSION;
- } else if (info->smack && temp && STRING_EQUAL == strcmp(temp, info->smack)) { /* owner */
+ } else if (info->smack && temp &&
+ ((STRING_EQUAL == strcmp(temp, info->smack)) || __ctsvc_is_allowed_client(info->smack, temp))) { /* owner || allow client*/
wi->id = id;
wi->type = CTSVC_TYPE_PERMISSION;
} else if (CONTACTS_ADDRESS_BOOK_MODE_NONE == mode) {
saved_smack = ctsvc_stmt_get_text(stmt, 1);
smack = ctsvc_get_client_smack_label();
- if (smack && saved_smack && STRING_EQUAL == strcmp(smack, saved_smack))
- ret = CONTACTS_ERROR_NONE;
-
+ if (smack && saved_smack) {
+ if (STRING_EQUAL == strcmp(smack, saved_smack)) /*owner*/
+ ret = CONTACTS_ERROR_NONE;
+ else if (__ctsvc_is_allowed_client(smack, saved_smack))
+ ret = CONTACTS_ERROR_NONE;
+ }
ctsvc_stmt_finalize(stmt);
free(smack);