Enable user level privilege validation (shortcut)
authorSung-jae Park <nicesj.park@samsung.com>
Sun, 30 Jun 2013 01:02:04 +0000 (10:02 +0900)
committerGerrit Code Review <gerrit2@localhost>
Sun, 30 Jun 2013 01:42:05 +0000 (10:42 +0900)
[model] Redwood
[binary_type] AP
[customer] Docomo/Orange/Open
[issue#] N/A
[problem]
[cause]
[solution]
[team] HomeTF
[request]
[horizontal_expansion]

Change-Id: I520eb223dd5464c4b005a5070bd0c53e615148f9

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

index b7764ee..0be9476 100755 (executable)
@@ -31,6 +31,7 @@ pkg_check_modules(pkg REQUIRED
        notification
        badge
        libsmack
+       shortcut
 )
 
 SET(PACKAGE "${PROJECT_NAME}")
index 7d24c10..4821bbf 100755 (executable)
@@ -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)
 BuildRequires: sec-product-features
 Requires(post): sys-assert
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;
                        }
                }