diff options
author | Hyunho Kang <hhstark.kang@samsung.com> | 2016-03-24 17:17:54 +0900 |
---|---|---|
committer | Hyunho Kang <hhstark.kang@samsung.com> | 2016-03-24 18:54:33 +0900 |
commit | 48932984fa364b61e43658aa2d99076734fa2686 (patch) | |
tree | 9b51888cedc3c0ca46088325b782822a899ff447 /src | |
parent | 779dbe413df49381ade165b634f23ad20d6c5529 (diff) | |
download | notification-48932984fa364b61e43658aa2d99076734fa2686.tar.gz notification-48932984fa364b61e43658aa2d99076734fa2686.tar.bz2 notification-48932984fa364b61e43658aa2d99076734fa2686.zip |
Add gdbus permission check logic & strerror to strerror_rsubmit/tizen/20160324.104731accepted/tizen/wearable/20160324.132802accepted/tizen/tv/20160324.132816accepted/tizen/mobile/20160324.132944accepted/tizen/ivi/20160324.131658accepted/tizen/common/20160325.135418
Change-Id: I7859588bfb5da986fe8c9f6f9fe1c606114c35ef
Signed-off-by: Hyunho Kang <hhstark.kang@samsung.com>
Diffstat (limited to 'src')
-rwxr-xr-x | src/notification_ipc.c | 26 | ||||
-rwxr-xr-x | src/notification_noti.c | 4 |
2 files changed, 21 insertions, 9 deletions
diff --git a/src/notification_ipc.c b/src/notification_ipc.c index c449005..9213bc7 100755 --- a/src/notification_ipc.c +++ b/src/notification_ipc.c @@ -44,6 +44,7 @@ #define DBUS_SERVICE_DBUS "org.freedesktop.DBus" #define DBUS_PATH_DBUS "/org/freedesktop/DBus" #define DBUS_INTERFACE_DBUS "org.freedesktop.DBus" +#define ERR_BUFFER_SIZE 1024 static const gchar *_bus_name = NULL; static GDBusConnection *_gdbus_conn = NULL; @@ -290,6 +291,7 @@ static notification_op *_ipc_create_op(notification_op_type_e type, static inline char *_dup_string(const char *string) { char *ret; + char err_buf[ERR_BUFFER_SIZE]; if (string == NULL) return NULL; @@ -298,7 +300,7 @@ static inline char *_dup_string(const char *string) ret = strdup(string); if (!ret) - NOTIFICATION_ERR("Error: %s\n", strerror(errno)); + NOTIFICATION_ERR("Error: %s\n", strerror_r(errno, err_buf, sizeof(err_buf))); return ret; } @@ -540,8 +542,12 @@ static int _send_sync_noti(GVariant *body, GDBusMessage **reply, char *cmd) } if (g_dbus_message_to_gerror(*reply, &err)) { - ret = err->code; - NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s", cmd, err->message); + if (err->code == G_DBUS_ERROR_ACCESS_DENIED) + ret = NOTIFICATION_ERROR_PERMISSION_DENIED; + else + ret = err->code; + + NOTIFICATION_ERR("_send_sync_noti cmd = %s, error %s, err code %d", cmd, err->message, ret); g_error_free(err); return ret; } @@ -579,9 +585,13 @@ static void _send_message_with_reply_async_cb(GDBusConnection *connection, result = NOTIFICATION_ERROR_SERVICE_NOT_READY; } else if (g_dbus_message_to_gerror(reply, &err)) { - result = err->code; - g_error_free(err); + if (err->code == G_DBUS_ERROR_ACCESS_DENIED) + result = NOTIFICATION_ERROR_PERMISSION_DENIED; + else + result = err->code; + NOTIFICATION_ERR("_send_async_noti error %s", err->message); + g_error_free(err); } NOTIFICATION_DBG("_send_async_noti done !![%d]", result); @@ -639,7 +649,7 @@ static int _send_async_noti(GVariant *body, result_cb_item *cb_item, char *cmd) int notification_ipc_request_insert(notification_h noti, int *priv_id) { int result; - int id; + int id = NOTIFICATION_PRIV_ID_NONE; GDBusMessage *reply = NULL; GVariant *body; GVariant *reply_body; @@ -676,14 +686,14 @@ int notification_ipc_request_insert(notification_h noti, int *priv_id) if(reply) g_object_unref(reply); - NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", *priv_id, result); + NOTIFICATION_DBG("notification_ipc_request_insert done [priv_id : %d, result: %d]", id, result); return result; } int notification_ipc_request_update(notification_h noti) { int result; - int priv_id; + int priv_id = NOTIFICATION_PRIV_ID_NONE; GDBusMessage *reply = NULL; GVariant *body; diff --git a/src/notification_noti.c b/src/notification_noti.c index 6987f67..d0510c4 100755 --- a/src/notification_noti.c +++ b/src/notification_noti.c @@ -41,6 +41,7 @@ #include <notification_setting_service.h> #define NOTI_BURST_DELETE_UNIT 10 +#define ERR_BUFFER_SIZE 1024 static void __free_and_set(void **target_ptr, void *new_ptr) { @@ -1223,6 +1224,7 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char char query[NOTIFICATION_QUERY_MAX] = { 0, }; char query_base[NOTIFICATION_QUERY_MAX] = { 0, }; char query_where[NOTIFICATION_QUERY_MAX] = { 0, }; + char err_buf[ERR_BUFFER_SIZE]; /* Open DB */ db = notification_db_open(DBPATH); @@ -1271,7 +1273,7 @@ EXPORT_API int notification_noti_delete_all(notification_type_e type, const char if (tmp) { *list_deleted_rowid = tmp; } else { - NOTIFICATION_ERR("Heap: %s\n", strerror(errno)); + NOTIFICATION_ERR("Heap: %s\n", strerror_r(errno, err_buf, sizeof(err_buf))); /*! * \TODO * How can I handle this? |