X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbus-proxyd%2Fbus-proxyd.c;h=d1f9f761038bc37468594dba0fe5688d0ff164b1;hb=f72a3e5bada52593aae7cf5fe577138165e83ff3;hp=d8caf406c7155d103be00f15e5dbddd202450884;hpb=0721804f03934c17509af4f485c3bcef9d86862c;p=elogind.git diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c index d8caf406c..d1f9f7610 100644 --- a/src/bus-proxyd/bus-proxyd.c +++ b/src/bus-proxyd/bus-proxyd.c @@ -41,12 +41,16 @@ #include "build.h" #include "strv.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 -static const char *arg_address = "kernel:path=/dev/kdbus/0-system/bus;unix:path=/run/dbus/system_bus_socket"; +# define DEFAULT_BUS_PATH KERNEL_BUS_PATH ";" UNIX_BUS_PATH #else -static const char *arg_address = "unix:path=/run/dbus/system_bus_socket"; +# define DEFAULT_BUS_PATH UNIX_BUS_PATH #endif +static const char *arg_address = DEFAULT_BUS_PATH; static char *arg_command_line_buffer = NULL; static int help(void) { @@ -55,7 +59,8 @@ static int help(void) { "Connect STDIO or a socket to a given bus address.\n\n" " -h --help Show this help\n" " --version Show package version\n" - " --address=ADDRESS Connect to bus specified by address\n", + " --address=ADDRESS Connect to the bus specified by ADDRESS\n" + " (default: " DEFAULT_BUS_PATH ")\n", program_invocation_short_name); return 0; @@ -80,7 +85,7 @@ static int parse_argv(int argc, char *argv[]) { assert(argc >= 0); assert(argv); - while ((c = getopt_long(argc, argv, "hsup:", options, NULL)) >= 0) { + while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) { switch (c) { @@ -266,6 +271,7 @@ int main(int argc, char *argv[]) { int events_a, events_b, fd; uint64_t timeout_a, timeout_b, t; struct timespec _ts, *ts; + struct pollfd *pollfd; int k; r = sd_bus_process(a, &m); @@ -374,14 +380,13 @@ int main(int argc, char *argv[]) { ts = timespec_store(&_ts, t); } - { - struct pollfd p[3] = { - {.fd = fd, .events = events_a, }, - {.fd = STDIN_FILENO, .events = events_b & POLLIN, }, - {.fd = STDOUT_FILENO, .events = events_b & POLLOUT, }}; + pollfd = (struct pollfd[3]) { + {.fd = fd, .events = events_a, }, + {.fd = in_fd, .events = events_b & POLLIN, }, + {.fd = out_fd, .events = events_b & POLLOUT, } + }; - r = ppoll(p, ELEMENTSOF(p), ts, NULL); - } + r = ppoll(pollfd, 3, ts, NULL); if (r < 0) { log_error("ppoll() failed: %m"); goto finish;