From 623f13d8198b83df890f014b1d27255f4d78f35b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 03:00:49 -0400 Subject: wip --- src/libsystemd/Makefile | 4 +- .../include-staging/systemd-staging/sd-device.h | 101 ++ .../include-staging/systemd-staging/sd-hwdb.h | 49 + .../include-staging/systemd-staging/sd-netlink.h | 163 ++ .../include-staging/systemd-staging/sd-network.h | 176 +++ .../include-staging/systemd-staging/sd-resolve.h | 116 ++ src/libsystemd/include/systemd/sd-bus.h | 4 +- src/libsystemd/src/Makefile | 12 +- src/libsystemd/src/sd-bus/Makefile | 31 +- src/libsystemd/src/sd-bus/bus-bloom.c | 4 +- src/libsystemd/src/sd-bus/bus-container.c | 6 +- src/libsystemd/src/sd-bus/bus-control.c | 14 +- src/libsystemd/src/sd-bus/bus-convenience.c | 4 +- src/libsystemd/src/sd-bus/bus-creds.c | 34 +- src/libsystemd/src/sd-bus/bus-dump.c | 22 +- src/libsystemd/src/sd-bus/bus-error.c | 8 +- src/libsystemd/src/sd-bus/bus-error.h | 2 +- src/libsystemd/src/sd-bus/bus-gvariant.h | 2 +- src/libsystemd/src/sd-bus/bus-internal.c | 6 +- src/libsystemd/src/sd-bus/bus-internal.h | 12 +- src/libsystemd/src/sd-bus/bus-introspect.c | 8 +- src/libsystemd/src/sd-bus/bus-introspect.h | 2 +- src/libsystemd/src/sd-bus/bus-kernel.c | 28 +- src/libsystemd/src/sd-bus/bus-match.c | 14 +- src/libsystemd/src/sd-bus/bus-match.h | 2 +- src/libsystemd/src/sd-bus/bus-message.c | 20 +- src/libsystemd/src/sd-bus/bus-message.h | 4 +- src/libsystemd/src/sd-bus/bus-objects.c | 10 +- src/libsystemd/src/sd-bus/bus-protocol.h | 2 +- src/libsystemd/src/sd-bus/bus-signature.c | 2 +- src/libsystemd/src/sd-bus/bus-slot.c | 4 +- src/libsystemd/src/sd-bus/bus-socket.c | 26 +- src/libsystemd/src/sd-bus/bus-track.c | 4 +- src/libsystemd/src/sd-bus/bus-type.h | 2 +- src/libsystemd/src/sd-bus/bus-util.c | 1551 ++++++++++++++++++++ src/libsystemd/src/sd-bus/bus-util.h | 160 ++ src/libsystemd/src/sd-bus/sd-bus.c | 28 +- src/libsystemd/src/sd-bus/test-bus-benchmark.c | 12 +- src/libsystemd/src/sd-bus/test-bus-chat.c | 14 +- src/libsystemd/src/sd-bus/test-bus-cleanup.c | 4 +- src/libsystemd/src/sd-bus/test-bus-creds.c | 4 +- src/libsystemd/src/sd-bus/test-bus-error.c | 4 +- src/libsystemd/src/sd-bus/test-bus-gvariant.c | 8 +- src/libsystemd/src/sd-bus/test-bus-introspect.c | 2 +- src/libsystemd/src/sd-bus/test-bus-kernel-bloom.c | 10 +- src/libsystemd/src/sd-bus/test-bus-kernel.c | 10 +- src/libsystemd/src/sd-bus/test-bus-marshal.c | 14 +- src/libsystemd/src/sd-bus/test-bus-match.c | 6 +- src/libsystemd/src/sd-bus/test-bus-objects.c | 12 +- src/libsystemd/src/sd-bus/test-bus-server.c | 8 +- src/libsystemd/src/sd-bus/test-bus-signature.c | 4 +- src/libsystemd/src/sd-bus/test-bus-zero-copy.c | 12 +- src/libsystemd/src/sd-daemon/sd-daemon.c | 16 +- .../src/sd-device/device-enumerator-private.h | 2 +- src/libsystemd/src/sd-device/device-enumerator.c | 18 +- src/libsystemd/src/sd-device/device-internal.h | 7 +- src/libsystemd/src/sd-device/device-private.c | 36 +- src/libsystemd/src/sd-device/device-private.h | 2 +- src/libsystemd/src/sd-device/device-util.h | 2 +- src/libsystemd/src/sd-device/sd-device.c | 30 +- src/libsystemd/src/sd-device/sd-device.h | 101 -- src/libsystemd/src/sd-event/sd-event.c | 28 +- src/libsystemd/src/sd-event/test-event.c | 10 +- src/libsystemd/src/sd-hwdb/Makefile | 33 +- src/libsystemd/src/sd-hwdb/hwdb-internal.h | 4 +- src/libsystemd/src/sd-hwdb/hwdb-util.h | 5 +- src/libsystemd/src/sd-hwdb/sd-hwdb.c | 12 +- src/libsystemd/src/sd-hwdb/sd-hwdb.h | 49 - src/libsystemd/src/sd-id128/id128-util.c | 8 +- src/libsystemd/src/sd-id128/id128-util.h | 2 +- src/libsystemd/src/sd-id128/sd-id128.c | 12 +- src/libsystemd/src/sd-journal/Makefile | 11 +- src/libsystemd/src/sd-journal/audit-type.c | 4 +- src/libsystemd/src/sd-journal/audit-type.h | 2 +- src/libsystemd/src/sd-journal/catalog.c | 28 +- src/libsystemd/src/sd-journal/catalog.h | 4 +- src/libsystemd/src/sd-journal/compress.c | 16 +- src/libsystemd/src/sd-journal/fsprg.c | 3 +- src/libsystemd/src/sd-journal/fsprg.h | 4 +- src/libsystemd/src/sd-journal/gcrypt-util.c | 1 - src/libsystemd/src/sd-journal/gcrypt-util.h | 1 - .../src/sd-journal/journal-authenticate.c | 6 +- src/libsystemd/src/sd-journal/journal-def.h | 8 +- src/libsystemd/src/sd-journal/journal-file.c | 20 +- src/libsystemd/src/sd-journal/journal-file.h | 6 +- src/libsystemd/src/sd-journal/journal-internal.h | 6 +- src/libsystemd/src/sd-journal/journal-send.c | 18 +- src/libsystemd/src/sd-journal/journal-vacuum.c | 14 +- src/libsystemd/src/sd-journal/journal-vacuum.h | 2 +- src/libsystemd/src/sd-journal/journal-verify.c | 14 +- src/libsystemd/src/sd-journal/lookup3.h | 2 +- src/libsystemd/src/sd-journal/mmap-cache.c | 16 +- src/libsystemd/src/sd-journal/sd-journal.c | 34 +- src/libsystemd/src/sd-login/sd-login.c | 38 +- src/libsystemd/src/sd-login/test-login.c | 12 +- src/libsystemd/src/sd-netlink/local-addresses.c | 6 +- src/libsystemd/src/sd-netlink/local-addresses.h | 5 +- src/libsystemd/src/sd-netlink/netlink-internal.h | 8 +- src/libsystemd/src/sd-netlink/netlink-message.c | 14 +- src/libsystemd/src/sd-netlink/netlink-socket.c | 14 +- src/libsystemd/src/sd-netlink/netlink-types.c | 8 +- src/libsystemd/src/sd-netlink/netlink-types.h | 2 +- src/libsystemd/src/sd-netlink/netlink-util.c | 3 +- src/libsystemd/src/sd-netlink/netlink-util.h | 5 +- src/libsystemd/src/sd-netlink/rtnl-message.c | 12 +- src/libsystemd/src/sd-netlink/sd-netlink.c | 16 +- src/libsystemd/src/sd-netlink/sd-netlink.h | 163 -- .../src/sd-netlink/test-local-addresses.c | 6 +- src/libsystemd/src/sd-netlink/test-netlink.c | 14 +- src/libsystemd/src/sd-network/network-util.c | 6 +- src/libsystemd/src/sd-network/network-util.h | 2 +- src/libsystemd/src/sd-network/sd-network.c | 23 +- src/libsystemd/src/sd-network/sd-network.h | 176 --- src/libsystemd/src/sd-resolve/sd-resolve.c | 17 +- src/libsystemd/src/sd-resolve/sd-resolve.h | 116 -- src/libsystemd/src/sd-resolve/test-resolve.c | 11 +- src/libsystemd/src/subdir.mk | 5 +- src/libsystemd/src/test.mk | 2 +- 118 files changed, 2903 insertions(+), 1139 deletions(-) create mode 100644 src/libsystemd/include-staging/systemd-staging/sd-device.h create mode 100644 src/libsystemd/include-staging/systemd-staging/sd-hwdb.h create mode 100644 src/libsystemd/include-staging/systemd-staging/sd-netlink.h create mode 100644 src/libsystemd/include-staging/systemd-staging/sd-network.h create mode 100644 src/libsystemd/include-staging/systemd-staging/sd-resolve.h mode change 120000 => 100644 src/libsystemd/src/sd-bus/Makefile create mode 100644 src/libsystemd/src/sd-bus/bus-util.c create mode 100644 src/libsystemd/src/sd-bus/bus-util.h delete mode 100644 src/libsystemd/src/sd-device/sd-device.h mode change 120000 => 100644 src/libsystemd/src/sd-hwdb/Makefile delete mode 100644 src/libsystemd/src/sd-hwdb/sd-hwdb.h delete mode 120000 src/libsystemd/src/sd-journal/gcrypt-util.c delete mode 120000 src/libsystemd/src/sd-journal/gcrypt-util.h delete mode 100644 src/libsystemd/src/sd-netlink/sd-netlink.h delete mode 100644 src/libsystemd/src/sd-network/sd-network.h delete mode 100644 src/libsystemd/src/sd-resolve/sd-resolve.h (limited to 'src/libsystemd') diff --git a/src/libsystemd/Makefile b/src/libsystemd/Makefile index 7ee4688791..b8b8e01968 100644 --- a/src/libsystemd/Makefile +++ b/src/libsystemd/Makefile @@ -48,9 +48,7 @@ libsystemd_la_LDFLAGS = \ -Wl,--version-script=$(srcdir)/libsystemd.sym libsystemd_la_LIBADD = \ - libsystemd-internal.la \ - libbasic.la \ - libsystemd-journal-internal.la + libsystemd-internal.la libsystemd_la_LIBADD = $(libsystemd-internal.DEPENDS) diff --git a/src/libsystemd/include-staging/systemd-staging/sd-device.h b/src/libsystemd/include-staging/systemd-staging/sd-device.h new file mode 100644 index 0000000000..5e32fc6110 --- /dev/null +++ b/src/libsystemd/include-staging/systemd-staging/sd-device.h @@ -0,0 +1,101 @@ +#ifndef foosddevicehfoo +#define foosddevicehfoo + +/*** + This file is part of systemd. + + Copyright 2008-2012 Kay Sievers + Copyright 2014-2015 Tom Gundersen + + 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 . +***/ + +#include +#include +#include + +#include + +_SD_BEGIN_DECLARATIONS; + +typedef struct sd_device sd_device; +typedef struct sd_device_enumerator sd_device_enumerator; + +/* device */ + +sd_device *sd_device_ref(sd_device *device); +sd_device *sd_device_unref(sd_device *device); + +int sd_device_new_from_syspath(sd_device **ret, const char *syspath); +int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum); +int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname); +int sd_device_new_from_device_id(sd_device **ret, const char *id); + +int sd_device_get_parent(sd_device *child, sd_device **ret); +int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret); + +int sd_device_get_syspath(sd_device *device, const char **ret); +int sd_device_get_subsystem(sd_device *device, const char **ret); +int sd_device_get_devtype(sd_device *device, const char **ret); +int sd_device_get_devnum(sd_device *device, dev_t *devnum); +int sd_device_get_ifindex(sd_device *device, int *ifindex); +int sd_device_get_driver(sd_device *device, const char **ret); +int sd_device_get_devpath(sd_device *device, const char **ret); +int sd_device_get_devname(sd_device *device, const char **ret); +int sd_device_get_sysname(sd_device *device, const char **ret); +int sd_device_get_sysnum(sd_device *device, const char **ret); + +int sd_device_get_is_initialized(sd_device *device, int *initialized); +int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec); + +const char *sd_device_get_tag_first(sd_device *device); +const char *sd_device_get_tag_next(sd_device *device); +const char *sd_device_get_devlink_first(sd_device *device); +const char *sd_device_get_devlink_next(sd_device *device); +const char *sd_device_get_property_first(sd_device *device, const char **value); +const char *sd_device_get_property_next(sd_device *device, const char **value); +const char *sd_device_get_sysattr_first(sd_device *device); +const char *sd_device_get_sysattr_next(sd_device *device); + +int sd_device_has_tag(sd_device *device, const char *tag); +int sd_device_get_property_value(sd_device *device, const char *key, const char **value); +int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value); + +int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value); + +/* device enumerator */ + +int sd_device_enumerator_new(sd_device_enumerator **ret); +sd_device_enumerator *sd_device_enumerator_ref(sd_device_enumerator *enumerator); +sd_device_enumerator *sd_device_enumerator_unref(sd_device_enumerator *enumerator); + +sd_device *sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator); +sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator); +sd_device *sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator); +sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator); + +int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enumerator, const char *subsystem, int match); +int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match); +int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value); +int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname); +int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag); +int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent); +int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator); + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device, sd_device_unref); +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_enumerator, sd_device_enumerator_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libsystemd/include-staging/systemd-staging/sd-hwdb.h b/src/libsystemd/include-staging/systemd-staging/sd-hwdb.h new file mode 100644 index 0000000000..f46d7ad561 --- /dev/null +++ b/src/libsystemd/include-staging/systemd-staging/sd-hwdb.h @@ -0,0 +1,49 @@ +#ifndef foosdhwdbhfoo +#define foosdhwdbhfoo + +/*** + This file is part of systemd. + + Copyright 2008-2012 Kay Sievers + Copyright 2014 Tom Gundersen + + 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 . +***/ + +#include + +_SD_BEGIN_DECLARATIONS; + +typedef struct sd_hwdb sd_hwdb; + +sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb); +sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb); + +int sd_hwdb_new(sd_hwdb **ret); + +int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **value); + +int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias); +int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value); + +/* the inverse condition avoids ambiguity of dangling 'else' after the macro */ +#define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \ + if (sd_hwdb_seek(hwdb, modalias) < 0) { } \ + else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0) + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_hwdb, sd_hwdb_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libsystemd/include-staging/systemd-staging/sd-netlink.h b/src/libsystemd/include-staging/systemd-staging/sd-netlink.h new file mode 100644 index 0000000000..7db35e1756 --- /dev/null +++ b/src/libsystemd/include-staging/systemd-staging/sd-netlink.h @@ -0,0 +1,163 @@ +#ifndef foosdnetlinkhfoo +#define foosdnetlinkhfoo + +/*** + This file is part of systemd. + + Copyright 2013 Tom Gundersen + + 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 . +***/ + +#include +#include +#include + +#include +#include + +#include +#include + +_SD_BEGIN_DECLARATIONS; + +typedef struct sd_netlink sd_netlink; +typedef struct sd_netlink_message sd_netlink_message; + +/* callback */ + +typedef int (*sd_netlink_message_handler_t)(sd_netlink *nl, sd_netlink_message *m, void *userdata); + +/* bus */ +int sd_netlink_new_from_netlink(sd_netlink **nl, int fd); +int sd_netlink_open(sd_netlink **nl); +int sd_netlink_open_fd(sd_netlink **nl, int fd); +int sd_netlink_inc_rcvbuf(sd_netlink *nl, const size_t size); + +sd_netlink *sd_netlink_ref(sd_netlink *nl); +sd_netlink *sd_netlink_unref(sd_netlink *nl); + +int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial); +int sd_netlink_call_async(sd_netlink *nl, sd_netlink_message *message, + sd_netlink_message_handler_t callback, + void *userdata, uint64_t usec, uint32_t *serial); +int sd_netlink_call_async_cancel(sd_netlink *nl, uint32_t serial); +int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout, + sd_netlink_message **reply); + +int sd_netlink_get_events(sd_netlink *nl); +int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout); +int sd_netlink_process(sd_netlink *nl, sd_netlink_message **ret); +int sd_netlink_wait(sd_netlink *nl, uint64_t timeout); + +int sd_netlink_add_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata); +int sd_netlink_remove_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata); + +int sd_netlink_attach_event(sd_netlink *nl, sd_event *e, int64_t priority); +int sd_netlink_detach_event(sd_netlink *nl); + +int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data); +int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type); +int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data); +int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data); +int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, uint32_t data); +int sd_netlink_message_append_data(sd_netlink_message *m, unsigned short type, const void *data, size_t len); +int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data); +int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data); +int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data); +int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info); + +int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type); +int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned short type, const char *key); +int sd_netlink_message_close_container(sd_netlink_message *m); + +int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data); +int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data); +int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data); +int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data); +int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short type, struct ether_addr *data); +int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short type, struct ifa_cacheinfo *info); +int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type, struct in_addr *data); +int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type, struct in6_addr *data); +int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short type); +int sd_netlink_message_exit_container(sd_netlink_message *m); + +int sd_netlink_message_rewind(sd_netlink_message *m); + +sd_netlink_message *sd_netlink_message_next(sd_netlink_message *m); + +sd_netlink_message *sd_netlink_message_ref(sd_netlink_message *m); +sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m); + +int sd_netlink_message_request_dump(sd_netlink_message *m, int dump); +int sd_netlink_message_is_error(sd_netlink_message *m); +int sd_netlink_message_get_errno(sd_netlink_message *m); +int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type); +int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags); +int sd_netlink_message_is_broadcast(sd_netlink_message *m); + +/* rtnl */ + +int sd_rtnl_message_new_link(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index); +int sd_rtnl_message_new_addr_update(sd_netlink *nl, sd_netlink_message **ret, int index, int family); +int sd_rtnl_message_new_addr(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int family); +int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int rtm_family, unsigned char rtm_protocol); +int sd_rtnl_message_new_neigh(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int nda_family); + +int sd_rtnl_message_get_family(sd_netlink_message *m, int *family); + +int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen); +int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope); +int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags); +int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family); +int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen); +int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope); +int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags); +int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex); + +int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change); +int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type); +int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family); +int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex); +int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags); +int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type); + +int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen); +int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen); +int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope); +int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags); +int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table); +int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags); +int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family); +int sd_rtnl_message_route_set_family(sd_netlink_message *m, int family); +int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol); +int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope); +int sd_rtnl_message_route_get_tos(sd_netlink_message *m, unsigned char *tos); +int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table); +int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len); +int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len); + +int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags); +int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state); +int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family); +int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *family); +int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state); +int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags); + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink, sd_netlink_unref); +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink_message, sd_netlink_message_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libsystemd/include-staging/systemd-staging/sd-network.h b/src/libsystemd/include-staging/systemd-staging/sd-network.h new file mode 100644 index 0000000000..ac2660de45 --- /dev/null +++ b/src/libsystemd/include-staging/systemd-staging/sd-network.h @@ -0,0 +1,176 @@ +#ifndef foosdnetworkhfoo +#define foosdnetworkhfoo + +/*** + This file is part of systemd. + + Copyright 2011 Lennart Poettering + Copyright 2014 Tom Gundersen + + 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 . +***/ + +#include +#include + +#include + +/* + * A few points: + * + * Instead of returning an empty string array or empty integer array, we + * may return NULL. + * + * Free the data the library returns with libc free(). String arrays + * are NULL terminated, and you need to free the array itself in + * addition to the strings contained. + * + * We return error codes as negative errno, kernel-style. On success, we + * return 0 or positive. + * + * These functions access data in /run. This is a virtual file system; + * therefore, accesses are relatively cheap. + * + * See sd-network(3) for more information. + */ + +_SD_BEGIN_DECLARATIONS; + +/* Get overall operational state + * Possible states: down, up, dormant, carrier, degraded, routable + * Possible return codes: + * -ENODATA: networkd is not aware of any links + */ +int sd_network_get_operational_state(char **state); + +/* Get DNS entries for all links. These are string representations of + * IP addresses */ +int sd_network_get_dns(char ***dns); + +/* Get NTP entries for all links. These are domain names or string + * representations of IP addresses */ +int sd_network_get_ntp(char ***ntp); + +/* Get the search domains for all links. */ +int sd_network_get_search_domains(char ***domains); + +/* Get the search domains for all links. */ +int sd_network_get_route_domains(char ***domains); + +/* Get setup state from ifindex. + * Possible states: + * pending: udev is still processing the link, we don't yet know if we will manage it + * failed: networkd failed to manage the link + * configuring: in the process of retrieving configuration or configuring the link + * configured: link configured successfully + * unmanaged: networkd is not handling the link + * linger: the link is gone, but has not yet been dropped by networkd + * Possible return codes: + * -ENODATA: networkd is not aware of the link + */ +int sd_network_link_get_setup_state(int ifindex, char **state); + +/* Get operational state from ifindex. + * Possible states: + * off: the device is powered down + * no-carrier: the device is powered up, but it does not yet have a carrier + * dormant: the device has a carrier, but is not yet ready for normal traffic + * carrier: the link has a carrier + * degraded: the link has carrier and addresses valid on the local link configured + * routable: the link has carrier and routable address configured + * Possible return codes: + * -ENODATA: networkd is not aware of the link + */ +int sd_network_link_get_operational_state(int ifindex, char **state); + +/* Get path to .network file applied to link */ +int sd_network_link_get_network_file(int ifindex, char **filename); + +/* Get DNS entries for a given link. These are string representations of + * IP addresses */ +int sd_network_link_get_dns(int ifindex, char ***ret); + +/* Get NTP entries for a given link. These are domain names or string + * representations of IP addresses */ +int sd_network_link_get_ntp(int ifindex, char ***ret); + +/* Indicates whether or not LLMNR should be enabled for the link + * Possible levels of support: yes, no, resolve + * Possible return codes: + * -ENODATA: networkd is not aware of the link + */ +int sd_network_link_get_llmnr(int ifindex, char **llmnr); + +/* Indicates whether or not MulticastDNS should be enabled for the + * link. + * Possible levels of support: yes, no, resolve + * Possible return codes: + * -ENODATA: networkd is not aware of the link + */ +int sd_network_link_get_mdns(int ifindex, char **mdns); + +/* Indicates whether or not DNSSEC should be enabled for the link + * Possible levels of support: yes, no, allow-downgrade + * Possible return codes: + * -ENODATA: networkd is not aware of the link + */ +int sd_network_link_get_dnssec(int ifindex, char **dnssec); + +/* Returns the list of per-interface DNSSEC negative trust anchors + * Possible return codes: + * -ENODATA: networkd is not aware of the link, or has no such data + */ +int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta); + +/* Get the search DNS domain names for a given link. */ +int sd_network_link_get_search_domains(int ifindex, char ***domains); + +/* Get the route DNS domain names for a given link. */ +int sd_network_link_get_route_domains(int ifindex, char ***domains); + +/* Get the carrier interface indexes to which current link is bound to. */ +int sd_network_link_get_carrier_bound_to(int ifindex, int **ifindexes); + +/* Get the CARRIERS that are bound to current link. */ +int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes); + +/* Get the timezone that was learnt on a specific link. */ +int sd_network_link_get_timezone(int ifindex, char **timezone); + +/* Monitor object */ +typedef struct sd_network_monitor sd_network_monitor; + +/* Create a new monitor. Category must be NULL, "links" or "leases". */ +int sd_network_monitor_new(sd_network_monitor **ret, const char *category); + +/* Destroys the passed monitor. Returns NULL. */ +sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m); + +/* Flushes the monitor */ +int sd_network_monitor_flush(sd_network_monitor *m); + +/* Get FD from monitor */ +int sd_network_monitor_get_fd(sd_network_monitor *m); + +/* Get poll() mask to monitor */ +int sd_network_monitor_get_events(sd_network_monitor *m); + +/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */ +int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec); + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor, sd_network_monitor_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libsystemd/include-staging/systemd-staging/sd-resolve.h b/src/libsystemd/include-staging/systemd-staging/sd-resolve.h new file mode 100644 index 0000000000..1996ae401a --- /dev/null +++ b/src/libsystemd/include-staging/systemd-staging/sd-resolve.h @@ -0,0 +1,116 @@ +#ifndef foosdresolvehfoo +#define foosdresolvehfoo + +/*** + This file is part of systemd. + + Copyright 2005-2014 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 . +***/ + +#include +#include +#include +#include + +#include +#include + +_SD_BEGIN_DECLARATIONS; + +/* An opaque sd-resolve session structure */ +typedef struct sd_resolve sd_resolve; + +/* An opaque sd-resolve query structure */ +typedef struct sd_resolve_query sd_resolve_query; + +/* A callback on completion */ +typedef int (*sd_resolve_getaddrinfo_handler_t)(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata); +typedef int (*sd_resolve_getnameinfo_handler_t)(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata); + +enum { + SD_RESOLVE_GET_HOST = UINT64_C(1), + SD_RESOLVE_GET_SERVICE = UINT64_C(2), + SD_RESOLVE_GET_BOTH = UINT64_C(3), +}; + +int sd_resolve_default(sd_resolve **ret); + +/* Allocate a new sd-resolve session. */ +int sd_resolve_new(sd_resolve **ret); + +/* Free a sd-resolve session. This destroys all attached + * sd_resolve_query objects automatically. */ +sd_resolve* sd_resolve_unref(sd_resolve *resolve); +sd_resolve* sd_resolve_ref(sd_resolve *resolve); + +/* Return the UNIX file descriptor to poll() for events on. Use this + * function to integrate sd-resolve with your custom main loop. */ +int sd_resolve_get_fd(sd_resolve *resolve); + +/* Return the poll() events (a combination of flags like POLLIN, + * POLLOUT, ...) to check for. */ +int sd_resolve_get_events(sd_resolve *resolve); + +/* Return the poll() timeout to pass. Returns (uint64_t) -1 as + * timeout if no timeout is needed. */ +int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *timeout_usec); + +/* Process pending responses. After this function is called, you can + * get the next completed query object(s) using + * sd_resolve_get_next(). */ +int sd_resolve_process(sd_resolve *resolve); + +/* Wait for a resolve event to complete. */ +int sd_resolve_wait(sd_resolve *resolve, uint64_t timeout_usec); + +int sd_resolve_get_tid(sd_resolve *resolve, pid_t *tid); + +int sd_resolve_attach_event(sd_resolve *resolve, sd_event *e, int64_t priority); +int sd_resolve_detach_event(sd_resolve *resolve); +sd_event *sd_resolve_get_event(sd_resolve *resolve); + +/* Issue a name-to-address query on the specified session. The + * arguments are compatible with those of libc's + * getaddrinfo(3). The function returns a new query object. When the + * query is completed, you may retrieve the results using + * sd_resolve_getaddrinfo_done(). */ +int sd_resolve_getaddrinfo(sd_resolve *resolve, sd_resolve_query **q, const char *node, const char *service, const struct addrinfo *hints, sd_resolve_getaddrinfo_handler_t callback, void *userdata); + +/* Issue an address-to-name query on the specified session. The + * arguments are compatible with those of libc's + * getnameinfo(3). The function returns a new query object. When the + * query is completed, you may retrieve the results using + * sd_resolve_getnameinfo_done(). Set gethost (resp. getserv) to non-zero + * if you want to query the hostname (resp. the service name). */ +int sd_resolve_getnameinfo(sd_resolve *resolve, sd_resolve_query **q, const struct sockaddr *sa, socklen_t salen, int flags, uint64_t get, sd_resolve_getnameinfo_handler_t callback, void *userdata); + +sd_resolve_query *sd_resolve_query_ref(sd_resolve_query* q); +sd_resolve_query *sd_resolve_query_unref(sd_resolve_query* q); + +/* Returns non-zero when the query operation specified by q has been completed. */ +int sd_resolve_query_is_done(sd_resolve_query*q); + +void *sd_resolve_query_get_userdata(sd_resolve_query *q); +void *sd_resolve_query_set_userdata(sd_resolve_query *q, void *userdata); + +sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q); + +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_resolve, sd_resolve_unref); +_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_resolve_query, sd_resolve_query_unref); + +_SD_END_DECLARATIONS; + +#endif diff --git a/src/libsystemd/include/systemd/sd-bus.h b/src/libsystemd/include/systemd/sd-bus.h index 779c4b07d3..4e338a3270 100644 --- a/src/libsystemd/include/systemd/sd-bus.h +++ b/src/libsystemd/include/systemd/sd-bus.h @@ -100,10 +100,10 @@ enum { /* Callbacks */ typedef int (*sd_bus_message_handler_t)(sd_bus_message *m, void *userdata, sd_bus_error *ret_error); +typedef int (*sd_bus_node_enumerator_t) (sd_bus *bus, const char *prefix, void *userdata, char ***ret_nodes, sd_bus_error *ret_error); +typedef int (*sd_bus_object_find_t) (sd_bus *bus, const char *path, const char *interface, void *userdata, void **ret_found, sd_bus_error *ret_error); typedef int (*sd_bus_property_get_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *ret_error); typedef int (*sd_bus_property_set_t) (sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *value, void *userdata, sd_bus_error *ret_error); -typedef int (*sd_bus_object_find_t) (sd_bus *bus, const char *path, const char *interface, void *userdata, void **ret_found, sd_bus_error *ret_error); -typedef int (*sd_bus_node_enumerator_t) (sd_bus *bus, const char *prefix, void *userdata, char ***ret_nodes, sd_bus_error *ret_error); typedef int (*sd_bus_track_handler_t) (sd_bus_track *track, void *userdata); #include "sd-bus-protocol.h" diff --git a/src/libsystemd/src/Makefile b/src/libsystemd/src/Makefile index 4554061f93..5907b378a4 100644 --- a/src/libsystemd/src/Makefile +++ b/src/libsystemd/src/Makefile @@ -79,6 +79,8 @@ _libsystemd_internal_la_SOURCES = \ src/libsystemd/sd-bus/kdbus.h \ src/libsystemd/sd-bus/bus-dump.c \ src/libsystemd/sd-bus/bus-dump.h \ + src/libsystemd/sd-bus/bus-util.c \ + src/libsystemd/sd-bus/bus-util.h \ src/libsystemd/sd-event/sd-event.c \ src/libsystemd/sd-netlink/sd-netlink.c \ src/libsystemd/sd-netlink/netlink-internal.h \ @@ -114,7 +116,7 @@ _libsystemd_internal_la_SOURCES = \ libsystemd_internal_la_LIBADD = \ -lresolv -noinst_LTLIBRARIES += \ +rootlibexec_LTLIBRARIES += \ libsystemd-internal.la _libsystemd_journal_internal_la_SOURCES = \ @@ -138,9 +140,7 @@ _libsystemd_journal_internal_la_SOURCES = \ src/journal/mmap-cache.h \ src/journal/compress.c \ src/journal/audit-type.h \ - src/journal/audit-type.c \ - src/shared/gcrypt-util.h \ - src/shared/gcrypt-util.c + src/journal/audit-type.c #nodist_libsystemd_journal_internal_la_SOURCES = \ src/journal/audit_type-to-name.h @@ -199,6 +199,10 @@ sd.libsystemd_SOURCES += $(patsubst src/libsystemd/%,%,$(filter %.c,$(_libsystem sd.libsystemd_SOURCES += $(addprefix sd-journal/,$(notdir $(filter %.c,$(_libsystemd_journal_internal_la_SOURCES)))) $(outdir)/libsystemd-internal.la: $(addprefix $(outdir)/,$(sd.libsystemd_SOURCES:.c=.lo)) +libsystemd_internal_la_LIBADD += \ + libsystemd-basic.la \ + libsystemd-gcrypt.la + nested.subdirs += sd-bus nested.subdirs += sd-daemon nested.subdirs += sd-device diff --git a/src/libsystemd/src/sd-bus/Makefile b/src/libsystemd/src/sd-bus/Makefile deleted file mode 120000 index 71a1159ce0..0000000000 --- a/src/libsystemd/src/sd-bus/Makefile +++ /dev/null @@ -1 +0,0 @@ -../subdir.mk \ No newline at end of file diff --git a/src/libsystemd/src/sd-bus/Makefile b/src/libsystemd/src/sd-bus/Makefile new file mode 100644 index 0000000000..a483e31fd1 --- /dev/null +++ b/src/libsystemd/src/sd-bus/Makefile @@ -0,0 +1,30 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- +# +# This file is part of systemd. +# +# Copyright 2010-2012 Lennart Poettering +# Copyright 2010-2012 Kay Sievers +# Copyright 2013 Zbigniew Jędrzejewski-Szmek +# Copyright 2013 David Strauss +# Copyright 2016 Luke Shumaker +# +# 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 . + +include $(dir $(lastword $(MAKEFILE_LIST)))/../../../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +sd.CPPFLAGS += $(libsystemd.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-basic.CPPFLAGS) + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/libsystemd/src/sd-bus/bus-bloom.c b/src/libsystemd/src/sd-bus/bus-bloom.c index 9327fb40c7..7441c1a7aa 100644 --- a/src/libsystemd/src/sd-bus/bus-bloom.c +++ b/src/libsystemd/src/sd-bus/bus-bloom.c @@ -17,8 +17,8 @@ along with systemd; If not, see . ***/ -#include "basic/siphash24.h" -#include "basic/util.h" +#include "systemd-basic/siphash24.h" +#include "systemd-basic/util.h" #include "bus-bloom.h" diff --git a/src/libsystemd/src/sd-bus/bus-container.c b/src/libsystemd/src/sd-bus/bus-container.c index 43b9d03aa9..2f91ffc8dd 100644 --- a/src/libsystemd/src/sd-bus/bus-container.c +++ b/src/libsystemd/src/sd-bus/bus-container.c @@ -20,9 +20,9 @@ #include #include -#include "basic/fd-util.h" -#include "basic/process-util.h" -#include "basic/util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/process-util.h" +#include "systemd-basic/util.h" #include "bus-container.h" #include "bus-internal.h" diff --git a/src/libsystemd/src/sd-bus/bus-control.c b/src/libsystemd/src/sd-bus/bus-control.c index 689b70bc60..606cdc44ba 100644 --- a/src/libsystemd/src/sd-bus/bus-control.c +++ b/src/libsystemd/src/sd-bus/bus-control.c @@ -26,18 +26,18 @@ #include -#include "basic/alloc-util.h" -#include "basic/capability-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/user-util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/capability-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/user-util.h" #include "bus-bloom.h" #include "bus-control.h" #include "bus-internal.h" #include "bus-message.h" +#include "bus-util.h" _public_ int sd_bus_get_unique_name(sd_bus *bus, const char **unique) { int r; diff --git a/src/libsystemd/src/sd-bus/bus-convenience.c b/src/libsystemd/src/sd-bus/bus-convenience.c index f76cbaf3d3..e6a92679cf 100644 --- a/src/libsystemd/src/sd-bus/bus-convenience.c +++ b/src/libsystemd/src/sd-bus/bus-convenience.c @@ -17,13 +17,13 @@ along with systemd; If not, see . ***/ -#include "basic/string-util.h" -#include "shared/bus-util.h" +#include "systemd-basic/string-util.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-signature.h" #include "bus-type.h" +#include "bus-util.h" _public_ int sd_bus_emit_signal( sd_bus *bus, diff --git a/src/libsystemd/src/sd-bus/bus-creds.c b/src/libsystemd/src/sd-bus/bus-creds.c index bc5a82fac4..3b4ebe9ee0 100644 --- a/src/libsystemd/src/sd-bus/bus-creds.c +++ b/src/libsystemd/src/sd-bus/bus-creds.c @@ -21,26 +21,26 @@ #include -#include "basic/alloc-util.h" -#include "basic/audit-util.h" -#include "basic/bus-label.h" -#include "basic/capability-util.h" -#include "basic/cgroup-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/formats-util.h" -#include "basic/hexdecoct.h" -#include "basic/parse-util.h" -#include "basic/process-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/terminal-util.h" -#include "basic/user-util.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/audit-util.h" +#include "systemd-basic/bus-label.h" +#include "systemd-basic/capability-util.h" +#include "systemd-basic/cgroup-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/process-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/terminal-util.h" +#include "systemd-basic/user-util.h" +#include "systemd-basic/util.h" #include "bus-creds.h" #include "bus-message.h" +#include "bus-util.h" enum { CAP_OFFSET_INHERITABLE = 0, diff --git a/src/libsystemd/src/sd-bus/bus-dump.c b/src/libsystemd/src/sd-bus/bus-dump.c index cec53d75e5..447aa5d9d7 100644 --- a/src/libsystemd/src/sd-bus/bus-dump.c +++ b/src/libsystemd/src/sd-bus/bus-dump.c @@ -17,17 +17,17 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/cap-list.h" -#include "basic/capability-util.h" -#include "basic/fileio.h" -#include "basic/formats-util.h" -#include "basic/locale-util.h" -#include "basic/macro.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/terminal-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/cap-list.h" +#include "systemd-basic/capability-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/locale-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/terminal-util.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-internal.h" diff --git a/src/libsystemd/src/sd-bus/bus-error.c b/src/libsystemd/src/sd-bus/bus-error.c index 616d784590..d6b45c47bc 100644 --- a/src/libsystemd/src/sd-bus/bus-error.c +++ b/src/libsystemd/src/sd-bus/bus-error.c @@ -26,10 +26,10 @@ #include -#include "basic/alloc-util.h" -#include "basic/errno-list.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/errno-list.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" #include "bus-error.h" diff --git a/src/libsystemd/src/sd-bus/bus-error.h b/src/libsystemd/src/sd-bus/bus-error.h index 0693d9c68c..308cf92f24 100644 --- a/src/libsystemd/src/sd-bus/bus-error.h +++ b/src/libsystemd/src/sd-bus/bus-error.h @@ -23,7 +23,7 @@ #include -#include "basic/macro.h" +#include "systemd-basic/macro.h" bool bus_error_is_dirty(sd_bus_error *e); diff --git a/src/libsystemd/src/sd-bus/bus-gvariant.h b/src/libsystemd/src/sd-bus/bus-gvariant.h index d9468ee9a8..45afe01631 100644 --- a/src/libsystemd/src/sd-bus/bus-gvariant.h +++ b/src/libsystemd/src/sd-bus/bus-gvariant.h @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ -#include "basic/macro.h" +#include "systemd-basic/macro.h" int bus_gvariant_get_size(const char *signature) _pure_; int bus_gvariant_get_alignment(const char *signature) _pure_; diff --git a/src/libsystemd/src/sd-bus/bus-internal.c b/src/libsystemd/src/sd-bus/bus-internal.c index 8dc441227a..bd63e453e4 100644 --- a/src/libsystemd/src/sd-bus/bus-internal.c +++ b/src/libsystemd/src/sd-bus/bus-internal.c @@ -17,9 +17,9 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/hexdecoct.h" -#include "basic/string-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/string-util.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/libsystemd/src/sd-bus/bus-internal.h b/src/libsystemd/src/sd-bus/bus-internal.h index e02df7981d..6e74da3283 100644 --- a/src/libsystemd/src/sd-bus/bus-internal.h +++ b/src/libsystemd/src/sd-bus/bus-internal.h @@ -24,12 +24,12 @@ #include -#include "basic/hashmap.h" -#include "basic/list.h" -#include "basic/prioq.h" -#include "basic/refcnt.h" -#include "basic/socket-util.h" -#include "basic/util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/list.h" +#include "systemd-basic/prioq.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" #include "bus-error.h" #include "bus-kernel.h" diff --git a/src/libsystemd/src/sd-bus/bus-introspect.c b/src/libsystemd/src/sd-bus/bus-introspect.c index 835b5e3909..85400c865f 100644 --- a/src/libsystemd/src/sd-bus/bus-introspect.c +++ b/src/libsystemd/src/sd-bus/bus-introspect.c @@ -17,10 +17,10 @@ along with systemd; If not, see . ***/ -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" #include "bus-internal.h" #include "bus-introspect.h" diff --git a/src/libsystemd/src/sd-bus/bus-introspect.h b/src/libsystemd/src/sd-bus/bus-introspect.h index af4ae10682..4a83e2aa38 100644 --- a/src/libsystemd/src/sd-bus/bus-introspect.h +++ b/src/libsystemd/src/sd-bus/bus-introspect.h @@ -23,7 +23,7 @@ #include -#include "basic/set.h" +#include "systemd-basic/set.h" struct introspect { FILE *f; diff --git a/src/libsystemd/src/sd-bus/bus-kernel.c b/src/libsystemd/src/sd-bus/bus-kernel.c index 9d767340b6..3321a54a51 100644 --- a/src/libsystemd/src/sd-bus/bus-kernel.c +++ b/src/libsystemd/src/sd-bus/bus-kernel.c @@ -32,25 +32,25 @@ #include #undef basename -#include "basic/alloc-util.h" -#include "basic/bus-label.h" -#include "basic/capability-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/formats-util.h" -#include "basic/memfd-util.h" -#include "basic/parse-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/user-util.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/bus-label.h" +#include "systemd-basic/capability-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/memfd-util.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/user-util.h" +#include "systemd-basic/util.h" #include "bus-bloom.h" #include "bus-internal.h" #include "bus-kernel.h" #include "bus-message.h" +#include "bus-util.h" #define UNIQUE_NAME_MAX (3+DECIMAL_STR_MAX(uint64_t)) diff --git a/src/libsystemd/src/sd-bus/bus-match.c b/src/libsystemd/src/sd-bus/bus-match.c index 185867679e..37a391b46a 100644 --- a/src/libsystemd/src/sd-bus/bus-match.c +++ b/src/libsystemd/src/sd-bus/bus-match.c @@ -17,17 +17,17 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/hexdecoct.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" #include "bus-internal.h" #include "bus-match.h" #include "bus-message.h" +#include "bus-util.h" /* Example: * diff --git a/src/libsystemd/src/sd-bus/bus-match.h b/src/libsystemd/src/sd-bus/bus-match.h index a85abcb377..54b40d5be8 100644 --- a/src/libsystemd/src/sd-bus/bus-match.h +++ b/src/libsystemd/src/sd-bus/bus-match.h @@ -21,7 +21,7 @@ #include -#include "basic/hashmap.h" +#include "systemd-basic/hashmap.h" enum bus_match_node_type { BUS_MATCH_ROOT, diff --git a/src/libsystemd/src/sd-bus/bus-message.c b/src/libsystemd/src/sd-bus/bus-message.c index 7fa5e822e0..181f6bccb2 100644 --- a/src/libsystemd/src/sd-bus/bus-message.c +++ b/src/libsystemd/src/sd-bus/bus-message.c @@ -23,22 +23,22 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/io-util.h" -#include "basic/memfd-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/time-util.h" -#include "basic/utf8.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/memfd-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/time-util.h" +#include "systemd-basic/utf8.h" +#include "systemd-basic/util.h" #include "bus-gvariant.h" #include "bus-internal.h" #include "bus-message.h" #include "bus-signature.h" #include "bus-type.h" +#include "bus-util.h" static int message_append_basic(sd_bus_message *m, char type, const void *p, const void **stored); diff --git a/src/libsystemd/src/sd-bus/bus-message.h b/src/libsystemd/src/sd-bus/bus-message.h index 35116c3803..93bbb9b00d 100644 --- a/src/libsystemd/src/sd-bus/bus-message.h +++ b/src/libsystemd/src/sd-bus/bus-message.h @@ -25,8 +25,8 @@ #include -#include "basic/macro.h" -#include "basic/time-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/time-util.h" #include "bus-creds.h" #include "bus-protocol.h" diff --git a/src/libsystemd/src/sd-bus/bus-objects.c b/src/libsystemd/src/sd-bus/bus-objects.c index a56b7e8d7e..a732a0a928 100644 --- a/src/libsystemd/src/sd-bus/bus-objects.c +++ b/src/libsystemd/src/sd-bus/bus-objects.c @@ -17,11 +17,10 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/set.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/set.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" #include "bus-internal.h" #include "bus-introspect.h" @@ -30,6 +29,7 @@ #include "bus-signature.h" #include "bus-slot.h" #include "bus-type.h" +#include "bus-util.h" static int node_vtable_get_userdata( sd_bus *bus, diff --git a/src/libsystemd/src/sd-bus/bus-protocol.h b/src/libsystemd/src/sd-bus/bus-protocol.h index 931dc21c46..732b512d3f 100644 --- a/src/libsystemd/src/sd-bus/bus-protocol.h +++ b/src/libsystemd/src/sd-bus/bus-protocol.h @@ -21,7 +21,7 @@ #include -#include "basic/macro.h" +#include "systemd-basic/macro.h" /* Packet header */ diff --git a/src/libsystemd/src/sd-bus/bus-signature.c b/src/libsystemd/src/sd-bus/bus-signature.c index c11b113186..4e7cf02ec1 100644 --- a/src/libsystemd/src/sd-bus/bus-signature.c +++ b/src/libsystemd/src/sd-bus/bus-signature.c @@ -17,7 +17,7 @@ along with systemd; If not, see . ***/ -#include "basic/util.h" +#include "systemd-basic/util.h" #include "bus-signature.h" #include "bus-type.h" diff --git a/src/libsystemd/src/sd-bus/bus-slot.c b/src/libsystemd/src/sd-bus/bus-slot.c index ebac784433..ffe992013a 100644 --- a/src/libsystemd/src/sd-bus/bus-slot.c +++ b/src/libsystemd/src/sd-bus/bus-slot.c @@ -19,8 +19,8 @@ #include -#include "basic/alloc-util.h" -#include "basic/string-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/string-util.h" #include "bus-control.h" #include "bus-objects.h" diff --git a/src/libsystemd/src/sd-bus/bus-socket.c b/src/libsystemd/src/sd-bus/bus-socket.c index b5fd60cf24..9beb7dffb3 100644 --- a/src/libsystemd/src/sd-bus/bus-socket.c +++ b/src/libsystemd/src/sd-bus/bus-socket.c @@ -25,19 +25,19 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/formats-util.h" -#include "basic/hexdecoct.h" -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/selinux-util.h" -#include "basic/signal-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/user-util.h" -#include "basic/utf8.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/selinux-util.h" +#include "systemd-basic/signal-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/user-util.h" +#include "systemd-basic/utf8.h" +#include "systemd-basic/util.h" #include "bus-internal.h" #include "bus-message.h" diff --git a/src/libsystemd/src/sd-bus/bus-track.c b/src/libsystemd/src/sd-bus/bus-track.c index 24c3a7050d..86b321bdea 100644 --- a/src/libsystemd/src/sd-bus/bus-track.c +++ b/src/libsystemd/src/sd-bus/bus-track.c @@ -19,11 +19,11 @@ #include -#include "basic/alloc-util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" #include "bus-internal.h" #include "bus-track.h" +#include "bus-util.h" struct sd_bus_track { unsigned n_ref; diff --git a/src/libsystemd/src/sd-bus/bus-type.h b/src/libsystemd/src/sd-bus/bus-type.h index d81aa20df3..a9cfa6ef36 100644 --- a/src/libsystemd/src/sd-bus/bus-type.h +++ b/src/libsystemd/src/sd-bus/bus-type.h @@ -23,7 +23,7 @@ #include -#include "basic/macro.h" +#include "systemd-basic/macro.h" bool bus_type_is_valid(char c) _const_; bool bus_type_is_valid_in_signature(char c) _const_; diff --git a/src/libsystemd/src/sd-bus/bus-util.c b/src/libsystemd/src/sd-bus/bus-util.c new file mode 100644 index 0000000000..c82390634e --- /dev/null +++ b/src/libsystemd/src/sd-bus/bus-util.c @@ -0,0 +1,1551 @@ +/*** + 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 . +***/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/bus-label.h" +#include "systemd-basic/def.h" +#include "systemd-basic/escape.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/proc-cmdline.h" +#include "systemd-basic/rlimit-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/user-util.h" + +#include "bus-internal.h" +#include "bus-message.h" +#include "bus-util.h" + +static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { + sd_event *e = userdata; + + assert(m); + assert(e); + + sd_bus_close(sd_bus_message_get_bus(m)); + sd_event_exit(e, 0); + + return 1; +} + +int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name) { + _cleanup_free_ char *match = NULL; + const char *unique; + int r; + + assert(e); + assert(bus); + assert(name); + + /* We unregister the name here and then wait for the + * NameOwnerChanged signal for this event to arrive before we + * quit. We do this in order to make sure that any queued + * requests are still processed before we really exit. */ + + r = sd_bus_get_unique_name(bus, &unique); + if (r < 0) + return r; + + r = asprintf(&match, + "sender='org.freedesktop.DBus'," + "type='signal'," + "interface='org.freedesktop.DBus'," + "member='NameOwnerChanged'," + "path='/org/freedesktop/DBus'," + "arg0='%s'," + "arg1='%s'," + "arg2=''", name, unique); + if (r < 0) + return -ENOMEM; + + r = sd_bus_add_match(bus, NULL, match, name_owner_change_callback, e); + if (r < 0) + return r; + + r = sd_bus_release_name(bus, name); + if (r < 0) + return r; + + return 0; +} + +int bus_event_loop_with_idle( + sd_event *e, + sd_bus *bus, + const char *name, + usec_t timeout, + check_idle_t check_idle, + void *userdata) { + bool exiting = false; + int r, code; + + assert(e); + assert(bus); + assert(name); + + for (;;) { + bool idle; + + r = sd_event_get_state(e); + if (r < 0) + return r; + if (r == SD_EVENT_FINISHED) + break; + + if (check_idle) + idle = check_idle(userdata); + else + idle = true; + + r = sd_event_run(e, exiting || !idle ? (uint64_t) -1 : timeout); + if (r < 0) + return r; + + if (r == 0 && !exiting && idle) { + + r = sd_bus_try_close(bus); + if (r == -EBUSY) + continue; + + /* Fallback for dbus1 connections: we + * unregister the name and wait for the + * response to come through for it */ + if (r == -EOPNOTSUPP) { + + /* Inform the service manager that we + * are going down, so that it will + * queue all further start requests, + * instead of assuming we are already + * running. */ + sd_notify(false, "STOPPING=1"); + + r = bus_async_unregister_and_exit(e, bus, name); + if (r < 0) + return r; + + exiting = true; + continue; + } + + if (r < 0) + return r; + + sd_event_exit(e, 0); + break; + } + } + + r = sd_event_get_exit_code(e, &code); + if (r < 0) + return r; + + return code; +} + +int bus_name_has_owner(sd_bus *c, const char *name, sd_bus_error *error) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *rep = NULL; + int r, has_owner = 0; + + assert(c); + assert(name); + + r = sd_bus_call_method(c, + "org.freedesktop.DBus", + "/org/freedesktop/dbus", + "org.freedesktop.DBus", + "NameHasOwner", + error, + &rep, + "s", + name); + if (r < 0) + return r; + + r = sd_bus_message_read_basic(rep, 'b', &has_owner); + if (r < 0) + return sd_bus_error_set_errno(error, r); + + return has_owner; +} + +static int check_good_user(sd_bus_message *m, uid_t good_user) { + _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; + uid_t sender_uid; + int r; + + assert(m); + + if (good_user == UID_INVALID) + return 0; + + r = sd_bus_query_sender_creds(m, SD_BUS_CREDS_EUID, &creds); + if (r < 0) + return r; + + /* Don't trust augmented credentials for authorization */ + assert_return((sd_bus_creds_get_augmented_mask(creds) & SD_BUS_CREDS_EUID) == 0, -EPERM); + + r = sd_bus_creds_get_euid(creds, &sender_uid); + if (r < 0) + return r; + + return sender_uid == good_user; +} + +int bus_test_polkit( + sd_bus_message *call, + int capability, + const char *action, + const char **details, + uid_t good_user, + bool *_challenge, + sd_bus_error *e) { + + int r; + + assert(call); + assert(action); + + /* Tests non-interactively! */ + + r = check_good_user(call, good_user); + if (r != 0) + return r; + + r = sd_bus_query_sender_privilege(call, capability); + if (r < 0) + return r; + else if (r > 0) + return 1; +#ifdef ENABLE_POLKIT + else { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *request = NULL; + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; + int authorized = false, challenge = false; + const char *sender, **k, **v; + + sender = sd_bus_message_get_sender(call); + if (!sender) + return -EBADMSG; + + r = sd_bus_message_new_method_call( + call->bus, + &request, + "org.freedesktop.PolicyKit1", + "/org/freedesktop/PolicyKit1/Authority", + "org.freedesktop.PolicyKit1.Authority", + "CheckAuthorization"); + if (r < 0) + return r; + + r = sd_bus_message_append( + request, + "(sa{sv})s", + "system-bus-name", 1, "name", "s", sender, + action); + if (r < 0) + return r; + + r = sd_bus_message_open_container(request, 'a', "{ss}"); + if (r < 0) + return r; + + STRV_FOREACH_PAIR(k, v, details) { + r = sd_bus_message_append(request, "{ss}", *k, *v); + if (r < 0) + return r; + } + + r = sd_bus_message_close_container(request); + if (r < 0) + return r; + + r = sd_bus_message_append(request, "us", 0, NULL); + if (r < 0) + return r; + + r = sd_bus_call(call->bus, request, 0, e, &reply); + if (r < 0) { + /* Treat no PK available as access denied */ + if (sd_bus_error_has_name(e, SD_BUS_ERROR_SERVICE_UNKNOWN)) { + sd_bus_error_free(e); + return -EACCES; + } + + return r; + } + + r = sd_bus_message_enter_container(reply, 'r', "bba{ss}"); + if (r < 0) + return r; + + r = sd_bus_message_read(reply, "bb", &authorized, &challenge); + if (r < 0) + return r; + + if (authorized) + return 1; + + if (_challenge) { + *_challenge = challenge; + return 0; + } + } +#endif + + return -EACCES; +} + +#ifdef ENABLE_POLKIT + +typedef struct AsyncPolkitQuery { + sd_bus_message *request, *reply; + sd_bus_message_handler_t callback; + void *userdata; + sd_bus_slot *slot; + Hashmap *registry; +} AsyncPolkitQuery; + +static void async_polkit_query_free(AsyncPolkitQuery *q) { + + if (!q) + return; + + sd_bus_slot_unref(q->slot); + + if (q->registry && q->request) + hashmap_remove(q->registry, q->request); + + sd_bus_message_unref(q->request); + sd_bus_message_unref(q->reply); + + free(q); +} + +static int async_polkit_callback(sd_bus_message *reply, void *userdata, sd_bus_error *error) { + _cleanup_(sd_bus_error_free) sd_bus_error error_buffer = SD_BUS_ERROR_NULL; + AsyncPolkitQuery *q = userdata; + int r; + + assert(reply); + assert(q); + + q->slot = sd_bus_slot_unref(q->slot); + q->reply = sd_bus_message_ref(reply); + + r = sd_bus_message_rewind(q->request, true); + if (r < 0) { + r = sd_bus_reply_method_errno(q->request, r, NULL); + goto finish; + } + + r = q->callback(q->request, q->userdata, &error_buffer); + r = bus_maybe_reply_error(q->request, r, &error_buffer); + +finish: + async_polkit_query_free(q); + + return r; +} + +#endif + +int bus_verify_polkit_async( + sd_bus_message *call, + int capability, + const char *action, + const char **details, + bool interactive, + uid_t good_user, + Hashmap **registry, + sd_bus_error *error) { + +#ifdef ENABLE_POLKIT + _cleanup_(sd_bus_message_unrefp) sd_bus_message *pk = NULL; + AsyncPolkitQuery *q; + const char *sender, **k, **v; + sd_bus_message_handler_t callback; + void *userdata; + int c; +#endif + int r; + + assert(call); + assert(action); + assert(registry); + + r = check_good_user(call, good_user); + if (r != 0) + return r; + +#ifdef ENABLE_POLKIT + q = hashmap_get(*registry, call); + if (q) { + int authorized, challenge; + + /* This is the second invocation of this function, and + * there's already a response from polkit, let's + * process it */ + assert(q->reply); + + if (sd_bus_message_is_method_error(q->reply, NULL)) { + const sd_bus_error *e; + + /* Copy error from polkit reply */ + e = sd_bus_message_get_error(q->reply); + sd_bus_error_copy(error, e); + + /* Treat no PK available as access denied */ + if (sd_bus_error_has_name(e, SD_BUS_ERROR_SERVICE_UNKNOWN)) + return -EACCES; + + return -sd_bus_error_get_errno(e); + } + + r = sd_bus_message_enter_container(q->reply, 'r', "bba{ss}"); + if (r >= 0) + r = sd_bus_message_read(q->reply, "bb", &authorized, &challenge); + + if (r < 0) + return r; + + if (authorized) + return 1; + + if (challenge) + return sd_bus_error_set(error, SD_BUS_ERROR_INTERACTIVE_AUTHORIZATION_REQUIRED, "Interactive authentication required."); + + return -EACCES; + } +#endif + + r = sd_bus_query_sender_privilege(call, capability); + if (r < 0) + return r; + else if (r > 0) + return 1; + +#ifdef ENABLE_POLKIT + if (sd_bus_get_current_message(call->bus) != call) + return -EINVAL; + + callback = sd_bus_get_current_handler(call->bus); + if (!callback) + return -EINVAL; + + userdata = sd_bus_get_current_userdata(call->bus); + + sender = sd_bus_message_get_sender(call); + if (!sender) + return -EBADMSG; + + c = sd_bus_message_get_allow_interactive_authorization(call); + if (c < 0) + return c; + if (c > 0) + interactive = true; + + r = hashmap_ensure_allocated(registry, NULL); + if (r < 0) + return r; + + r = sd_bus_message_new_method_call( + call->bus, + &pk, + "org.freedesktop.PolicyKit1", + "/org/freedesktop/PolicyKit1/Authority", + "org.freedesktop.PolicyKit1.Authority", + "CheckAuthorization"); + if (r < 0) + return r; + + r = sd_bus_message_append( + pk, + "(sa{sv})s", + "system-bus-name", 1, "name", "s", sender, + action); + if (r < 0) + return r; + + r = sd_bus_message_open_container(pk, 'a', "{ss}"); + if (r < 0) + return r; + + STRV_FOREACH_PAIR(k, v, details) { + r = sd_bus_message_append(pk, "{ss}", *k, *v); + if (r < 0) + return r; + } + + r = sd_bus_message_close_container(pk); + if (r < 0) + return r; + + r = sd_bus_message_append(pk, "us", !!interactive, NULL); + if (r < 0) + return r; + + q = new0(AsyncPolkitQuery, 1); + if (!q) + return -ENOMEM; + + q->request = sd_bus_message_ref(call); + q->callback = callback; + q->userdata = userdata; + + r = hashmap_put(*registry, call, q); + if (r < 0) { + async_polkit_query_free(q); + return r; + } + + q->registry = *registry; + + r = sd_bus_call_async(call->bus, &q->slot, pk, async_polkit_callback, q, 0); + if (r < 0) { + async_polkit_query_free(q); + return r; + } + + return 0; +#endif + + return -EACCES; +} + +void bus_verify_polkit_async_registry_free(Hashmap *registry) { +#ifdef ENABLE_POLKIT + AsyncPolkitQuery *q; + + while ((q = hashmap_steal_first(registry))) + async_polkit_query_free(q); + + hashmap_free(registry); +#endif +} + +int bus_check_peercred(sd_bus *c) { + struct ucred ucred; + socklen_t l; + int fd; + + assert(c); + + fd = sd_bus_get_fd(c); + if (fd < 0) + return fd; + + l = sizeof(struct ucred); + if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &ucred, &l) < 0) + return -errno; + + if (l != sizeof(struct ucred)) + return -E2BIG; + + if (ucred.uid != 0 && ucred.uid != geteuid()) + return -EPERM; + + return 1; +} + +int bus_connect_system_systemd(sd_bus **_bus) { + _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; + int r; + + assert(_bus); + + if (geteuid() != 0) + return sd_bus_default_system(_bus); + + /* If we are root and kdbus is not available, then let's talk + * directly to the system instance, instead of going via the + * bus */ + + r = sd_bus_new(&bus); + if (r < 0) + return r; + + r = sd_bus_set_address(bus, KERNEL_SYSTEM_BUS_ADDRESS); + if (r < 0) + return r; + + bus->bus_client = true; + + r = sd_bus_start(bus); + if (r >= 0) { + *_bus = bus; + bus = NULL; + return 0; + } + + bus = sd_bus_unref(bus); + + r = sd_bus_new(&bus); + if (r < 0) + return r; + + r = sd_bus_set_address(bus, "unix:path=/run/systemd/private"); + if (r < 0) + return r; + + r = sd_bus_start(bus); + if (r < 0) + return sd_bus_default_system(_bus); + + r = bus_check_peercred(bus); + if (r < 0) + return r; + + *_bus = bus; + bus = NULL; + + return 0; +} + +int bus_connect_user_systemd(sd_bus **_bus) { + _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; + _cleanup_free_ char *ee = NULL; + const char *e; + int r; + + /* Try via kdbus first, and then directly */ + + assert(_bus); + + r = sd_bus_new(&bus); + if (r < 0) + return r; + + if (asprintf(&bus->address, KERNEL_USER_BUS_ADDRESS_FMT, getuid()) < 0) + return -ENOMEM; + + bus->bus_client = true; + + r = sd_bus_start(bus); + if (r >= 0) { + *_bus = bus; + bus = NULL; + return 0; + } + + bus = sd_bus_unref(bus); + + e = secure_getenv("XDG_RUNTIME_DIR"); + if (!e) + return sd_bus_default_user(_bus); + + ee = bus_address_escape(e); + if (!ee) + return -ENOMEM; + + r = sd_bus_new(&bus); + if (r < 0) + return r; + + bus->address = strjoin("unix:path=", ee, "/systemd/private", NULL); + if (!bus->address) + return -ENOMEM; + + r = sd_bus_start(bus); + if (r < 0) + return sd_bus_default_user(_bus); + + r = bus_check_peercred(bus); + if (r < 0) + return r; + + *_bus = bus; + bus = NULL; + + return 0; +} + +#define print_property(name, fmt, ...) \ + do { \ + if (value) \ + printf(fmt "\n", __VA_ARGS__); \ + else \ + printf("%s=" fmt "\n", name, __VA_ARGS__); \ + } while(0) + +int bus_print_property(const char *name, sd_bus_message *property, bool value, bool all) { + char type; + const char *contents; + int r; + + assert(name); + assert(property); + + r = sd_bus_message_peek_type(property, &type, &contents); + if (r < 0) + return r; + + switch (type) { + + case SD_BUS_TYPE_STRING: { + const char *s; + + r = sd_bus_message_read_basic(property, type, &s); + if (r < 0) + return r; + + if (all || !isempty(s)) { + _cleanup_free_ char *escaped = NULL; + + escaped = xescape(s, "\n"); + if (!escaped) + return -ENOMEM; + + print_property(name, "%s", escaped); + } + + return 1; + } + + case SD_BUS_TYPE_BOOLEAN: { + int b; + + r = sd_bus_message_read_basic(property, type, &b); + if (r < 0) + return r; + + print_property(name, "%s", yes_no(b)); + + return 1; + } + + case SD_BUS_TYPE_UINT64: { + uint64_t u; + + r = sd_bus_message_read_basic(property, type, &u); + if (r < 0) + return r; + + /* Yes, heuristics! But we can change this check + * should it turn out to not be sufficient */ + + if (endswith(name, "Timestamp")) { + char timestamp[FORMAT_TIMESTAMP_MAX], *t; + + t = format_timestamp(timestamp, sizeof(timestamp), u); + if (t || all) + print_property(name, "%s", strempty(t)); + + } else if (strstr(name, "USec")) { + char timespan[FORMAT_TIMESPAN_MAX]; + + print_property(name, "%s", format_timespan(timespan, sizeof(timespan), u, 0)); + } else + print_property(name, "%"PRIu64, u); + + return 1; + } + + case SD_BUS_TYPE_INT64: { + int64_t i; + + r = sd_bus_message_read_basic(property, type, &i); + if (r < 0) + return r; + + print_property(name, "%"PRIi64, i); + + return 1; + } + + case SD_BUS_TYPE_UINT32: { + uint32_t u; + + r = sd_bus_message_read_basic(property, type, &u); + if (r < 0) + return r; + + if (strstr(name, "UMask") || strstr(name, "Mode")) + print_property(name, "%04o", u); + else + print_property(name, "%"PRIu32, u); + + return 1; + } + + case SD_BUS_TYPE_INT32: { + int32_t i; + + r = sd_bus_message_read_basic(property, type, &i); + if (r < 0) + return r; + + print_property(name, "%"PRIi32, i); + return 1; + } + + case SD_BUS_TYPE_DOUBLE: { + double d; + + r = sd_bus_message_read_basic(property, type, &d); + if (r < 0) + return r; + + print_property(name, "%g", d); + return 1; + } + + case SD_BUS_TYPE_ARRAY: + if (streq(contents, "s")) { + bool first = true; + const char *str; + + r = sd_bus_message_enter_container(property, SD_BUS_TYPE_ARRAY, contents); + if (r < 0) + return r; + + while ((r = sd_bus_message_read_basic(property, SD_BUS_TYPE_STRING, &str)) > 0) { + _cleanup_free_ char *escaped = NULL; + + if (first && !value) + printf("%s=", name); + + escaped = xescape(str, "\n "); + if (!escaped) + return -ENOMEM; + + printf("%s%s", first ? "" : " ", escaped); + + first = false; + } + if (r < 0) + return r; + + if (first && all && !value) + printf("%s=", name); + if (!first || all) + puts(""); + + r = sd_bus_message_exit_container(property); + if (r < 0) + return r; + + return 1; + + } else if (streq(contents, "y")) { + const uint8_t *u; + size_t n; + + r = sd_bus_message_read_array(property, SD_BUS_TYPE_BYTE, (const void**) &u, &n); + if (r < 0) + return r; + + if (all || n > 0) { + unsigned int i; + + if (!value) + printf("%s=", name); + + for (i = 0; i < n; i++) + printf("%02x", u[i]); + + puts(""); + } + + return 1; + + } else if (streq(contents, "u")) { + uint32_t *u; + size_t n; + + r = sd_bus_message_read_array(property, SD_BUS_TYPE_UINT32, (const void**) &u, &n); + if (r < 0) + return r; + + if (all || n > 0) { + unsigned int i; + + if (!value) + printf("%s=", name); + + for (i = 0; i < n; i++) + printf("%08x", u[i]); + + puts(""); + } + + return 1; + } + + break; + } + + return 0; +} + +int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *reply = NULL; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; + + assert(bus); + assert(path); + + r = sd_bus_call_method(bus, + dest, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + &error, + &reply, + "s", ""); + if (r < 0) + return r; + + r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_ARRAY, "{sv}"); + if (r < 0) + return r; + + while ((r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_DICT_ENTRY, "sv")) > 0) { + const char *name; + const char *contents; + + r = sd_bus_message_read_basic(reply, SD_BUS_TYPE_STRING, &name); + if (r < 0) + return r; + + if (!filter || strv_find(filter, name)) { + r = sd_bus_message_peek_type(reply, NULL, &contents); + if (r < 0) + return r; + + r = sd_bus_message_enter_container(reply, SD_BUS_TYPE_VARIANT, contents); + if (r < 0) + return r; + + r = bus_print_property(name, reply, value, all); + if (r < 0) + return r; + if (r == 0) { + if (all) + printf("%s=[unprintable]\n", name); + /* skip what we didn't read */ + r = sd_bus_message_skip(reply, contents); + if (r < 0) + return r; + } + + r = sd_bus_message_exit_container(reply); + if (r < 0) + return r; + } else { + r = sd_bus_message_skip(reply, "v"); + if (r < 0) + return r; + } + + r = sd_bus_message_exit_container(reply); + if (r < 0) + return r; + } + if (r < 0) + return r; + + r = sd_bus_message_exit_container(reply); + if (r < 0) + return r; + + return 0; +} + +int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { + sd_id128_t *p = userdata; + const void *v; + size_t n; + int r; + + r = sd_bus_message_read_array(m, SD_BUS_TYPE_BYTE, &v, &n); + if (r < 0) + return r; + + if (n == 0) + *p = SD_ID128_NULL; + else if (n == 16) + memcpy((*p).bytes, v, n); + else + return -EINVAL; + + return 0; +} + +static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) { + char type; + int r; + + r = sd_bus_message_peek_type(m, &type, NULL); + if (r < 0) + return r; + + switch (type) { + case SD_BUS_TYPE_STRING: { + const char *s; + char **p = userdata; + + r = sd_bus_message_read_basic(m, type, &s); + if (r < 0) + break; + + if (isempty(s)) + break; + + r = free_and_strdup(p, s); + break; + } + + case SD_BUS_TYPE_ARRAY: { + _cleanup_strv_free_ char **l = NULL; + char ***p = userdata; + + r = bus_message_read_strv_extend(m, &l); + if (r < 0) + break; + + strv_free(*p); + *p = l; + l = NULL; + + break; + } + + case SD_BUS_TYPE_BOOLEAN: { + unsigned b; + int *p = userdata; + + r = sd_bus_message_read_basic(m, type, &b); + if (r < 0) + break; + + *p = b; + + break; + } + + case SD_BUS_TYPE_UINT32: { + uint32_t u; + uint32_t *p = userdata; + + r = sd_bus_message_read_basic(m, type, &u); + if (r < 0) + break; + + *p = u; + + break; + } + + case SD_BUS_TYPE_UINT64: { + uint64_t t; + uint64_t *p = userdata; + + r = sd_bus_message_read_basic(m, type, &t); + if (r < 0) + break; + + *p = t; + + break; + } + + case SD_BUS_TYPE_DOUBLE: { + double d; + double *p = userdata; + + r = sd_bus_message_read_basic(m, type, &d); + if (r < 0) + break; + + *p = d; + + break; + } + + default: + break; + } + + return r; +} + +int bus_message_map_all_properties( + sd_bus_message *m, + const struct bus_properties_map *map, + void *userdata) { + + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; + + assert(m); + assert(map); + + r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{sv}"); + if (r < 0) + return r; + + while ((r = sd_bus_message_enter_container(m, SD_BUS_TYPE_DICT_ENTRY, "sv")) > 0) { + const struct bus_properties_map *prop; + const char *member; + const char *contents; + void *v; + unsigned i; + + r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &member); + if (r < 0) + return r; + + for (i = 0, prop = NULL; map[i].member; i++) + if (streq(map[i].member, member)) { + prop = &map[i]; + break; + } + + if (prop) { + r = sd_bus_message_peek_type(m, NULL, &contents); + if (r < 0) + return r; + + r = sd_bus_message_enter_container(m, SD_BUS_TYPE_VARIANT, contents); + if (r < 0) + return r; + + v = (uint8_t *)userdata + prop->offset; + if (map[i].set) + r = prop->set(sd_bus_message_get_bus(m), member, m, &error, v); + else + r = map_basic(sd_bus_message_get_bus(m), member, m, &error, v); + if (r < 0) + return r; + + r = sd_bus_message_exit_container(m); + if (r < 0) + return r; + } else { + r = sd_bus_message_skip(m, "v"); + if (r < 0) + return r; + } + + r = sd_bus_message_exit_container(m); + if (r < 0) + return r; + } + if (r < 0) + return r; + + return sd_bus_message_exit_container(m); +} + +int bus_message_map_properties_changed( + sd_bus_message *m, + const struct bus_properties_map *map, + void *userdata) { + + const char *member; + int r, invalidated, i; + + assert(m); + assert(map); + + r = bus_message_map_all_properties(m, map, userdata); + if (r < 0) + return r; + + r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "s"); + if (r < 0) + return r; + + invalidated = 0; + while ((r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &member)) > 0) + for (i = 0; map[i].member; i++) + if (streq(map[i].member, member)) { + ++invalidated; + break; + } + if (r < 0) + return r; + + r = sd_bus_message_exit_container(m); + if (r < 0) + return r; + + return invalidated; +} + +int bus_map_all_properties( + sd_bus *bus, + const char *destination, + const char *path, + const struct bus_properties_map *map, + void *userdata) { + + _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + int r; + + assert(bus); + assert(destination); + assert(path); + assert(map); + + r = sd_bus_call_method( + bus, + destination, + path, + "org.freedesktop.DBus.Properties", + "GetAll", + &error, + &m, + "s", ""); + if (r < 0) + return r; + + return bus_message_map_all_properties(m, map, userdata); +} + +int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus) { + int r; + + assert(transport >= 0); + assert(transport < _BUS_TRANSPORT_MAX); + assert(bus); + + assert_return((transport == BUS_TRANSPORT_LOCAL) == !host, -EINVAL); + assert_return(transport == BUS_TRANSPORT_LOCAL || !user, -EOPNOTSUPP); + + switch (transport) { + + case BUS_TRANSPORT_LOCAL: + if (user) + r = sd_bus_default_user(bus); + else + r = sd_bus_default_system(bus); + + break; + + case BUS_TRANSPORT_REMOTE: + r = sd_bus_open_system_remote(bus, host); + break; + + case BUS_TRANSPORT_MACHINE: + r = sd_bus_open_system_machine(bus, host); + break; + + default: + assert_not_reached("Hmm, unknown transport type."); + } + + return r; +} + +int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus) { + int r; + + assert(transport >= 0); + assert(transport < _BUS_TRANSPORT_MAX); + assert(bus); + + assert_return((transport == BUS_TRANSPORT_LOCAL) == !host, -EINVAL); + assert_return(transport == BUS_TRANSPORT_LOCAL || !user, -EOPNOTSUPP); + + switch (transport) { + + case BUS_TRANSPORT_LOCAL: + if (user) + r = bus_connect_user_systemd(bus); + else + r = bus_connect_system_systemd(bus); + + break; + + case BUS_TRANSPORT_REMOTE: + r = sd_bus_open_system_remote(bus, host); + break; + + case BUS_TRANSPORT_MACHINE: + r = sd_bus_open_system_machine(bus, host); + break; + + default: + assert_not_reached("Hmm, unknown transport type."); + } + + return r; +} + +int bus_property_get_bool( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + int b = *(bool*) userdata; + + return sd_bus_message_append_basic(reply, 'b', &b); +} + +#if __SIZEOF_SIZE_T__ != 8 +int bus_property_get_size( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + uint64_t sz = *(size_t*) userdata; + + return sd_bus_message_append_basic(reply, 't', &sz); +} +#endif + +#if __SIZEOF_LONG__ != 8 +int bus_property_get_long( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + int64_t l = *(long*) userdata; + + return sd_bus_message_append_basic(reply, 'x', &l); +} + +int bus_property_get_ulong( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + uint64_t ul = *(unsigned long*) userdata; + + return sd_bus_message_append_basic(reply, 't', &ul); +} +#endif + +int bus_log_parse_error(int r) { + return log_error_errno(r, "Failed to parse bus message: %m"); +} + +int bus_log_create_error(int r) { + return log_error_errno(r, "Failed to create bus message: %m"); +} + +/** + * bus_path_encode_unique() - encode unique object path + * @b: bus connection or NULL + * @prefix: object path prefix + * @sender_id: unique-name of client, or NULL + * @external_id: external ID to be chosen by client, or NULL + * @ret_path: storage for encoded object path pointer + * + * Whenever we provide a bus API that allows clients to create and manage + * server-side objects, we need to provide a unique name for these objects. If + * we let the server choose the name, we suffer from a race condition: If a + * client creates an object asynchronously, it cannot destroy that object until + * it received the method reply. It cannot know the name of the new object, + * thus, it cannot destroy it. Furthermore, it enforces a round-trip. + * + * Therefore, many APIs allow the client to choose the unique name for newly + * created objects. There're two problems to solve, though: + * 1) Object names are usually defined via dbus object paths, which are + * usually globally namespaced. Therefore, multiple clients must be able + * to choose unique object names without interference. + * 2) If multiple libraries share the same bus connection, they must be + * able to choose unique object names without interference. + * The first problem is solved easily by prefixing a name with the + * unique-bus-name of a connection. The server side must enforce this and + * reject any other name. The second problem is solved by providing unique + * suffixes from within sd-bus. + * + * This helper allows clients to create unique object-paths. It uses the + * template '/prefix/sender_id/external_id' and returns the new path in + * @ret_path (must be freed by the caller). + * If @sender_id is NULL, the unique-name of @b is used. If @external_id is + * NULL, this function allocates a unique suffix via @b (by requesting a new + * cookie). If both @sender_id and @external_id are given, @b can be passed as + * NULL. + * + * Returns: 0 on success, negative error code on failure. + */ +int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path) { + _cleanup_free_ char *sender_label = NULL, *external_label = NULL; + char external_buf[DECIMAL_STR_MAX(uint64_t)], *p; + int r; + + assert_return(b || (sender_id && external_id), -EINVAL); + assert_return(object_path_is_valid(prefix), -EINVAL); + assert_return(ret_path, -EINVAL); + + if (!sender_id) { + r = sd_bus_get_unique_name(b, &sender_id); + if (r < 0) + return r; + } + + if (!external_id) { + xsprintf(external_buf, "%"PRIu64, ++b->cookie); + external_id = external_buf; + } + + sender_label = bus_label_escape(sender_id); + if (!sender_label) + return -ENOMEM; + + external_label = bus_label_escape(external_id); + if (!external_label) + return -ENOMEM; + + p = strjoin(prefix, "/", sender_label, "/", external_label, NULL); + if (!p) + return -ENOMEM; + + *ret_path = p; + return 0; +} + +/** + * bus_path_decode_unique() - decode unique object path + * @path: object path to decode + * @prefix: object path prefix + * @ret_sender: output parameter for sender-id label + * @ret_external: output parameter for external-id label + * + * This does the reverse of bus_path_encode_unique() (see its description for + * details). Both trailing labels, sender-id and external-id, are unescaped and + * returned in the given output parameters (the caller must free them). + * + * Note that this function returns 0 if the path does not match the template + * (see bus_path_encode_unique()), 1 if it matched. + * + * Returns: Negative error code on failure, 0 if the given object path does not + * match the template (return parameters are set to NULL), 1 if it was + * parsed successfully (return parameters contain allocated labels). + */ +int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external) { + const char *p, *q; + char *sender, *external; + + assert(object_path_is_valid(path)); + assert(object_path_is_valid(prefix)); + assert(ret_sender); + assert(ret_external); + + p = object_path_startswith(path, prefix); + if (!p) { + *ret_sender = NULL; + *ret_external = NULL; + return 0; + } + + q = strchr(p, '/'); + if (!q) { + *ret_sender = NULL; + *ret_external = NULL; + return 0; + } + + sender = bus_label_unescape_n(p, q - p); + external = bus_label_unescape(q + 1); + if (!sender || !external) { + free(sender); + free(external); + return -ENOMEM; + } + + *ret_sender = sender; + *ret_external = external; + return 1; +} + +int bus_property_get_rlimit( + sd_bus *bus, + const char *path, + const char *interface, + const char *property, + sd_bus_message *reply, + void *userdata, + sd_bus_error *error) { + + struct rlimit *rl; + uint64_t u; + rlim_t x; + const char *is_soft; + + assert(bus); + assert(reply); + assert(userdata); + + is_soft = endswith(property, "Soft"); + rl = *(struct rlimit**) userdata; + if (rl) + x = is_soft ? rl->rlim_cur : rl->rlim_max; + else { + struct rlimit buf = {}; + int z; + const char *s; + + s = is_soft ? strndupa(property, is_soft - property) : property; + + z = rlimit_from_string(strstr(s, "Limit")); + assert(z >= 0); + + getrlimit(z, &buf); + x = is_soft ? buf.rlim_cur : buf.rlim_max; + } + + /* rlim_t might have different sizes, let's map + * RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on + * all archs */ + u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x; + + return sd_bus_message_append(reply, "t", u); +} diff --git a/src/libsystemd/src/sd-bus/bus-util.h b/src/libsystemd/src/sd-bus/bus-util.h new file mode 100644 index 0000000000..6b45fad3ce --- /dev/null +++ b/src/libsystemd/src/sd-bus/bus-util.h @@ -0,0 +1,160 @@ +#pragma once + +/*** + 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 . +***/ + +#include +#include +#include +#include + +#include +#include + +#include "systemd-basic/hashmap.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/string-util.h" + +typedef enum BusTransport { + BUS_TRANSPORT_LOCAL, + BUS_TRANSPORT_REMOTE, + BUS_TRANSPORT_MACHINE, + _BUS_TRANSPORT_MAX, + _BUS_TRANSPORT_INVALID = -1 +} BusTransport; + +typedef int (*bus_property_set_t) (sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); + +struct bus_properties_map { + const char *member; + const char *signature; + bus_property_set_t set; + size_t offset; +}; + +int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata); + +int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, void *userdata); +int bus_message_map_properties_changed(sd_bus_message *m, const struct bus_properties_map *map, void *userdata); +int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map, void *userdata); + +int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name); + +typedef bool (*check_idle_t)(void *userdata); + +int bus_event_loop_with_idle(sd_event *e, sd_bus *bus, const char *name, usec_t timeout, check_idle_t check_idle, void *userdata); + +int bus_name_has_owner(sd_bus *c, const char *name, sd_bus_error *error); + +int bus_check_peercred(sd_bus *c); + +int bus_test_polkit(sd_bus_message *call, int capability, const char *action, const char **details, uid_t good_user, bool *_challenge, sd_bus_error *e); + +int bus_verify_polkit_async(sd_bus_message *call, int capability, const char *action, const char **details, bool interactive, uid_t good_user, Hashmap **registry, sd_bus_error *error); +void bus_verify_polkit_async_registry_free(Hashmap *registry); + +int bus_connect_system_systemd(sd_bus **_bus); +int bus_connect_user_systemd(sd_bus **_bus); + +int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **bus); +int bus_connect_transport_systemd(BusTransport transport, const char *host, bool user, sd_bus **bus); + +int bus_print_property(const char *name, sd_bus_message *property, bool value, bool all); +int bus_print_all_properties(sd_bus *bus, const char *dest, const char *path, char **filter, bool value, bool all); + +int bus_property_get_bool(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); + +#define bus_property_get_usec ((sd_bus_property_get_t) NULL) +#define bus_property_set_usec ((sd_bus_property_set_t) NULL) + +assert_cc(sizeof(int) == sizeof(int32_t)); +#define bus_property_get_int ((sd_bus_property_get_t) NULL) + +assert_cc(sizeof(unsigned) == sizeof(unsigned)); +#define bus_property_get_unsigned ((sd_bus_property_get_t) NULL) + +/* On 64bit machines we can use the default serializer for size_t and + * friends, otherwise we need to cast this manually */ +#if __SIZEOF_SIZE_T__ == 8 +#define bus_property_get_size ((sd_bus_property_get_t) NULL) +#else +int bus_property_get_size(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); +#endif + +#if __SIZEOF_LONG__ == 8 +#define bus_property_get_long ((sd_bus_property_get_t) NULL) +#define bus_property_get_ulong ((sd_bus_property_get_t) NULL) +#else +int bus_property_get_long(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); +int bus_property_get_ulong(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); +#endif + +/* uid_t and friends on Linux 32 bit. This means we can just use the + * default serializer for 32bit unsigned, for serializing it, and map + * it to NULL here */ +assert_cc(sizeof(uid_t) == sizeof(uint32_t)); +#define bus_property_get_uid ((sd_bus_property_get_t) NULL) + +assert_cc(sizeof(gid_t) == sizeof(uint32_t)); +#define bus_property_get_gid ((sd_bus_property_get_t) NULL) + +assert_cc(sizeof(pid_t) == sizeof(uint32_t)); +#define bus_property_get_pid ((sd_bus_property_get_t) NULL) + +assert_cc(sizeof(mode_t) == sizeof(uint32_t)); +#define bus_property_get_mode ((sd_bus_property_get_t) NULL) + +int bus_log_parse_error(int r); +int bus_log_create_error(int r); + +#define BUS_DEFINE_PROPERTY_GET_ENUM(function, name, type) \ + int function(sd_bus *bus, \ + const char *path, \ + const char *interface, \ + const char *property, \ + sd_bus_message *reply, \ + void *userdata, \ + sd_bus_error *error) { \ + \ + const char *value; \ + type *field = userdata; \ + int r; \ + \ + assert(bus); \ + assert(reply); \ + assert(field); \ + \ + value = strempty(name##_to_string(*field)); \ + \ + r = sd_bus_message_append_basic(reply, 's', value); \ + if (r < 0) \ + return r; \ + \ + return 1; \ + } \ + struct __useless_struct_to_allow_trailing_semicolon__ + +#define BUS_PROPERTY_DUAL_TIMESTAMP(name, offset, flags) \ + SD_BUS_PROPERTY(name, "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, realtime), (flags)), \ + SD_BUS_PROPERTY(name "Monotonic", "t", bus_property_get_usec, (offset) + offsetof(struct dual_timestamp, monotonic), (flags)) + +int bus_path_encode_unique(sd_bus *b, const char *prefix, const char *sender_id, const char *external_id, char **ret_path); +int bus_path_decode_unique(const char *path, const char *prefix, char **ret_sender, char **ret_external); + +int bus_property_get_rlimit(sd_bus *bus, const char *path, const char *interface, const char *property, sd_bus_message *reply, void *userdata, sd_bus_error *error); diff --git a/src/libsystemd/src/sd-bus/sd-bus.c b/src/libsystemd/src/sd-bus/sd-bus.c index 83a021e2f5..52d3e8f2b3 100644 --- a/src/libsystemd/src/sd-bus/sd-bus.c +++ b/src/libsystemd/src/sd-bus/sd-bus.c @@ -27,20 +27,19 @@ #include -#include "basic/alloc-util.h" -#include "basic/bus-label.h" -#include "basic/cgroup-util.h" -#include "basic/def.h" -#include "basic/fd-util.h" -#include "basic/hexdecoct.h" -#include "basic/hostname-util.h" -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/parse-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/bus-label.h" +#include "systemd-basic/cgroup-util.h" +#include "systemd-basic/def.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/hostname-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" #include "bus-container.h" #include "bus-control.h" @@ -53,6 +52,7 @@ #include "bus-socket.h" #include "bus-track.h" #include "bus-type.h" +#include "bus-util.h" #define log_debug_bus_message(m) \ do { \ diff --git a/src/libsystemd/src/sd-bus/test-bus-benchmark.c b/src/libsystemd/src/sd-bus/test-bus-benchmark.c index c8f0d11b84..4561e830c7 100644 --- a/src/libsystemd/src/sd-bus/test-bus-benchmark.c +++ b/src/libsystemd/src/sd-bus/test-bus-benchmark.c @@ -21,15 +21,15 @@ #include -#include "basic/alloc-util.h" -#include "basic/def.h" -#include "basic/fd-util.h" -#include "basic/time-util.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/def.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/time-util.h" +#include "systemd-basic/util.h" #include "bus-internal.h" #include "bus-kernel.h" +#include "bus-util.h" #define MAX_SIZE (2*1024*1024) diff --git a/src/libsystemd/src/sd-bus/test-bus-chat.c b/src/libsystemd/src/sd-bus/test-bus-chat.c index 8f3e88a7c0..6dc643c173 100644 --- a/src/libsystemd/src/sd-bus/test-bus-chat.c +++ b/src/libsystemd/src/sd-bus/test-bus-chat.c @@ -24,17 +24,17 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/formats-util.h" -#include "basic/log.h" -#include "basic/macro.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/util.h" #include "bus-error.h" #include "bus-internal.h" #include "bus-match.h" +#include "bus-util.h" static int match_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { log_info("Match triggered! interface=%s member=%s", strna(sd_bus_message_get_interface(m)), strna(sd_bus_message_get_member(m))); diff --git a/src/libsystemd/src/sd-bus/test-bus-cleanup.c b/src/libsystemd/src/sd-bus/test-bus-cleanup.c index f4b9f96c03..1a461032cc 100644 --- a/src/libsystemd/src/sd-bus/test-bus-cleanup.c +++ b/src/libsystemd/src/sd-bus/test-bus-cleanup.c @@ -21,11 +21,11 @@ #include -#include "basic/refcnt.h" -#include "shared/bus-util.h" +#include "systemd-basic/refcnt.h" #include "bus-internal.h" #include "bus-message.h" +#include "bus-util.h" static void test_bus_new(void) { _cleanup_(sd_bus_unrefp) sd_bus *bus = NULL; diff --git a/src/libsystemd/src/sd-bus/test-bus-creds.c b/src/libsystemd/src/sd-bus/test-bus-creds.c index 125d7db810..fd226e06d2 100644 --- a/src/libsystemd/src/sd-bus/test-bus-creds.c +++ b/src/libsystemd/src/sd-bus/test-bus-creds.c @@ -19,10 +19,10 @@ #include -#include "basic/cgroup-util.h" -#include "shared/bus-util.h" +#include "systemd-basic/cgroup-util.h" #include "bus-dump.h" +#include "bus-util.h" int main(int argc, char *argv[]) { _cleanup_(sd_bus_creds_unrefp) sd_bus_creds *creds = NULL; diff --git a/src/libsystemd/src/sd-bus/test-bus-error.c b/src/libsystemd/src/sd-bus/test-bus-error.c index 2d0aa92c6c..dbc120b4df 100644 --- a/src/libsystemd/src/sd-bus/test-bus-error.c +++ b/src/libsystemd/src/sd-bus/test-bus-error.c @@ -19,11 +19,11 @@ #include -#include "basic/errno-list.h" -#include "shared/bus-util.h" +#include "systemd-basic/errno-list.h" #include "bus-common-errors.h" #include "bus-error.h" +#include "bus-util.h" static void test_error(void) { _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL, second = SD_BUS_ERROR_NULL; diff --git a/src/libsystemd/src/sd-bus/test-bus-gvariant.c b/src/libsystemd/src/sd-bus/test-bus-gvariant.c index 5fdf8e661c..ca396bd426 100644 --- a/src/libsystemd/src/sd-bus/test-bus-gvariant.c +++ b/src/libsystemd/src/sd-bus/test-bus-gvariant.c @@ -23,15 +23,15 @@ #include -#include "basic/alloc-util.h" -#include "basic/macro.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-gvariant.h" #include "bus-internal.h" #include "bus-message.h" +#include "bus-util.h" static void test_bus_gvariant_is_fixed_size(void) { assert_se(bus_gvariant_is_fixed_size("") > 0); diff --git a/src/libsystemd/src/sd-bus/test-bus-introspect.c b/src/libsystemd/src/sd-bus/test-bus-introspect.c index 517e3668ae..76a33fee67 100644 --- a/src/libsystemd/src/sd-bus/test-bus-introspect.c +++ b/src/libsystemd/src/sd-bus/test-bus-introspect.c @@ -17,7 +17,7 @@ along with systemd; If not, see . ***/ -#include "basic/log.h" +#include "systemd-basic/log.h" #include "bus-introspect.h" diff --git a/src/libsystemd/src/sd-bus/test-bus-kernel-bloom.c b/src/libsystemd/src/sd-bus/test-bus-kernel-bloom.c index cb8c41b792..ace45d770d 100644 --- a/src/libsystemd/src/sd-bus/test-bus-kernel-bloom.c +++ b/src/libsystemd/src/sd-bus/test-bus-kernel-bloom.c @@ -19,13 +19,13 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/log.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/util.h" #include "bus-kernel.h" +#include "bus-util.h" static int test_match(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { int *found = userdata; diff --git a/src/libsystemd/src/sd-bus/test-bus-kernel.c b/src/libsystemd/src/sd-bus/test-bus-kernel.c index 871bf2e62c..040bfe0dcf 100644 --- a/src/libsystemd/src/sd-bus/test-bus-kernel.c +++ b/src/libsystemd/src/sd-bus/test-bus-kernel.c @@ -21,14 +21,14 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/log.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-kernel.h" +#include "bus-util.h" int main(int argc, char *argv[]) { _cleanup_close_ int bus_ref = -1; diff --git a/src/libsystemd/src/sd-bus/test-bus-marshal.c b/src/libsystemd/src/sd-bus/test-bus-marshal.c index 4d8f22b042..9c66ba4538 100644 --- a/src/libsystemd/src/sd-bus/test-bus-marshal.c +++ b/src/libsystemd/src/sd-bus/test-bus-marshal.c @@ -30,16 +30,16 @@ #include -#include "basic/alloc-util.h" -#include "basic/bus-label.h" -#include "basic/fd-util.h" -#include "basic/hexdecoct.h" -#include "basic/log.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/bus-label.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/log.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-message.h" +#include "bus-util.h" static void test_bus_path_encode_unique(void) { _cleanup_free_ char *a = NULL, *b = NULL, *c = NULL, *d = NULL, *e = NULL; diff --git a/src/libsystemd/src/sd-bus/test-bus-match.c b/src/libsystemd/src/sd-bus/test-bus-match.c index e50cebcdc6..bedc4d41bd 100644 --- a/src/libsystemd/src/sd-bus/test-bus-match.c +++ b/src/libsystemd/src/sd-bus/test-bus-match.c @@ -17,13 +17,13 @@ along with systemd; If not, see . ***/ -#include "basic/log.h" -#include "basic/macro.h" -#include "shared/bus-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" #include "bus-match.h" #include "bus-message.h" #include "bus-slot.h" +#include "bus-util.h" static bool mask[32]; diff --git a/src/libsystemd/src/sd-bus/test-bus-objects.c b/src/libsystemd/src/sd-bus/test-bus-objects.c index 1c6e28e76e..379c6f85ee 100644 --- a/src/libsystemd/src/sd-bus/test-bus-objects.c +++ b/src/libsystemd/src/sd-bus/test-bus-objects.c @@ -22,16 +22,16 @@ #include -#include "basic/alloc-util.h" -#include "basic/log.h" -#include "basic/macro.h" -#include "basic/strv.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-internal.h" #include "bus-message.h" +#include "bus-util.h" struct context { int fds[2]; diff --git a/src/libsystemd/src/sd-bus/test-bus-server.c b/src/libsystemd/src/sd-bus/test-bus-server.c index 9ffefa6cd0..ce78faaefb 100644 --- a/src/libsystemd/src/sd-bus/test-bus-server.c +++ b/src/libsystemd/src/sd-bus/test-bus-server.c @@ -22,12 +22,12 @@ #include -#include "basic/log.h" -#include "basic/macro.h" -#include "basic/util.h" -#include "shared/bus-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/util.h" #include "bus-internal.h" +#include "bus-util.h" struct context { int fds[2]; diff --git a/src/libsystemd/src/sd-bus/test-bus-signature.c b/src/libsystemd/src/sd-bus/test-bus-signature.c index c08999b8e1..ae50f50f08 100644 --- a/src/libsystemd/src/sd-bus/test-bus-signature.c +++ b/src/libsystemd/src/sd-bus/test-bus-signature.c @@ -17,8 +17,8 @@ along with systemd; If not, see . ***/ -#include "basic/log.h" -#include "basic/string-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/string-util.h" #include "bus-internal.h" #include "bus-signature.h" diff --git a/src/libsystemd/src/sd-bus/test-bus-zero-copy.c b/src/libsystemd/src/sd-bus/test-bus-zero-copy.c index ac453e5887..32ff9c0364 100644 --- a/src/libsystemd/src/sd-bus/test-bus-zero-copy.c +++ b/src/libsystemd/src/sd-bus/test-bus-zero-copy.c @@ -21,12 +21,12 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/log.h" -#include "basic/memfd-util.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/memfd-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" #include "bus-dump.h" #include "bus-kernel.h" diff --git a/src/libsystemd/src/sd-daemon/sd-daemon.c b/src/libsystemd/src/sd-daemon/sd-daemon.c index e848c16212..1424d60a78 100644 --- a/src/libsystemd/src/sd-daemon/sd-daemon.c +++ b/src/libsystemd/src/sd-daemon/sd-daemon.c @@ -33,14 +33,14 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fs-util.h" -#include "basic/parse-util.h" -#include "basic/path-util.h" -#include "basic/socket-util.h" -#include "basic/strv.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/libsystemd/src/sd-device/device-enumerator-private.h b/src/libsystemd/src/sd-device/device-enumerator-private.h index eb06f9542d..7bf39d188a 100644 --- a/src/libsystemd/src/sd-device/device-enumerator-private.h +++ b/src/libsystemd/src/sd-device/device-enumerator-private.h @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ -#include "sd-device.h" +#include "systemd-staging/sd-device.h" int device_enumerator_scan_devices(sd_device_enumerator *enumeartor); int device_enumerator_scan_subsystems(sd_device_enumerator *enumeartor); diff --git a/src/libsystemd/src/sd-device/device-enumerator.c b/src/libsystemd/src/sd-device/device-enumerator.c index 4e0edb6573..b4577a5a39 100644 --- a/src/libsystemd/src/sd-device/device-enumerator.c +++ b/src/libsystemd/src/sd-device/device-enumerator.c @@ -18,18 +18,18 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/dirent-util.h" -#include "basic/fd-util.h" -#include "basic/prioq.h" -#include "basic/set.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/dirent-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/prioq.h" +#include "systemd-basic/set.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-device.h" #include "device-enumerator-private.h" #include "device-util.h" -#include "sd-device.h" #define DEVICE_ENUMERATE_MAX_DEPTH 256 diff --git a/src/libsystemd/src/sd-device/device-internal.h b/src/libsystemd/src/sd-device/device-internal.h index 04384c66c5..c23e329ed4 100644 --- a/src/libsystemd/src/sd-device/device-internal.h +++ b/src/libsystemd/src/sd-device/device-internal.h @@ -20,10 +20,9 @@ along with systemd; If not, see . ***/ -#include "basic/hashmap.h" -#include "basic/set.h" - -#include "sd-device.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/set.h" +#include "systemd-staging/sd-device.h" struct sd_device { uint64_t n_ref; diff --git a/src/libsystemd/src/sd-device/device-private.c b/src/libsystemd/src/sd-device/device-private.c index bf028fbbc6..03c04b5eae 100644 --- a/src/libsystemd/src/sd-device/device-private.c +++ b/src/libsystemd/src/sd-device/device-private.c @@ -22,28 +22,28 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/fs-util.h" -#include "basic/hashmap.h" -#include "basic/macro.h" -#include "basic/mkdir.h" -#include "basic/parse-util.h" -#include "basic/path-util.h" -#include "basic/refcnt.h" -#include "basic/set.h" -#include "basic/string-table.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/strxcpyx.h" -#include "basic/user-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/mkdir.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/set.h" +#include "systemd-basic/string-table.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/strxcpyx.h" +#include "systemd-basic/user-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-device.h" #include "device-internal.h" #include "device-private.h" #include "device-util.h" -#include "sd-device.h" int device_add_property(sd_device *device, const char *key, const char *value) { int r; diff --git a/src/libsystemd/src/sd-device/device-private.h b/src/libsystemd/src/sd-device/device-private.h index 29b3e155fb..504507e3cb 100644 --- a/src/libsystemd/src/sd-device/device-private.h +++ b/src/libsystemd/src/sd-device/device-private.h @@ -23,7 +23,7 @@ #include #include -#include "sd-device.h" +#include "systemd-staging/sd-device.h" int device_new_from_nulstr(sd_device **ret, uint8_t *nulstr, size_t len); int device_new_from_strv(sd_device **ret, char **strv); diff --git a/src/libsystemd/src/sd-device/device-util.h b/src/libsystemd/src/sd-device/device-util.h index a8aca6d8f4..40bfa62de1 100644 --- a/src/libsystemd/src/sd-device/device-util.h +++ b/src/libsystemd/src/sd-device/device-util.h @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ -#include "basic/util.h" +#include "systemd-basic/util.h" #define FOREACH_DEVICE_PROPERTY(device, key, value) \ for (key = sd_device_get_property_first(device, &(value)); \ diff --git a/src/libsystemd/src/sd-device/sd-device.c b/src/libsystemd/src/sd-device/sd-device.c index 79c2c2caeb..3f7e21af96 100644 --- a/src/libsystemd/src/sd-device/sd-device.c +++ b/src/libsystemd/src/sd-device/sd-device.c @@ -22,25 +22,25 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/fs-util.h" -#include "basic/hashmap.h" -#include "basic/macro.h" -#include "basic/parse-util.h" -#include "basic/path-util.h" -#include "basic/set.h" -#include "basic/stat-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/strxcpyx.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/set.h" +#include "systemd-basic/stat-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/strxcpyx.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-device.h" #include "device-internal.h" #include "device-private.h" #include "device-util.h" -#include "sd-device.h" int device_new_aux(sd_device **ret) { _cleanup_(sd_device_unrefp) sd_device *device = NULL; diff --git a/src/libsystemd/src/sd-device/sd-device.h b/src/libsystemd/src/sd-device/sd-device.h deleted file mode 100644 index 5e32fc6110..0000000000 --- a/src/libsystemd/src/sd-device/sd-device.h +++ /dev/null @@ -1,101 +0,0 @@ -#ifndef foosddevicehfoo -#define foosddevicehfoo - -/*** - This file is part of systemd. - - Copyright 2008-2012 Kay Sievers - Copyright 2014-2015 Tom Gundersen - - 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 . -***/ - -#include -#include -#include - -#include - -_SD_BEGIN_DECLARATIONS; - -typedef struct sd_device sd_device; -typedef struct sd_device_enumerator sd_device_enumerator; - -/* device */ - -sd_device *sd_device_ref(sd_device *device); -sd_device *sd_device_unref(sd_device *device); - -int sd_device_new_from_syspath(sd_device **ret, const char *syspath); -int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum); -int sd_device_new_from_subsystem_sysname(sd_device **ret, const char *subsystem, const char *sysname); -int sd_device_new_from_device_id(sd_device **ret, const char *id); - -int sd_device_get_parent(sd_device *child, sd_device **ret); -int sd_device_get_parent_with_subsystem_devtype(sd_device *child, const char *subsystem, const char *devtype, sd_device **ret); - -int sd_device_get_syspath(sd_device *device, const char **ret); -int sd_device_get_subsystem(sd_device *device, const char **ret); -int sd_device_get_devtype(sd_device *device, const char **ret); -int sd_device_get_devnum(sd_device *device, dev_t *devnum); -int sd_device_get_ifindex(sd_device *device, int *ifindex); -int sd_device_get_driver(sd_device *device, const char **ret); -int sd_device_get_devpath(sd_device *device, const char **ret); -int sd_device_get_devname(sd_device *device, const char **ret); -int sd_device_get_sysname(sd_device *device, const char **ret); -int sd_device_get_sysnum(sd_device *device, const char **ret); - -int sd_device_get_is_initialized(sd_device *device, int *initialized); -int sd_device_get_usec_since_initialized(sd_device *device, uint64_t *usec); - -const char *sd_device_get_tag_first(sd_device *device); -const char *sd_device_get_tag_next(sd_device *device); -const char *sd_device_get_devlink_first(sd_device *device); -const char *sd_device_get_devlink_next(sd_device *device); -const char *sd_device_get_property_first(sd_device *device, const char **value); -const char *sd_device_get_property_next(sd_device *device, const char **value); -const char *sd_device_get_sysattr_first(sd_device *device); -const char *sd_device_get_sysattr_next(sd_device *device); - -int sd_device_has_tag(sd_device *device, const char *tag); -int sd_device_get_property_value(sd_device *device, const char *key, const char **value); -int sd_device_get_sysattr_value(sd_device *device, const char *sysattr, const char **_value); - -int sd_device_set_sysattr_value(sd_device *device, const char *sysattr, char *value); - -/* device enumerator */ - -int sd_device_enumerator_new(sd_device_enumerator **ret); -sd_device_enumerator *sd_device_enumerator_ref(sd_device_enumerator *enumerator); -sd_device_enumerator *sd_device_enumerator_unref(sd_device_enumerator *enumerator); - -sd_device *sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator); -sd_device *sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator); -sd_device *sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator); -sd_device *sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator); - -int sd_device_enumerator_add_match_subsystem(sd_device_enumerator *enumerator, const char *subsystem, int match); -int sd_device_enumerator_add_match_sysattr(sd_device_enumerator *enumerator, const char *sysattr, const char *value, int match); -int sd_device_enumerator_add_match_property(sd_device_enumerator *enumerator, const char *property, const char *value); -int sd_device_enumerator_add_match_sysname(sd_device_enumerator *enumerator, const char *sysname); -int sd_device_enumerator_add_match_tag(sd_device_enumerator *enumerator, const char *tag); -int sd_device_enumerator_add_match_parent(sd_device_enumerator *enumerator, sd_device *parent); -int sd_device_enumerator_allow_uninitialized(sd_device_enumerator *enumerator); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device, sd_device_unref); -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_device_enumerator, sd_device_enumerator_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libsystemd/src/sd-event/sd-event.c b/src/libsystemd/src/sd-event/sd-event.c index 495e97eea2..3dcf70999c 100644 --- a/src/libsystemd/src/sd-event/sd-event.c +++ b/src/libsystemd/src/sd-event/sd-event.c @@ -25,20 +25,20 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/hashmap.h" -#include "basic/list.h" -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/prioq.h" -#include "basic/process-util.h" -#include "basic/set.h" -#include "basic/signal-util.h" -#include "basic/string-table.h" -#include "basic/string-util.h" -#include "basic/time-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/list.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/prioq.h" +#include "systemd-basic/process-util.h" +#include "systemd-basic/set.h" +#include "systemd-basic/signal-util.h" +#include "systemd-basic/string-table.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/time-util.h" +#include "systemd-basic/util.h" #define DEFAULT_ACCURACY_USEC (250 * USEC_PER_MSEC) diff --git a/src/libsystemd/src/sd-event/test-event.c b/src/libsystemd/src/sd-event/test-event.c index 10395f155f..7c1289423f 100644 --- a/src/libsystemd/src/sd-event/test-event.c +++ b/src/libsystemd/src/sd-event/test-event.c @@ -19,11 +19,11 @@ #include -#include "basic/fd-util.h" -#include "basic/log.h" -#include "basic/macro.h" -#include "basic/signal-util.h" -#include "basic/util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/signal-util.h" +#include "systemd-basic/util.h" static int prepare_handler(sd_event_source *s, void *userdata) { log_info("preparing %c", PTR_TO_INT(userdata)); diff --git a/src/libsystemd/src/sd-hwdb/Makefile b/src/libsystemd/src/sd-hwdb/Makefile deleted file mode 120000 index 71a1159ce0..0000000000 --- a/src/libsystemd/src/sd-hwdb/Makefile +++ /dev/null @@ -1 +0,0 @@ -../subdir.mk \ No newline at end of file diff --git a/src/libsystemd/src/sd-hwdb/Makefile b/src/libsystemd/src/sd-hwdb/Makefile new file mode 100644 index 0000000000..a2696e2976 --- /dev/null +++ b/src/libsystemd/src/sd-hwdb/Makefile @@ -0,0 +1,32 @@ +# -*- Mode: makefile; indent-tabs-mode: t -*- +# +# This file is part of systemd. +# +# Copyright 2010-2012 Lennart Poettering +# Copyright 2010-2012 Kay Sievers +# Copyright 2013 Zbigniew Jędrzejewski-Szmek +# Copyright 2013 David Strauss +# Copyright 2016 Luke Shumaker +# +# 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 . + +include $(dir $(lastword $(MAKEFILE_LIST)))/../../../../config.mk +include $(topsrcdir)/build-aux/Makefile.head.mk + +sd.CPPFLAGS += $(libsystemd.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-staging.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-basic.CPPFLAGS) +sd.CPPFLAGS += -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" + +include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/libsystemd/src/sd-hwdb/hwdb-internal.h b/src/libsystemd/src/sd-hwdb/hwdb-internal.h index 7b32bbd11d..35d4378122 100644 --- a/src/libsystemd/src/sd-hwdb/hwdb-internal.h +++ b/src/libsystemd/src/sd-hwdb/hwdb-internal.h @@ -19,8 +19,8 @@ along with systemd; If not, see . ***/ -#include "basic/sparse-endian.h" -#include "basic/util.h" +#include "systemd-basic/sparse-endian.h" +#include "systemd-basic/util.h" #define HWDB_SIG { 'K', 'S', 'L', 'P', 'H', 'H', 'R', 'H' } diff --git a/src/libsystemd/src/sd-hwdb/hwdb-util.h b/src/libsystemd/src/sd-hwdb/hwdb-util.h index c8c0a4938e..5585965c83 100644 --- a/src/libsystemd/src/sd-hwdb/hwdb-util.h +++ b/src/libsystemd/src/sd-hwdb/hwdb-util.h @@ -19,8 +19,7 @@ along with systemd; If not, see . ***/ -#include "basic/util.h" - -#include "sd-hwdb.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-hwdb.h" bool hwdb_validate(sd_hwdb *hwdb); diff --git a/src/libsystemd/src/sd-hwdb/sd-hwdb.c b/src/libsystemd/src/sd-hwdb/sd-hwdb.c index a48c7af124..0891719604 100644 --- a/src/libsystemd/src/sd-hwdb/sd-hwdb.c +++ b/src/libsystemd/src/sd-hwdb/sd-hwdb.c @@ -27,15 +27,15 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/hashmap.h" -#include "basic/refcnt.h" -#include "basic/string-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/string-util.h" +#include "systemd-staging/sd-hwdb.h" #include "hwdb-internal.h" #include "hwdb-util.h" -#include "sd-hwdb.h" struct sd_hwdb { RefCount n_ref; diff --git a/src/libsystemd/src/sd-hwdb/sd-hwdb.h b/src/libsystemd/src/sd-hwdb/sd-hwdb.h deleted file mode 100644 index f46d7ad561..0000000000 --- a/src/libsystemd/src/sd-hwdb/sd-hwdb.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef foosdhwdbhfoo -#define foosdhwdbhfoo - -/*** - This file is part of systemd. - - Copyright 2008-2012 Kay Sievers - Copyright 2014 Tom Gundersen - - 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 . -***/ - -#include - -_SD_BEGIN_DECLARATIONS; - -typedef struct sd_hwdb sd_hwdb; - -sd_hwdb *sd_hwdb_ref(sd_hwdb *hwdb); -sd_hwdb *sd_hwdb_unref(sd_hwdb *hwdb); - -int sd_hwdb_new(sd_hwdb **ret); - -int sd_hwdb_get(sd_hwdb *hwdb, const char *modalias, const char *key, const char **value); - -int sd_hwdb_seek(sd_hwdb *hwdb, const char *modalias); -int sd_hwdb_enumerate(sd_hwdb *hwdb, const char **key, const char **value); - -/* the inverse condition avoids ambiguity of dangling 'else' after the macro */ -#define SD_HWDB_FOREACH_PROPERTY(hwdb, modalias, key, value) \ - if (sd_hwdb_seek(hwdb, modalias) < 0) { } \ - else while (sd_hwdb_enumerate(hwdb, &(key), &(value)) > 0) - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_hwdb, sd_hwdb_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libsystemd/src/sd-id128/id128-util.c b/src/libsystemd/src/sd-id128/id128-util.c index a9c43f9730..cd32543d0c 100644 --- a/src/libsystemd/src/sd-id128/id128-util.c +++ b/src/libsystemd/src/sd-id128/id128-util.c @@ -20,10 +20,10 @@ #include #include -#include "basic/fd-util.h" -#include "basic/hexdecoct.h" -#include "basic/io-util.h" -#include "basic/stdio-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/stdio-util.h" #include "id128-util.h" diff --git a/src/libsystemd/src/sd-id128/id128-util.h b/src/libsystemd/src/sd-id128/id128-util.h index d45c556746..0c57d693e5 100644 --- a/src/libsystemd/src/sd-id128/id128-util.h +++ b/src/libsystemd/src/sd-id128/id128-util.h @@ -23,7 +23,7 @@ #include -#include "basic/macro.h" +#include "systemd-basic/macro.h" char *id128_to_uuid_string(sd_id128_t id, char s[37]); diff --git a/src/libsystemd/src/sd-id128/sd-id128.c b/src/libsystemd/src/sd-id128/sd-id128.c index 06fbe32f62..9c036fb4cb 100644 --- a/src/libsystemd/src/sd-id128/sd-id128.c +++ b/src/libsystemd/src/sd-id128/sd-id128.c @@ -23,12 +23,12 @@ #include -#include "basic/fd-util.h" -#include "basic/hexdecoct.h" -#include "basic/io-util.h" -#include "basic/macro.h" -#include "basic/random-util.h" -#include "basic/util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/random-util.h" +#include "systemd-basic/util.h" #include "id128-util.h" diff --git a/src/libsystemd/src/sd-journal/Makefile b/src/libsystemd/src/sd-journal/Makefile index f13c2b51fa..38a3458f4b 100644 --- a/src/libsystemd/src/sd-journal/Makefile +++ b/src/libsystemd/src/sd-journal/Makefile @@ -23,12 +23,12 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk -audit_list_includes = -include linux/audit.h -include $(topsrcdir)/src/libbasic/include/basic/missing.h +audit_list_includes = -include linux/audit.h -include $(topsrcdir)/src/libsystemd-basic/include/systemd-basic/missing.h ifneq ($(HAVE_AUDIT),) audit_list_includes += -include libaudit.h endif # HAVE_AUDIT -$(outdir)/audit_type-list.txt: $(call at.path,$(topsrcdir)/src/libbasic/include/basic/missing.h) +$(outdir)/audit_type-list.txt: $(call at.path,$(topsrcdir)/src/libsystemd-basic/include/systemd-basic/missing.h) $(AM_V_GEN)$(CPP) $(sd.ALL_CPPFLAGS) -dM $(audit_list_includes) - $@ $(outdir)/audit_type-to-name.h: $(outdir)/audit_type-list.txt @@ -37,8 +37,11 @@ $(outdir)/audit_type-to-name.h: $(outdir)/audit_type-list.txt # fsprg.c is a drop-in file using void pointer arithmetic $(outdir)/fsprg.lo: sd.ALL_CFLAGS += -Wno-pointer-arith -sd.CPPFLAGS += $(libbasic.CPPFLAGS) -sd.CPPFLAGS += -DCATALOG_DATABASE=\"$(catalogstatedir)/database\" $(outdir)/audit-type.lo: $(outdir)/audit_type-to-name.h +sd.CPPFLAGS += $(libsystemd.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-basic.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-gcrypt.CPPFLAGS) +sd.CPPFLAGS += -DCATALOG_DATABASE=\"$(catalogstatedir)/database\" + include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/libsystemd/src/sd-journal/audit-type.c b/src/libsystemd/src/sd-journal/audit-type.c index f4dd1e9417..1644e3f1b1 100644 --- a/src/libsystemd/src/sd-journal/audit-type.c +++ b/src/libsystemd/src/sd-journal/audit-type.c @@ -24,8 +24,8 @@ # include #endif -#include "basic/macro.h" -#include "basic/missing.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" #include "audit-type.h" #include "audit_type-to-name.h" diff --git a/src/libsystemd/src/sd-journal/audit-type.h b/src/libsystemd/src/sd-journal/audit-type.h index 8b96e2e466..0b4748b01f 100644 --- a/src/libsystemd/src/sd-journal/audit-type.h +++ b/src/libsystemd/src/sd-journal/audit-type.h @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ -#include "basic/macro.h" +#include "systemd-basic/macro.h" const char *audit_type_to_string(int type); int audit_type_from_string(const char *s); diff --git a/src/libsystemd/src/sd-journal/catalog.c b/src/libsystemd/src/sd-journal/catalog.c index 7dc02deb49..fce4649f6f 100644 --- a/src/libsystemd/src/sd-journal/catalog.c +++ b/src/libsystemd/src/sd-journal/catalog.c @@ -27,20 +27,20 @@ #include -#include "basic/alloc-util.h" -#include "basic/conf-files.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/hashmap.h" -#include "basic/log.h" -#include "basic/mkdir.h" -#include "basic/path-util.h" -#include "basic/siphash24.h" -#include "basic/sparse-endian.h" -#include "basic/strbuf.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/conf-files.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/log.h" +#include "systemd-basic/mkdir.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/siphash24.h" +#include "systemd-basic/sparse-endian.h" +#include "systemd-basic/strbuf.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" #include "catalog.h" diff --git a/src/libsystemd/src/sd-journal/catalog.h b/src/libsystemd/src/sd-journal/catalog.h index fa60757723..49fec555a4 100644 --- a/src/libsystemd/src/sd-journal/catalog.h +++ b/src/libsystemd/src/sd-journal/catalog.h @@ -23,8 +23,8 @@ #include -#include "basic/hashmap.h" -#include "basic/strbuf.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/strbuf.h" int catalog_import_file(Hashmap *h, const char *path); int catalog_update(const char* database, const char* root, const char* const* dirs); diff --git a/src/libsystemd/src/sd-journal/compress.c b/src/libsystemd/src/sd-journal/compress.c index a96d93c455..c6c5f3c500 100644 --- a/src/libsystemd/src/sd-journal/compress.c +++ b/src/libsystemd/src/sd-journal/compress.c @@ -32,14 +32,14 @@ #include #endif -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/io-util.h" -#include "basic/macro.h" -#include "basic/sparse-endian.h" -#include "basic/string-table.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/sparse-endian.h" +#include "systemd-basic/string-table.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" #include "compress.h" #include "journal-def.h" diff --git a/src/libsystemd/src/sd-journal/fsprg.c b/src/libsystemd/src/sd-journal/fsprg.c index 612b10f3a9..c0f59b28fd 100644 --- a/src/libsystemd/src/sd-journal/fsprg.c +++ b/src/libsystemd/src/sd-journal/fsprg.c @@ -29,8 +29,9 @@ #include #include +#include "systemd-gcrypt/gcrypt-util.h" + #include "fsprg.h" -#include "gcrypt-util.h" #define ISVALID_SECPAR(secpar) (((secpar) % 16 == 0) && ((secpar) >= 16) && ((secpar) <= 16384)) #define VALIDATE_SECPAR(secpar) assert(ISVALID_SECPAR(secpar)); diff --git a/src/libsystemd/src/sd-journal/fsprg.h b/src/libsystemd/src/sd-journal/fsprg.h index ef6d34fb4e..15a4e04fe8 100644 --- a/src/libsystemd/src/sd-journal/fsprg.h +++ b/src/libsystemd/src/sd-journal/fsprg.h @@ -26,8 +26,8 @@ #include #include -#include "basic/macro.h" -#include "basic/util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/util.h" #ifdef __cplusplus extern "C" { diff --git a/src/libsystemd/src/sd-journal/gcrypt-util.c b/src/libsystemd/src/sd-journal/gcrypt-util.c deleted file mode 120000 index 56bb2382a6..0000000000 --- a/src/libsystemd/src/sd-journal/gcrypt-util.c +++ /dev/null @@ -1 +0,0 @@ -../../../libshared/src/gcrypt-util.c \ No newline at end of file diff --git a/src/libsystemd/src/sd-journal/gcrypt-util.h b/src/libsystemd/src/sd-journal/gcrypt-util.h deleted file mode 120000 index c1168ad265..0000000000 --- a/src/libsystemd/src/sd-journal/gcrypt-util.h +++ /dev/null @@ -1 +0,0 @@ -../../../libshared/include/shared/gcrypt-util.h \ No newline at end of file diff --git a/src/libsystemd/src/sd-journal/journal-authenticate.c b/src/libsystemd/src/sd-journal/journal-authenticate.c index 5400d38ffd..f3a207d88d 100644 --- a/src/libsystemd/src/sd-journal/journal-authenticate.c +++ b/src/libsystemd/src/sd-journal/journal-authenticate.c @@ -20,11 +20,11 @@ #include #include -#include "basic/fd-util.h" -#include "basic/hexdecoct.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hexdecoct.h" +#include "systemd-gcrypt/gcrypt-util.h" #include "fsprg.h" -#include "gcrypt-util.h" #include "journal-authenticate.h" #include "journal-def.h" #include "journal-file.h" diff --git a/src/libsystemd/src/sd-journal/journal-def.h b/src/libsystemd/src/sd-journal/journal-def.h index 86c843905a..1c604487fb 100644 --- a/src/libsystemd/src/sd-journal/journal-def.h +++ b/src/libsystemd/src/sd-journal/journal-def.h @@ -21,8 +21,8 @@ #include -#include "basic/macro.h" -#include "basic/sparse-endian.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/sparse-endian.h" /* * If you change this file you probably should also change its documentation: @@ -32,20 +32,16 @@ */ typedef struct Header Header; - typedef struct ObjectHeader ObjectHeader; typedef union Object Object; - typedef struct DataObject DataObject; typedef struct FieldObject FieldObject; typedef struct EntryObject EntryObject; typedef struct HashTableObject HashTableObject; typedef struct EntryArrayObject EntryArrayObject; typedef struct TagObject TagObject; - typedef struct EntryItem EntryItem; typedef struct HashItem HashItem; - typedef struct FSSHeader FSSHeader; /* Object types */ diff --git a/src/libsystemd/src/sd-journal/journal-file.c b/src/libsystemd/src/sd-journal/journal-file.c index d8f4671617..7910270925 100644 --- a/src/libsystemd/src/sd-journal/journal-file.c +++ b/src/libsystemd/src/sd-journal/journal-file.c @@ -30,16 +30,16 @@ #include -#include "basic/alloc-util.h" -#include "basic/btrfs-util.h" -#include "basic/chattr-util.h" -#include "basic/fd-util.h" -#include "basic/parse-util.h" -#include "basic/path-util.h" -#include "basic/random-util.h" -#include "basic/set.h" -#include "basic/string-util.h" -#include "basic/xattr-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/btrfs-util.h" +#include "systemd-basic/chattr-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/random-util.h" +#include "systemd-basic/set.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/xattr-util.h" #include "compress.h" #include "journal-authenticate.h" diff --git a/src/libsystemd/src/sd-journal/journal-file.h b/src/libsystemd/src/sd-journal/journal-file.h index daafc8ae0d..054fe5794b 100644 --- a/src/libsystemd/src/sd-journal/journal-file.h +++ b/src/libsystemd/src/sd-journal/journal-file.h @@ -28,9 +28,9 @@ #include #include -#include "basic/hashmap.h" -#include "basic/macro.h" -#include "basic/sparse-endian.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/sparse-endian.h" #include "journal-def.h" #include "mmap-cache.h" diff --git a/src/libsystemd/src/sd-journal/journal-internal.h b/src/libsystemd/src/sd-journal/journal-internal.h index e249a8b979..83f38b51ed 100644 --- a/src/libsystemd/src/sd-journal/journal-internal.h +++ b/src/libsystemd/src/sd-journal/journal-internal.h @@ -26,9 +26,9 @@ #include #include -#include "basic/hashmap.h" -#include "basic/list.h" -#include "basic/set.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/list.h" +#include "systemd-basic/set.h" #include "journal-def.h" #include "journal-file.h" diff --git a/src/libsystemd/src/sd-journal/journal-send.c b/src/libsystemd/src/sd-journal/journal-send.c index 180311009c..c168902e9a 100644 --- a/src/libsystemd/src/sd-journal/journal-send.c +++ b/src/libsystemd/src/sd-journal/journal-send.c @@ -29,15 +29,15 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/io-util.h" -#include "basic/memfd-util.h" -#include "basic/socket-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/memfd-util.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" #define SNDBUF_SIZE (8*1024*1024) diff --git a/src/libsystemd/src/sd-journal/journal-vacuum.c b/src/libsystemd/src/sd-journal/journal-vacuum.c index a3ebf9b029..4bbe3ee800 100644 --- a/src/libsystemd/src/sd-journal/journal-vacuum.c +++ b/src/libsystemd/src/sd-journal/journal-vacuum.c @@ -23,13 +23,13 @@ #include -#include "basic/alloc-util.h" -#include "basic/dirent-util.h" -#include "basic/fd-util.h" -#include "basic/parse-util.h" -#include "basic/string-util.h" -#include "basic/util.h" -#include "basic/xattr-util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/dirent-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" +#include "systemd-basic/xattr-util.h" #include "journal-def.h" #include "journal-file.h" diff --git a/src/libsystemd/src/sd-journal/journal-vacuum.h b/src/libsystemd/src/sd-journal/journal-vacuum.h index c7b38e2da9..1e76aa856d 100644 --- a/src/libsystemd/src/sd-journal/journal-vacuum.h +++ b/src/libsystemd/src/sd-journal/journal-vacuum.h @@ -22,6 +22,6 @@ #include #include -#include "basic/time-util.h" +#include "systemd-basic/time-util.h" int journal_directory_vacuum(const char *directory, uint64_t max_use, uint64_t n_max_files, usec_t max_retention_usec, usec_t *oldest_usec, bool verbose); diff --git a/src/libsystemd/src/sd-journal/journal-verify.c b/src/libsystemd/src/sd-journal/journal-verify.c index bb890273b3..de75cc94ef 100644 --- a/src/libsystemd/src/sd-journal/journal-verify.c +++ b/src/libsystemd/src/sd-journal/journal-verify.c @@ -22,13 +22,13 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/fs-util.h" -#include "basic/macro.h" -#include "basic/terminal-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/terminal-util.h" +#include "systemd-basic/util.h" #include "compress.h" #include "journal-authenticate.h" diff --git a/src/libsystemd/src/sd-journal/lookup3.h b/src/libsystemd/src/sd-journal/lookup3.h index 28ab5ca4f5..0c8c0b0ae4 100644 --- a/src/libsystemd/src/sd-journal/lookup3.h +++ b/src/libsystemd/src/sd-journal/lookup3.h @@ -3,7 +3,7 @@ #include #include -#include "basic/macro.h" +#include "systemd-basic/macro.h" uint32_t jenkins_hashword(const uint32_t *k, size_t length, uint32_t initval) _pure_; void jenkins_hashword2(const uint32_t *k, size_t length, uint32_t *pc, uint32_t *pb); diff --git a/src/libsystemd/src/sd-journal/mmap-cache.c b/src/libsystemd/src/sd-journal/mmap-cache.c index bda21aed05..2fdb445f3f 100644 --- a/src/libsystemd/src/sd-journal/mmap-cache.c +++ b/src/libsystemd/src/sd-journal/mmap-cache.c @@ -21,14 +21,14 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/hashmap.h" -#include "basic/list.h" -#include "basic/log.h" -#include "basic/macro.h" -#include "basic/sigbus.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/list.h" +#include "systemd-basic/log.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/sigbus.h" +#include "systemd-basic/util.h" #include "mmap-cache.h" diff --git a/src/libsystemd/src/sd-journal/sd-journal.c b/src/libsystemd/src/sd-journal/sd-journal.c index 1a4b0c6418..58307e1626 100644 --- a/src/libsystemd/src/sd-journal/sd-journal.c +++ b/src/libsystemd/src/sd-journal/sd-journal.c @@ -30,23 +30,23 @@ #include -#include "basic/alloc-util.h" -#include "basic/dirent-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/formats-util.h" -#include "basic/fs-util.h" -#include "basic/hashmap.h" -#include "basic/hostname-util.h" -#include "basic/io-util.h" -#include "basic/list.h" -#include "basic/missing.h" -#include "basic/path-util.h" -#include "basic/replace-var.h" -#include "basic/stat-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/dirent-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/hostname-util.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/list.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/replace-var.h" +#include "systemd-basic/stat-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" #include "catalog.h" #include "compress.h" diff --git a/src/libsystemd/src/sd-login/sd-login.c b/src/libsystemd/src/sd-login/sd-login.c index 2698dc5c2b..9be4ec6c39 100644 --- a/src/libsystemd/src/sd-login/sd-login.c +++ b/src/libsystemd/src/sd-login/sd-login.c @@ -25,25 +25,25 @@ #include -#include "basic/alloc-util.h" -#include "basic/cgroup-util.h" -#include "basic/dirent-util.h" -#include "basic/escape.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/formats-util.h" -#include "basic/fs-util.h" -#include "basic/hostname-util.h" -#include "basic/io-util.h" -#include "basic/login-util.h" -#include "basic/macro.h" -#include "basic/parse-util.h" -#include "basic/path-util.h" -#include "basic/socket-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/user-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/cgroup-util.h" +#include "systemd-basic/dirent-util.h" +#include "systemd-basic/escape.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/hostname-util.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/login-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/path-util.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/user-util.h" +#include "systemd-basic/util.h" /* Error codes: * diff --git a/src/libsystemd/src/sd-login/test-login.c b/src/libsystemd/src/sd-login/test-login.c index bec645242a..348ce1e790 100644 --- a/src/libsystemd/src/sd-login/test-login.c +++ b/src/libsystemd/src/sd-login/test-login.c @@ -22,12 +22,12 @@ #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/formats-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" static void test_login(void) { _cleanup_close_pair_ int pair[2] = { -1, -1 }; diff --git a/src/libsystemd/src/sd-netlink/local-addresses.c b/src/libsystemd/src/sd-netlink/local-addresses.c index 0baaab557f..6d6ee9c504 100644 --- a/src/libsystemd/src/sd-netlink/local-addresses.c +++ b/src/libsystemd/src/sd-netlink/local-addresses.c @@ -18,11 +18,11 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/macro.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/macro.h" +#include "systemd-staging/sd-netlink.h" #include "local-addresses.h" -#include "sd-netlink.h" static int address_compare(const void *_a, const void *_b) { const struct local_address *a = _a, *b = _b; diff --git a/src/libsystemd/src/sd-netlink/local-addresses.h b/src/libsystemd/src/sd-netlink/local-addresses.h index 5eb0683131..f1e91ccfd2 100644 --- a/src/libsystemd/src/sd-netlink/local-addresses.h +++ b/src/libsystemd/src/sd-netlink/local-addresses.h @@ -20,9 +20,8 @@ ***/ -#include "basic/in-addr-util.h" - -#include "sd-netlink.h" +#include "systemd-basic/in-addr-util.h" +#include "systemd-staging/sd-netlink.h" struct local_address { int family, ifindex; diff --git a/src/libsystemd/src/sd-netlink/netlink-internal.h b/src/libsystemd/src/sd-netlink/netlink-internal.h index 69511f87ad..0df449a43c 100644 --- a/src/libsystemd/src/sd-netlink/netlink-internal.h +++ b/src/libsystemd/src/sd-netlink/netlink-internal.h @@ -21,12 +21,12 @@ #include -#include "basic/list.h" -#include "basic/prioq.h" -#include "basic/refcnt.h" +#include "systemd-basic/list.h" +#include "systemd-basic/prioq.h" +#include "systemd-basic/refcnt.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-types.h" -#include "sd-netlink.h" #define RTNL_DEFAULT_TIMEOUT ((usec_t) (25 * USEC_PER_SEC)) diff --git a/src/libsystemd/src/sd-netlink/netlink-message.c b/src/libsystemd/src/sd-netlink/netlink-message.c index 352df2f35a..73afe876b6 100644 --- a/src/libsystemd/src/sd-netlink/netlink-message.c +++ b/src/libsystemd/src/sd-netlink/netlink-message.c @@ -21,17 +21,17 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/formats-util.h" -#include "basic/missing.h" -#include "basic/refcnt.h" -#include "basic/socket-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-internal.h" #include "netlink-types.h" #include "netlink-util.h" -#include "sd-netlink.h" #define GET_CONTAINER(m, i) ((i) < (m)->n_containers ? (struct rtattr*)((uint8_t*)(m)->hdr + (m)->containers[i].offset) : NULL) #define PUSH_CONTAINER(m, new) (m)->container_offsets[(m)->n_containers++] = (uint8_t*)(new) - (uint8_t*)(m)->hdr; diff --git a/src/libsystemd/src/sd-netlink/netlink-socket.c b/src/libsystemd/src/sd-netlink/netlink-socket.c index ec3513bcf8..f9a0df9f20 100644 --- a/src/libsystemd/src/sd-netlink/netlink-socket.c +++ b/src/libsystemd/src/sd-netlink/netlink-socket.c @@ -21,17 +21,17 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/formats-util.h" -#include "basic/missing.h" -#include "basic/refcnt.h" -#include "basic/socket-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-internal.h" #include "netlink-types.h" #include "netlink-util.h" -#include "sd-netlink.h" int socket_open(int family) { int fd; diff --git a/src/libsystemd/src/sd-netlink/netlink-types.c b/src/libsystemd/src/sd-netlink/netlink-types.c index 7aaecd2272..c3f3789fe5 100644 --- a/src/libsystemd/src/sd-netlink/netlink-types.c +++ b/src/libsystemd/src/sd-netlink/netlink-types.c @@ -31,10 +31,10 @@ #include #include -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/string-table.h" -#include "basic/util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/string-table.h" +#include "systemd-basic/util.h" #include "netlink-types.h" diff --git a/src/libsystemd/src/sd-netlink/netlink-types.h b/src/libsystemd/src/sd-netlink/netlink-types.h index 56b9cb143f..3cd57715c3 100644 --- a/src/libsystemd/src/sd-netlink/netlink-types.h +++ b/src/libsystemd/src/sd-netlink/netlink-types.h @@ -19,7 +19,7 @@ along with systemd; If not, see . ***/ -#include "basic/macro.h" +#include "systemd-basic/macro.h" enum { NETLINK_TYPE_UNSPEC, diff --git a/src/libsystemd/src/sd-netlink/netlink-util.c b/src/libsystemd/src/sd-netlink/netlink-util.c index 9248aa0b18..4bb99b00af 100644 --- a/src/libsystemd/src/sd-netlink/netlink-util.c +++ b/src/libsystemd/src/sd-netlink/netlink-util.c @@ -17,9 +17,10 @@ along with systemd; If not, see . ***/ +#include "systemd-staging/sd-netlink.h" + #include "netlink-internal.h" #include "netlink-util.h" -#include "sd-netlink.h" int rtnl_set_link_name(sd_netlink **rtnl, int ifindex, const char *name) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; diff --git a/src/libsystemd/src/sd-netlink/netlink-util.h b/src/libsystemd/src/sd-netlink/netlink-util.h index c9b932f994..9fc80af61d 100644 --- a/src/libsystemd/src/sd-netlink/netlink-util.h +++ b/src/libsystemd/src/sd-netlink/netlink-util.h @@ -19,9 +19,8 @@ along with systemd; If not, see . ***/ -#include "basic/util.h" - -#include "sd-netlink.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" int rtnl_message_new_synthetic_error(int error, uint32_t serial, sd_netlink_message **ret); uint32_t rtnl_message_get_serial(sd_netlink_message *m); diff --git a/src/libsystemd/src/sd-netlink/rtnl-message.c b/src/libsystemd/src/sd-netlink/rtnl-message.c index 42178e5706..315da4f0ca 100644 --- a/src/libsystemd/src/sd-netlink/rtnl-message.c +++ b/src/libsystemd/src/sd-netlink/rtnl-message.c @@ -21,16 +21,16 @@ #include #include -#include "basic/formats-util.h" -#include "basic/missing.h" -#include "basic/refcnt.h" -#include "basic/socket-util.h" -#include "basic/util.h" +#include "systemd-basic/formats-util.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/refcnt.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-internal.h" #include "netlink-types.h" #include "netlink-util.h" -#include "sd-netlink.h" int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen) { struct rtmsg *rtm; diff --git a/src/libsystemd/src/sd-netlink/sd-netlink.c b/src/libsystemd/src/sd-netlink/sd-netlink.c index d78777397e..4999f59d24 100644 --- a/src/libsystemd/src/sd-netlink/sd-netlink.c +++ b/src/libsystemd/src/sd-netlink/sd-netlink.c @@ -20,17 +20,17 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/hashmap.h" -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/socket-util.h" -#include "basic/util.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/hashmap.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-internal.h" #include "netlink-util.h" -#include "sd-netlink.h" static int sd_netlink_new(sd_netlink **ret) { _cleanup_(sd_netlink_unrefp) sd_netlink *rtnl = NULL; diff --git a/src/libsystemd/src/sd-netlink/sd-netlink.h b/src/libsystemd/src/sd-netlink/sd-netlink.h deleted file mode 100644 index 7db35e1756..0000000000 --- a/src/libsystemd/src/sd-netlink/sd-netlink.h +++ /dev/null @@ -1,163 +0,0 @@ -#ifndef foosdnetlinkhfoo -#define foosdnetlinkhfoo - -/*** - This file is part of systemd. - - Copyright 2013 Tom Gundersen - - 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 . -***/ - -#include -#include -#include - -#include -#include - -#include -#include - -_SD_BEGIN_DECLARATIONS; - -typedef struct sd_netlink sd_netlink; -typedef struct sd_netlink_message sd_netlink_message; - -/* callback */ - -typedef int (*sd_netlink_message_handler_t)(sd_netlink *nl, sd_netlink_message *m, void *userdata); - -/* bus */ -int sd_netlink_new_from_netlink(sd_netlink **nl, int fd); -int sd_netlink_open(sd_netlink **nl); -int sd_netlink_open_fd(sd_netlink **nl, int fd); -int sd_netlink_inc_rcvbuf(sd_netlink *nl, const size_t size); - -sd_netlink *sd_netlink_ref(sd_netlink *nl); -sd_netlink *sd_netlink_unref(sd_netlink *nl); - -int sd_netlink_send(sd_netlink *nl, sd_netlink_message *message, uint32_t *serial); -int sd_netlink_call_async(sd_netlink *nl, sd_netlink_message *message, - sd_netlink_message_handler_t callback, - void *userdata, uint64_t usec, uint32_t *serial); -int sd_netlink_call_async_cancel(sd_netlink *nl, uint32_t serial); -int sd_netlink_call(sd_netlink *nl, sd_netlink_message *message, uint64_t timeout, - sd_netlink_message **reply); - -int sd_netlink_get_events(sd_netlink *nl); -int sd_netlink_get_timeout(sd_netlink *nl, uint64_t *timeout); -int sd_netlink_process(sd_netlink *nl, sd_netlink_message **ret); -int sd_netlink_wait(sd_netlink *nl, uint64_t timeout); - -int sd_netlink_add_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata); -int sd_netlink_remove_match(sd_netlink *nl, uint16_t match, sd_netlink_message_handler_t c, void *userdata); - -int sd_netlink_attach_event(sd_netlink *nl, sd_event *e, int64_t priority); -int sd_netlink_detach_event(sd_netlink *nl); - -int sd_netlink_message_append_string(sd_netlink_message *m, unsigned short type, const char *data); -int sd_netlink_message_append_flag(sd_netlink_message *m, unsigned short type); -int sd_netlink_message_append_u8(sd_netlink_message *m, unsigned short type, uint8_t data); -int sd_netlink_message_append_u16(sd_netlink_message *m, unsigned short type, uint16_t data); -int sd_netlink_message_append_u32(sd_netlink_message *m, unsigned short type, uint32_t data); -int sd_netlink_message_append_data(sd_netlink_message *m, unsigned short type, const void *data, size_t len); -int sd_netlink_message_append_in_addr(sd_netlink_message *m, unsigned short type, const struct in_addr *data); -int sd_netlink_message_append_in6_addr(sd_netlink_message *m, unsigned short type, const struct in6_addr *data); -int sd_netlink_message_append_ether_addr(sd_netlink_message *m, unsigned short type, const struct ether_addr *data); -int sd_netlink_message_append_cache_info(sd_netlink_message *m, unsigned short type, const struct ifa_cacheinfo *info); - -int sd_netlink_message_open_container(sd_netlink_message *m, unsigned short type); -int sd_netlink_message_open_container_union(sd_netlink_message *m, unsigned short type, const char *key); -int sd_netlink_message_close_container(sd_netlink_message *m); - -int sd_netlink_message_read_string(sd_netlink_message *m, unsigned short type, const char **data); -int sd_netlink_message_read_u8(sd_netlink_message *m, unsigned short type, uint8_t *data); -int sd_netlink_message_read_u16(sd_netlink_message *m, unsigned short type, uint16_t *data); -int sd_netlink_message_read_u32(sd_netlink_message *m, unsigned short type, uint32_t *data); -int sd_netlink_message_read_ether_addr(sd_netlink_message *m, unsigned short type, struct ether_addr *data); -int sd_netlink_message_read_cache_info(sd_netlink_message *m, unsigned short type, struct ifa_cacheinfo *info); -int sd_netlink_message_read_in_addr(sd_netlink_message *m, unsigned short type, struct in_addr *data); -int sd_netlink_message_read_in6_addr(sd_netlink_message *m, unsigned short type, struct in6_addr *data); -int sd_netlink_message_enter_container(sd_netlink_message *m, unsigned short type); -int sd_netlink_message_exit_container(sd_netlink_message *m); - -int sd_netlink_message_rewind(sd_netlink_message *m); - -sd_netlink_message *sd_netlink_message_next(sd_netlink_message *m); - -sd_netlink_message *sd_netlink_message_ref(sd_netlink_message *m); -sd_netlink_message *sd_netlink_message_unref(sd_netlink_message *m); - -int sd_netlink_message_request_dump(sd_netlink_message *m, int dump); -int sd_netlink_message_is_error(sd_netlink_message *m); -int sd_netlink_message_get_errno(sd_netlink_message *m); -int sd_netlink_message_get_type(sd_netlink_message *m, uint16_t *type); -int sd_netlink_message_set_flags(sd_netlink_message *m, uint16_t flags); -int sd_netlink_message_is_broadcast(sd_netlink_message *m); - -/* rtnl */ - -int sd_rtnl_message_new_link(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index); -int sd_rtnl_message_new_addr_update(sd_netlink *nl, sd_netlink_message **ret, int index, int family); -int sd_rtnl_message_new_addr(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int family); -int sd_rtnl_message_new_route(sd_netlink *nl, sd_netlink_message **ret, uint16_t nlmsg_type, int rtm_family, unsigned char rtm_protocol); -int sd_rtnl_message_new_neigh(sd_netlink *nl, sd_netlink_message **ret, uint16_t msg_type, int index, int nda_family); - -int sd_rtnl_message_get_family(sd_netlink_message *m, int *family); - -int sd_rtnl_message_addr_set_prefixlen(sd_netlink_message *m, unsigned char prefixlen); -int sd_rtnl_message_addr_set_scope(sd_netlink_message *m, unsigned char scope); -int sd_rtnl_message_addr_set_flags(sd_netlink_message *m, unsigned char flags); -int sd_rtnl_message_addr_get_family(sd_netlink_message *m, int *family); -int sd_rtnl_message_addr_get_prefixlen(sd_netlink_message *m, unsigned char *prefixlen); -int sd_rtnl_message_addr_get_scope(sd_netlink_message *m, unsigned char *scope); -int sd_rtnl_message_addr_get_flags(sd_netlink_message *m, unsigned char *flags); -int sd_rtnl_message_addr_get_ifindex(sd_netlink_message *m, int *ifindex); - -int sd_rtnl_message_link_set_flags(sd_netlink_message *m, unsigned flags, unsigned change); -int sd_rtnl_message_link_set_type(sd_netlink_message *m, unsigned type); -int sd_rtnl_message_link_set_family(sd_netlink_message *m, unsigned family); -int sd_rtnl_message_link_get_ifindex(sd_netlink_message *m, int *ifindex); -int sd_rtnl_message_link_get_flags(sd_netlink_message *m, unsigned *flags); -int sd_rtnl_message_link_get_type(sd_netlink_message *m, unsigned short *type); - -int sd_rtnl_message_route_set_dst_prefixlen(sd_netlink_message *m, unsigned char prefixlen); -int sd_rtnl_message_route_set_src_prefixlen(sd_netlink_message *m, unsigned char prefixlen); -int sd_rtnl_message_route_set_scope(sd_netlink_message *m, unsigned char scope); -int sd_rtnl_message_route_set_flags(sd_netlink_message *m, unsigned flags); -int sd_rtnl_message_route_set_table(sd_netlink_message *m, unsigned char table); -int sd_rtnl_message_route_get_flags(sd_netlink_message *m, unsigned *flags); -int sd_rtnl_message_route_get_family(sd_netlink_message *m, int *family); -int sd_rtnl_message_route_set_family(sd_netlink_message *m, int family); -int sd_rtnl_message_route_get_protocol(sd_netlink_message *m, unsigned char *protocol); -int sd_rtnl_message_route_get_scope(sd_netlink_message *m, unsigned char *scope); -int sd_rtnl_message_route_get_tos(sd_netlink_message *m, unsigned char *tos); -int sd_rtnl_message_route_get_table(sd_netlink_message *m, unsigned char *table); -int sd_rtnl_message_route_get_dst_prefixlen(sd_netlink_message *m, unsigned char *dst_len); -int sd_rtnl_message_route_get_src_prefixlen(sd_netlink_message *m, unsigned char *src_len); - -int sd_rtnl_message_neigh_set_flags(sd_netlink_message *m, uint8_t flags); -int sd_rtnl_message_neigh_set_state(sd_netlink_message *m, uint16_t state); -int sd_rtnl_message_neigh_get_family(sd_netlink_message *m, int *family); -int sd_rtnl_message_neigh_get_ifindex(sd_netlink_message *m, int *family); -int sd_rtnl_message_neigh_get_state(sd_netlink_message *m, uint16_t *state); -int sd_rtnl_message_neigh_get_flags(sd_netlink_message *m, uint8_t *flags); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink, sd_netlink_unref); -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_netlink_message, sd_netlink_message_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libsystemd/src/sd-netlink/test-local-addresses.c b/src/libsystemd/src/sd-netlink/test-local-addresses.c index 8755a27182..b08cac9907 100644 --- a/src/libsystemd/src/sd-netlink/test-local-addresses.c +++ b/src/libsystemd/src/sd-netlink/test-local-addresses.c @@ -17,9 +17,9 @@ along with systemd; If not, see . ***/ -#include "basic/af-list.h" -#include "basic/alloc-util.h" -#include "basic/in-addr-util.h" +#include "systemd-basic/af-list.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/in-addr-util.h" #include "local-addresses.h" diff --git a/src/libsystemd/src/sd-netlink/test-netlink.c b/src/libsystemd/src/sd-netlink/test-netlink.c index 1fde81778e..b16419a3ab 100644 --- a/src/libsystemd/src/sd-netlink/test-netlink.c +++ b/src/libsystemd/src/sd-netlink/test-netlink.c @@ -20,15 +20,15 @@ #include #include -#include "basic/ether-addr-util.h" -#include "basic/macro.h" -#include "basic/missing.h" -#include "basic/socket-util.h" -#include "basic/string-util.h" -#include "basic/util.h" +#include "systemd-basic/ether-addr-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-netlink.h" #include "netlink-util.h" -#include "sd-netlink.h" static void test_message_link_bridge(sd_netlink *rtnl) { _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *message = NULL; diff --git a/src/libsystemd/src/sd-network/network-util.c b/src/libsystemd/src/sd-network/network-util.c index ae3e51ae77..317a7ac804 100644 --- a/src/libsystemd/src/sd-network/network-util.c +++ b/src/libsystemd/src/sd-network/network-util.c @@ -17,9 +17,9 @@ along with systemd; If not, see . ***/ -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/strv.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/strv.h" #include "network-util.h" diff --git a/src/libsystemd/src/sd-network/network-util.h b/src/libsystemd/src/sd-network/network-util.h index 902be2b2e8..253a6b9934 100644 --- a/src/libsystemd/src/sd-network/network-util.h +++ b/src/libsystemd/src/sd-network/network-util.h @@ -21,6 +21,6 @@ #include -#include "sd-network.h" +#include "systemd-staging/sd-network.h" bool network_is_online(void); diff --git a/src/libsystemd/src/sd-network/sd-network.c b/src/libsystemd/src/sd-network/sd-network.c index c3755371ff..2467fdb7ff 100644 --- a/src/libsystemd/src/sd-network/sd-network.c +++ b/src/libsystemd/src/sd-network/sd-network.c @@ -23,18 +23,17 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/fileio.h" -#include "basic/fs-util.h" -#include "basic/macro.h" -#include "basic/parse-util.h" -#include "basic/stdio-util.h" -#include "basic/string-util.h" -#include "basic/strv.h" -#include "basic/util.h" - -#include "sd-network.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/fileio.h" +#include "systemd-basic/fs-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/parse-util.h" +#include "systemd-basic/stdio-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-basic/strv.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-network.h" _public_ int sd_network_get_operational_state(char **state) { _cleanup_free_ char *s = NULL; diff --git a/src/libsystemd/src/sd-network/sd-network.h b/src/libsystemd/src/sd-network/sd-network.h deleted file mode 100644 index ac2660de45..0000000000 --- a/src/libsystemd/src/sd-network/sd-network.h +++ /dev/null @@ -1,176 +0,0 @@ -#ifndef foosdnetworkhfoo -#define foosdnetworkhfoo - -/*** - This file is part of systemd. - - Copyright 2011 Lennart Poettering - Copyright 2014 Tom Gundersen - - 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 . -***/ - -#include -#include - -#include - -/* - * A few points: - * - * Instead of returning an empty string array or empty integer array, we - * may return NULL. - * - * Free the data the library returns with libc free(). String arrays - * are NULL terminated, and you need to free the array itself in - * addition to the strings contained. - * - * We return error codes as negative errno, kernel-style. On success, we - * return 0 or positive. - * - * These functions access data in /run. This is a virtual file system; - * therefore, accesses are relatively cheap. - * - * See sd-network(3) for more information. - */ - -_SD_BEGIN_DECLARATIONS; - -/* Get overall operational state - * Possible states: down, up, dormant, carrier, degraded, routable - * Possible return codes: - * -ENODATA: networkd is not aware of any links - */ -int sd_network_get_operational_state(char **state); - -/* Get DNS entries for all links. These are string representations of - * IP addresses */ -int sd_network_get_dns(char ***dns); - -/* Get NTP entries for all links. These are domain names or string - * representations of IP addresses */ -int sd_network_get_ntp(char ***ntp); - -/* Get the search domains for all links. */ -int sd_network_get_search_domains(char ***domains); - -/* Get the search domains for all links. */ -int sd_network_get_route_domains(char ***domains); - -/* Get setup state from ifindex. - * Possible states: - * pending: udev is still processing the link, we don't yet know if we will manage it - * failed: networkd failed to manage the link - * configuring: in the process of retrieving configuration or configuring the link - * configured: link configured successfully - * unmanaged: networkd is not handling the link - * linger: the link is gone, but has not yet been dropped by networkd - * Possible return codes: - * -ENODATA: networkd is not aware of the link - */ -int sd_network_link_get_setup_state(int ifindex, char **state); - -/* Get operational state from ifindex. - * Possible states: - * off: the device is powered down - * no-carrier: the device is powered up, but it does not yet have a carrier - * dormant: the device has a carrier, but is not yet ready for normal traffic - * carrier: the link has a carrier - * degraded: the link has carrier and addresses valid on the local link configured - * routable: the link has carrier and routable address configured - * Possible return codes: - * -ENODATA: networkd is not aware of the link - */ -int sd_network_link_get_operational_state(int ifindex, char **state); - -/* Get path to .network file applied to link */ -int sd_network_link_get_network_file(int ifindex, char **filename); - -/* Get DNS entries for a given link. These are string representations of - * IP addresses */ -int sd_network_link_get_dns(int ifindex, char ***ret); - -/* Get NTP entries for a given link. These are domain names or string - * representations of IP addresses */ -int sd_network_link_get_ntp(int ifindex, char ***ret); - -/* Indicates whether or not LLMNR should be enabled for the link - * Possible levels of support: yes, no, resolve - * Possible return codes: - * -ENODATA: networkd is not aware of the link - */ -int sd_network_link_get_llmnr(int ifindex, char **llmnr); - -/* Indicates whether or not MulticastDNS should be enabled for the - * link. - * Possible levels of support: yes, no, resolve - * Possible return codes: - * -ENODATA: networkd is not aware of the link - */ -int sd_network_link_get_mdns(int ifindex, char **mdns); - -/* Indicates whether or not DNSSEC should be enabled for the link - * Possible levels of support: yes, no, allow-downgrade - * Possible return codes: - * -ENODATA: networkd is not aware of the link - */ -int sd_network_link_get_dnssec(int ifindex, char **dnssec); - -/* Returns the list of per-interface DNSSEC negative trust anchors - * Possible return codes: - * -ENODATA: networkd is not aware of the link, or has no such data - */ -int sd_network_link_get_dnssec_negative_trust_anchors(int ifindex, char ***nta); - -/* Get the search DNS domain names for a given link. */ -int sd_network_link_get_search_domains(int ifindex, char ***domains); - -/* Get the route DNS domain names for a given link. */ -int sd_network_link_get_route_domains(int ifindex, char ***domains); - -/* Get the carrier interface indexes to which current link is bound to. */ -int sd_network_link_get_carrier_bound_to(int ifindex, int **ifindexes); - -/* Get the CARRIERS that are bound to current link. */ -int sd_network_link_get_carrier_bound_by(int ifindex, int **ifindexes); - -/* Get the timezone that was learnt on a specific link. */ -int sd_network_link_get_timezone(int ifindex, char **timezone); - -/* Monitor object */ -typedef struct sd_network_monitor sd_network_monitor; - -/* Create a new monitor. Category must be NULL, "links" or "leases". */ -int sd_network_monitor_new(sd_network_monitor **ret, const char *category); - -/* Destroys the passed monitor. Returns NULL. */ -sd_network_monitor* sd_network_monitor_unref(sd_network_monitor *m); - -/* Flushes the monitor */ -int sd_network_monitor_flush(sd_network_monitor *m); - -/* Get FD from monitor */ -int sd_network_monitor_get_fd(sd_network_monitor *m); - -/* Get poll() mask to monitor */ -int sd_network_monitor_get_events(sd_network_monitor *m); - -/* Get timeout for poll(), as usec value relative to CLOCK_MONOTONIC's epoch */ -int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *timeout_usec); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_network_monitor, sd_network_monitor_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libsystemd/src/sd-resolve/sd-resolve.c b/src/libsystemd/src/sd-resolve/sd-resolve.c index d638a374a1..629eeb7799 100644 --- a/src/libsystemd/src/sd-resolve/sd-resolve.c +++ b/src/libsystemd/src/sd-resolve/sd-resolve.c @@ -29,15 +29,14 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/fd-util.h" -#include "basic/io-util.h" -#include "basic/list.h" -#include "basic/missing.h" -#include "basic/socket-util.h" -#include "basic/util.h" - -#include "sd-resolve.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/fd-util.h" +#include "systemd-basic/io-util.h" +#include "systemd-basic/list.h" +#include "systemd-basic/missing.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/util.h" +#include "systemd-staging/sd-resolve.h" #define WORKERS_MIN 1U #define WORKERS_MAX 16U diff --git a/src/libsystemd/src/sd-resolve/sd-resolve.h b/src/libsystemd/src/sd-resolve/sd-resolve.h deleted file mode 100644 index 1996ae401a..0000000000 --- a/src/libsystemd/src/sd-resolve/sd-resolve.h +++ /dev/null @@ -1,116 +0,0 @@ -#ifndef foosdresolvehfoo -#define foosdresolvehfoo - -/*** - This file is part of systemd. - - Copyright 2005-2014 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 . -***/ - -#include -#include -#include -#include - -#include -#include - -_SD_BEGIN_DECLARATIONS; - -/* An opaque sd-resolve session structure */ -typedef struct sd_resolve sd_resolve; - -/* An opaque sd-resolve query structure */ -typedef struct sd_resolve_query sd_resolve_query; - -/* A callback on completion */ -typedef int (*sd_resolve_getaddrinfo_handler_t)(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata); -typedef int (*sd_resolve_getnameinfo_handler_t)(sd_resolve_query *q, int ret, const char *host, const char *serv, void *userdata); - -enum { - SD_RESOLVE_GET_HOST = UINT64_C(1), - SD_RESOLVE_GET_SERVICE = UINT64_C(2), - SD_RESOLVE_GET_BOTH = UINT64_C(3), -}; - -int sd_resolve_default(sd_resolve **ret); - -/* Allocate a new sd-resolve session. */ -int sd_resolve_new(sd_resolve **ret); - -/* Free a sd-resolve session. This destroys all attached - * sd_resolve_query objects automatically. */ -sd_resolve* sd_resolve_unref(sd_resolve *resolve); -sd_resolve* sd_resolve_ref(sd_resolve *resolve); - -/* Return the UNIX file descriptor to poll() for events on. Use this - * function to integrate sd-resolve with your custom main loop. */ -int sd_resolve_get_fd(sd_resolve *resolve); - -/* Return the poll() events (a combination of flags like POLLIN, - * POLLOUT, ...) to check for. */ -int sd_resolve_get_events(sd_resolve *resolve); - -/* Return the poll() timeout to pass. Returns (uint64_t) -1 as - * timeout if no timeout is needed. */ -int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *timeout_usec); - -/* Process pending responses. After this function is called, you can - * get the next completed query object(s) using - * sd_resolve_get_next(). */ -int sd_resolve_process(sd_resolve *resolve); - -/* Wait for a resolve event to complete. */ -int sd_resolve_wait(sd_resolve *resolve, uint64_t timeout_usec); - -int sd_resolve_get_tid(sd_resolve *resolve, pid_t *tid); - -int sd_resolve_attach_event(sd_resolve *resolve, sd_event *e, int64_t priority); -int sd_resolve_detach_event(sd_resolve *resolve); -sd_event *sd_resolve_get_event(sd_resolve *resolve); - -/* Issue a name-to-address query on the specified session. The - * arguments are compatible with those of libc's - * getaddrinfo(3). The function returns a new query object. When the - * query is completed, you may retrieve the results using - * sd_resolve_getaddrinfo_done(). */ -int sd_resolve_getaddrinfo(sd_resolve *resolve, sd_resolve_query **q, const char *node, const char *service, const struct addrinfo *hints, sd_resolve_getaddrinfo_handler_t callback, void *userdata); - -/* Issue an address-to-name query on the specified session. The - * arguments are compatible with those of libc's - * getnameinfo(3). The function returns a new query object. When the - * query is completed, you may retrieve the results using - * sd_resolve_getnameinfo_done(). Set gethost (resp. getserv) to non-zero - * if you want to query the hostname (resp. the service name). */ -int sd_resolve_getnameinfo(sd_resolve *resolve, sd_resolve_query **q, const struct sockaddr *sa, socklen_t salen, int flags, uint64_t get, sd_resolve_getnameinfo_handler_t callback, void *userdata); - -sd_resolve_query *sd_resolve_query_ref(sd_resolve_query* q); -sd_resolve_query *sd_resolve_query_unref(sd_resolve_query* q); - -/* Returns non-zero when the query operation specified by q has been completed. */ -int sd_resolve_query_is_done(sd_resolve_query*q); - -void *sd_resolve_query_get_userdata(sd_resolve_query *q); -void *sd_resolve_query_set_userdata(sd_resolve_query *q, void *userdata); - -sd_resolve *sd_resolve_query_get_resolve(sd_resolve_query *q); - -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_resolve, sd_resolve_unref); -_SD_DEFINE_POINTER_CLEANUP_FUNC(sd_resolve_query, sd_resolve_query_unref); - -_SD_END_DECLARATIONS; - -#endif diff --git a/src/libsystemd/src/sd-resolve/test-resolve.c b/src/libsystemd/src/sd-resolve/test-resolve.c index d552a48da8..0a5bba81cf 100644 --- a/src/libsystemd/src/sd-resolve/test-resolve.c +++ b/src/libsystemd/src/sd-resolve/test-resolve.c @@ -26,12 +26,11 @@ #include #include -#include "basic/alloc-util.h" -#include "basic/macro.h" -#include "basic/socket-util.h" -#include "basic/string-util.h" - -#include "sd-resolve.h" +#include "systemd-basic/alloc-util.h" +#include "systemd-basic/macro.h" +#include "systemd-basic/socket-util.h" +#include "systemd-basic/string-util.h" +#include "systemd-staging/sd-resolve.h" static int getaddrinfo_handler(sd_resolve_query *q, int ret, const struct addrinfo *ai, void *userdata) { const struct addrinfo *i; diff --git a/src/libsystemd/src/subdir.mk b/src/libsystemd/src/subdir.mk index 71691e8dac..73c05740ce 100644 --- a/src/libsystemd/src/subdir.mk +++ b/src/libsystemd/src/subdir.mk @@ -25,8 +25,7 @@ include $(dir $(lastword $(MAKEFILE_LIST)))/../../../../config.mk include $(topsrcdir)/build-aux/Makefile.head.mk sd.CPPFLAGS += $(libsystemd.CPPFLAGS) -sd.CPPFLAGS += $(libbasic.CPPFLAGS) -sd.CPPFLAGS += $(libshared.CPPFLAGS) -sd.CPPFLAGS += -DUDEVLIBEXECDIR=\"$(udevlibexecdir)\" +sd.CPPFLAGS += $(libsystemd-staging.CPPFLAGS) +sd.CPPFLAGS += $(libsystemd-basic.CPPFLAGS) include $(topsrcdir)/build-aux/Makefile.tail.mk diff --git a/src/libsystemd/src/test.mk b/src/libsystemd/src/test.mk index e75904d554..1a5917121e 100644 --- a/src/libsystemd/src/test.mk +++ b/src/libsystemd/src/test.mk @@ -71,7 +71,7 @@ test_bus_error_SOURCES = \ # Link statically because this test uses BUS_ERROR_MAP_ELF_REGISTER test_bus_error_LDADD = \ - libshared.la + libsystemd-shared.la test_bus_gvariant_SOURCES = \ src/libsystemd/sd-bus/test-bus-gvariant.c -- cgit v1.2.3-54-g00ecf