change uid/gid 47/66247/4
authorSangkoo Kim <sangkoo.kim@samsung.com>
Mon, 18 Apr 2016 05:34:33 +0000 (14:34 +0900)
committerSangkoo Kim <sangkoo.kim@samsung.com>
Mon, 18 Apr 2016 06:00:56 +0000 (15:00 +0900)
Change-Id: Icb47ed8a5335c8ceab26058387230e289c611ef6

framework/main.cpp
framework/setting-handler/MsgSettingHandler.cpp
include/utils/MsgUtilFile.h
packaging/msg-server.service
packaging/msg-server.socket
packaging/msg-service.spec
utils/CMakeLists.txt
utils/MsgIpcSocket.cpp
utils/MsgUtilFile.cpp

index ba9249c..f025111 100755 (executable)
@@ -56,11 +56,6 @@ void* InitMsgServer(void*)
        MsgInitCallStatusManager();
 
        try {
-               /* ipc data folder set acl for priv_read and priv_write */
-               if (!MsgAclInit()) {
-                       MSG_ERR("FAIL TO INITIALIZE ACL [%d]", err);
-               }
-
                /* storage handler initialize */
                err = MsgStoInitDB(false);
                if (err != MSG_SUCCESS) {
index 5d850d6..37c4cf0 100755 (executable)
 
 /* To store latest setting values */
 /* when it sets to vconf, it will be compared with below values */
-MSG_GENERAL_OPT_S              g_generalOpt;
-MSG_SMS_SENDOPT_S              g_smsSendOpt;
-MSG_SMSC_LIST_S                        g_smscList;
-MSG_MMS_SENDOPT_S              g_mmsSendOpt;
-MSG_MMS_RECVOPT_S              g_mmsRecvOpt;
-MSG_MMS_STYLEOPT_S             g_mmsStyleOpt;
-MSG_PUSHMSG_OPT_S              g_pushMsgOpt;
+MSG_GENERAL_OPT_S              g_generalOpt = {0,};
+MSG_SMS_SENDOPT_S              g_smsSendOpt = {0,};
+MSG_SMSC_LIST_S                        g_smscList = {0,};
+MSG_MMS_SENDOPT_S              g_mmsSendOpt = {0,};
+MSG_MMS_RECVOPT_S              g_mmsRecvOpt = {0,};
+MSG_MMS_STYLEOPT_S             g_mmsStyleOpt = {0,};
+MSG_PUSHMSG_OPT_S              g_pushMsgOpt = {0,};
 
 /*==================================================================================================
                                      FUNCTION IMPLEMENTATION
index 0407143..691546b 100755 (executable)
@@ -65,6 +65,5 @@ int MsgCheckFilepathSmack(const char *app_smack_label, char *file_path);
 
 void MsgGetMimeType(char *filePath, char *mimeType, int size);
 int MsgTcsScanFile(const char *filepath, int *bLevel);
-bool MsgAclInit();
 #endif /* MSG_UTIL_FILE_H */
 
index 4ad8912..cd2d14a 100755 (executable)
@@ -4,6 +4,8 @@ After=contacts-service.service
 
 [Service]
 Type=simple
+User=messaging
+Group=messaging
 ExecStart=/usr/bin/msg-server
 Restart=always
 MemoryLimit=10M
index e9787a6..018a133 100644 (file)
@@ -1,4 +1,6 @@
 [Socket]
+SocketUser=messaging
+SocketGroup=messaging
 ListenStream=/tmp/.msgfw_socket
 Service=msg-server.service
 
index bb9f740..707a182 100755 (executable)
@@ -17,8 +17,9 @@ Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 Requires(post): systemd
 Requires(postun): systemd
+Requires: acl
+Requires: security-config
 BuildRequires: cmake
-BuildRequires: libacl-devel
 BuildRequires: pkgconfig(alarm-service)
 BuildRequires: pkgconfig(aul)
 BuildRequires: pkgconfig(boost)
@@ -191,26 +192,37 @@ rm %{buildroot}/usr/share/msg-service/msg-service-db.sql
 chmod 640 %{TZ_SYS_DB}/.msg_service.db
 chmod 660 %{TZ_SYS_DB}/.msg_service.db-journal
 
-mkdir -p -m 775 %{TZ_SYS_DATA}/msg-service
-mkdir -p -m 770 %{TZ_SYS_DATA}/msg-service/msgdata
-mkdir -p -m 770 %{TZ_SYS_DATA}/msg-service/smildata
+mkdir -p -m 770 %{TZ_SYS_DATA}/msg-service
+mkdir -p -m 750 %{TZ_SYS_DATA}/msg-service/msgdata
+mkdir -p -m 750 %{TZ_SYS_DATA}/msg-service/smildata
 mkdir -p -m 770 %{TZ_SYS_DATA}/msg-service/ipcdata
-mkdir -p -m 770 %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails
+mkdir -p -m 750 %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails
 
+chown messaging:priv_message_read %{TZ_SYS_DB}/.msg_service.db
+chown messaging:priv_message_read %{TZ_SYS_DB}/.msg_service.db-journal
+chown messaging:priv_message_read %{TZ_SYS_DATA}/msg-service
+chown messaging:priv_message_read %{TZ_SYS_DATA}/msg-service/msgdata
+chown messaging:priv_message_read %{TZ_SYS_DATA}/msg-service/smildata
+chown messaging:priv_message_read %{TZ_SYS_DATA}/msg-service/ipcdata
+chown messaging:priv_message_read %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails
 
-chgrp priv_message_read %{TZ_SYS_DB}/.msg_service.db
-chgrp priv_message_read %{TZ_SYS_DATA}/msg-service/msgdata
-chgrp priv_message_read %{TZ_SYS_DATA}/msg-service/smildata
-chgrp priv_message_write %{TZ_SYS_DATA}/msg-service/ipcdata
-chgrp priv_message_read %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails
-
+chmod g+s %{TZ_SYS_DATA}/msg-service/msgdata
+chmod g+s %{TZ_SYS_DATA}/msg-service/smildata
+chmod g+s %{TZ_SYS_DATA}/msg-service/ipcdata
+chmod g+s %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails
 
 chsmack -a "*" %{TZ_SYS_DB}/.msg_service.db
+chsmack -a "*" %{TZ_SYS_DB}/.msg_service.db-journal
+chsmack -a "System::Shared" %{TZ_SYS_DATA}/msg-service/
 chsmack -a "System::Shared" %{TZ_SYS_DATA}/msg-service/msgdata -t
 chsmack -a "System::Shared" %{TZ_SYS_DATA}/msg-service/smildata -t
 chsmack -a "System::Run" %{TZ_SYS_DATA}/msg-service/ipcdata -t
 chsmack -a "System::Shared" %{TZ_SYS_DATA}/msg-service/msgdata/thumbnails -t
 
+#Multi group to ipcdata directory
+chmod o= %{TZ_SYS_DATA}/msg-service/ipcdata
+setfacl -m group:priv_message_write:rw %{TZ_SYS_DATA}/msg-service/ipcdata
+
 %post -n sms-plugin -p /sbin/ldconfig
 %post -n mms-plugin -p /sbin/ldconfig
 
index cb248ee..4302373 100755 (executable)
@@ -61,7 +61,7 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
 SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
 
 ADD_LIBRARY(${UTILS-LIB} SHARED ${UTILS-SRCS})
-TARGET_LINK_LIBRARIES(${UTILS-LIB} ${utils_pkgs_LDFLAGS} rt ${VOBJECT-LIB} acl)
+TARGET_LINK_LIBRARIES(${UTILS-LIB} ${utils_pkgs_LDFLAGS} rt ${VOBJECT-LIB})
 
 INSTALL(TARGETS ${UTILS-LIB} DESTINATION ${LIBDIR} COMPONENT RuntimeLibraries)
 
index bd8b18d..c7ac95e 100755 (executable)
@@ -61,6 +61,7 @@ msg_error_t MsgIpcClientSocket::connect(const char* path)
        int len = strlen(serverSA.sun_path) + sizeof(serverSA.sun_family);
 
        if (::connect(sockfd, (struct sockaddr *)&serverSA, len) == CUSTOM_SOCKET_ERROR) {
+               MSG_DEBUG("errno=[%d]", errno);
                if(errno == EACCES)
                        THROW(MsgException::SECURITY_ERROR, "cannot connect server %s", g_strerror(errno));
                else
index 71fc128..5aa59dd 100755 (executable)
@@ -26,7 +26,6 @@
 #include <unistd.h>
 #include <fcntl.h>
 #include <libgen.h>
-#include <acl/libacl.h>
 
 #include <thumbnail_util.h>
 #include <image_util.h>
@@ -1113,7 +1112,6 @@ bool MsgChown(const char *filepath, int uid, int gid)
        }
 
        close(fd);
-
        return true;
 }
 
@@ -1296,48 +1294,3 @@ int MsgTcsScanFile(const char *filepath, int *bLevel)
 
        return 0;
 }
-
-
-bool MsgAclInit()
-{
-       /* ACL */
-       /* In msg-service.spec file use libacl-devel. Because acl get not process open API */
-       /* So have to set TARGET_LINK_LIBRARIES(acl) in makefile */
-       /* After GPL-3.0, not supply shell commend (setfacl, getfacl) by license issue, use the API */
-       MSG_BEGIN();
-
-       const char *priv_read =
-                       "user::rwx\n"
-                       "group::rwx\n"
-                       "group:priv_message_read:rwx\n"
-                       "mask::rwx\n"
-                       "other::---";
-       acl_t acl = NULL;
-       int ret = 0;
-
-       acl = acl_from_text(priv_read);
-       if (!acl) {
-               MSG_ERR("%s: `%s': %s\n", MSG_IPC_DATA_PATH, priv_read, g_strerror(errno));
-               return false;
-       }
-
-       ret = acl_check(acl, NULL);
-       if (ret != 0) {
-               acl_free(acl);
-               if (ret == ACL_DUPLICATE_ERROR) {
-                       MSG_DEBUG("Already Set ACL");
-                       return true;
-               }
-               MSG_ERR("acl_check Fail : [%d],[%s]", ret, acl_error(ret));
-               return false;
-       }
-
-       ret = acl_set_file((const char *)MSG_IPC_DATA_PATH, ACL_TYPE_ACCESS, acl);
-       if (ret != 0) {
-               MSG_ERR("acl_set_file Fail : [%d][%s]", ret, g_strerror(errno));
-       }
-       acl_free(acl);
-
-       MSG_END();
-       return true;
-}