mirror of
https://git.proxmox.com/git/fwupd
synced 2025-08-09 22:49:08 +00:00
Pass the socket address when setting up the daemon
This commit is contained in:
parent
065b2a33f4
commit
7b806dbb2a
@ -828,7 +828,7 @@ fwupd_client_connect_async(FwupdClient *self,
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
socket_address = g_strdup("tcp:host=localhost,port=1341");
|
socket_address = g_strdup(FWUPD_DBUS_P2P_SOCKET_ADDRESS);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,6 +28,12 @@ G_BEGIN_DECLS
|
|||||||
* The dbus interface
|
* The dbus interface
|
||||||
**/
|
**/
|
||||||
#define FWUPD_DBUS_INTERFACE "org.freedesktop.fwupd"
|
#define FWUPD_DBUS_INTERFACE "org.freedesktop.fwupd"
|
||||||
|
/**
|
||||||
|
* FWUPD_DBUS_P2P_SOCKET_ADDRESS:
|
||||||
|
*
|
||||||
|
* The D-Bus socket address when using point-to-point connections.
|
||||||
|
**/
|
||||||
|
#define FWUPD_DBUS_P2P_SOCKET_ADDRESS "tcp:host=localhost,port=1341"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FWUPD_DEVICE_ID_ANY:
|
* FWUPD_DEVICE_ID_ANY:
|
||||||
|
@ -2110,11 +2110,9 @@ fu_daemon_set_machine_kind(FuDaemon *self, FuDaemonMachineKind machine_kind)
|
|||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
fu_daemon_setup(FuDaemon *self, GError **error)
|
fu_daemon_setup(FuDaemon *self, const gchar *socket_address, GError **error)
|
||||||
{
|
{
|
||||||
const gchar *machine_kind = g_getenv("FWUPD_MACHINE_KIND");
|
const gchar *machine_kind = g_getenv("FWUPD_MACHINE_KIND");
|
||||||
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
|
||||||
g_autofree gchar *socket_address = NULL;
|
|
||||||
|
|
||||||
g_return_val_if_fail(FU_IS_DAEMON(self), FALSE);
|
g_return_val_if_fail(FU_IS_DAEMON(self), FALSE);
|
||||||
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
||||||
@ -2183,24 +2181,6 @@ fu_daemon_setup(FuDaemon *self, GError **error)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* convert from filename to address, if required */
|
|
||||||
if (socket_filename != NULL) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
#ifdef _WIN32
|
|
||||||
socket_address = g_strdup("tcp:host=localhost,port=1341");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/* own the object */
|
/* own the object */
|
||||||
if (socket_address != NULL) {
|
if (socket_address != NULL) {
|
||||||
g_autofree gchar *guid = g_dbus_generate_guid();
|
g_autofree gchar *guid = g_dbus_generate_guid();
|
||||||
|
@ -21,7 +21,7 @@ typedef enum {
|
|||||||
FuDaemon *
|
FuDaemon *
|
||||||
fu_daemon_new(void);
|
fu_daemon_new(void);
|
||||||
gboolean
|
gboolean
|
||||||
fu_daemon_setup(FuDaemon *self, GError **error);
|
fu_daemon_setup(FuDaemon *self, const gchar *socket_address, GError **error);
|
||||||
void
|
void
|
||||||
fu_daemon_start(FuDaemon *self);
|
fu_daemon_start(FuDaemon *self);
|
||||||
void
|
void
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include "fwupd-common.h"
|
||||||
|
|
||||||
#include "fu-daemon.h"
|
#include "fu-daemon.h"
|
||||||
#include "fu-debug.h"
|
#include "fu-debug.h"
|
||||||
|
|
||||||
@ -88,7 +90,7 @@ fu_main_svc_main_cb(DWORD dwArgc, LPSTR *lpszArgv)
|
|||||||
|
|
||||||
/* set up the daemon, which includes coldplugging devices -- then run it */
|
/* set up the daemon, which includes coldplugging devices -- then run it */
|
||||||
fu_main_svc_report_status(SERVICE_START_PENDING, NO_ERROR, 1000);
|
fu_main_svc_report_status(SERVICE_START_PENDING, NO_ERROR, 1000);
|
||||||
if (!fu_daemon_setup(daemon, &error)) {
|
if (!fu_daemon_setup(daemon, FWUPD_DBUS_P2P_SOCKET_ADDRESS, &error)) {
|
||||||
g_warning("Failed to load daemon: %s", error->message);
|
g_warning("Failed to load daemon: %s", error->message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -112,7 +114,7 @@ fu_main_console(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* set up the daemon, which includes coldplugging devices -- then run it */
|
/* set up the daemon, which includes coldplugging devices -- then run it */
|
||||||
if (!fu_daemon_setup(daemon, &error)) {
|
if (!fu_daemon_setup(daemon, FWUPD_DBUS_P2P_SOCKET_ADDRESS, &error)) {
|
||||||
g_printerr("Failed to load daemon: %s\n", error->message);
|
g_printerr("Failed to load daemon: %s\n", error->message);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
gboolean immediate_exit = FALSE;
|
gboolean immediate_exit = FALSE;
|
||||||
gboolean timed_exit = FALSE;
|
gboolean timed_exit = FALSE;
|
||||||
|
const gchar *socket_filename = g_getenv("FWUPD_DBUS_SOCKET");
|
||||||
const GOptionEntry options[] = {
|
const GOptionEntry options[] = {
|
||||||
{"timed-exit",
|
{"timed-exit",
|
||||||
'\0',
|
'\0',
|
||||||
@ -115,6 +116,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(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]);
|
||||||
g_autoptr(GOptionContext) context = NULL;
|
g_autoptr(GOptionContext) context = NULL;
|
||||||
@ -151,8 +153,22 @@ main(int argc, char *argv[])
|
|||||||
fu_daemon_set_machine_kind(daemon, FU_DAEMON_MACHINE_KIND_PHYSICAL);
|
fu_daemon_set_machine_kind(daemon, FU_DAEMON_MACHINE_KIND_PHYSICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* convert from filename to address, if required */
|
||||||
|
if (socket_filename != NULL) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* set up the daemon, which includes coldplugging devices */
|
/* set up the daemon, which includes coldplugging devices */
|
||||||
if (!fu_daemon_setup(daemon, &error)) {
|
if (!fu_daemon_setup(daemon, socket_address, &error)) {
|
||||||
g_printerr("Failed to load daemon: %s\n", error->message);
|
g_printerr("Failed to load daemon: %s\n", error->message);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user