Group :: System/Libraries
RPM: libdbus-c++
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: libdbus-c++-0.9.0-alt-enable_auth.patch
Download
Download
--- a/include/dbus-c++/server.h
+++ b/include/dbus-c++/server.h
@@ -56,6 +56,8 @@ public:
void disconnect();
+ void enable_auth(bool);
+
struct Private;
protected:
@@ -65,6 +67,8 @@ protected:
virtual void on_new_connection(Connection &c) = 0;
+ virtual bool on_user_auth(unsigned long uid);
+
private:
RefPtrI<Private> _pvt;
--- a/src/connection.cpp
+++ b/src/connection.cpp
@@ -93,6 +93,7 @@ void Connection::Private::init()
dbus_connection_set_dispatch_status_function(conn, dispatch_status_stub, this, 0);
dbus_connection_set_exit_on_disconnect(conn, false); //why was this set to true??
+ dbus_connection_set_unix_user_function (conn, 0, 0, 0);
}
void Connection::Private::detach_server()
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -36,7 +36,7 @@
using namespace DBus;
Server::Private::Private(DBusServer *s)
- : server(s)
+ : server(s), auth_enabled(false)
{
}
@@ -54,9 +54,19 @@ void Server::Private::on_new_conn_cb(DBu
s->on_new_connection(nc);
+ if (s->_pvt->auth_enabled)
+ dbus_connection_set_unix_user_function (conn, Private::on_unix_auth_cb, s, NULL);
+
debug_log("incoming connection 0x%08x", conn);
}
+dbus_bool_t Server::Private::on_unix_auth_cb(DBusConnection *c, unsigned long uid, void *data)
+{
+ Server *s = static_cast<Server *>(data);
+
+ return s->on_user_auth(uid);
+}
+
Server::Server(const char *address)
{
InternalError e;
@@ -127,3 +137,12 @@ void Server::disconnect()
dbus_server_disconnect(_pvt->server);
}
+bool Server::on_user_auth(unsigned long uid)
+{
+ return true;
+}
+
+void Server::enable_auth(bool enable)
+{
+ _pvt->auth_enabled = enable;
+}
--- a/src/server_p.h
+++ b/src/server_p.h
@@ -46,11 +46,15 @@ struct DXXAPILOCAL Server::Private
ConnectionList connections;
+ bool auth_enabled;
+
Private(DBusServer *);
~Private();
static void on_new_conn_cb(DBusServer *server, DBusConnection *conn, void *data);
+
+ static dbus_bool_t on_unix_auth_cb(DBusConnection *conn, unsigned long uid, void *data);
};
} /* namespace DBus */