[Title] fix bug about launch problem in emulator
authorgreatim <jaewon81.lim@samsung.com>
Thu, 11 Apr 2013 12:21:38 +0000 (21:21 +0900)
committergreatim <jaewon81.lim@samsung.com>
Thu, 11 Apr 2013 12:21:38 +0000 (21:21 +0900)
[Desc.]
[Issue]

Change-Id: I8b09c7924e20ecdb067eab54c737435118b220cd

daemon/Makefile
daemon/daemon.c
daemon/utils.c
packaging/dynamic-analysis-manager.spec

index c5889ca..8163b36 100644 (file)
@@ -41,6 +41,7 @@ LIBS_TIZEN :=# -lcapi-system-runtime-info \
                                -lSLP-db-util
 LIBS_COMMON := -lglib-2.0 \
                                -lvconf \
+                               -lsmack \
                                -lcapi-system-info
 
 DEBUG_ON := -DDEBUG=1
index d77ce44..db7bf57 100644 (file)
@@ -871,7 +871,16 @@ int daemonLoop()
                        }
                        else if(events[i].data.fd == manager.host.data_socket)
                        {
-                               LOGW("host message from data socket\n");
+                               char recvBuf[32];
+                               recvLen = recv(manager.host.data_socket, recvBuf, RECV_BUF_MAX, MSG_DONTWAIT);
+                               if(recvLen == 0)
+                               {       // close data socket
+                                       epoll_ctl(efd, EPOLL_CTL_DEL, manager.host.data_socket, NULL);
+                                       close(manager.host.data_socket);
+                                       manager.host.data_socket = -1;
+                               }
+       
+                               LOGW("host message from data socket %d\n", recvLen);
                        }
                        // unknown socket
                        else
index c6278db..e7b822a 100644 (file)
@@ -38,6 +38,7 @@
 #include <sys/stat.h>  // for open
 #include <fcntl.h>             // for open
 #include <grp.h>               // for setgroups
+#include <sys/smack.h>
 
 #include "daemon.h"
 #include "utils.h"
@@ -194,38 +195,18 @@ void set_appuser_groups(void)
 
 int get_smack_label(const char* execpath, char* buffer, int buflen)
 {
-       int i, ret = 0;
-       char* temp;
-       if(strncmp(execpath, APPDIR1, strlen(APPDIR1)) == 0)
-       {
-               execpath = execpath + strlen(APPDIR1);
-               temp = strchr(execpath, '/');
-               for(i = 0; i < strlen(execpath) ; i++)
-               {
-                       if(execpath + i == temp)
-                               break;
-                       buffer[i] = execpath[i];
-               }
-               buffer[i] = '\0';
-       }
-       else if(strncmp(execpath, APPDIR2, strlen(APPDIR2)) == 0)
+       char* appid = NULL;
+       int rc;
+
+       rc = smack_lgetlabel(execpath, &appid, SMACK_LABEL_ACCESS);
+       if(rc == 0 && appid != NULL)
        {
-               execpath = execpath + strlen(APPDIR2);
-               temp = strchr(execpath, '/');
-               for(i = 0; i < strlen(execpath) ; i++)
-               {
-                       if(execpath + i == temp)
-                               break;
-                       buffer[i] = execpath[i];
-               }
-               buffer[i] = '\0';
+               strncpy(buffer, appid, (buflen < strlen(appid))? buflen:strlen(appid));
+               free(appid);
+               return 0;
        }
        else
-       {
-               ret = -1;
-       }
-
-       return ret;
+               return -1;
 }
 
 // return 0 if succeed
@@ -292,7 +273,7 @@ int exec_app(const char* exec_path, int app_type)
     else if(pid > 0)
        return 1;               // exit parent process with successness
 
-       if(get_smack_label(exec_path, appid, SMACK_LABEL_LEN) < 0)
+       if(get_smack_label(exec_path, appid, SMACK_LABEL_LEN - 1) < 0)
        {
                LOGE("failed to get smack label\n");
                return 0;
index 86d2e79..ebdd41a 100644 (file)
@@ -5,6 +5,7 @@ Release:    1
 Group:      System/Libraries
 License:       Apache License, Version 2
 Source:    %{name}_%{version}.tar.gz
+BuildRequires:  smack-devel
 BuildRequires:  libattr-devel
 BuildRequires:  glib2-devel
 BuildRequires:  aul-devel