#include <unistd.h>
#include <errno.h>
+/*
+ * Converts string with unique name into __u64 id number. If the name is not unique, sets error.
+ */
__u64 sender_name_to_id(const char* name, DBusError* error)
{
__u64 sender_id = 0;
return sender_id;
}
+/*
+ * Creates kdbus bus of given type.
+ */
char* make_kdbus_bus(DBusBusType type, DBusError *error)
{
struct {
return bus;
}
+/*
+ * Minimal server init needed by context to go further.
+ */
DBusServer* empty_server_init(char* address)
{
return dbus_server_init_mini(address);
}
+/*
+ * Connects daemon to bus created by him and adds matches for "system" broadcasts.
+ * Do not requests org.freedesktop.DBus name, because it's to early
+ * (some structures of BusContext are not ready yet).
+ */
DBusConnection* daemon_as_client(DBusBusType type, char* address, DBusError *error)
{
DBusConnection* connection;
return connection;
}
+/*
+ * Asks bus for org.freedesktop.DBus well-known name.
+ */
dbus_bool_t register_daemon_name(DBusConnection* connection)
{
DBusString daemon_name;
return list_kdbus_names(fd, listp, array_len);
}
+/*
+ * Register match rule in kdbus on behalf of sender of the message
+ */
dbus_bool_t kdbus_add_match_rule (DBusConnection* connection, DBusMessage* message, const char* text, DBusError* error)
{
__u64 sender_id;
return TRUE;
}
+/*
+ * Removes match rule in kdbus on behalf of sender of the message
+ */
dbus_bool_t kdbus_remove_match (DBusConnection* connection, DBusMessage* message, DBusError* error)
{
__u64 sender_id;
return TRUE;
}
+/*
+ * Asks kdbus for uid of the owner of the name given in the message
+ */
dbus_bool_t kdbus_get_connection_unix_user(DBusConnection* connection, DBusMessage* message, unsigned long* uid, DBusError* error)
{
char* name = NULL;
return ret;
}
+/*
+ * Asks kdbus for pid of the owner of the name given in the message
+ */
dbus_bool_t kdbus_get_connection_unix_process_id(DBusConnection* connection, DBusMessage* message, unsigned long* pid, DBusError* error)
{
char* name = NULL;
return ret;
}
+/*
+ * Asks kdbus for selinux_security_context of the owner of the name given in the message
+ */
dbus_bool_t kdbus_get_connection_unix_selinux_security_context(DBusConnection* connection, DBusMessage* message, DBusMessage* reply, DBusError* error)
{
char* name = NULL;
return ret;
}
-DBusConnection* create_phantom_connection(DBusConnection* connection, const char* unique_name, DBusError* error)
+/*
+ * Create connection structure for given name. It is needed to control starters - activatable services
+ * and for ListQueued method (as long as kdbus is not supporting it). This connections don't have it's own
+ * fd so it is set up on the basis of daemon's transport. Functionality of such connection is limited.
+ */
+DBusConnection* create_phantom_connection(DBusConnection* connection, const char* name, DBusError* error)
{
DBusConnection *phantom_connection;
- DBusString name;
+ DBusString Sname;
- _dbus_string_init_const(&name, unique_name);
+ _dbus_string_init_const(&Sname, name);
phantom_connection = _dbus_connection_new_for_used_transport (dbus_connection_get_transport(connection));
if(phantom_connection == NULL)
{
dbus_connection_unref_phantom(phantom_connection);
phantom_connection = NULL;
- dbus_set_error (error, DBUS_ERROR_FAILED , "Name \"%s\" could not be acquired", unique_name);
+ dbus_set_error (error, DBUS_ERROR_FAILED , "Name \"%s\" could not be acquired", name);
goto out;
}
- if(!bus_connection_complete(phantom_connection, &name, error))
+ if(!bus_connection_complete(phantom_connection, &Sname, error))
{
bus_connection_disconnected(phantom_connection);
phantom_connection = NULL;
return phantom_connection;
}
+/*
+ * Registers activatable services as kdbus starters.
+ */
dbus_bool_t register_kdbus_starters(DBusConnection* connection)
{
int i,j, len;
return retval;
}
+/*
+ * Updates kdbus starters (activatable services) after configuration was reloaded.
+ * It releases all previous starters and registers all new.
+ */
dbus_bool_t update_kdbus_starters(DBusConnection* connection)
{
dbus_bool_t retval = FALSE;
return TRUE;
}*/
+/*
+ * Analyzes system broadcasts about id and name changes.
+ * Basing on this it sends NameAcquired and NameLost signals and clear phantom connections.
+ */
void handleNameOwnerChanged(DBusMessage *msg, BusTransaction *transaction, DBusConnection *connection)
{
const char *name, *old, *new;
* Name of the policy equals name on the bus.
*
* @param name name of the policy = name of the connection
- * @param connection the connection
- * @param error place to store errors
+ * @param fd - file descriptor of the connection
*
* @returns #TRUE on success
*/
return TRUE;
}
+/*
+ * Asks kdbus for well-known names registered on the bus
+ */
dbus_bool_t list_kdbus_names(int fd, char ***listp, int *array_len)
{
struct kdbus_cmd_names* pCmd;
}
/**
- * kdbus version of dbus_bus_request_name.
*
- * Asks the bus to assign the given name to this connection.
+ * Asks the bus to assign the given name to the connection.
*
* Use same flags as original dbus version with one exception below.
* Result flag #DBUS_REQUEST_NAME_REPLY_ALREADY_OWNER is currently
* never returned by kdbus, instead DBUS_REQUEST_NAME_REPLY_PRIMARY_OWNER
* is returned by kdbus.
*
- * @param connection the connection
+ * @param fd - file descriptor of the connection
* @param name the name to request
* @param flags flags
- * @param error location to store the error
- * @returns a result code, -1 if error is set
+ * @param id unique id of the connection for which the name is being registered
+ * @returns a DBus result code on success, -errno on error
*/
int request_kdbus_name(int fd, const char *name, const __u64 flags, __u64 id)
{
cmd_name = alloca(size);
-// memset(cmd_name, 0, size);
strcpy(cmd_name->name, name);
cmd_name->size = size;
*/
}
+/**
+ *
+ * Releases well-known name - the connections resign from the name
+ * which can be then assigned to another connection or the connection
+ * is being removed from the queue for that name
+ *
+ * @param fd - file descriptor of the connection
+ * @param name the name to request
+ * @param id unique id of the connection for which the name is being released
+ * @returns a DBus result code on success, -errno on error
+ */
int release_kdbus_name(int fd, const char *name, __u64 id)
{
struct kdbus_cmd_name *cmd_name;