mirror of
https://git.proxmox.com/git/fwupd
synced 2025-06-06 04:12:25 +00:00
Allow specifying a non-file D-Bus transport
e.g. on Windows you can do: FWUPD_DBUS_SOCKET=tcp:host=localhost,port=12345
This commit is contained in:
parent
bbd6010929
commit
418d883ea7
@ -804,6 +804,7 @@ fwupd_client_connect_async(FwupdClient *self,
|
|||||||
{
|
{
|
||||||
FwupdClientPrivate *priv = GET_PRIVATE(self);
|
FwupdClientPrivate *priv = GET_PRIVATE(self);
|
||||||
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
||||||
|
g_autofree gchar *socket_address = NULL;
|
||||||
g_autoptr(GTask) task = g_task_new(self, cancellable, callback, callback_data);
|
g_autoptr(GTask) task = g_task_new(self, cancellable, callback, callback_data);
|
||||||
g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->proxy_mutex);
|
g_autoptr(GMutexLocker) locker = g_mutex_locker_new(&priv->proxy_mutex);
|
||||||
|
|
||||||
@ -818,10 +819,18 @@ fwupd_client_connect_async(FwupdClient *self,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* use peer-to-peer only if the env variable is set */
|
/* convert from filename to address, if required */
|
||||||
if (socket_filename != NULL) {
|
if (socket_filename != NULL) {
|
||||||
g_autofree gchar *address = g_strdup_printf("unix:path=%s", socket_filename);
|
if (g_strrstr(socket_filename, "=") == NULL) {
|
||||||
g_dbus_connection_new_for_address(address,
|
socket_address = g_strdup_printf("unix:path=%s", socket_filename);
|
||||||
|
} else {
|
||||||
|
socket_address = g_strdup(socket_filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* use peer-to-peer only if the env variable is set */
|
||||||
|
if (socket_address != NULL) {
|
||||||
|
g_dbus_connection_new_for_address(socket_address,
|
||||||
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
|
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
|
||||||
NULL,
|
NULL,
|
||||||
cancellable,
|
cancellable,
|
||||||
|
@ -2247,6 +2247,7 @@ main(int argc, char *argv[])
|
|||||||
N_("Exit after the engine has loaded"),
|
N_("Exit after the engine has loaded"),
|
||||||
NULL},
|
NULL},
|
||||||
{NULL}};
|
{NULL}};
|
||||||
|
g_autofree gchar *socket_address = NULL;
|
||||||
g_autoptr(FuMainPrivate) priv = NULL;
|
g_autoptr(FuMainPrivate) priv = NULL;
|
||||||
g_autoptr(GError) error = NULL;
|
g_autoptr(GError) error = NULL;
|
||||||
g_autoptr(GFile) argv0_file = g_file_new_for_path(argv[0]);
|
g_autoptr(GFile) argv0_file = g_file_new_for_path(argv[0]);
|
||||||
@ -2368,17 +2369,26 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* own the object */
|
/* convert from filename to address, if required */
|
||||||
if (socket_filename != NULL) {
|
if (socket_filename != NULL) {
|
||||||
g_autofree gchar *address = g_strdup_printf("unix:path=%s", socket_filename);
|
if (g_strrstr(socket_filename, "=") == NULL) {
|
||||||
|
#ifndef HAVE_SYSTEMD
|
||||||
|
/* this must be owned by root */
|
||||||
|
if (g_file_test(socket_filename, G_FILE_TEST_EXISTS))
|
||||||
|
g_unlink(socket_filename);
|
||||||
|
#endif
|
||||||
|
socket_address = g_strdup_printf("unix:path=%s", socket_filename);
|
||||||
|
} else {
|
||||||
|
socket_address = g_strdup(socket_filename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* own the object */
|
||||||
|
if (socket_address != NULL) {
|
||||||
g_autofree gchar *guid = g_dbus_generate_guid();
|
g_autofree gchar *guid = g_dbus_generate_guid();
|
||||||
g_autoptr(GDBusServer) server = NULL;
|
g_autoptr(GDBusServer) server = NULL;
|
||||||
|
|
||||||
/* this must be owned by root */
|
server = g_dbus_server_new_sync(socket_address,
|
||||||
#ifndef HAVE_SYSTEMD
|
|
||||||
g_unlink(socket_filename);
|
|
||||||
#endif
|
|
||||||
server = g_dbus_server_new_sync(address,
|
|
||||||
G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS,
|
G_DBUS_SERVER_FLAGS_AUTHENTICATION_ALLOW_ANONYMOUS,
|
||||||
guid,
|
guid,
|
||||||
NULL,
|
NULL,
|
||||||
|
Loading…
Reference in New Issue
Block a user