Validate the user level smack rule for shortcut
authorSung-jae Park <nicesj.park@samsung.com>
Sun, 30 Jun 2013 01:19:10 +0000 (10:19 +0900)
committerGerrit Code Review <gerrit@gerrit.vlan144.tizendev.org>
Mon, 1 Jul 2013 12:16:41 +0000 (12:16 +0000)
Change-Id: I8f01b121415b0b1537df2dcd4b93de22292c7ae3

CMakeLists.txt
packaging/data-provider-master.spec
src/shortcut_service.c

index 4264e32..d5c7722 100644 (file)
@@ -31,6 +31,7 @@ pkg_check_modules(pkg REQUIRED
        notification
        badge
        libsmack
+       shortcut
 )
 
 SET(PACKAGE "${PROJECT_NAME}")
index 0f03aaf..fd1283f 100644 (file)
@@ -1,6 +1,6 @@
 Name: data-provider-master
 Summary: Master service provider for liveboxes.
-Version: 0.24.14
+Version: 0.24.15
 Release: 1
 Group: HomeTF/Livebox
 License: Flora License
@@ -35,6 +35,7 @@ BuildRequires: pkgconfig(pkgmgr)
 BuildRequires: pkgconfig(livebox-service)
 BuildRequires: pkgconfig(notification)
 BuildRequires: pkgconfig(badge)
+BuildRequires: pkgconfig(shortcut)
 BuildRequires: pkgconfig(security-server)
 Requires(post): sys-assert
 Requires(post): dbus
index 14f840c..82408a3 100644 (file)
@@ -25,6 +25,7 @@
 #include <sys/smack.h>
 
 #include <security-server.h>
+#include <shortcut.h>
 
 #include "service_common.h"
 #include "debug.h"
@@ -88,6 +89,22 @@ static inline struct tcb *get_reply_context(double seq)
        return tcb;
 }
 
+static inline void send_reply_packet(struct tcb *tcb, struct packet *packet, int ret)
+{
+       struct packet *reply_packet;
+
+       reply_packet = packet_create_reply(packet, "i", ret);
+       if (!reply_packet) {
+               ErrPrint("Failed to create a packet\n");
+               return;
+       }
+
+       if (service_common_unicast_packet(tcb, reply_packet) < 0)
+               ErrPrint("Unable to send reply packet\n");
+
+       packet_destroy(reply_packet);
+}
+
 /*!
  * SERVICE THREAD
  */
@@ -116,11 +133,16 @@ static int service_thread_main(struct tcb *tcb, struct packet *packet, void *dat
                        ret = security_server_check_privilege_by_sockfd(tcb_fd(tcb), "data-provider-master::shortcut.livebox", "w");
                        if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
                                ErrPrint("SMACK:Access denied\n");
+                               send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION);
+                               break;
                        }
+
                } else if (!strcmp(command, "add_shortcut") || !strcmp(command, "rm_shortcut")) {
                        ret = security_server_check_privilege_by_sockfd(tcb_fd(tcb), "data-provider-master::shortcut.shortcut", "w");
                        if (ret == SECURITY_SERVER_API_ERROR_ACCESS_DENIED) {
                                ErrPrint("SMACK:Access denied\n");
+                               send_reply_packet(tcb, packet, SHORTCUT_ERROR_PERMISSION);
+                               break;
                        }
                }