mirror of
https://github.com/systemd/systemd.git
synced 2025-01-21 22:04:01 +03:00
Move bus path definitions to def.h
This commit is contained in:
parent
da13d4d20f
commit
ab9001a1e3
@ -40,17 +40,9 @@
|
||||
#include "bus-util.h"
|
||||
#include "build.h"
|
||||
#include "strv.h"
|
||||
#include "def.h"
|
||||
|
||||
#define UNIX_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
|
||||
#define KERNEL_BUS_PATH "kernel:path=/dev/kdbus/0-system/bus"
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
# define DEFAULT_BUS_PATH KERNEL_BUS_PATH ";" UNIX_BUS_PATH
|
||||
#else
|
||||
# define DEFAULT_BUS_PATH UNIX_BUS_PATH
|
||||
#endif
|
||||
|
||||
static const char *arg_address = DEFAULT_BUS_PATH;
|
||||
static const char *arg_address = DEFAULT_SYSTEM_BUS_PATH;
|
||||
static char *arg_command_line_buffer = NULL;
|
||||
|
||||
static int help(void) {
|
||||
@ -60,7 +52,7 @@ static int help(void) {
|
||||
" -h --help Show this help\n"
|
||||
" --version Show package version\n"
|
||||
" --address=ADDRESS Connect to the bus specified by ADDRESS\n"
|
||||
" (default: " DEFAULT_BUS_PATH ")\n",
|
||||
" (default: " DEFAULT_SYSTEM_BUS_PATH ")\n",
|
||||
program_invocation_short_name);
|
||||
|
||||
return 0;
|
||||
|
@ -483,7 +483,7 @@ int bus_open_system_systemd(sd_bus **_bus) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_set_address(bus, "kernel:path=/dev/kdbus/0-system/bus");
|
||||
r = sd_bus_set_address(bus, KERNEL_SYSTEM_BUS_PATH);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -536,7 +536,7 @@ int bus_open_user_systemd(sd_bus **_bus) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (asprintf(&bus->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid()) < 0)
|
||||
if (asprintf(&bus->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid()) < 0)
|
||||
return -ENOMEM;
|
||||
|
||||
bus->bus_client = true;
|
||||
|
@ -34,6 +34,7 @@
|
||||
#include "strv.h"
|
||||
#include "set.h"
|
||||
#include "missing.h"
|
||||
#include "def.h"
|
||||
|
||||
#include "sd-bus.h"
|
||||
#include "bus-internal.h"
|
||||
@ -1047,12 +1048,7 @@ _public_ int sd_bus_open_system(sd_bus **ret) {
|
||||
if (e)
|
||||
r = sd_bus_set_address(b, e);
|
||||
else
|
||||
#ifdef ENABLE_KDBUS
|
||||
r = sd_bus_set_address(b, "kernel:path=/dev/kdbus/0-system/bus;unix:path=/run/dbus/system_bus_socket");
|
||||
#else
|
||||
r = sd_bus_set_address(b, "unix:path=/run/dbus/system_bus_socket");
|
||||
#endif
|
||||
|
||||
r = sd_bus_set_address(b, DEFAULT_SYSTEM_BUS_PATH);
|
||||
if (r < 0)
|
||||
goto fail;
|
||||
|
||||
@ -1103,13 +1099,13 @@ _public_ int sd_bus_open_user(sd_bus **ret) {
|
||||
}
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus;unix:path=%s/bus", (unsigned long) getuid(), ee);
|
||||
asprintf(&b->address, KERNEL_USER_BUS_FMT ";" UNIX_USER_BUS_FMT, (unsigned long) getuid(), ee);
|
||||
#else
|
||||
b->address = strjoin("unix:path=", ee, "/bus", NULL);
|
||||
asprintf(&b->address, UNIX_USER_BUS_FMT, (unsigned long) getuid());
|
||||
#endif
|
||||
} else {
|
||||
#ifdef ENABLE_KDBUS
|
||||
asprintf(&b->address, "kernel:path=/dev/kdbus/%lu-user/bus", (unsigned long) getuid());
|
||||
asprintf(&b->address, KERNEL_USER_BUS_FMT, (unsigned long) getuid());
|
||||
#else
|
||||
return -ECONNREFUSED;
|
||||
#endif
|
||||
|
@ -59,3 +59,15 @@
|
||||
"/usr/share/kbd/keymaps/\0" \
|
||||
"/usr/lib/kbd/keymaps/\0"
|
||||
#endif
|
||||
|
||||
#define UNIX_SYSTEM_BUS_PATH "unix:path=/run/dbus/system_bus_socket"
|
||||
#define KERNEL_SYSTEM_BUS_PATH "kernel:path=/dev/kdbus/0-system/bus"
|
||||
|
||||
#ifdef ENABLE_KDBUS
|
||||
# define DEFAULT_SYSTEM_BUS_PATH KERNEL_SYSTEM_BUS_PATH ";" UNIX_SYSTEM_BUS_PATH
|
||||
#else
|
||||
# define DEFAULT_SYSTEM_BUS_PATH UNIX_SYSTEM_BUS_PATH
|
||||
#endif
|
||||
|
||||
#define UNIX_USER_BUS_FMT "unix:path=%s/bus"
|
||||
#define KERNEL_USER_BUS_FMT "kernel:path=/dev/kdbus/%lu-user/bus"
|
||||
|
Loading…
x
Reference in New Issue
Block a user