From 9378ba57f1d5507fed275b215c70e1d53d774a61 Mon Sep 17 00:00:00 2001 From: DoHyun Pyun Date: Wed, 29 Jun 2016 21:53:41 +0900 Subject: [PATCH] Revert "Modify the bt-service label from system to user" This reverts commit 4341e1ed25d943162e7f47d3392fc7701812c95e. Change-Id: Ic45d71f8740d0b33ead0070c0e4700526066ba37 --- bt-api/bt-common.c | 65 ---------------------------- bt-api/bt-event-handler.c | 8 ++-- bt-api/bt-request-sender.c | 3 +- bt-api/include/bt-common.h | 5 --- bt-service-emul/bt-request-handler.c | 4 +- bt-service/CMakeLists.txt | 4 +- bt-service/bluetooth-frwk-service.conf.in | 10 ----- bt-service/bt-request-handler.c | 6 +-- bt-service/bt-service-event-sender.c | 2 +- bt-service/org.projectx.bt.service | 1 + packaging/bluetooth-frwk-mobile-sprd.service | 7 ++- packaging/bluetooth-frwk.spec | 18 ++++---- 12 files changed, 28 insertions(+), 105 deletions(-) diff --git a/bt-api/bt-common.c b/bt-api/bt-common.c index 548d52c..515d4ce 100644 --- a/bt-api/bt-common.c +++ b/bt-api/bt-common.c @@ -49,8 +49,6 @@ static GDBusConnection *system_gdbus_conn = NULL; static guint bus_id; static GDBusConnection *system_gconn = NULL; -static GDBusConnection *session_gconn = NULL; - #define DBUS_TIMEOUT 20 * 1000 /* 20 Seconds */ @@ -86,38 +84,6 @@ GDBusConnection *g_bus_get_private_conn(void) return private_gconn; } -GDBusConnection *g_bus_get_private_session_conn(void) -{ - GError *error = NULL; - char *address; - GDBusConnection *private_gconn = NULL; - - address = g_dbus_address_get_for_bus_sync(G_BUS_TYPE_SESSION, NULL, &error); - if (address == NULL) { - if (error) { - BT_ERR("Failed to get bus address: %s", error->message); - g_clear_error(&error); - } - return NULL; - } - - private_gconn = g_dbus_connection_new_for_address_sync(address, - G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT | - G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION, - NULL, /* GDBusAuthObserver */ - NULL, - &error); - if (!private_gconn) { - if (error) { - BT_ERR("Unable to connect to dbus: %s", error->message); - g_clear_error(&error); - } - return NULL; - } - - return private_gconn; -} - GDBusConnection *_bt_gdbus_init_system_gconn(void) { dbus_threads_init_default(); @@ -130,18 +96,6 @@ GDBusConnection *_bt_gdbus_init_system_gconn(void) return system_gconn; } -GDBusConnection *_bt_gdbus_init_session_gconn(void) -{ - dbus_threads_init_default(); - - if (session_gconn != NULL) - return session_gconn; - - session_gconn = g_bus_get_private_session_conn(); - - return session_gconn; -} - GDBusConnection *_bt_gdbus_get_system_gconn(void) { @@ -155,20 +109,6 @@ GDBusConnection *_bt_gdbus_get_system_gconn(void) return system_gconn; } -GDBusConnection *_bt_gdbus_get_session_gconn(void) -{ - - - if (session_gconn == NULL) { - session_gconn = _bt_gdbus_init_session_gconn(); - } else if (g_dbus_connection_is_closed(session_gconn)) { - session_gconn = g_bus_get_private_session_conn(); - } - - return session_gconn; -} - - void _bt_print_device_address_t(const bluetooth_device_address_t *addr) { BT_DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X\n", addr->addr[0], addr->addr[1], addr->addr[2], @@ -1720,11 +1660,6 @@ BT_EXPORT_API int bluetooth_unregister_callback(void) g_object_unref(system_gconn); system_gconn = NULL; } - - if (session_gconn) { - g_object_unref(session_gconn); - session_gconn = NULL; - } return BLUETOOTH_ERROR_NONE; } diff --git a/bt-api/bt-event-handler.c b/bt-api/bt-event-handler.c index 058383f..96a5e2d 100644 --- a/bt-api/bt-event-handler.c +++ b/bt-api/bt-event-handler.c @@ -2616,7 +2616,7 @@ int _bt_register_event(int event_type, void *event_cb, void *user_data) return BLUETOOTH_ERROR_INTERNAL; } - connection_type = _bt_gdbus_get_session_gconn(); + connection_type = _bt_gdbus_get_system_gconn(); if (connection_type == NULL) return BLUETOOTH_ERROR_INTERNAL; @@ -2657,7 +2657,7 @@ int _bt_unregister_event(int event_type) return BLUETOOTH_ERROR_INTERNAL; } - connection_type = _bt_gdbus_get_session_gconn(); + connection_type = _bt_gdbus_get_system_gconn(); event_list = g_slist_remove(event_list, (void *)cb_data); @@ -2705,7 +2705,7 @@ void _bt_register_name_owner_changed(void) { GDBusConnection *connection_type; - connection_type = _bt_gdbus_get_session_gconn(); + connection_type = _bt_gdbus_get_system_gconn(); if (connection_type == NULL) { BT_ERR("Unable to get the bus"); return; @@ -2720,7 +2720,7 @@ void _bt_unregister_name_owner_changed(void) { GDBusConnection *connection_type; - connection_type = _bt_gdbus_get_session_gconn(); + connection_type = _bt_gdbus_get_system_gconn(); if (connection_type != NULL && owner_sig_id != -1) { g_dbus_connection_signal_unsubscribe(connection_type, owner_sig_id); diff --git a/bt-api/bt-request-sender.c b/bt-api/bt-request-sender.c index fa4448b..b240fb8 100644 --- a/bt-api/bt-request-sender.c +++ b/bt-api/bt-request-sender.c @@ -43,8 +43,7 @@ static GDBusProxy *__bt_gdbus_init_service_proxy(void) GDBusProxy *proxy; GError *err = NULL; -// service_gconn = _bt_gdbus_get_system_gconn(); - service_gconn = _bt_gdbus_get_session_gconn(); + service_gconn = _bt_gdbus_get_system_gconn(); if (!service_gconn) return NULL; diff --git a/bt-api/include/bt-common.h b/bt-api/include/bt-common.h index ff6ed81..8040910 100755 --- a/bt-api/include/bt-common.h +++ b/bt-api/include/bt-common.h @@ -341,11 +341,6 @@ GDBusConnection *_bt_gdbus_init_system_gconn(void); GDBusConnection *_bt_gdbus_get_system_gconn(void); -GDBusConnection *_bt_gdbus_init_session_gconn(void); - -GDBusConnection *_bt_gdbus_get_session_gconn(void); - - GVariant *_bt_get_managed_objects(void); void _bt_convert_device_path_to_address(const char *device_path, diff --git a/bt-service-emul/bt-request-handler.c b/bt-service-emul/bt-request-handler.c index f269e7b..f3b0055 100644 --- a/bt-service-emul/bt-request-handler.c +++ b/bt-service-emul/bt-request-handler.c @@ -2741,10 +2741,10 @@ int _bt_service_register(void) GError *err = NULL; int result; - conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err); + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL); - owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, + owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, BT_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, diff --git a/bt-service/CMakeLists.txt b/bt-service/CMakeLists.txt index fc6dec6..5d6da03 100644 --- a/bt-service/CMakeLists.txt +++ b/bt-service/CMakeLists.txt @@ -133,7 +133,7 @@ ELSE(LIBNOTIFY_SUPPORT) ENDIF(LIBNOTIFY_SUPPORT) #CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service.in ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service DESTINATION share/dbus-1/services) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/org.projectx.bt.service DESTINATION share/dbus-1/system-services) INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-pair-blacklist DESTINATION /opt/var/lib/bluetooth/) @@ -147,7 +147,7 @@ ELSE () INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/mobile/stack_info DESTINATION /usr/etc/bluetooth/) ENDIF (TIZEN_WEARABLE) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/session.d) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/bluetooth-frwk-service.conf DESTINATION /etc/dbus-1/system.d) SET(PREFIX ${CMAKE_INSTALL_PREFIX}) diff --git a/bt-service/bluetooth-frwk-service.conf.in b/bt-service/bluetooth-frwk-service.conf.in index 79c4979..8fc61f5 100644 --- a/bt-service/bluetooth-frwk-service.conf.in +++ b/bt-service/bluetooth-frwk-service.conf.in @@ -6,7 +6,6 @@ - @@ -14,15 +13,6 @@ - - - - - - - - - diff --git a/bt-service/bt-request-handler.c b/bt-service/bt-request-handler.c index b352f71..2a97c5f 100644 --- a/bt-service/bt-request-handler.c +++ b/bt-service/bt-request-handler.c @@ -2657,8 +2657,6 @@ gboolean __bt_service_check_privilege(int function_name, case BT_LE_IPSP_DEINIT: case BT_LE_IPSP_CONNECT: case BT_LE_IPSP_DISCONNECT: - case BT_PASSKEY_REPLY: - case BT_PASSKEY_CONFIRMATION_REPLY: ret_val = cynara_check(p_cynara, client_creds, client_session, user_creds, BT_PRIVILEGE_PLATFORM); @@ -2765,10 +2763,10 @@ int _bt_service_register(void) GError *err = NULL; int result; - conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err); + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL); - owner_id = g_bus_own_name(G_BUS_TYPE_SESSION, + owner_id = g_bus_own_name(G_BUS_TYPE_SYSTEM, BT_SERVICE_NAME, G_BUS_NAME_OWNER_FLAGS_NONE, NULL, NULL, NULL, diff --git a/bt-service/bt-service-event-sender.c b/bt-service/bt-service-event-sender.c index 8d83d8a..f539589 100644 --- a/bt-service/bt-service-event-sender.c +++ b/bt-service/bt-service-event-sender.c @@ -530,7 +530,7 @@ int _bt_init_service_event_sender(void) return BLUETOOTH_ERROR_INTERNAL; } - conn = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &err); + conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err); retv_if(conn == NULL, BLUETOOTH_ERROR_INTERNAL); if (conn == NULL) { BT_ERR("conn == NULL"); diff --git a/bt-service/org.projectx.bt.service b/bt-service/org.projectx.bt.service index 079751c..7444ab5 100644 --- a/bt-service/org.projectx.bt.service +++ b/bt-service/org.projectx.bt.service @@ -1,4 +1,5 @@ [D-BUS Service] Name=org.projectx.bt Exec=/bin/false +User=root SystemdService=bluetooth-frwk.service diff --git a/packaging/bluetooth-frwk-mobile-sprd.service b/packaging/bluetooth-frwk-mobile-sprd.service index b24b1bb..81a5223 100644 --- a/packaging/bluetooth-frwk-mobile-sprd.service +++ b/packaging/bluetooth-frwk-mobile-sprd.service @@ -1,11 +1,16 @@ [Unit] Description=Bluetooth service +After=multi-user.target [Service] +User=owner +Group=users +SupplementaryGroups=priv_mediastorage priv_externalstorage Type=dbus BusName=org.projectx.bt ExecStart=/usr/bin/bt-service KillMode=process +Environment=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/5001/dbus/user_bus_socket [Install] -WantedBy=default.target +WantedBy=multi-user.target diff --git a/packaging/bluetooth-frwk.spec b/packaging/bluetooth-frwk.spec index c05c8c9..a0458cc 100644 --- a/packaging/bluetooth-frwk.spec +++ b/packaging/bluetooth-frwk.spec @@ -129,7 +129,7 @@ export CFLAGS="$CFLAGS -DTIZEN_NETWORK_TETHERING_ENABLE -DTIZEN_BT_FLIGHTMODE_EN %else %define _servicefile packaging/bluetooth-frwk-mobile.service %endif -%define _servicedir default.target.wants +%define _servicedir multi-user.target.wants %endif %if "%{?profile}" == "wearable" @@ -198,9 +198,9 @@ install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-frwk-devel #mkdir -p %{buildroot}%{_libdir}/systemd/user #install -m 0644 packaging/bluetooth-frwk-tv.service %{buildroot}%{_libdir}/systemd/user -mkdir -p %{buildroot}/usr/lib/systemd/user/%{_servicedir} -install -m 0644 %{_servicefile} %{buildroot}/usr/lib/systemd/user/bluetooth-frwk.service -ln -s ../bluetooth-frwk.service %{buildroot}/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service +mkdir -p %{buildroot}%{_unitdir}/%{_servicedir} +install -m 0644 %{_servicefile} %{buildroot}%{_unitdir}/bluetooth-frwk.service +ln -s ../bluetooth-frwk.service %{buildroot}%{_unitdir}/%{_servicedir}/bluetooth-frwk.service %if %{with bluetooth_frwk_libnotify} || %{with bluetooth_frwk_libnotification} mkdir -p %{buildroot}%{_datadir}/icons/default @@ -247,8 +247,8 @@ sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-servi %defattr(-, root, root) %{_libdir}/libbluetooth-api.so.* %{_datadir}/license/bluetooth-frwk -/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service -/usr/lib/systemd/user/bluetooth-frwk.service +%{_unitdir}/%{_servicedir}/bluetooth-frwk.service +%{_unitdir}/bluetooth-frwk.service %files devel %defattr(-, root, root) @@ -266,11 +266,11 @@ sed -i 's/%TZ_SYS_DEFAULT_USER/app/' %{buildroot}%{_datadir}/dbus-1/system-servi %files service %manifest %{name}.manifest %defattr(-, root, root) -%{_datadir}/dbus-1/services/org.projectx.bt.service +%{_datadir}/dbus-1/system-services/org.projectx.bt.service %{_bindir}/bt-service #%{_libdir}/systemd/user/bluetooth-frwk-tv.service -/usr/lib/systemd/user/%{_servicedir}/bluetooth-frwk.service -%{_sysconfdir}/dbus-1/session.d/bluetooth-frwk-service.conf +%{_unitdir}/%{_servicedir}/bluetooth-frwk.service +%{_sysconfdir}/dbus-1/system.d/bluetooth-frwk-service.conf %{_bindir}/bluetooth-frwk-test #%{_bindir}/bluetooth-gatt-test #%{_bindir}/bluetooth-advertising-test -- 2.7.4