Modify the uid and gid of obexd to network_fw 70/131570/2 accepted/tizen/unified/20170613.194443 submit/tizen/20170613.061600
authorDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 30 May 2017 05:18:36 +0000 (14:18 +0900)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 8 Jun 2017 07:16:56 +0000 (16:16 +0900)
The uid of tizen's bt-service will be changed to network_fw from owner.
'network_fw' is a no app user, so it can't use the session bus connection.
Because of this, tizen obexd's dbus connection also change to system bus.

Change-Id: I73f66e8a451a2b3b62c9f03a8468b824813d8767
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
17 files changed:
Makefile.obexd
obexd/client/ftp.c
obexd/client/map.c
obexd/client/mns-tizen.c
obexd/client/opp.c
obexd/client/pbap.c
obexd/client/session.c
obexd/client/sync.c
obexd/plugins/messages-tizen.c
obexd/plugins/pcsuite.c
obexd/src/manager.c
obexd/src/obex.service.in
obexd/src/org.bluez.obex.service
packaging/bluez.spec
tools/mpris-proxy.c
tools/obexctl.c
unit/test-gdbus-client.c

index 05a3b6b..ca0a72c 100755 (executable)
@@ -1,9 +1,11 @@
 
 if SYSTEMD
-systemduserunitdir = @SYSTEMD_USERUNITDIR@
+#systemduserunitdir = @SYSTEMD_USERUNITDIR@
+systemduserunitdir = @SYSTEMD_SYSTEMUNITDIR@
 systemduserunit_DATA = obexd/src/obex.service
 
-dbussessionbusdir = @DBUS_SESSIONBUSDIR@
+#dbussessionbusdir = @DBUS_SESSIONBUSDIR@
+dbussessionbusdir = @DBUS_SYSTEMBUSDIR@
 dbussessionbus_DATA = obexd/src/org.bluez.obex.service
 endif
 
index 3628657..dd4db44 100755 (executable)
@@ -476,7 +476,11 @@ int ftp_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index 4c6d676..cc48916 100755 (executable)
@@ -2074,7 +2074,11 @@ int map_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index c6da1eb..47963e4 100755 (executable)
@@ -246,7 +246,11 @@ int mns_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index 9a6cf34..fb6d438 100755 (executable)
@@ -205,7 +205,11 @@ int opp_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index db46a80..b84d2e2 100755 (executable)
@@ -1365,7 +1365,11 @@ int pbap_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index 6c7c337..441c461 100755 (executable)
@@ -626,7 +626,12 @@ struct obc_session *obc_session_create(const char *source,
        if (driver == NULL)
                return NULL;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
+
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (conn == NULL)
                return NULL;
 
index 548c318..1f17343 100755 (executable)
@@ -237,7 +237,11 @@ int sync_init(void)
 
        DBG("");
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!conn)
                return -EIO;
 
index e59c37b..5006607 100755 (executable)
@@ -334,7 +334,11 @@ static void create_folder_tree()
 
 int messages_init(void)
 {
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       g_conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+#else
        g_conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+#endif
        if (!g_conn) {
                error("Can't get on session bus");
                return -1;
index 43ab409..7092b9f 100755 (executable)
@@ -333,7 +333,11 @@ static gboolean send_backup_dbus_message(const char *oper,
 
        file_size = size ? *size : 0;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+#else
        conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+#endif
 
        if (conn == NULL)
                return FALSE;
index 90c5114..92479df 100755 (executable)
@@ -623,7 +623,11 @@ gboolean manager_init(void)
 
        dbus_error_init(&err);
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       connection = g_dbus_setup_bus(DBUS_BUS_SYSTEM, OBEXD_SERVICE, &err);
+#else
        connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OBEXD_SERVICE, &err);
+#endif
        if (connection == NULL) {
                if (dbus_error_is_set(&err) == TRUE) {
                        fprintf(stderr, "%s\n", err.message);
index bca3aef..cfa059a 100755 (executable)
@@ -2,6 +2,9 @@
 Description=Bluetooth OBEX service
 
 [Service]
+User=network_fw
+Group=network_fw
+SupplementaryGroups=priv_mediastorage priv_externalstorage
 Type=dbus
 BusName=org.bluez.obex
 ExecStart=@libexecdir@/obexd
index 3abb555..404dd80 100755 (executable)
@@ -1,3 +1,5 @@
 [D-BUS Service]
 Name=org.bluez.obex
 Exec=/bin/sh -c 'exec /usr/libexec/bluetooth/obexd -d --noplugin=ftp,syncevolution,pcsuite,irmc --symlinks -r /opt/usr/home/owner/media/'
+User=network_fw
+Group=network_fw
\ No newline at end of file
index 98c0643..21728c9 100755 (executable)
@@ -380,8 +380,8 @@ popd
 %manifest %{name}.manifest
 %defattr(-,root,root,-)
 %{_libexecdir}/bluetooth/obexd
-%{_libpath}/systemd/user/obex.service
-%{_datadir}/dbus-1/services/org.bluez.obex.service
+%{_libpath}/systemd/system/obex.service
+%{_datadir}/dbus-1/system-services/org.bluez.obex.service
 #%{_sysconfdir}/obex/root-setup.d/000_create-symlinks
 #%{_bindir}/obex-root-setup
 #%{_bindir}/obex.sh
index bf8148f..466ac31 100755 (executable)
@@ -1988,8 +1988,13 @@ static void register_player(GDBusProxy *proxy)
 
        printf("Player %s created\n", player->bus_name);
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       player->conn = g_dbus_setup_private(DBUS_BUS_SYSTEM, player->bus_name,
+                                                                       NULL);
+#else
        player->conn = g_dbus_setup_private(DBUS_BUS_SESSION, player->bus_name,
                                                                        NULL);
+#endif
        if (!session) {
                fprintf(stderr, "Could not register bus name %s",
                                                        player->bus_name);
@@ -2541,7 +2546,11 @@ int main(int argc, char *argv[])
                exit(1);
        }
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       session = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+#else
        session = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+#endif
        if (!session) {
                fprintf(stderr, "Can't get on session bus");
                exit(1);
index 86c81d5..892fcb3 100755 (executable)
@@ -2519,7 +2519,11 @@ int main(int argc, char *argv[])
        }
 
        main_loop = g_main_loop_new(NULL, FALSE);
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       dbus_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+#else
        dbus_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+#endif
 
        rl_attempted_completion_function = cmd_completion;
 
index dd17c00..3554d38 100755 (executable)
@@ -63,8 +63,13 @@ static struct context *create_context(void)
 
        dbus_error_init(&err);
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       context->dbus_conn = g_dbus_setup_private(DBUS_BUS_SYSTEM,
+                                                       SERVICE_NAME, &err);
+#else
        context->dbus_conn = g_dbus_setup_private(DBUS_BUS_SESSION,
                                                        SERVICE_NAME, &err);
+#endif
        if (context->dbus_conn == NULL) {
                if (dbus_error_is_set(&err)) {
                        tester_debug("D-Bus setup failed: %s", err.message);
@@ -883,7 +888,11 @@ static void client_force_disconnect(const void *data)
        if (context == NULL)
                return;
 
+#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+       conn = g_dbus_setup_private(DBUS_BUS_SYSTEM, SERVICE_NAME1, NULL);
+#else
        conn = g_dbus_setup_private(DBUS_BUS_SESSION, SERVICE_NAME1, NULL);
+#endif
        g_assert(conn != NULL);
 
        /* Avoid D-Bus library calling _exit() before next test finishes. */