diff --git a/Makefile.am b/Makefile.am
index f639f7f..297d077 100644
--- a/Makefile.am
+++ b/Makefile.am
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
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/obexd/client/bip.c b/obexd/client/bip.c
index 9d9ecec..ec75fdd 100644
--- a/obexd/client/bip.c
+++ b/obexd/client/bip.c
#include "gobex/gobex.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
+
#include "transfer.h"
#include "session.h"
#include "driver.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/client/ftp.c b/obexd/client/ftp.c
index 160e063..b61f5bb 100644
--- a/obexd/client/ftp.c
+++ b/obexd/client/ftp.c
#include "gdbus/gdbus.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "transfer.h"
#include "session.h"
#include "driver.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/client/map.c b/obexd/client/map.c
index 513dcaf..29b0ed9 100644
--- a/obexd/client/map.c
+++ b/obexd/client/map.c
#include "gdbus/gdbus.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "obexd/src/map_ap.h"
#include "map-event.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/client/opp.c b/obexd/client/opp.c
index 90d0c0c..c22e919 100644
--- a/obexd/client/opp.c
+++ b/obexd/client/opp.c
#include "gdbus/gdbus.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "transfer.h"
#include "session.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/client/pbap.c b/obexd/client/pbap.c
index 2d2aa95..bc3fdcf 100644
--- a/obexd/client/pbap.c
+++ b/obexd/client/pbap.c
#include "gdbus/gdbus.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "transfer.h"
#include "session.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/client/session.c b/obexd/client/session.c
index 13a834e..2770b92 100644
--- a/obexd/client/session.c
+++ b/obexd/client/session.c
#include "gobex/gobex.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "transfer.h"
#include "session.h"
#include "driver.h"
if (driver == NULL)
return NULL;
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (conn == NULL)
return NULL;
diff --git a/obexd/client/sync.c b/obexd/client/sync.c
index 92faf44..fe70b91 100644
--- a/obexd/client/sync.c
+++ b/obexd/client/sync.c
#include "gdbus/gdbus.h"
#include "obexd/src/log.h"
+#include "obexd/src/obexd.h"
#include "transfer.h"
#include "session.h"
DBG("");
- conn = dbus_bus_get(DBUS_BUS_SESSION, NULL);
+ conn = obex_get_dbus_connection();
if (!conn)
return -EIO;
diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index 07c444f..1755ffb 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
file_size = size ? *size : 0;
- conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+ conn = obex_setup_dbus_connection(NULL, NULL);
if (conn == NULL)
return FALSE;
diff --git a/obexd/src/main.c b/obexd/src/main.c
index 151574a..7031736 100644
--- a/obexd/src/main.c
+++ b/obexd/src/main.c
#define DEFAULT_CAP_FILE CONFIGDIR "/capability.xml"
static GMainLoop *main_loop = NULL;
+static DBusConnection *connection;
+
static gboolean signal_handler(GIOChannel *channel, GIOCondition cond,
gpointer user_data)
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)
"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 },
};
return is_dir(root);
}
+DBusConnection *obex_get_dbus_connection(void)
+{
+ if (connection)
+ return dbus_connection_ref(connection);
+
+ connection = dbus_bus_get(option_system_bus ?
+ DBUS_BUS_SYSTEM : DBUS_BUS_SESSION, NULL);
+
+ return connection;
+}
+
+DBusConnection *obex_setup_dbus_connection(const char *name,
+ DBusError *error)
+{
+ connection = g_dbus_setup_bus(option_system_bus ?
+ DBUS_BUS_SYSTEM : DBUS_BUS_SESSION,
+ name, error);
+
+ return connection;
+}
+
int main(int argc, char *argv[])
{
GOptionContext *context;
diff --git a/obexd/src/manager.c b/obexd/src/manager.c
index 3c0c2a7..5a6fd9b 100644
--- a/obexd/src/manager.c
+++ b/obexd/src/manager.c
dbus_error_init(&err);
- connection = g_dbus_setup_bus(DBUS_BUS_SESSION, OBEXD_SERVICE, &err);
+ connection = obex_setup_dbus_connection(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 0000000..114bdb8
--- /dev/null
+++ b/obexd/src/obex.conf
+<!-- 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 af5265d..5e5edc4 100644
--- a/obexd/src/obexd.h
+++ b/obexd/src/obexd.h
*
*/
+#include <dbus/dbus.h>
+
#define OBEX_OPP (1 << 1)
#define OBEX_FTP (1 << 2)
#define OBEX_BIP (1 << 3)
const char *obex_option_root_folder(void);
gboolean obex_option_symlinks(void);
const char *obex_option_capability(void);
+DBusConnection *obex_get_dbus_connection(void);
+DBusConnection *obex_setup_dbus_connection(const char *name,
+ DBusError *error);