Modify the uid and gid to network_fw 63/134663/3 accepted/tizen/4.0/unified/20170816.013336 accepted/tizen/4.0/unified/20170816.015845 accepted/tizen/unified/20170803.010528 submit/tizen/20170802.083449 submit/tizen_4.0/20170811.094300 submit/tizen_4.0/20170814.115522 submit/tizen_4.0_unified/20170814.115522
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 20 Jun 2017 01:56:24 +0000 (10:56 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Fri, 14 Jul 2017 02:02:06 +0000 (11:02 +0900)
Change-Id: Idf045a06dd42baecc9bf28590d25fe470e7ac1e3
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
bt-share/CMakeLists.txt
bt-share/include/bt-share-common.h
bt-share/src/bt-share-common.c
bt-share/src/obex-event-handler.c
packaging/bluetooth-share.service
packaging/bluetooth-share.spec
packaging/init_db.sh

index 9db598e..5c73189 100644 (file)
@@ -25,7 +25,7 @@ pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api
                                capi-content-media-content
                                libtzplatform-config eventsystem
                                cynara-creds-dbus cynara-client cynara-session
-                               storage db-util)
+                               storage db-util libsystemd-login)
 #pkg_check_modules(CALENDAR_SERVICE2 calendar-service2)
 #pkg_check_modules(CONTACTS_SERVICE2 contacts-service2 zlib)
 
index 68c332c..8a0f4bf 100644 (file)
@@ -75,6 +75,7 @@ void _bt_remove_tmp_file(char *file_path);
 void _bt_remove_vcf_file(char *file_path);
 char *_bt_get_time_of_the_day(void);
 char *_bt_share_get_storage_path(int storage_type);
+int _bt_share_get_active_uid(uid_t *uid);
 
 #ifdef __cplusplus
 }
index ca6d9fb..c48e13b 100644 (file)
@@ -29,6 +29,7 @@
 #include <sys/xattr.h>
 #include <linux/xattr.h>
 #include <storage.h>
+#include <systemd/sd-login.h>
 
 #include "vconf-keys.h"
 #include "applog.h"
@@ -305,3 +306,38 @@ char *_bt_share_get_storage_path(int storage_type)
        return path;
 }
 
+int _bt_share_get_active_uid(uid_t *uid)
+{
+       DBG("+");
+
+       int ret = 0;
+       uid_t *active_user_list = NULL;
+       char *slice = NULL;
+       *uid = getuid();
+
+       ret = sd_pid_get_slice(getpid(), &slice);
+       if (0 <= ret && slice) {
+               if (!g_strcmp0(slice, "system.slice")) {
+                       ret = sd_get_active_uids(&active_user_list);
+                       /* the number of active users is 1 in tizen3.0 */
+                       if (1 == ret && active_user_list) {
+                               *uid = active_user_list[0];
+                               DBG("uid = %d", *uid);
+                       } else {
+                               ERR("sd_get_active_uids() Fail(%d)", ret);
+                               free(active_user_list);
+                               free(slice);
+                               return BT_SHARE_ERROR_NONE;
+                       }
+                       free(active_user_list);
+               }
+               free(slice);
+       } else {
+               ERR("sd_pid_get_slice() Fail(%d)", ret);
+       }
+
+       DBG("getuid() = %d, uid =  %d", getuid(), *uid);
+
+       return BT_SHARE_ERROR_NONE;
+}
+
index aaf5322..881734e 100644 (file)
@@ -38,6 +38,7 @@
 #include <bluetooth-share-api.h>
 #include <notification.h>
 #include <media_content.h>
+#include <media_content_internal.h>
 #include <sys/stat.h>
 #include <aul.h>
 #include <storage.h>
@@ -284,8 +285,14 @@ static bt_file_type_e __get_file_type(char *extn)
 static gboolean __bt_scan_media_file(char *file_path)
 {
        int ret = 0;
+       uid_t uid = 0;
 
-       ret = media_content_connect();
+       /* Set active UID for system session's bt-share process */
+       ret = _bt_share_get_active_uid(&uid);
+       retvm_if(ret != BT_SHARE_ERROR_NONE, FALSE,
+               "Fail to get the active uid: %d", ret);
+
+       ret = media_content_connect_with_uid(uid);
        retvm_if(ret != MEDIA_CONTENT_ERROR_NONE, FALSE,
                "Fail to connect the media content: %d", ret);
 
index 0ef379c..26fb3ab 100644 (file)
@@ -2,10 +2,9 @@
 Description=Bluetooth service
 
 [Service]
-User=owner
-Group=users
+User=network_fw
+Group=network_fw
 SupplementaryGroups=priv_mediastorage priv_externalstorage
 Type=simple
-SmackProcessLabel=User
 ExecStart=/usr/bin/bluetooth-share
 KillMode=process
index 03df7da..76da9eb 100644 (file)
@@ -38,6 +38,7 @@ BuildRequires:  pkgconfig(cynara-session)
 BuildRequires:  pkgconfig(cynara-creds-dbus)
 BuildRequires:  pkgconfig(eventsystem)
 BuildRequires:  pkgconfig(storage)
+BuildRequires:  pkgconfig(libsystemd)
 
 %description
 Bluetooth File Share Agent
index 95e295e..961b672 100644 (file)
@@ -36,10 +36,10 @@ then
        );      '
 fi
 
-/usr/bin/chown 5001:100 $TZ_SYS_DB/.bluetooth_transfer.db
-/usr/bin/chown 5001:100 $TZ_SYS_DB/.bluetooth_transfer.db-journal
-/usr/bin/chmod 664 $TZ_SYS_DB/.bluetooth_transfer.db
-/usr/bin/chmod 664 $TZ_SYS_DB/.bluetooth_transfer.db-journal
+/usr/bin/chown network_fw:network_fw $TZ_SYS_DB/.bluetooth_transfer.db
+/usr/bin/chown network_fw:network_fw $TZ_SYS_DB/.bluetooth_transfer.db-journal
+/usr/bin/chmod 644 $TZ_SYS_DB/.bluetooth_transfer.db
+/usr/bin/chmod 644 $TZ_SYS_DB/.bluetooth_transfer.db-journal
 
-/usr/bin/chsmack -a 'User::Home' $TZ_SYS_DB/.bluetooth_transfer.db
-/usr/bin/chsmack -a 'User::Home' $TZ_SYS_DB/.bluetooth_transfer.db-journal
+/usr/bin/chsmack -a _ $TZ_SYS_DB/.bluetooth_transfer.db
+/usr/bin/chsmack -a _ $TZ_SYS_DB/.bluetooth_transfer.db-journal