diff mbox series

[BlueZ,v3] obexd: Add system bus support for obexd

Message ID 20241104124517.4112676-1-quic_dgangire@quicinc.com (mailing list archive)
State New
Headers show
Series [BlueZ,v3] obexd: Add system bus support for obexd | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 12: B3 Line contains hard tab characters (\t): " "Use System bus "},"
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild warning ScanBuild: obexd/src/main.c:286:6: warning: Array access (from variable 'option_root') results in a null pointer dereference if (option_root[0] != '/') { ^~~~~~~~~~~~~~ 1 warning generated.

Commit Message

Damodar Reddy GangiReddy Nov. 4, 2024, 12:45 p.m. UTC
From: Damodar Reddy GangiReddy <quic_dgangire@quicinc.com>

Currently obexd uses session bus.
Distros  where session bus is not supported and still obex profiles
are required in that case use system bus instead of session bus
which can be configured at run time.

An Command line option has been added to achieve it.
{ "system-bus", 's', 0, G_OPTION_ARG_NONE, &option_system_bus,
				"Use System bus "},

we can use option obexd -s to use system bus.

---
 Makefile.am             |  6 +++++-
 gdbus/gdbus.h           |  5 +++++
 gdbus/mainloop.c        | 25 +++++++++++++++++++++++++
 obexd/client/ftp.c      |  3 ++-
 obexd/client/map.c      |  3 ++-
 obexd/client/opp.c      |  3 ++-
 obexd/client/pbap.c     |  3 ++-
 obexd/client/session.c  |  3 ++-
 obexd/client/sync.c     |  3 ++-
 obexd/plugins/pcsuite.c |  2 +-
 obexd/src/main.c        |  8 ++++++++
 obexd/src/manager.c     |  4 +++-
 obexd/src/obex.conf     | 28 ++++++++++++++++++++++++++++
 obexd/src/obexd.h       |  3 +++
 14 files changed, 90 insertions(+), 9 deletions(-)
 create mode 100644 obexd/src/obex.conf

Comments

bluez.test.bot@gmail.com Nov. 4, 2024, 2:51 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=906048

---Test result---

Test Summary:
CheckPatch                    PASS      0.54 seconds
GitLint                       FAIL      0.51 seconds
BuildEll                      PASS      24.76 seconds
BluezMake                     PASS      1718.51 seconds
MakeCheck                     PASS      13.67 seconds
MakeDistcheck                 PASS      181.53 seconds
CheckValgrind                 PASS      256.28 seconds
CheckSmatch                   PASS      359.14 seconds
bluezmakeextell               PASS      121.55 seconds
IncrementalBuild              PASS      1448.49 seconds
ScanBuild                     WARNING   1020.13 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint
Output:
[BlueZ,v3] obexd: Add system bus support for obexd

WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search
12: B3 Line contains hard tab characters (\t): "				"Use System bus "},"
##############################
Test: ScanBuild - WARNING
Desc: Run Scan Build
Output:
obexd/src/main.c:286:6: warning: Array access (from variable 'option_root') results in a null pointer dereference
        if (option_root[0] != '/') {
            ^~~~~~~~~~~~~~
1 warning generated.



---
Regards,
Linux Bluetooth
Luiz Augusto von Dentz Nov. 4, 2024, 9:32 p.m. UTC | #2
Hi,

On Mon, Nov 4, 2024 at 7:47 AM <quic_dgangire@quicinc.com> wrote:
>
> From: Damodar Reddy GangiReddy <quic_dgangire@quicinc.com>
>
> Currently obexd uses session bus.
> Distros  where session bus is not supported and still obex profiles
> are required in that case use system bus instead of session bus
> which can be configured at run time.
>
> An Command line option has been added to achieve it.
> { "system-bus", 's', 0, G_OPTION_ARG_NONE, &option_system_bus,
>                                 "Use System bus "},
>
> we can use option obexd -s to use system bus.
>
> ---
>  Makefile.am             |  6 +++++-
>  gdbus/gdbus.h           |  5 +++++
>  gdbus/mainloop.c        | 25 +++++++++++++++++++++++++
>  obexd/client/ftp.c      |  3 ++-
>  obexd/client/map.c      |  3 ++-
>  obexd/client/opp.c      |  3 ++-
>  obexd/client/pbap.c     |  3 ++-
>  obexd/client/session.c  |  3 ++-
>  obexd/client/sync.c     |  3 ++-
>  obexd/plugins/pcsuite.c |  2 +-
>  obexd/src/main.c        |  8 ++++++++
>  obexd/src/manager.c     |  4 +++-
>  obexd/src/obex.conf     | 28 ++++++++++++++++++++++++++++
>  obexd/src/obexd.h       |  3 +++
>  14 files changed, 90 insertions(+), 9 deletions(-)
>  create mode 100644 obexd/src/obex.conf
>
> diff --git a/Makefile.am b/Makefile.am
> index f639f7f8b..297d0774c 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -39,6 +39,10 @@ if DATAFILES
>  dbusdir = $(DBUS_CONFDIR)/dbus-1/system.d
>  dbus_DATA = src/bluetooth.conf
>
> +if OBEX
> +dbus_DATA += obexd/src/obex.conf
> +endif
> +
>  conf_DATA = src/main.conf
>  conf_DATA += profiles/input/input.conf
>  conf_DATA += profiles/network/network.conf
> @@ -421,7 +425,7 @@ manual_pages += doc/org.bluez.obex.Client.5 doc/org.bluez.obex.Session.5 \
>
>  EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
>                         src/main.conf profiles/network/network.conf \
> -                       profiles/input/input.conf
> +                       profiles/input/input.conf obexd/src/obex.conf
>
>  test_scripts =
>  unit_tests =
> diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
> index d7be17661..8e0d9c1ea 100644
> --- a/gdbus/gdbus.h
> +++ b/gdbus/gdbus.h
> @@ -40,6 +40,11 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
>  DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
>                                                         DBusError *error);
>
> +DBusConnection *get_dbus_connection(gboolean bus_type);
> +
> +DBusConnection *setup_dbus_connection(gboolean bus_type, const char *name,
> +                                                       DBusError *error);
> +
>  gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
>                                                         DBusError *error);
>
> diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
> index a04ebb19b..7bf691191 100644
> --- a/gdbus/mainloop.c
> +++ b/gdbus/mainloop.c
> @@ -293,6 +293,31 @@ DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
>         return conn;
>  }
>
> +DBusConnection *get_dbus_connection(gboolean bus_type)
> +{
> +       DBusConnection *conn = NULL;
> +
> +       if (bus_type)
> +               conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
> +       else
> +               conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +
> +       return conn;
> +}
> +
> +DBusConnection *setup_dbus_connection(gboolean bus_type, const char *name,
> +                                                       DBusError *error)
> +{
> +       DBusConnection *conn = NULL;
> +
> +       if (bus_type)
> +               conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, name, error);
> +       else
> +               conn = g_dbus_setup_bus(DBUS_BUS_SESSION, name, error);
> +
> +       return conn;
> +}

Don't recall suggesting putting these helpers into gdbus, how is this
going to help us in any way if it is just passing a bool instead of
the type?

>  DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
>                                                         DBusError *error)
>  {
> diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c
> index 160e0636a..31fcd42fb 100644
> --- a/obexd/client/ftp.c
> +++ b/obexd/client/ftp.c
> @@ -19,6 +19,7 @@
>  #include "gdbus/gdbus.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>  #include "transfer.h"
>  #include "session.h"
>  #include "driver.h"
> @@ -463,7 +464,7 @@ int ftp_init(void)
>
>         DBG("");
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());

What I suggested is that we have something similar to
btd_get_dbus_connection (e.g. obexd_get_dbus_connection) which returns
a static variable so it is the same reference.

>         if (!conn)
>                 return -EIO;
>
> diff --git a/obexd/client/map.c b/obexd/client/map.c
> index 513dcaf14..2732eb7df 100644
> --- a/obexd/client/map.c
> +++ b/obexd/client/map.c
> @@ -27,6 +27,7 @@
>  #include "gdbus/gdbus.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>  #include "obexd/src/map_ap.h"
>  #include "map-event.h"
>
> @@ -2063,7 +2064,7 @@ int map_init(void)
>
>         DBG("");
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());
>         if (!conn)
>                 return -EIO;
>
> diff --git a/obexd/client/opp.c b/obexd/client/opp.c
> index 90d0c0c8e..13c49d12f 100644
> --- a/obexd/client/opp.c
> +++ b/obexd/client/opp.c
> @@ -17,6 +17,7 @@
>  #include "gdbus/gdbus.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>
>  #include "transfer.h"
>  #include "session.h"
> @@ -178,7 +179,7 @@ int opp_init(void)
>
>         DBG("");
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());
>         if (!conn)
>                 return -EIO;
>
> diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
> index 2d2aa9508..5280cbac5 100644
> --- a/obexd/client/pbap.c
> +++ b/obexd/client/pbap.c
> @@ -27,6 +27,7 @@
>  #include "gdbus/gdbus.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>
>  #include "transfer.h"
>  #include "session.h"
> @@ -1303,7 +1304,7 @@ int pbap_init(void)
>
>         DBG("");
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());
>         if (!conn)
>                 return -EIO;
>
> diff --git a/obexd/client/session.c b/obexd/client/session.c
> index 13a834e14..3460690dd 100644
> --- a/obexd/client/session.c
> +++ b/obexd/client/session.c
> @@ -27,6 +27,7 @@
>  #include "gobex/gobex.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>  #include "transfer.h"
>  #include "session.h"
>  #include "driver.h"
> @@ -591,7 +592,7 @@ struct obc_session *obc_session_create(const char *source,
>         if (driver == NULL)
>                 return NULL;
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());
>         if (conn == NULL)
>                 return NULL;
>
> diff --git a/obexd/client/sync.c b/obexd/client/sync.c
> index 92faf4434..0283d9729 100644
> --- a/obexd/client/sync.c
> +++ b/obexd/client/sync.c
> @@ -21,6 +21,7 @@
>  #include "gdbus/gdbus.h"
>
>  #include "obexd/src/log.h"
> +#include "obexd/src/obexd.h"
>
>  #include "transfer.h"
>  #include "session.h"
> @@ -224,7 +225,7 @@ int sync_init(void)
>
>         DBG("");
>
> -       conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
> +       conn = get_dbus_connection(obex_option_system_bus());
>         if (!conn)
>                 return -EIO;
>
> diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
> index 07c444ff2..06aca7366 100644
> --- a/obexd/plugins/pcsuite.c
> +++ b/obexd/plugins/pcsuite.c
> @@ -322,7 +322,7 @@ static gboolean send_backup_dbus_message(const char *oper,
>
>         file_size = size ? *size : 0;
>
> -       conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
> +       conn = setup_dbus_connection(obex_option_system_bus(), NULL, NULL);
>
>         if (conn == NULL)
>                 return FALSE;
> diff --git a/obexd/src/main.c b/obexd/src/main.c
> index 151574afa..aee86ebd1 100644
> --- a/obexd/src/main.c
> +++ b/obexd/src/main.c
> @@ -126,6 +126,7 @@ static char *option_noplugin = NULL;
>
>  static gboolean option_autoaccept = FALSE;
>  static gboolean option_symlinks = FALSE;
> +static gboolean option_system_bus = FALSE;
>
>  static gboolean parse_debug(const char *key, const char *value,
>                                 gpointer user_data, GError **error)
> @@ -164,6 +165,8 @@ static const GOptionEntry options[] = {
>                                 "scripts", "FILE" },
>         { "auto-accept", 'a', 0, G_OPTION_ARG_NONE, &option_autoaccept,
>                                 "Automatically accept push requests" },
> +       { "system-bus", 's', 0, G_OPTION_ARG_NONE, &option_system_bus,
> +                               "Use System bus "},
>         { NULL },
>  };
>
> @@ -172,6 +175,11 @@ gboolean obex_option_auto_accept(void)
>         return option_autoaccept;
>  }
>
> +gboolean obex_option_system_bus(void)
> +{
> +       return option_system_bus;
> +}
> +
>  const char *obex_option_root_folder(void)
>  {
>         return option_root;
> diff --git a/obexd/src/manager.c b/obexd/src/manager.c
> index 3c0c2a7cc..dff2e3783 100644
> --- a/obexd/src/manager.c
> +++ b/obexd/src/manager.c
> @@ -488,7 +488,9 @@ gboolean manager_init(void)
>
>         dbus_error_init(&err);
>
> -       connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OBEXD_SERVICE, &err);
> +       connection =
> +               setup_dbus_connection(obex_option_system_bus(),
> +                                                       OBEXD_SERVICE, &err);
>         if (connection == NULL) {
>                 if (dbus_error_is_set(&err) == TRUE) {
>                         fprintf(stderr, "%s\n", err.message);
> diff --git a/obexd/src/obex.conf b/obexd/src/obex.conf
> new file mode 100644
> index 000000000..114bdb882
> --- /dev/null
> +++ b/obexd/src/obex.conf
> @@ -0,0 +1,28 @@
> +<!-- This configuration file specifies the required security policies
> +     for Bluetooth core daemon to work. -->
> +
> +<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
> + "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
> +<busconfig>
> +
> +  <!-- ../system.conf have denied everything, so we just punch some holes -->
> +
> +  <policy user="root">
> +    <allow own="org.bluez.obex"/>
> +    <allow send_destination="org.bluez.obex"/>
> +    <allow send_interface="org.bluez.obex.Agent1"/>
> +    <allow send_interface="org.bluez.obex.Client1"/>
> +    <allow send_interface="org.bluez.obex.Session1"/>
> +    <allow send_interface="org.bluez.obex.Transfer1"/>
> +    <allow send_interface="org.bluez.obex.ObjectPush1"/>
> +    <allow send_interface="org.bluez.obex.PhonebookAccess1"/>
> +    <allow send_interface="org.bluez.obex.Synchronization1"/>
> +    <allow send_interface="org.bluez.obex.MessageAccess1"/>
> +    <allow send_interface="org.bluez.obex.Message1"/>
> +  </policy>
> +
> +  <policy context="default">
> +    <allow send_destination="org.bluez.obex"/>
> +  </policy>
> +
> +</busconfig>
> diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h
> index af5265da5..72b04b993 100644
> --- a/obexd/src/obexd.h
> +++ b/obexd/src/obexd.h
> @@ -8,6 +8,8 @@
>   *
>   */
>
> +#include "gdbus/gdbus.h"
> +
>  #define OBEX_OPP       (1 << 1)
>  #define OBEX_FTP       (1 << 2)
>  #define OBEX_BIP       (1 << 3)
> @@ -28,3 +30,4 @@ gboolean obex_option_auto_accept(void);
>  const char *obex_option_root_folder(void);
>  gboolean obex_option_symlinks(void);
>  const char *obex_option_capability(void);
> +gboolean obex_option_system_bus(void);

Or better yet, do obex_get_dbus_connection directly instead of getting
the option of system to only then resolve the connection in a second
call.

> --
> 2.34.1
>
>
diff mbox series

Patch

diff --git a/Makefile.am b/Makefile.am
index f639f7f8b..297d0774c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -39,6 +39,10 @@  if DATAFILES
 dbusdir = $(DBUS_CONFDIR)/dbus-1/system.d
 dbus_DATA = src/bluetooth.conf
 
+if OBEX
+dbus_DATA += obexd/src/obex.conf
+endif
+
 conf_DATA = src/main.conf
 conf_DATA += profiles/input/input.conf
 conf_DATA += profiles/network/network.conf
@@ -421,7 +425,7 @@  manual_pages += doc/org.bluez.obex.Client.5 doc/org.bluez.obex.Session.5 \
 
 EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
 			src/main.conf profiles/network/network.conf \
-			profiles/input/input.conf
+			profiles/input/input.conf obexd/src/obex.conf
 
 test_scripts =
 unit_tests =
diff --git a/gdbus/gdbus.h b/gdbus/gdbus.h
index d7be17661..8e0d9c1ea 100644
--- a/gdbus/gdbus.h
+++ b/gdbus/gdbus.h
@@ -40,6 +40,11 @@  DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
 DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
 							DBusError *error);
 
+DBusConnection *get_dbus_connection(gboolean bus_type);
+
+DBusConnection *setup_dbus_connection(gboolean bus_type, const char *name,
+							DBusError *error);
+
 gboolean g_dbus_request_name(DBusConnection *connection, const char *name,
 							DBusError *error);
 
diff --git a/gdbus/mainloop.c b/gdbus/mainloop.c
index a04ebb19b..7bf691191 100644
--- a/gdbus/mainloop.c
+++ b/gdbus/mainloop.c
@@ -293,6 +293,31 @@  DBusConnection *g_dbus_setup_bus(DBusBusType type, const char *name,
 	return conn;
 }
 
+DBusConnection *get_dbus_connection(gboolean bus_type)
+{
+	DBusConnection *conn = NULL;
+
+	if (bus_type)
+		conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
+	else
+		conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+
+	return conn;
+}
+
+DBusConnection *setup_dbus_connection(gboolean bus_type, const char *name,
+							DBusError *error)
+{
+	DBusConnection *conn = NULL;
+
+	if (bus_type)
+		conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, name, error);
+	else
+		conn = g_dbus_setup_bus(DBUS_BUS_SESSION, name, error);
+
+	return conn;
+}
+
 DBusConnection *g_dbus_setup_private(DBusBusType type, const char *name,
 							DBusError *error)
 {
diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c
index 160e0636a..31fcd42fb 100644
--- a/obexd/client/ftp.c
+++ b/obexd/client/ftp.c
@@ -19,6 +19,7 @@ 
 #include "gdbus/gdbus.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 #include "transfer.h"
 #include "session.h"
 #include "driver.h"
@@ -463,7 +464,7 @@  int ftp_init(void)
 
 	DBG("");
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (!conn)
 		return -EIO;
 
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 513dcaf14..2732eb7df 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
@@ -27,6 +27,7 @@ 
 #include "gdbus/gdbus.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 #include "obexd/src/map_ap.h"
 #include "map-event.h"
 
@@ -2063,7 +2064,7 @@  int map_init(void)
 
 	DBG("");
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (!conn)
 		return -EIO;
 
diff --git a/obexd/client/opp.c b/obexd/client/opp.c
index 90d0c0c8e..13c49d12f 100644
--- a/obexd/client/opp.c
+++ b/obexd/client/opp.c
@@ -17,6 +17,7 @@ 
 #include "gdbus/gdbus.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 
 #include "transfer.h"
 #include "session.h"
@@ -178,7 +179,7 @@  int opp_init(void)
 
 	DBG("");
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (!conn)
 		return -EIO;
 
diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index 2d2aa9508..5280cbac5 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
@@ -27,6 +27,7 @@ 
 #include "gdbus/gdbus.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 
 #include "transfer.h"
 #include "session.h"
@@ -1303,7 +1304,7 @@  int pbap_init(void)
 
 	DBG("");
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (!conn)
 		return -EIO;
 
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 13a834e14..3460690dd 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
@@ -27,6 +27,7 @@ 
 #include "gobex/gobex.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 #include "transfer.h"
 #include "session.h"
 #include "driver.h"
@@ -591,7 +592,7 @@  struct obc_session *obc_session_create(const char *source,
 	if (driver == NULL)
 		return NULL;
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (conn == NULL)
 		return NULL;
 
diff --git a/obexd/client/sync.c b/obexd/client/sync.c
index 92faf4434..0283d9729 100644
--- a/obexd/client/sync.c
+++ b/obexd/client/sync.c
@@ -21,6 +21,7 @@ 
 #include "gdbus/gdbus.h"
 
 #include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
 
 #include "transfer.h"
 #include "session.h"
@@ -224,7 +225,7 @@  int sync_init(void)
 
 	DBG("");
 
-	conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+	conn = get_dbus_connection(obex_option_system_bus());
 	if (!conn)
 		return -EIO;
 
diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index 07c444ff2..06aca7366 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
@@ -322,7 +322,7 @@  static gboolean send_backup_dbus_message(const char *oper,
 
 	file_size = size ? *size : 0;
 
-	conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+	conn = setup_dbus_connection(obex_option_system_bus(), NULL, NULL);
 
 	if (conn == NULL)
 		return FALSE;
diff --git a/obexd/src/main.c b/obexd/src/main.c
index 151574afa..aee86ebd1 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
@@ -126,6 +126,7 @@  static char *option_noplugin = NULL;
 
 static gboolean option_autoaccept = FALSE;
 static gboolean option_symlinks = FALSE;
+static gboolean option_system_bus = FALSE;
 
 static gboolean parse_debug(const char *key, const char *value,
 				gpointer user_data, GError **error)
@@ -164,6 +165,8 @@  static const GOptionEntry options[] = {
 				"scripts", "FILE" },
 	{ "auto-accept", 'a', 0, G_OPTION_ARG_NONE, &option_autoaccept,
 				"Automatically accept push requests" },
+	{ "system-bus", 's', 0, G_OPTION_ARG_NONE, &option_system_bus,
+				"Use System bus "},
 	{ NULL },
 };
 
@@ -172,6 +175,11 @@  gboolean obex_option_auto_accept(void)
 	return option_autoaccept;
 }
 
+gboolean obex_option_system_bus(void)
+{
+	return option_system_bus;
+}
+
 const char *obex_option_root_folder(void)
 {
 	return option_root;
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 3c0c2a7cc..dff2e3783 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
@@ -488,7 +488,9 @@  gboolean manager_init(void)
 
 	dbus_error_init(&err);
 
-	connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OBEXD_SERVICE, &err);
+	connection =
+		setup_dbus_connection(obex_option_system_bus(),
+							OBEXD_SERVICE, &err);
 	if (connection == NULL) {
 		if (dbus_error_is_set(&err) == TRUE) {
 			fprintf(stderr, "%s\n", err.message);
diff --git a/obexd/src/obex.conf b/obexd/src/obex.conf
new file mode 100644
index 000000000..114bdb882
--- /dev/null
+++ b/obexd/src/obex.conf
@@ -0,0 +1,28 @@ 
+<!-- This configuration file specifies the required security policies
+     for Bluetooth core daemon to work. -->
+
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+<busconfig>
+
+  <!-- ../system.conf have denied everything, so we just punch some holes -->
+
+  <policy user="root">
+    <allow own="org.bluez.obex"/>
+    <allow send_destination="org.bluez.obex"/>
+    <allow send_interface="org.bluez.obex.Agent1"/>
+    <allow send_interface="org.bluez.obex.Client1"/>
+    <allow send_interface="org.bluez.obex.Session1"/>
+    <allow send_interface="org.bluez.obex.Transfer1"/>
+    <allow send_interface="org.bluez.obex.ObjectPush1"/>
+    <allow send_interface="org.bluez.obex.PhonebookAccess1"/>
+    <allow send_interface="org.bluez.obex.Synchronization1"/>
+    <allow send_interface="org.bluez.obex.MessageAccess1"/>
+    <allow send_interface="org.bluez.obex.Message1"/>
+  </policy>
+
+  <policy context="default">
+    <allow send_destination="org.bluez.obex"/>
+  </policy>
+
+</busconfig>
diff --git a/obexd/src/obexd.h b/obexd/src/obexd.h
index af5265da5..72b04b993 100644
--- a/obexd/src/obexd.h
+++ b/obexd/src/obexd.h
@@ -8,6 +8,8 @@ 
  *
  */
 
+#include "gdbus/gdbus.h"
+
 #define OBEX_OPP	(1 << 1)
 #define OBEX_FTP	(1 << 2)
 #define OBEX_BIP	(1 << 3)
@@ -28,3 +30,4 @@  gboolean obex_option_auto_accept(void);
 const char *obex_option_root_folder(void);
 gboolean obex_option_symlinks(void);
 const char *obex_option_capability(void);
+gboolean obex_option_system_bus(void);