bus-proxyd.c revision bcf3295d2b0d87caefad2e73d221aac080d0c11e
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek This file is part of systemd.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Copyright 2010 Lennart Poettering
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Copyright 2013 Daniel Mack
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Copyright 2014 Kay Sievers
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is free software; you can redistribute it and/or modify it
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek under the terms of the GNU Lesser General Public License as published by
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek the Free Software Foundation; either version 2.1 of the License, or
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek (at your option) any later version.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek systemd is distributed in the hope that it will be useful, but
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek WITHOUT ANY WARRANTY; without even the implied warranty of
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek Lesser General Public License for more details.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek You should have received a copy of the GNU Lesser General Public License
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek along with systemd; If not, see <http://www.gnu.org/licenses/>.
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic const char *arg_address = DEFAULT_SYSTEM_BUS_PATH;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic char *arg_command_line_buffer = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic bool arg_drop_privileges = false;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int help(void) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "Connect STDIO or a socket to a given bus address.\n\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " -h --help Show this help\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " --version Show package version\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " --drop-privileges Drop privileges\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " --address=ADDRESS Connect to the bus specified by ADDRESS\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " (default: " DEFAULT_SYSTEM_BUS_PATH ")\n",
7f1ad696a273703789b624fe0b209fb63e953016Lennart Poetteringstatic int parse_argv(int argc, char *argv[]) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek static const struct option options[] = {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "help", no_argument, NULL, 'h' },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "version", no_argument, NULL, ARG_VERSION },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "address", required_argument, NULL, ARG_ADDRESS },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek { "drop-privileges", no_argument, NULL, ARG_DROP_PRIVILEGES },
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek assert_not_reached("Unhandled option");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* If the first command line argument is only "x" characters
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * we'll write who we are talking to into it, so that "ps" is
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * explanatory */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek arg_command_line_buffer = argv[optind];
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek (arg_command_line_buffer && arg_command_line_buffer[strspn(arg_command_line_buffer, "x")] != 0)) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Too many arguments");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int rename_service(sd_bus *a, sd_bus *b) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek _cleanup_free_ char *p = NULL, *name = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_peer_creds(b, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_CMDLINE|SD_BUS_CREDS_COMM, &creds);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_uid(creds, &uid);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_pid(creds, &pid);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_cmdline(creds, &cmdline);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_comm(creds, &comm);
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek /* The status string gets the full command line ... */
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek "STATUS=Processing requests from client PID "PID_FMT" (%s); UID "UID_FMT" (%s)",
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek /* ... and the argv line only the short comm */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek m = strlen(arg_command_line_buffer);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek w = snprintf(arg_command_line_buffer, m,
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "[PID "PID_FMT"/%s; UID "UID_FMT"/%s]",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek memzero(arg_command_line_buffer + w, m - w);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_debug("Running on behalf of PID "PID_FMT" (%s), UID "UID_FMT" (%s), %s",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int synthesize_name_acquired(sd_bus *a, sd_bus *b, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const char *name, *old_owner, *new_owner;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* If we get NameOwnerChanged for our own name, we need to
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * synthesize NameLost/NameAcquired, since socket clients need
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * that, even though it is obsoleted on kdbus */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!sd_bus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged") ||
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek !streq_ptr(m->path, "/org/freedesktop/DBus") ||
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek !streq_ptr(m->sender, "org.freedesktop.DBus"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "sss", &name, &old_owner, &new_owner);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_rewind(m, true);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (streq(old_owner, a->unique_name)) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.DBus",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (streq(new_owner, a->unique_name)) {
23ad4dd8844c582929115a11ed2830a1371568d6Jan Alexander Steffens (heftig) r = sd_bus_message_new_signal(
23ad4dd8844c582929115a11ed2830a1371568d6Jan Alexander Steffens (heftig) "org.freedesktop.DBus",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "NameAcquired");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_append(n, "s", name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_message_append_sender(n, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_seal_synthetic_message(b, n);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int process_policy(sd_bus *a, sd_bus *b, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "GetAll"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!streq_ptr(m->path, "/org/gnome/DisplayManager/Slave"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_errorf(m, &n, SD_BUS_ERROR_ACCESS_DENIED, "gdm, you are stupid");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_message_append_sender(n, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to append sender to gdm reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_seal_synthetic_message(b, n);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to seal gdm reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to send gdm reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int synthetic_driver_send(sd_bus *b, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_message_append_sender(m, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_seal_synthetic_message(b, m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int synthetic_reply_method_error(sd_bus_message *call, const sd_bus_error *e) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_error(call, &m, e);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_driver_send(call->bus, m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int synthetic_reply_method_errno(sd_bus_message *call, int error, const sd_bus_error *p) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error berror = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_error(call, p);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek sd_bus_error_set_errno(&berror, error);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_error(call, &berror);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int synthetic_reply_method_return(sd_bus_message *call, const char *types, ...) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering if (call->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk r = sd_bus_message_new_method_return(call, &m);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk return synthetic_driver_send(call->bus, m);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchukstatic int synthetic_reply_return_strv(sd_bus_message *call, char **l) {
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk r = sd_bus_message_new_method_return(call, &m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(call, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_append_strv(m, l);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(call, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_driver_send(call->bus, m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int get_creds_by_name(sd_bus *bus, const char *name, uint64_t mask, sd_bus_creds **_creds, sd_bus_error *error) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *c = NULL;
ed375bebf46c1251f4baa170b39ee93761dbdb19Zbigniew Jędrzejewski-Szmek assert_return(service_name_is_valid(name), -EINVAL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_owner(bus, name, mask, &c);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return sd_bus_error_setf(error, SD_BUS_ERROR_NAME_HAS_NO_OWNER, "Name %s is currently not owned by anyone.", name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, sd_bus_creds **_creds, sd_bus_error *error) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return get_creds_by_name(bus, name, mask, _creds, error);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int peer_is_privileged(sd_bus *bus, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = get_creds_by_message(bus, m, SD_BUS_CREDS_UID, &creds, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_uid(creds, &uid);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_has_effective_cap(creds, CAP_SYS_ADMIN);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (!streq_ptr(sd_bus_message_get_destination(m), "org.freedesktop.DBus"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (0 && !isempty(sd_bus_message_get_signature(m, true))) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_error_setf(&error, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, &error);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "s",
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <method name=\"Introspect\">\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " </interface>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <interface name=\"org.freedesktop.DBus\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"AddMatch\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"RemoveMatch\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"GetConnectionSELinuxSecurityContext\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"ay\" direction=\"out\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"GetConnectionUnixProcessID\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <arg type=\"u\" direction=\"out\"/>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <method name=\"GetConnectionUnixUser\">\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <arg type=\"u\" direction=\"out\"/>\n"
e40ec7aec5e64cd0cfa5fc556d6a9747229b5794Zbigniew Jędrzejewski-Szmek " <method name=\"GetId\">\n"
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering " <arg type=\"s\" direction=\"out\"/>\n"
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering " </method>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"GetNameOwner\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"out\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"Hello\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"out\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"ListActivatableNames\">\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"as\" direction=\"out\"/>\n"
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering " </method>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <method name=\"ListNames\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"as\" direction=\"out\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <method name=\"ListQueuedOwners\">\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"s\" direction=\"in\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"as\" direction=\"out\"/>\n"
d378991747d67fff1d4dc39e7fb2bc8f49f1b561Mirco Tischler " </method>\n"
adb435bb70815461eeddf44dd5d6f1fc2ad9026dLennart Poettering " <method name=\"NameHasOwner\">\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"b\" direction=\"out\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <method name=\"ReleaseName\">\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"u\" direction=\"out\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <method name=\"ReloadConfig\">\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <method name=\"RequestName\">\n"
82499507b369fea3033a74c22813bf423301aef4Lennart Poettering " <arg type=\"s\" direction=\"in\"/>\n"
82499507b369fea3033a74c22813bf423301aef4Lennart Poettering " <arg type=\"u\" direction=\"in\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"u\" direction=\"out\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <method name=\"StartServiceByName\">\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"s\" direction=\"in\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <arg type=\"u\" direction=\"in\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"u\" direction=\"out\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " </method>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <method name=\"UpdateActivationEnvironment\">\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"a{ss}\" direction=\"in\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <signal name=\"NameAcquired\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\"/>\n"
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek " <signal name=\"NameLost\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\"/>\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <signal name=\"NameOwnerChanged\">\n"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek " <arg type=\"s\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " <arg type=\"s\"/>\n"
c2457105d76e3daf159f554a9bafb9751b23d756Holger Hans Peter Freyther " <arg type=\"s\"/>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering " </interface>\n"
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "AddMatch")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &match);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_add_match(a, NULL, match, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "RemoveMatch")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &match);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_remove_match_by_string(a, match, NULL, NULL);
3a83211689bdf4ab617a4fb79e11980c50918123Shawn Landden return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_MATCH_RULE_NOT_FOUND, "Match rule not found"));
3a83211689bdf4ab617a4fb79e11980c50918123Shawn Landden return synthetic_reply_method_errno(m, r, NULL);
3a83211689bdf4ab617a4fb79e11980c50918123Shawn Landden return synthetic_reply_method_return(m, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionSELinuxSecurityContext")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
0a20e3c10761378869af7bbef2733e3ae879d0f1Holger Hans Peter Freyther r = get_creds_by_message(a, m, SD_BUS_CREDS_SELINUX_CONTEXT, &creds, NULL);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering return synthetic_reply_method_errno(m, r, NULL);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering return synthetic_reply_method_return(m, "y", creds->label, strlen(creds->label));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionUnixProcessID")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering r = get_creds_by_message(a, m, SD_BUS_CREDS_PID, &creds, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "u", (uint32_t) creds->pid);
7027ff61a34a12487712b382a061c654acc3a679Lennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetConnectionUnixUser")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = get_creds_by_message(a, m, SD_BUS_CREDS_UID, &creds, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering return synthetic_reply_method_return(m, "u", (uint32_t) creds->uid);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetId")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "s", sd_id128_to_string(server_id, buf));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "GetNameOwner")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek _cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering return synthetic_reply_method_errno(m, r, NULL);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering return synthetic_reply_method_return(m, "s", "org.freedesktop.DBus");
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering r = get_creds_by_name(a, name, SD_BUS_CREDS_UNIQUE_NAME, &creds, &error);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering return synthetic_reply_method_errno(m, r, &error);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering return synthetic_reply_method_return(m, "s", creds->unique_name);
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering /* "Hello" is handled in process_hello() */
0a244b8ecb6dfcb381fe831dc2aa9bacb2c12975Lennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListActivatableNames")) {
ae018d9bc900d6355dea4af05119b49c67945184Lennart Poettering return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* Let's sort the names list to make it stable */
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_return_strv(m, names);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListNames")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **names = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_list_names(a, &names, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
e7ff4e7fe9f3abd2297e4ef7b95dcb2804e051c3Greg Kroah-Hartman r = strv_extend(&names, "org.freedesktop.DBus");
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* Let's sort the names list to make it stable */
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_return_strv(m, names);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListQueuedOwners")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek struct kdbus_cmd_name_list cmd = {};
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek struct kdbus_name_list *name_list;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **owners = NULL;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &arg0);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (service_name_is_valid(arg0) < 0)
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek cmd.flags = KDBUS_NAME_LIST_QUEUED;
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = ioctl(a->input_fd, KDBUS_CMD_NAME_LIST, &cmd);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -errno, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek name_list = (struct kdbus_name_list *) ((uint8_t *) a->kdbus_buffer + cmd.offset);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek KDBUS_ITEM_FOREACH(name, name_list, names) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (name->size <= sizeof(*name))
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (asprintf(&n, ":1.%llu", (unsigned long long) name->owner_id) < 0) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = ioctl(a->input_fd, KDBUS_CMD_FREE, &cmd.offset);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, err, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_return_strv(m, owners);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "NameHasOwner")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &name);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (service_name_is_valid(name) < 0)
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (streq(name, "org.freedesktop.DBus"))
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "b", true);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_get_owner(a, name, 0, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (r < 0 && r != -ESRCH && r != -ENXIO)
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering return synthetic_reply_method_return(m, "b", r >= 0);
19cace379f3f680d3201cd257ab3ca6708b2d45dLennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReleaseName")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "s", &name);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek if (service_name_is_valid(name) < 0)
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_release_name(a, name);
a569398925430de1f8479262e8ab39502054f2e9Lennart Poettering return synthetic_reply_method_return(m, "u", BUS_NAME_NON_EXISTENT);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "u", BUS_NAME_NOT_OWNER);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
adb435bb70815461eeddf44dd5d6f1fc2ad9026dLennart Poettering return synthetic_reply_method_return(m, "u", BUS_NAME_RELEASED);
adb435bb70815461eeddf44dd5d6f1fc2ad9026dLennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReloadConfig")) {
adb435bb70815461eeddf44dd5d6f1fc2ad9026dLennart Poettering _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_error_setf(&error, SD_BUS_ERROR_NOT_SUPPORTED, "%s() is not supported", sd_bus_message_get_member(m));
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, &error);
adb435bb70815461eeddf44dd5d6f1fc2ad9026dLennart Poettering } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "RequestName")) {
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "su", &name, &flags);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (service_name_is_valid(name) < 0)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if ((flags & ~(BUS_NAME_ALLOW_REPLACEMENT|BUS_NAME_REPLACE_EXISTING|BUS_NAME_DO_NOT_QUEUE)) != 0)
da4993920cdf5527b8528f0a483b54ab3cbc1971Kay Sievers return synthetic_reply_method_errno(m, -EINVAL, NULL);
40adcda869bda55f44b57fd3a2bd71d006dfb51bLennart Poettering return synthetic_reply_method_return(m, "u", BUS_NAME_EXISTS);
82499507b369fea3033a74c22813bf423301aef4Lennart Poettering return synthetic_reply_method_return(m, "u", BUS_NAME_ALREADY_OWNER);
82499507b369fea3033a74c22813bf423301aef4Lennart Poettering return synthetic_reply_method_errno(m, r, NULL);
da4993920cdf5527b8528f0a483b54ab3cbc1971Kay Sievers return synthetic_reply_method_return(m, "u", BUS_NAME_IN_QUEUE);
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering return synthetic_reply_method_return(m, "u", BUS_NAME_PRIMARY_OWNER);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "StartServiceByName")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "su", &name, &flags);
b92bea5d2a9481de69bb627a7b442a9f58fca43dZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (service_name_is_valid(name) < 0)
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_owner(a, name, 0, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (r >= 0 || streq(name, "org.freedesktop.DBus"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "u", BUS_START_REPLY_ALREADY_RUNNING);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_call(
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.DBus.Peer",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d07f7b9ef2835c290d6beadebd17d15308608eeaLennart Poettering return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, "u", BUS_START_REPLY_SUCCESS);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "UpdateActivationEnvironment")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_strv_free_ char **args = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EPERM, NULL);
968f319679d9069af037240d0c3bcd126181cdacZbigniew Jędrzejewski-Szmek r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{ss}");
7027ff61a34a12487712b382a061c654acc3a679Lennart Poettering return synthetic_reply_method_errno(m, r, NULL);
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek while ((r = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "ss")) > 0) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_read(m, "ss", &key, &value);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek s = strjoin(key, "=", value, NULL);
2f5df74a5ec135ab2baebf26af6f088e5b4b8205Holger Hans Peter Freyther return synthetic_reply_method_errno(m, -ENOMEM, NULL);
2f5df74a5ec135ab2baebf26af6f088e5b4b8205Holger Hans Peter Freyther return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_exit_container(m);
7027ff61a34a12487712b382a061c654acc3a679Lennart Poettering return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_exit_container(m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, -EINVAL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_new_method_call(
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.systemd1.Manager",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "SetEnvironment");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek r = sd_bus_message_append_strv(msg, args);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_call(a, msg, 0, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, NULL);
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek return synthetic_reply_method_return(m, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_error_setf(&error, SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method '%s'.", m->member);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek return synthetic_reply_method_errno(m, r, &error);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hello) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *n = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* As reaction to hello we need to respond with two messages:
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * the callback reply and the NameAcquired for the unique
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * name, since hello is otherwise obsolete on kdbus. */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "Hello") &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek streq_ptr(m->destination, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("First packet isn't hello (it's %s.%s), aborting.", m->interface, m->member);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Got duplicate hello, aborting.");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to generate HELLO reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_append(n, "s", a->unique_name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to append unique name to HELLO reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_message_append_sender(n, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to append sender to HELLO reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_seal_synthetic_message(b, n);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to seal HELLO reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to send HELLO reply: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "org.freedesktop.DBus",
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "NameAcquired");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to allocate initial NameAcquired message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_message_append(n, "s", a->unique_name);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to append unique name to NameAcquired message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_message_append_sender(n, "org.freedesktop.DBus");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to append sender to NameAcquired message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = bus_seal_synthetic_message(b, n);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to seal NameAcquired message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to send NameAcquired message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekstatic int patch_sender(sd_bus *a, sd_bus_message *m) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* We will change the sender of messages from the bus driver
93b73b064c663d6248bebfbbbd82989b5ca10fc5Lennart Poettering * so that they originate from the bus driver. This is a
93b73b064c663d6248bebfbbbd82989b5ca10fc5Lennart Poettering * speciality originating from dbus1, where the bus driver did
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek * not have a unique id, but only the well-known name. */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek c = sd_bus_message_get_creds(m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_creds_get_well_known_names(c, &well_known);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (strv_contains(well_known, "org.freedesktop.DBus"))
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek m->sender = "org.freedesktop.DBus";
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmekint main(int argc, char *argv[]) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_unref_ sd_bus *a = NULL, *b = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ char *peersec = NULL;
253f59dff9c93ee1d2c33444b5715e42bc1c6889Lennart Poettering log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to load policy: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* policy_dump(&policy); */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek } else if (r == 1) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Illegal number of file descriptors passed");
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek sd_is_socket(in_fd, AF_UNIX, 0, 0) > 0 &&
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek sd_is_socket(out_fd, AF_UNIX, 0, 0) > 0;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek const char *user = "systemd-bus-proxy";
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = get_user_creds(&user, &uid, &gid, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Cannot resolve user name %s: %s", user, strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = drop_privileges(uid, gid, 1ULL << CAP_IPC_OWNER);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to allocate bus: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_set_name(a, "sd-proxy");
289f910e16d0a962e128979b67fed5f2ef668e00Zbigniew Jędrzejewski-Szmek log_error("Failed to set bus name: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_set_address(a, arg_address);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to set address to connect to: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_negotiate_fds(a, is_unix);
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk log_error("Failed to set FD negotiation: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek a->manual_peer_interface = true;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to start bus client: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_server_id(a, &server_id);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get server ID: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to allocate bus: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_set_fd(b, in_fd, out_fd);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to set fds: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_set_server(b, 1, server_id);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to set server mode: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_negotiate_fds(b, is_unix);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to set FD negotiation: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_set_anonymous(b, true);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to set anonymous authentication: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek b->manual_peer_interface = true;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to start bus client: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_debug("Failed to rename process: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_free_ char *match = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_unique_name(a, &unique);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get unique name: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek match = strjoin("type='signal',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "sender='org.freedesktop.DBus',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "interface='org.freedesktop.DBus',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "member='NameOwnerChanged',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_add_match(a, NULL, match, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to add match for NameLost: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek match = strjoin("type='signal',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "sender='org.freedesktop.DBus',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "interface='org.freedesktop.DBus',"
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek "member='NameOwnerChanged',"
670b110c3b59dfa335ac43065b2038400d1d04a9Zbigniew Jędrzejewski-Szmek r = sd_bus_add_match(a, NULL, match, NULL, NULL);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to add match for NameAcquired: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek _cleanup_bus_message_unref_ sd_bus_message *m = NULL;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek uint64_t timeout_a, timeout_b, t;
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* treat 'connection reset by peer' as clean exit condition */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to process bus a: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* We officially got EOF, let's quit */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek k = synthesize_name_acquired(a, b, m);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to synthesize message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to send message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* treat 'connection reset by peer' as clean exit condition */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to process bus b: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek /* We officially got EOF, let's quit */
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek k = process_hello(a, b, m, &got_hello);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to process HELLO: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to process policy: %s", strerror(-r));
db91ea32aa223d1b087d99811226a9c59a1bb281Zbigniew Jędrzejewski-Szmek log_error("Failed to process driver calls: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to send message: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get fd: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek events_a = sd_bus_get_events(a);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get events mask: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_timeout(a, &timeout_a);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get timeout: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek events_b = sd_bus_get_events(b);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get events mask: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek r = sd_bus_get_timeout(b, &timeout_b);
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek log_error("Failed to get timeout: %s", strerror(-r));
d025f1e4dca8fc1436aff76f9e6185fe3e728daaZbigniew Jędrzejewski-Szmek if (t == (uint64_t) -1 || (timeout_b != (uint64_t) -1 && timeout_b < timeout_a))
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk {.fd = in_fd, .events = events_b & POLLIN, },
26687bf8a907009dedcff79346860ed41511405eOleksii Shevchuk {.fd = out_fd, .events = events_b & POLLOUT, }