Revert "change the path of socket & inotify file" 10/106510/2 accepted/tizen/common/20161222.131224 accepted/tizen/ivi/20161223.095322 accepted/tizen/mobile/20161223.095245 accepted/tizen/wearable/20161223.095304 submit/tizen/20161222.044214
authorJongkyu Koo <jk.koo@samsung.com>
Thu, 22 Dec 2016 03:40:33 +0000 (19:40 -0800)
committerJongkyu Koo <jk.koo@samsung.com>
Thu, 22 Dec 2016 04:34:46 +0000 (13:34 +0900)
This reverts commit aeadb3515c1bf7a0f7ac866fb049a9cdeef99a34.

Change-Id: Ie8e637068efae2e46beb109ec95eb2805de24461

common/ctsvc_inotify.c
common/ctsvc_notify.h
common/ctsvc_struct.h
packaging/contacts-service.spec
server/ctsvc_server.c

index 2cd1c67..9aa31d0 100644 (file)
@@ -20,6 +20,7 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <sys/types.h>
+#include <pwd.h>
 #include <sys/inotify.h>
 
 #include "contacts.h"
@@ -578,14 +579,30 @@ void ctsvc_inotify_close(void)
        }
 }
 
+static const char* __ctsvc_inotify_get_username(uid_t uid)
+{
+       struct passwd pwd;
+       struct passwd* pwd_result;
+       char tmp[CTSVC_STR_SHORT_LEN];
+
+       int ret = getpwuid_r(uid, &pwd, tmp, sizeof(tmp), &pwd_result);
+       if (ret != 0 || pwd_result == NULL) {
+               ERR("getpwuid_r() fail");
+               return "";
+       }
+
+       return pwd.pw_name;
+}
+
 char*  ctsvc_inotify_makepath(const char *file)
 {
        RETV_IF(NULL == file, NULL);
 
-       static int user_id_max = 10;
+       static int user_name_max = 32;
        int path_len = 0;
        char *path = NULL;
        uid_t uid = getuid();
+       const char* user_name = NULL;
 
 #ifdef _CONTACTS_IPC_CLIENT
        if (ctsvc_client_is_in_system_session()) {
@@ -594,14 +611,15 @@ char*  ctsvc_inotify_makepath(const char *file)
        }
 #endif
 
-       path_len = strlen(CTSVC_NOTI_PATH) + user_id_max + strlen(file) + 1;
+       path_len = strlen(CTSVC_NOTI_PATH) + user_name_max + strlen(file) + 1;
        path = calloc(1, path_len);
        if (NULL == path) {
                ERR("calloc() fail");
                return NULL;
        }
 
-       snprintf(path, path_len, CTSVC_NOTI_PATH"/%s", uid, file);
+       user_name = __ctsvc_inotify_get_username(uid);
+       snprintf(path, path_len, CTSVC_NOTI_PATH"/%s", user_name, file);
        DBG("%s", path);
        return path;
 }
index a14b9ba..ac83573 100644 (file)
@@ -31,7 +31,7 @@
 #define CTS_LOGO_IMAGE_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/logo")
 #define CTSVC_CONTACT_IMG_FULL_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/contact")
 
-#define CTSVC_NOTI_PATH "/run/user_ext/%d/contacts-svc"
+#define CTSVC_NOTI_PATH "/opt/usr/home/%s/data/contacts-svc"
 #define CTSVC_NOTI_IPC_READY ".CONTACTS_SVC_IPC_READY"
 #define CTSVC_NOTI_ADDRESSBOOK_CHANGED ".CONTACTS_SVC_AB_CHANGED"
 #define CTSVC_NOTI_GROUP_CHANGED ".CONTACTS_SVC_GROUP_CHANGED"
index 7d71198..4fd07ad 100644 (file)
@@ -28,7 +28,7 @@
 
 #include "contacts_views.h"
 
-#define CTSVC_SOCK_PATH "/run/user_ext/%d"
+#define CTSVC_SOCK_PATH "/run/user/%d"
 #define CTSVC_IMG_FULL_PATH_SIZE_MAX 1024              /* current max length file path is 256 */
 #define CTSVC_PATH_MAX_LEN 1024
 #define CTSVC_STR_SHORT_LEN 1024
index a720a31..2ec57c9 100644 (file)
@@ -1,6 +1,6 @@
 Name:       contacts-service
 Summary:    Contacts Service
-Version:    0.13.65
+Version:    0.13.66
 Release:    0
 Group:      Social & Content/Service
 License:    Apache-2.0
index 6cbdec3..1fe2d14 100644 (file)
@@ -309,12 +309,12 @@ void __ctsvc_create_noti_file_set_permission(const char *file, mode_t mode)
        fd = creat(path,  mode);
        if (0 <= fd) {
                close(fd);
-               chmod(path, CTS_SECURITY_DEFAULT_PERMISSION);
+               chmod(path, 0644);
        }
        free(path);
 }
 
-
+/*
 void __ctsvc_create_noti_rep_set_permission(mode_t mode)
 {
        char path[CTSVC_PATH_MAX_LEN] = {0};
@@ -323,7 +323,7 @@ void __ctsvc_create_noti_rep_set_permission(mode_t mode)
        if (-1 == access(path, F_OK))
                mkdir(path, mode);
 }
-
+*/
 
 int main(int argc, char *argv[])
 {
@@ -352,7 +352,7 @@ int main(int argc, char *argv[])
        __ctsvc_create_rep_set_permission(CTS_LOGO_IMAGE_LOCATION, 0750);
        __ctsvc_create_rep_set_permission(CTSVC_CONTACT_IMG_FULL_LOCATION, 0750);
 
-       __ctsvc_create_noti_rep_set_permission(0755);
+       //__ctsvc_create_noti_rep_set_permission(0744);
        __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_IPC_READY, CTS_SECURITY_DEFAULT_PERMISSION);
        __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_ADDRESSBOOK_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
        __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_GROUP_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);