[systemd-commits] 3 commits - Makefile.am src/journal src/libsystemd-bus src/systemd
Lennart Poettering
lennart at kemper.freedesktop.org
Sun Mar 31 09:19:00 PDT 2013
Makefile.am | 6 -
src/journal/journal-gatewayd.c | 56 ++++++++++-
src/libsystemd-bus/bus-internal.h | 8 -
src/libsystemd-bus/bus-match.c | 8 -
src/libsystemd-bus/bus-match.h | 6 -
src/libsystemd-bus/bus-socket.c | 8 -
src/libsystemd-bus/sd-bus-protocol.h | 153 ------------------------------
src/libsystemd-bus/sd-bus.c | 38 +++----
src/libsystemd-bus/sd-bus.h | 177 -----------------------------------
src/libsystemd-bus/test-bus-chat.c | 4
src/systemd/sd-bus-protocol.h | 153 ++++++++++++++++++++++++++++++
src/systemd/sd-bus.h | 174 ++++++++++++++++++++++++++++++++++
12 files changed, 419 insertions(+), 372 deletions(-)
New commits:
commit a7edaadd78271e1c35ff9032f068cb08de645437
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Mar 31 18:15:59 2013 +0200
journal-gatewayd: query PID 1 for virtalization
Since journal-gatewayd is now running unprivileged, and detecting
virtalization requires privileges, query PID1 via D-Bus for the used
virtualization.
This is also the first time we use libsystemd-bus for more than just
testing.
https://bugs.freedesktop.org/show_bug.cgi?id=62173
diff --git a/Makefile.am b/Makefile.am
index 07f4362..ef13ad2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -167,6 +167,7 @@ AM_CPPFLAGS = \
-I $(top_srcdir)/src/core \
-I $(top_srcdir)/src/libudev \
-I $(top_srcdir)/src/udev \
+ -I $(top_srcdir)/src/libsystemd-bus \
$(OUR_CPPFLAGS)
AM_CFLAGS = $(OUR_CFLAGS)
@@ -1666,9 +1667,9 @@ EXTRA_DIST += \
# ------------------------------------------------------------------------------
libsystemd_bus_la_SOURCES = \
+ src/systemd/sd-bus.h \
+ src/systemd/sd-bus-protocol.h \
src/libsystemd-bus/sd-bus.c \
- src/libsystemd-bus/sd-bus.h \
- src/libsystemd-bus/sd-bus-protocol.h \
src/libsystemd-bus/bus-control.c \
src/libsystemd-bus/bus-control.h \
src/libsystemd-bus/bus-error.c \
@@ -2867,6 +2868,7 @@ systemd_journal_gatewayd_LDADD = \
libsystemd-journal-internal.la \
libsystemd-id128-internal.la \
libsystemd-daemon.la \
+ libsystemd-bus.la \
$(MICROHTTPD_LIBS)
systemd_journal_gatewayd_CFLAGS = \
diff --git a/src/journal/journal-gatewayd.c b/src/journal/journal-gatewayd.c
index 8161b7e..133d0ae 100644
--- a/src/journal/journal-gatewayd.c
+++ b/src/journal/journal-gatewayd.c
@@ -31,9 +31,11 @@
#include "util.h"
#include "sd-journal.h"
#include "sd-daemon.h"
+#include "sd-bus.h"
+#include "bus-message.h"
+#include "bus-internal.h"
#include "logs-show.h"
#include "microhttpd-util.h"
-#include "virt.h"
#include "build.h"
#include "fileio.h"
@@ -740,6 +742,52 @@ static int request_handler_file(
return ret;
}
+static int get_virtualization(char **v) {
+ _cleanup_bus_message_unref_ sd_bus_message *m = NULL, *reply = NULL;
+ _cleanup_bus_unref_ sd_bus *bus = NULL;
+ const char *t;
+ char *b;
+ int r;
+
+ r = sd_bus_open_system(&bus);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_new_method_call(
+ bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ "org.freedesktop.DBus.Properties",
+ "Get",
+ &m);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_append(m, "ss", "org.freedesktop.systemd1.Manager", "Virtualization");
+ if (r < 0)
+ return r;
+
+ r = sd_bus_send_with_reply_and_block(bus, m, 0, NULL, &reply);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_message_read(reply, "v", "s", &t);
+ if (r < 0)
+ return r;
+
+ if (isempty(t)) {
+ *v = NULL;
+ return 0;
+ }
+
+ b = strdup(t);
+ if (!b)
+ return -ENOMEM;
+
+ *v = b;
+ return 1;
+}
+
static int request_handler_machine(
struct MHD_Connection *connection,
void *connection_cls) {
@@ -751,7 +799,7 @@ static int request_handler_machine(
uint64_t cutoff_from, cutoff_to, usage;
char *json;
sd_id128_t mid, bid;
- const char *v = "bare";
+ _cleanup_free_ char *v = NULL;
assert(connection);
assert(m);
@@ -782,7 +830,7 @@ static int request_handler_machine(
parse_env_file("/etc/os-release", NEWLINE, "PRETTY_NAME", &os_name, NULL);
- detect_virtualization(&v);
+ get_virtualization(&v);
r = asprintf(&json,
"{ \"machine_id\" : \"" SD_ID128_FORMAT_STR "\","
@@ -797,7 +845,7 @@ static int request_handler_machine(
SD_ID128_FORMAT_VAL(bid),
hostname_cleanup(hostname),
os_name ? os_name : "Linux",
- v,
+ v ? v : "bare",
(unsigned long long) usage,
(unsigned long long) cutoff_from,
(unsigned long long) cutoff_to);
diff --git a/src/libsystemd-bus/sd-bus-protocol.h b/src/libsystemd-bus/sd-bus-protocol.h
deleted file mode 100644
index 7922f6b..0000000
--- a/src/libsystemd-bus/sd-bus-protocol.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdbusprotocolhfoo
-#define foosdbusprotocolhfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <endian.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Types of message */
-
-enum {
- _SD_BUS_MESSAGE_TYPE_INVALID = 0,
- SD_BUS_MESSAGE_TYPE_METHOD_CALL,
- SD_BUS_MESSAGE_TYPE_METHOD_RETURN,
- SD_BUS_MESSAGE_TYPE_METHOD_ERROR,
- SD_BUS_MESSAGE_TYPE_SIGNAL,
- _SD_BUS_MESSAGE_TYPE_MAX
-};
-
-/* Primitive types */
-
-enum {
- _SD_BUS_TYPE_INVALID = 0,
- SD_BUS_TYPE_BYTE = 'y',
- SD_BUS_TYPE_BOOLEAN = 'b',
- SD_BUS_TYPE_INT16 = 'n',
- SD_BUS_TYPE_UINT16 = 'q',
- SD_BUS_TYPE_INT32 = 'i',
- SD_BUS_TYPE_UINT32 = 'u',
- SD_BUS_TYPE_INT64 = 'x',
- SD_BUS_TYPE_UINT64 = 't',
- SD_BUS_TYPE_DOUBLE = 'd',
- SD_BUS_TYPE_STRING = 's',
- SD_BUS_TYPE_OBJECT_PATH = 'o',
- SD_BUS_TYPE_SIGNATURE = 'g',
- SD_BUS_TYPE_UNIX_FD = 'h',
- SD_BUS_TYPE_ARRAY = 'a',
- SD_BUS_TYPE_VARIANT = 'v',
- SD_BUS_TYPE_STRUCT = 'r', /* not actually used in signatures */
- SD_BUS_TYPE_STRUCT_BEGIN = '(',
- SD_BUS_TYPE_STRUCT_END = ')',
- SD_BUS_TYPE_DICT_ENTRY = 'e', /* not actually used in signatures */
- SD_BUS_TYPE_DICT_ENTRY_BEGIN = '{',
- SD_BUS_TYPE_DICT_ENTRY_END = '}',
-};
-
-/* Endianess */
-
-enum {
- _SD_BUS_INVALID_ENDIAN = 0,
- SD_BUS_LITTLE_ENDIAN = 'l',
- SD_BUS_BIG_ENDIAN = 'B',
-#if __BYTE_ORDER == __BIG_ENDIAN
- SD_BUS_NATIVE_ENDIAN = SD_BUS_BIG_ENDIAN,
- SD_BUS_REVERSE_ENDIAN = SD_BUS_LITTLE_ENDIAN
-#else
- SD_BUS_NATIVE_ENDIAN = SD_BUS_LITTLE_ENDIAN,
- SD_BUS_REVERSE_ENDIAN = SD_BUS_BIG_ENDIAN
-#endif
-};
-
-/* Flags */
-
-enum {
- SD_BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
- SD_BUS_MESSAGE_NO_AUTO_START = 2
-};
-
-/* Header fields */
-
-enum {
- _SD_BUS_MESSAGE_HEADER_INVALID = 0,
- SD_BUS_MESSAGE_HEADER_PATH,
- SD_BUS_MESSAGE_HEADER_INTERFACE,
- SD_BUS_MESSAGE_HEADER_MEMBER,
- SD_BUS_MESSAGE_HEADER_ERROR_NAME,
- SD_BUS_MESSAGE_HEADER_REPLY_SERIAL,
- SD_BUS_MESSAGE_HEADER_DESTINATION,
- SD_BUS_MESSAGE_HEADER_SENDER,
- SD_BUS_MESSAGE_HEADER_SIGNATURE,
- SD_BUS_MESSAGE_HEADER_UNIX_FDS,
- _SD_BUS_MESSAGE_HEADER_MAX
-};
-
-#define SD_BUS_INTROSPECT_DOCTYPE \
- "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
- "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
-
-#define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES \
- " <interface name=\"org.freedesktop.DBus.Properties\">\n" \
- " <method name=\"Get\">\n" \
- " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
- " </method>\n" \
- " <method name=\"GetAll\">\n" \
- " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
- " </method>\n" \
- " <method name=\"Set\">\n" \
- " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
- " <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \
- " </method>\n" \
- " <signal name=\"PropertiesChanged\">\n" \
- " <arg type=\"s\" name=\"interface\"/>\n" \
- " <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \
- " <arg type=\"as\" name=\"invalidated_properties\"/>\n" \
- " </signal>\n" \
- " </interface>\n"
-
-#define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
- " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
- " <method name=\"Introspect\">\n" \
- " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
- " </method>\n" \
- " </interface>\n"
-
-#define SD_BUS_INTROSPECT_INTERFACE_PEER \
- "<interface name=\"org.freedesktop.DBus.Peer\">\n" \
- " <method name=\"Ping\"/>\n" \
- " <method name=\"GetMachineId\">\n" \
- " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
- " </method>\n" \
- "</interface>\n"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/libsystemd-bus/sd-bus.h b/src/libsystemd-bus/sd-bus.h
deleted file mode 100644
index f792bfa..0000000
--- a/src/libsystemd-bus/sd-bus.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
-#ifndef foosdbushfoo
-#define foosdbushfoo
-
-/***
- This file is part of systemd.
-
- Copyright 2013 Lennart Poettering
-
- systemd is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published by
- the Free Software Foundation; either version 2.1 of the License, or
- (at your option) any later version.
-
- systemd is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with systemd; If not, see <http://www.gnu.org/licenses/>.
-***/
-
-#include <inttypes.h>
-#include <sys/types.h>
-
-#include <sd-id128.h>
-#include "sd-bus-protocol.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* TODO:
- * - add page donation logic
- * - api for appending/reading fixed arrays
- * - merge busctl into systemctl or so?
- * - default policy (allow uid == 0 and our own uid)
- */
-
-typedef struct sd_bus sd_bus;
-typedef struct sd_bus_message sd_bus_message;
-
-typedef struct {
- const char *name;
- const char *message;
- int need_free;
-} sd_bus_error;
-
-typedef int (*sd_bus_message_handler_t)(sd_bus *bus, int ret, sd_bus_message *m, void *userdata);
-
-/* Connections */
-
-int sd_bus_open_system(sd_bus **ret);
-int sd_bus_open_user(sd_bus **ret);
-
-int sd_bus_new(sd_bus **ret);
-int sd_bus_set_address(sd_bus *bus, const char *address);
-int sd_bus_set_fd(sd_bus *bus, int fd);
-int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
-int sd_bus_set_bus_client(sd_bus *bus, int b);
-int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
-int sd_bus_set_anonymous(sd_bus *bus, int b);
-int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
-int sd_bus_start(sd_bus *ret);
-
-void sd_bus_close(sd_bus *bus);
-
-sd_bus *sd_bus_ref(sd_bus *bus);
-sd_bus *sd_bus_unref(sd_bus *bus);
-
-int sd_bus_is_open(sd_bus *bus);
-int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
-
-int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
-int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
-int sd_bus_send_with_reply_cancel(sd_bus *bus, uint64_t serial);
-int sd_bus_send_with_reply_and_block(sd_bus *bus, sd_bus_message *m, uint64_t usec, sd_bus_error *error, sd_bus_message **r);
-
-int sd_bus_get_fd(sd_bus *bus);
-int sd_bus_get_events(sd_bus *bus);
-int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec);
-int sd_bus_process(sd_bus *bus, sd_bus_message **r);
-int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
-int sd_bus_flush(sd_bus *bus);
-
-int sd_bus_add_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_remove_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
-
-int sd_bus_add_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_remove_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
-
-int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
-
-int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
-
-/* Message object */
-
-int sd_bus_message_new_signal(sd_bus *bus, const char *path, const char *interface, const char *member, sd_bus_message **m);
-int sd_bus_message_new_method_call(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message **m);
-int sd_bus_message_new_method_return(sd_bus *bus, sd_bus_message *call, sd_bus_message **m);
-int sd_bus_message_new_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m);
-
-sd_bus_message* sd_bus_message_ref(sd_bus_message *m);
-sd_bus_message* sd_bus_message_unref(sd_bus_message *m);
-
-int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type);
-int sd_bus_message_get_serial(sd_bus_message *m, uint64_t *serial);
-int sd_bus_message_get_reply_serial(sd_bus_message *m, uint64_t *serial);
-int sd_bus_message_get_no_reply(sd_bus_message *m);
-
-const char *sd_bus_message_get_path(sd_bus_message *m);
-const char *sd_bus_message_get_interface(sd_bus_message *m);
-const char *sd_bus_message_get_member(sd_bus_message *m);
-const char *sd_bus_message_get_destination(sd_bus_message *m);
-const char *sd_bus_message_get_sender(sd_bus_message *m);
-const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m);
-
-int sd_bus_message_get_uid(sd_bus_message *m, uid_t *uid);
-int sd_bus_message_get_gid(sd_bus_message *m, gid_t *gid);
-int sd_bus_message_get_pid(sd_bus_message *m, pid_t *pid);
-int sd_bus_message_get_tid(sd_bus_message *m, pid_t *tid);
-const char *sd_bus_message_get_label(sd_bus_message *m);
-
-int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
-int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
-int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
-
-int sd_bus_message_set_no_reply(sd_bus_message *m, int b);
-int sd_bus_message_set_destination(sd_bus_message *m, const char *destination);
-
-int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
-int sd_bus_message_append_basic(sd_bus_message *m, char type, const void *p);
-int sd_bus_message_open_container(sd_bus_message *m, char type, const char *contents);
-int sd_bus_message_close_container(sd_bus_message *m);
-
-int sd_bus_message_read(sd_bus_message *m, const char *types, ...);
-int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
-int sd_bus_message_enter_container(sd_bus_message *m, char type, const char *contents);
-int sd_bus_message_exit_container(sd_bus_message *m);
-int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char **contents);
-int sd_bus_message_rewind(sd_bus_message *m, int complete);
-
-/* Bus management */
-
-int sd_bus_get_unique_name(sd_bus *bus, const char **unique);
-int sd_bus_request_name(sd_bus *bus, const char *name, int flags);
-int sd_bus_release_name(sd_bus *bus, const char *name);
-int sd_bus_list_names(sd_bus *bus, char ***l);
-int sd_bus_get_owner(sd_bus *bus, const char *name, char **owner);
-int sd_bus_get_owner_uid(sd_bus *bus, const char *name, uid_t *uid);
-int sd_bus_get_owner_pid(sd_bus *bus, const char *name, pid_t *pid);
-
-/* Error structures */
-
-#define SD_BUS_ERROR_INIT {NULL, NULL, 0}
-#define SD_BUS_ERROR_INIT_CONST(name, message) {(name), (message), 0}
-
-void sd_bus_error_free(sd_bus_error *e);
-int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...);
-void sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message);
-int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e);
-int sd_bus_error_is_set(const sd_bus_error *e);
-int sd_bus_error_has_name(const sd_bus_error *e, const char *name);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/systemd/sd-bus-protocol.h b/src/systemd/sd-bus-protocol.h
new file mode 100644
index 0000000..7922f6b
--- /dev/null
+++ b/src/systemd/sd-bus-protocol.h
@@ -0,0 +1,153 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foosdbusprotocolhfoo
+#define foosdbusprotocolhfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2013 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <endian.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Types of message */
+
+enum {
+ _SD_BUS_MESSAGE_TYPE_INVALID = 0,
+ SD_BUS_MESSAGE_TYPE_METHOD_CALL,
+ SD_BUS_MESSAGE_TYPE_METHOD_RETURN,
+ SD_BUS_MESSAGE_TYPE_METHOD_ERROR,
+ SD_BUS_MESSAGE_TYPE_SIGNAL,
+ _SD_BUS_MESSAGE_TYPE_MAX
+};
+
+/* Primitive types */
+
+enum {
+ _SD_BUS_TYPE_INVALID = 0,
+ SD_BUS_TYPE_BYTE = 'y',
+ SD_BUS_TYPE_BOOLEAN = 'b',
+ SD_BUS_TYPE_INT16 = 'n',
+ SD_BUS_TYPE_UINT16 = 'q',
+ SD_BUS_TYPE_INT32 = 'i',
+ SD_BUS_TYPE_UINT32 = 'u',
+ SD_BUS_TYPE_INT64 = 'x',
+ SD_BUS_TYPE_UINT64 = 't',
+ SD_BUS_TYPE_DOUBLE = 'd',
+ SD_BUS_TYPE_STRING = 's',
+ SD_BUS_TYPE_OBJECT_PATH = 'o',
+ SD_BUS_TYPE_SIGNATURE = 'g',
+ SD_BUS_TYPE_UNIX_FD = 'h',
+ SD_BUS_TYPE_ARRAY = 'a',
+ SD_BUS_TYPE_VARIANT = 'v',
+ SD_BUS_TYPE_STRUCT = 'r', /* not actually used in signatures */
+ SD_BUS_TYPE_STRUCT_BEGIN = '(',
+ SD_BUS_TYPE_STRUCT_END = ')',
+ SD_BUS_TYPE_DICT_ENTRY = 'e', /* not actually used in signatures */
+ SD_BUS_TYPE_DICT_ENTRY_BEGIN = '{',
+ SD_BUS_TYPE_DICT_ENTRY_END = '}',
+};
+
+/* Endianess */
+
+enum {
+ _SD_BUS_INVALID_ENDIAN = 0,
+ SD_BUS_LITTLE_ENDIAN = 'l',
+ SD_BUS_BIG_ENDIAN = 'B',
+#if __BYTE_ORDER == __BIG_ENDIAN
+ SD_BUS_NATIVE_ENDIAN = SD_BUS_BIG_ENDIAN,
+ SD_BUS_REVERSE_ENDIAN = SD_BUS_LITTLE_ENDIAN
+#else
+ SD_BUS_NATIVE_ENDIAN = SD_BUS_LITTLE_ENDIAN,
+ SD_BUS_REVERSE_ENDIAN = SD_BUS_BIG_ENDIAN
+#endif
+};
+
+/* Flags */
+
+enum {
+ SD_BUS_MESSAGE_NO_REPLY_EXPECTED = 1,
+ SD_BUS_MESSAGE_NO_AUTO_START = 2
+};
+
+/* Header fields */
+
+enum {
+ _SD_BUS_MESSAGE_HEADER_INVALID = 0,
+ SD_BUS_MESSAGE_HEADER_PATH,
+ SD_BUS_MESSAGE_HEADER_INTERFACE,
+ SD_BUS_MESSAGE_HEADER_MEMBER,
+ SD_BUS_MESSAGE_HEADER_ERROR_NAME,
+ SD_BUS_MESSAGE_HEADER_REPLY_SERIAL,
+ SD_BUS_MESSAGE_HEADER_DESTINATION,
+ SD_BUS_MESSAGE_HEADER_SENDER,
+ SD_BUS_MESSAGE_HEADER_SIGNATURE,
+ SD_BUS_MESSAGE_HEADER_UNIX_FDS,
+ _SD_BUS_MESSAGE_HEADER_MAX
+};
+
+#define SD_BUS_INTROSPECT_DOCTYPE \
+ "<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\"\n" \
+ "\"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd\">\n"
+
+#define SD_BUS_INTROSPECT_INTERFACE_PROPERTIES \
+ " <interface name=\"org.freedesktop.DBus.Properties\">\n" \
+ " <method name=\"Get\">\n" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"value\" direction=\"out\" type=\"v\"/>\n" \
+ " </method>\n" \
+ " <method name=\"GetAll\">\n" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>\n" \
+ " </method>\n" \
+ " <method name=\"Set\">\n" \
+ " <arg name=\"interface\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"property\" direction=\"in\" type=\"s\"/>\n" \
+ " <arg name=\"value\" direction=\"in\" type=\"v\"/>\n" \
+ " </method>\n" \
+ " <signal name=\"PropertiesChanged\">\n" \
+ " <arg type=\"s\" name=\"interface\"/>\n" \
+ " <arg type=\"a{sv}\" name=\"changed_properties\"/>\n" \
+ " <arg type=\"as\" name=\"invalidated_properties\"/>\n" \
+ " </signal>\n" \
+ " </interface>\n"
+
+#define SD_BUS_INTROSPECT_INTERFACE_INTROSPECTABLE \
+ " <interface name=\"org.freedesktop.DBus.Introspectable\">\n" \
+ " <method name=\"Introspect\">\n" \
+ " <arg name=\"data\" type=\"s\" direction=\"out\"/>\n" \
+ " </method>\n" \
+ " </interface>\n"
+
+#define SD_BUS_INTROSPECT_INTERFACE_PEER \
+ "<interface name=\"org.freedesktop.DBus.Peer\">\n" \
+ " <method name=\"Ping\"/>\n" \
+ " <method name=\"GetMachineId\">\n" \
+ " <arg type=\"s\" name=\"machine_uuid\" direction=\"out\"/>\n" \
+ " </method>\n" \
+ "</interface>\n"
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
new file mode 100644
index 0000000..f792bfa
--- /dev/null
+++ b/src/systemd/sd-bus.h
@@ -0,0 +1,174 @@
+/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
+
+#ifndef foosdbushfoo
+#define foosdbushfoo
+
+/***
+ This file is part of systemd.
+
+ Copyright 2013 Lennart Poettering
+
+ systemd is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published by
+ the Free Software Foundation; either version 2.1 of the License, or
+ (at your option) any later version.
+
+ systemd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with systemd; If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include <inttypes.h>
+#include <sys/types.h>
+
+#include <sd-id128.h>
+#include "sd-bus-protocol.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* TODO:
+ * - add page donation logic
+ * - api for appending/reading fixed arrays
+ * - merge busctl into systemctl or so?
+ * - default policy (allow uid == 0 and our own uid)
+ */
+
+typedef struct sd_bus sd_bus;
+typedef struct sd_bus_message sd_bus_message;
+
+typedef struct {
+ const char *name;
+ const char *message;
+ int need_free;
+} sd_bus_error;
+
+typedef int (*sd_bus_message_handler_t)(sd_bus *bus, int ret, sd_bus_message *m, void *userdata);
+
+/* Connections */
+
+int sd_bus_open_system(sd_bus **ret);
+int sd_bus_open_user(sd_bus **ret);
+
+int sd_bus_new(sd_bus **ret);
+int sd_bus_set_address(sd_bus *bus, const char *address);
+int sd_bus_set_fd(sd_bus *bus, int fd);
+int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
+int sd_bus_set_bus_client(sd_bus *bus, int b);
+int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
+int sd_bus_set_anonymous(sd_bus *bus, int b);
+int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
+int sd_bus_start(sd_bus *ret);
+
+void sd_bus_close(sd_bus *bus);
+
+sd_bus *sd_bus_ref(sd_bus *bus);
+sd_bus *sd_bus_unref(sd_bus *bus);
+
+int sd_bus_is_open(sd_bus *bus);
+int sd_bus_can_send(sd_bus *bus, char type);
+int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
+
+int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
+int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
+int sd_bus_send_with_reply_cancel(sd_bus *bus, uint64_t serial);
+int sd_bus_send_with_reply_and_block(sd_bus *bus, sd_bus_message *m, uint64_t usec, sd_bus_error *error, sd_bus_message **r);
+
+int sd_bus_get_fd(sd_bus *bus);
+int sd_bus_get_events(sd_bus *bus);
+int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec);
+int sd_bus_process(sd_bus *bus, sd_bus_message **r);
+int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
+int sd_bus_flush(sd_bus *bus);
+
+int sd_bus_add_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
+
+int sd_bus_add_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
+
+int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
+
+int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+
+/* Message object */
+
+int sd_bus_message_new_signal(sd_bus *bus, const char *path, const char *interface, const char *member, sd_bus_message **m);
+int sd_bus_message_new_method_call(sd_bus *bus, const char *destination, const char *path, const char *interface, const char *member, sd_bus_message **m);
+int sd_bus_message_new_method_return(sd_bus *bus, sd_bus_message *call, sd_bus_message **m);
+int sd_bus_message_new_method_error(sd_bus *bus, sd_bus_message *call, const sd_bus_error *e, sd_bus_message **m);
+
+sd_bus_message* sd_bus_message_ref(sd_bus_message *m);
+sd_bus_message* sd_bus_message_unref(sd_bus_message *m);
+
+int sd_bus_message_get_type(sd_bus_message *m, uint8_t *type);
+int sd_bus_message_get_serial(sd_bus_message *m, uint64_t *serial);
+int sd_bus_message_get_reply_serial(sd_bus_message *m, uint64_t *serial);
+int sd_bus_message_get_no_reply(sd_bus_message *m);
+
+const char *sd_bus_message_get_path(sd_bus_message *m);
+const char *sd_bus_message_get_interface(sd_bus_message *m);
+const char *sd_bus_message_get_member(sd_bus_message *m);
+const char *sd_bus_message_get_destination(sd_bus_message *m);
+const char *sd_bus_message_get_sender(sd_bus_message *m);
+const sd_bus_error *sd_bus_message_get_error(sd_bus_message *m);
+
+int sd_bus_message_get_uid(sd_bus_message *m, uid_t *uid);
+int sd_bus_message_get_gid(sd_bus_message *m, gid_t *gid);
+int sd_bus_message_get_pid(sd_bus_message *m, pid_t *pid);
+int sd_bus_message_get_tid(sd_bus_message *m, pid_t *tid);
+const char *sd_bus_message_get_label(sd_bus_message *m);
+
+int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const char *member);
+int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
+int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
+
+int sd_bus_message_set_no_reply(sd_bus_message *m, int b);
+int sd_bus_message_set_destination(sd_bus_message *m, const char *destination);
+
+int sd_bus_message_append(sd_bus_message *m, const char *types, ...);
+int sd_bus_message_append_basic(sd_bus_message *m, char type, const void *p);
+int sd_bus_message_open_container(sd_bus_message *m, char type, const char *contents);
+int sd_bus_message_close_container(sd_bus_message *m);
+
+int sd_bus_message_read(sd_bus_message *m, const char *types, ...);
+int sd_bus_message_read_basic(sd_bus_message *m, char type, void *p);
+int sd_bus_message_enter_container(sd_bus_message *m, char type, const char *contents);
+int sd_bus_message_exit_container(sd_bus_message *m);
+int sd_bus_message_peek_type(sd_bus_message *m, char *type, const char **contents);
+int sd_bus_message_rewind(sd_bus_message *m, int complete);
+
+/* Bus management */
+
+int sd_bus_get_unique_name(sd_bus *bus, const char **unique);
+int sd_bus_request_name(sd_bus *bus, const char *name, int flags);
+int sd_bus_release_name(sd_bus *bus, const char *name);
+int sd_bus_list_names(sd_bus *bus, char ***l);
+int sd_bus_get_owner(sd_bus *bus, const char *name, char **owner);
+int sd_bus_get_owner_uid(sd_bus *bus, const char *name, uid_t *uid);
+int sd_bus_get_owner_pid(sd_bus *bus, const char *name, pid_t *pid);
+
+/* Error structures */
+
+#define SD_BUS_ERROR_INIT {NULL, NULL, 0}
+#define SD_BUS_ERROR_INIT_CONST(name, message) {(name), (message), 0}
+
+void sd_bus_error_free(sd_bus_error *e);
+int sd_bus_error_set(sd_bus_error *e, const char *name, const char *format, ...);
+void sd_bus_error_set_const(sd_bus_error *e, const char *name, const char *message);
+int sd_bus_error_copy(sd_bus_error *dest, const sd_bus_error *e);
+int sd_bus_error_is_set(const sd_bus_error *e);
+int sd_bus_error_has_name(const sd_bus_error *e, const char *name);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
commit 98178d3947d951ca001eaf400b5f362f458dceb5
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Mar 31 16:46:21 2013 +0200
bus: rename sd_bus_get_peer() to sd_bus_get_server_id()
This function always returns the server side ID. The name suggested it
was actually always the peer's ID, but that's not correct if the call is
called on a server bus context. Hence, let's correct the name a bit.
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index a11dc8c..0149604 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -112,7 +112,7 @@ struct sd_bus {
} sockaddr;
socklen_t sockaddr_size;
- sd_id128_t peer;
+ sd_id128_t server_id;
char *address;
unsigned address_index;
diff --git a/src/libsystemd-bus/bus-socket.c b/src/libsystemd-bus/bus-socket.c
index cb1e942..fed1971 100644
--- a/src/libsystemd-bus/bus-socket.c
+++ b/src/libsystemd-bus/bus-socket.c
@@ -146,11 +146,11 @@ static int bus_socket_auth_verify_client(sd_bus *b) {
peer.bytes[i/2] = ((uint8_t) x << 4 | (uint8_t) y);
}
- if (!sd_id128_equal(b->peer, SD_ID128_NULL) &&
- !sd_id128_equal(b->peer, peer))
+ if (!sd_id128_equal(b->server_id, SD_ID128_NULL) &&
+ !sd_id128_equal(b->server_id, peer))
return -EPERM;
- b->peer = peer;
+ b->server_id = peer;
/* And possibly check the second line, too */
@@ -286,7 +286,7 @@ static int bus_socket_auth_write_ok(sd_bus *b) {
assert(b);
- snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->peer));
+ snprintf(t, sizeof(t), "OK " SD_ID128_FORMAT_STR "\r\n", SD_ID128_FORMAT_VAL(b->server_id));
char_array_0(t);
return bus_socket_auth_write(b, t);
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 9b9281d..a71d7b5 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -200,16 +200,16 @@ int sd_bus_set_negotiate_fds(sd_bus *bus, int b) {
return 0;
}
-int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server) {
+int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id) {
if (!bus)
return -EINVAL;
- if (!b && !sd_id128_equal(server, SD_ID128_NULL))
+ if (!b && !sd_id128_equal(server_id, SD_ID128_NULL))
return -EINVAL;
if (bus->state != BUS_UNSET)
return -EPERM;
bus->is_server = !!b;
- bus->peer = server;
+ bus->server_id = server_id;
return 0;
}
@@ -604,7 +604,7 @@ static void bus_reset_parsed_address(sd_bus *b) {
free(b->exec_path);
b->exec_path = NULL;
b->exec_argv = NULL;
- b->peer = SD_ID128_NULL;
+ b->server_id = SD_ID128_NULL;
}
static int bus_parse_next_address(sd_bus *b) {
@@ -664,7 +664,7 @@ static int bus_parse_next_address(sd_bus *b) {
}
if (guid) {
- r = sd_id128_from_string(guid, &b->peer);
+ r = sd_id128_from_string(guid, &b->server_id);
if (r < 0)
return r;
}
@@ -907,19 +907,19 @@ int sd_bus_can_send(sd_bus *bus, char type) {
return bus_type_is_valid(type);
}
-int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer) {
+int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *server_id) {
int r;
if (!bus)
return -EINVAL;
- if (!peer)
+ if (!server_id)
return -EINVAL;
r = bus_ensure_running(bus);
if (r < 0)
return r;
- *peer = bus->peer;
+ *server_id = bus->server_id;
return 0;
}
diff --git a/src/libsystemd-bus/sd-bus.h b/src/libsystemd-bus/sd-bus.h
index 413b7dc..f792bfa 100644
--- a/src/libsystemd-bus/sd-bus.h
+++ b/src/libsystemd-bus/sd-bus.h
@@ -60,9 +60,9 @@ int sd_bus_set_address(sd_bus *bus, const char *address);
int sd_bus_set_fd(sd_bus *bus, int fd);
int sd_bus_set_exec(sd_bus *bus, const char *path, char *const argv[]);
int sd_bus_set_bus_client(sd_bus *bus, int b);
-int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_set_server(sd_bus *bus, int b, sd_id128_t server_id);
int sd_bus_set_anonymous(sd_bus *bus, int b);
+int sd_bus_set_negotiate_fds(sd_bus *bus, int b);
int sd_bus_start(sd_bus *ret);
void sd_bus_close(sd_bus *bus);
@@ -72,7 +72,7 @@ sd_bus *sd_bus_unref(sd_bus *bus);
int sd_bus_is_open(sd_bus *bus);
int sd_bus_can_send(sd_bus *bus, char type);
-int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer);
+int sd_bus_get_server_id(sd_bus *bus, sd_id128_t *peer);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
diff --git a/src/libsystemd-bus/test-bus-chat.c b/src/libsystemd-bus/test-bus-chat.c
index 2dd3091..459d39f 100644
--- a/src/libsystemd-bus/test-bus-chat.c
+++ b/src/libsystemd-bus/test-bus-chat.c
@@ -85,9 +85,9 @@ static int server_init(sd_bus **_bus) {
goto fail;
}
- r = sd_bus_get_peer(bus, &id);
+ r = sd_bus_get_server_id(bus, &id);
if (r < 0) {
- log_error("Failed to get peer ID: %s", strerror(-r));
+ log_error("Failed to get server ID: %s", strerror(-r));
goto fail;
}
commit 52f3ba915bdce4d7476c3ea53b8371deff5f567d
Author: Lennart Poettering <lennart at poettering.net>
Date: Sun Mar 31 16:26:14 2013 +0200
bus: s/sd_message_handler_t/sd_bus_message_handler_t/g
diff --git a/src/libsystemd-bus/bus-internal.h b/src/libsystemd-bus/bus-internal.h
index 1dcb383..a11dc8c 100644
--- a/src/libsystemd-bus/bus-internal.h
+++ b/src/libsystemd-bus/bus-internal.h
@@ -35,7 +35,7 @@
#include "bus-match.h"
struct reply_callback {
- sd_message_handler_t callback;
+ sd_bus_message_handler_t callback;
void *userdata;
usec_t timeout;
uint64_t serial;
@@ -43,14 +43,14 @@ struct reply_callback {
};
struct filter_callback {
- sd_message_handler_t callback;
+ sd_bus_message_handler_t callback;
void *userdata;
LIST_FIELDS(struct filter_callback, callbacks);
};
struct object_callback {
- sd_message_handler_t callback;
+ sd_bus_message_handler_t callback;
void *userdata;
char *path;
diff --git a/src/libsystemd-bus/bus-match.c b/src/libsystemd-bus/bus-match.c
index ff1edfa..972ac8e 100644
--- a/src/libsystemd-bus/bus-match.c
+++ b/src/libsystemd-bus/bus-match.c
@@ -481,7 +481,7 @@ static int bus_match_find_compare_value(
static int bus_match_add_leaf(
struct bus_match_node *where,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata,
struct bus_match_node **ret) {
@@ -511,7 +511,7 @@ static int bus_match_add_leaf(
static int bus_match_find_leaf(
struct bus_match_node *where,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata,
struct bus_match_node **ret) {
@@ -778,7 +778,7 @@ fail:
int bus_match_add(
struct bus_match_node *root,
const char *match,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata,
struct bus_match_node **ret) {
@@ -819,7 +819,7 @@ finish:
int bus_match_remove(
struct bus_match_node *root,
const char *match,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata) {
struct match_component *components = NULL;
diff --git a/src/libsystemd-bus/bus-match.h b/src/libsystemd-bus/bus-match.h
index 0a63b55..a31c5d6 100644
--- a/src/libsystemd-bus/bus-match.h
+++ b/src/libsystemd-bus/bus-match.h
@@ -58,7 +58,7 @@ struct bus_match_node {
char *str;
} value;
struct {
- sd_message_handler_t callback;
+ sd_bus_message_handler_t callback;
void *userdata;
} leaf;
struct {
@@ -70,8 +70,8 @@ struct bus_match_node {
int bus_match_run(sd_bus *bus, struct bus_match_node *root, int ret, sd_bus_message *m);
-int bus_match_add(struct bus_match_node *root, const char *match, sd_message_handler_t callback, void *userdata, struct bus_match_node **ret);
-int bus_match_remove(struct bus_match_node *root, const char *match, sd_message_handler_t callback, void *userdata);
+int bus_match_add(struct bus_match_node *root, const char *match, sd_bus_message_handler_t callback, void *userdata, struct bus_match_node **ret);
+int bus_match_remove(struct bus_match_node *root, const char *match, sd_bus_message_handler_t callback, void *userdata);
void bus_match_free(struct bus_match_node *node);
diff --git a/src/libsystemd-bus/sd-bus.c b/src/libsystemd-bus/sd-bus.c
index 0a263ea..9b9281d 100644
--- a/src/libsystemd-bus/sd-bus.c
+++ b/src/libsystemd-bus/sd-bus.c
@@ -1117,7 +1117,7 @@ static int timeout_compare(const void *a, const void *b) {
int sd_bus_send_with_reply(
sd_bus *bus,
sd_bus_message *m,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata,
uint64_t usec,
uint64_t *serial) {
@@ -1946,7 +1946,7 @@ int sd_bus_flush(sd_bus *bus) {
}
}
-int sd_bus_add_filter(sd_bus *bus, sd_message_handler_t callback, void *userdata) {
+int sd_bus_add_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata) {
struct filter_callback *f;
if (!bus)
@@ -1964,7 +1964,7 @@ int sd_bus_add_filter(sd_bus *bus, sd_message_handler_t callback, void *userdata
return 0;
}
-int sd_bus_remove_filter(sd_bus *bus, sd_message_handler_t callback, void *userdata) {
+int sd_bus_remove_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata) {
struct filter_callback *f;
if (!bus)
@@ -1987,7 +1987,7 @@ static int bus_add_object(
sd_bus *bus,
bool fallback,
const char *path,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata) {
struct object_callback *c;
@@ -2032,7 +2032,7 @@ static int bus_remove_object(
sd_bus *bus,
bool fallback,
const char *path,
- sd_message_handler_t callback,
+ sd_bus_message_handler_t callback,
void *userdata) {
struct object_callback *c;
@@ -2059,23 +2059,23 @@ static int bus_remove_object(
return 1;
}
-int sd_bus_add_object(sd_bus *bus, const char *path, sd_message_handler_t callback, void *userdata) {
+int sd_bus_add_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata) {
return bus_add_object(bus, false, path, callback, userdata);
}
-int sd_bus_remove_object(sd_bus *bus, const char *path, sd_message_handler_t callback, void *userdata) {
+int sd_bus_remove_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata) {
return bus_remove_object(bus, false, path, callback, userdata);
}
-int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_message_handler_t callback, void *userdata) {
+int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata) {
return bus_add_object(bus, true, prefix, callback, userdata);
}
-int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_message_handler_t callback, void *userdata) {
+int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata) {
return bus_remove_object(bus, true, prefix, callback, userdata);
}
-int sd_bus_add_match(sd_bus *bus, const char *match, sd_message_handler_t callback, void *userdata) {
+int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata) {
int r = 0;
if (!bus)
@@ -2101,7 +2101,7 @@ int sd_bus_add_match(sd_bus *bus, const char *match, sd_message_handler_t callba
return r;
}
-int sd_bus_remove_match(sd_bus *bus, const char *match, sd_message_handler_t callback, void *userdata) {
+int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata) {
int r = 0, q = 0;
if (!bus)
diff --git a/src/libsystemd-bus/sd-bus.h b/src/libsystemd-bus/sd-bus.h
index e0970cd..413b7dc 100644
--- a/src/libsystemd-bus/sd-bus.h
+++ b/src/libsystemd-bus/sd-bus.h
@@ -33,9 +33,6 @@ extern "C" {
#endif
/* TODO:
- * - sd_message_handler_t needs to be renamed to sd_bus_message_handler_t
- *
- * Later:
* - add page donation logic
* - api for appending/reading fixed arrays
* - merge busctl into systemctl or so?
@@ -51,7 +48,7 @@ typedef struct {
int need_free;
} sd_bus_error;
-typedef int (*sd_message_handler_t)(sd_bus *bus, int ret, sd_bus_message *m, void *userdata);
+typedef int (*sd_bus_message_handler_t)(sd_bus *bus, int ret, sd_bus_message *m, void *userdata);
/* Connections */
@@ -78,7 +75,7 @@ int sd_bus_can_send(sd_bus *bus, char type);
int sd_bus_get_peer(sd_bus *bus, sd_id128_t *peer);
int sd_bus_send(sd_bus *bus, sd_bus_message *m, uint64_t *serial);
-int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
+int sd_bus_send_with_reply(sd_bus *bus, sd_bus_message *m, sd_bus_message_handler_t callback, void *userdata, uint64_t usec, uint64_t *serial);
int sd_bus_send_with_reply_cancel(sd_bus *bus, uint64_t serial);
int sd_bus_send_with_reply_and_block(sd_bus *bus, sd_bus_message *m, uint64_t usec, sd_bus_error *error, sd_bus_message **r);
@@ -89,17 +86,17 @@ int sd_bus_process(sd_bus *bus, sd_bus_message **r);
int sd_bus_wait(sd_bus *bus, uint64_t timeout_usec);
int sd_bus_flush(sd_bus *bus);
-int sd_bus_add_filter(sd_bus *bus, sd_message_handler_t callback, void *userdata);
-int sd_bus_remove_filter(sd_bus *bus, sd_message_handler_t callback, void *userdata);
+int sd_bus_add_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_filter(sd_bus *bus, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_add_object(sd_bus *bus, const char *path, sd_message_handler_t callback, void *userdata);
-int sd_bus_remove_object(sd_bus *bus, const char *path, sd_message_handler_t callback, void *userdata);
+int sd_bus_add_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_object(sd_bus *bus, const char *path, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_message_handler_t callback, void *userdata);
-int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_message_handler_t callback, void *userdata);
+int sd_bus_add_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_fallback(sd_bus *bus, const char *prefix, sd_bus_message_handler_t callback, void *userdata);
-int sd_bus_add_match(sd_bus *bus, const char *match, sd_message_handler_t callback, void *userdata);
-int sd_bus_remove_match(sd_bus *bus, const char *match, sd_message_handler_t callback, void *userdata);
+int sd_bus_add_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
+int sd_bus_remove_match(sd_bus *bus, const char *match, sd_bus_message_handler_t callback, void *userdata);
/* Message object */
More information about the systemd-commits
mailing list