summaryrefslogtreecommitdiff
path: root/src/libsystemd
AgeCommit message (Collapse)Author
2015-08-27sd-bus: it's not a user error to query the error contained in a bus messageLennart Poettering
It's an OK way to check whether a message contains an erro, let's not consider this a loggable assertion event.
2015-08-26dhcp,network: implement RFC 4833 (DHCP Timezone option)Lennart Poettering
This one is simply to add: encode the tzdata timezone in the DHCP options and optionally make use of it.
2015-08-24machined: validate machine names at more placesLennart Poettering
When enumerating machines from /run, and when accepting machine names for operations, be more strict and always validate. Note that these checks are strictly speaking unnecessary, since enumeration happens only on the trusted /run...
2015-08-24util: make machine_name_is_valid() a macro and move it to hostname-util.hLennart Poettering
As it turns out machine_name_is_valid() does the exact same thing as hostname_is_valid() these days, as it just invoked that and checked the name length was < 64. However, hostname_is_valid() checks the length against HOST_NAME_MAX anyway (which is 64 on Linux), hence any additional check is redundant. We hence replace machine_name_is_valid() by a macro that simply maps it to hostname_is_valid() but sets the allow_trailing_dot parameter to false. We also move this this call to hostname-util.h, to the same place as the hostname_is_valid() declaration.
2015-08-24Merge pull request #1012 from gentoo-root/masterTom Gundersen
sd-device: fix enumeration of devices without subsystem
2015-08-24sd-bus: don't list activators as proper peersDavid Herrmann
If a connection passed KDBUS_HELLO_ACTIVATOR, it cannot do I/O on the bus. Hence, we should not treat it as proper peer. To actually query it, you have to explicitly ask for activators. This makes kdbus in-line with what dbus-daemon does.
2015-08-24Revert "sd-bus: include queried path in GetManagedObjects"David Herrmann
This reverts commit 92d16a53e385781a55d9231d9f8f89c1747ab0e4. As it turns out, this is not how ObjectManager is supposed to work. It is just a special behavior of BlueZ, but no-one else implements it this way. Revert the patch as discussed on github, and as such revert to the previous behavior (as described in the spec).
2015-08-22sd-device: fix enumeration of devices without subsystemMaxim Mikityanskiy
Prior to commit c32eb440bab953a0169cd207dfef5cad16dfb340, libudev's function udev_enumerate_scan_devices() had behaved differently. If parent match was added with udev_enumerate_add_match_parent(), udev_enumerate_scan_devices() did not return error if some child devices had no subsystem symlink in sysfs. An example of such devices is USB endpoints /sys/bus/usb/devices/*/ep_*. If there was a parent match against USB device, old implementation of udev_enumerate_scan_devices() did not treat ep_* device directories without subsystem symlink as error and just ignored them, but new implementation returns -ENOENT (also ignoring these devices) though correctly enumerates all other matching devices. To compare, you could look at 96df036fe3d25525a44f5efdb2fc8560e82e6cfd, in src/libudev/libudev-enumerate.c, function parent_add_child(): if (!match_subsystem(enumerate, udev_device_get_subsystem(dev))) goto nomatch; udev_device_get_subsystem() was returning NULL, match_subsystem() was returning false, and USB endpoint device was ignored. New parent_add_child() from src/libsystemd/sd-device/device-enumerator.c checks return value of sd_device_get_subsystem() and fails if subsystem was not found. Absence of subsystem symlink should not be really treated as error because all enumerations of children of USB devices will fail with -ENOENT. This new behavior also breaks system-config-printer. So restore old behavior and treat absence of subsystem symlink as no match.
2015-08-17Merge pull request #977 from richardmaw-codethink/machinectl-userns-login-v2Lennart Poettering
Fix machinectl login with containers in user namespaces (v2)
2015-08-17Merge pull request #976 from elfring/Remove_unnecessary_checks2Lennart Poettering
Delete unnecessary checks before some function calls
2015-08-17namespace helpers: Allow entering a UID namespaceRichard Maw
To be able to use `systemd-run` or `machinectl login` on a container that is in a private user namespace, the sub-process must have entered the user namespace before connecting to the container's D-Bus, otherwise the UID and GID in the peer credentials are garbage. So we extend namespace_open and namespace_enter to support UID namespaces, and we enter the UID namespace in bus_container_connect_{socket,kernel}. namespace_open will degrade to a no-op if user namespaces are not enabled in the kernel. Special handling is required for the setns call in namespace_enter with a user namespace, since transitioning to your own namespace is forbidden, as it would result in re-entering your user namespace as root. Arguably it may be valid to check this at the call site, rather than inside namespace_enter, but it is less code to do it inside, and if the intention of calling namespace_enter is to *be* in the target namespace, rather than to transition to the target namespace, it is a reasonable approach. The check for whether the user namespace is the same must happen before entering namespaces, as we may not be able to access /proc during the intermediate transition stage. We can't instead attempt to enter the user namespace and then ignore the failure from it being the same namespace, since the error code is not distinct, and we can't compare namespaces while mid-transition.
2015-08-17Bug #944: Deletion of unnecessary checks before a few calls of systemd functionsMarkus Elfring
The following functions return immediately if a null pointer was passed. * calendar_spec_free * link_address_free * manager_free * sd_bus_unref * sd_journal_close * udev_monitor_unref * udev_unref It is therefore not needed that a function caller repeats a corresponding check. This issue was fixed by using the software Coccinelle 1.0.1.
2015-08-17Merge pull request #953 from poettering/ebadfDaniel Mack
tree-wide: generate EBADF when we get invalid fds
2015-08-17Bug #944: Replacement of a free() call by mfree()Markus Elfring
The function "mfree" should be called instead of "free" at a specific source code place.
2015-08-16sd-bus: always fill in sd_bus_error paramters, on errorLennart Poettering
Whenever one of our calls is invoked with a non-NULL, writable sd_bus_error parameter, let's fill in some valid error on failure. We previously only filled in remote errors, but never local errors, which is hard to handle by users. Hence, let's clean this up to always fill in the error. This introduces a new bus_assert_return() macro that works like assert_return() but optionally also initializes a bus_error struct. Fixes #224. Based on a patch by Umut Tezduyar.
2015-08-16Merge pull request #932 from kaysievers/busLennart Poettering
sd-bus: do not connect to dbus-1 socket when kdbus is available
2015-08-14tree-wide: generate EBADF when we get invalid fdsLennart Poettering
This is a follow-up to #907, and makes the same change for all our other public APIs.
2015-08-13Merge pull request #907 from keszybz/sd-daemon-badfLennart Poettering
sd-daemon: return EBADF for invalid fd numbers
2015-08-12Merge pull request #939 from karelzak/smatchTom Gundersen
treewide: trivial issues detected by smatch
2015-08-11 sd-bus: do not connect to dbus-1 socket when kdbus is availableKay Sievers
We should not fall back to dbus-1 and connect to the proxy when kdbus returns an error that indicates that kdbus is running but just does not accept new connections because of quota limits or something similar. Using is_kdbus_available() in libsystemd/ requires it to move from shared/ to libsystemd/. Based on a patch from David Herrmann: https://github.com/systemd/systemd/pull/886
2015-08-08Coverity #1299015reverendhomer
bus can never be NULL due to assert
2015-08-07sd-daemon: return EBADF for invalid fd numbersZbigniew Jędrzejewski-Szmek
This matches what open(2) and other system functions do.
2015-08-06sd-bus: ignore BLOOM_FILTER kdbus itemsLennart Poettering
The kernel nowadays sends these along, and that's OK, hence don't even debug log about it, but completely ignore it.
2015-08-06libsystemd: fix RTNL_CONTAINER_DEPTH assertKarel Zak
The m->n_containers is index and has to be smaller than the array size.
2015-08-06tree-wide: fix indentationThomas Hindoe Paaboel Andersen
2015-08-03sd-event: make sure sd_event_now() cannot failLennart Poettering
Previously, if the event loop never ran before sd_event_now() would fail. With this change it will instead fall back to invoking now(). This way, the function cannot fail anymore, except for programming error when invoking it with wrong parameters. This takes into account the fact that many callers did not handle the error condition correctly, and if the callers did, then they kept simply invoking now() as fall back on their own. Hence let's shorten the code using this call, and make things more robust, and let's just fall back to now() internally. Whether now() is used or the cache timestamp may still be detected via the return value of sd_event_now(). If > 0 is returned, then the fall back to now() was used, if == 0 is returned, then the cached value was returned. This patch also simplifies many of the invocations of sd_event_now(): the manual fall back to now() can be removed. Also, in cases where the call is invoked withing void functions we can now protect the invocation via assert_se(), acknowledging the fact that the call cannot fail anymore except for programming errors with the parameters. This change is inspired by #841.
2015-08-02sd-bus: cleanup bus_reset_parsed_address()Namhyung Kim
Both strv_free() and mfree() return NULL pointer after free.
2015-08-02sd-bus: use mfree() in bus_reset_queues()Namhyung Kim
Recently mfree() was introduced to reduce work of tedious free + reset pointers. Use it in bus_reset_queues() too.
2015-08-02sd-bus: cleanup bus_close_fds()Namhyung Kim
The safe_close() already checks the fd and returns -1.
2015-07-31Merge pull request #813 from dvdhrm/bus-clientLennart Poettering
busctl: make sure --address connects as bus-client
2015-07-31Merge pull request #814 from dvdhrm/mfreeDaniel Mack
tree-wide: introduce mfree()
2015-07-31busctl: make sure --address connects as bus-clientDavid Herrmann
There is really no reason to use `busctl` to connect to legacy private bus endpoints. Fix this and make sure `busctl --address=unix:path=/foo` works!
2015-07-31tree-wide: introduce mfree()David Herrmann
Pretty trivial helper which wraps free() but returns NULL, so we can simplify this: free(foobar); foobar = NULL; to this: foobar = mfree(foobar);
2015-08-01busctl: fix assertion failure on --size optionNamhyung Kim
Using --size option triggers an assert failure below because parse_size() requires the second argument, base, being either 1000 or 1024. As it's for a packet size, it'd be better using IEC binary suffix (base 1024) IMHO. $ busctl --size 2048 Assertion 'base == 1000 || base == 1024' failed at src/basic/util.c:2222, function parse_size(). Aborting. Aborted (core dumped)
2015-08-01busctl: add missing description of --size optionNamhyung Kim
The size option was to specify maximum captured patch length but was missing its description in the command line help. Add it.
2015-08-01busctl: add and use strcmp_ptr()Namhyung Kim
In member_compare_func(), it compares interface, type and name of members. But as it can contain NULL pointer, it needs to check them before calling strcmp(). So make it as a separate strcmp_ptr function (named after streq_ptr) so that it can be used by others. Also let streq_ptr() to use it in order to make the code simpler.
2015-07-31bus-proxy: fix NameAcquired and NameLost to be directedDavid Herrmann
The NameAcquired and NameLost signals are _directed_ signals. Make sure we properly set the destination correctly, and verify it in our proxy-test.
2015-07-30Merge pull request #787 from dvdhrm/bus-listDaniel Mack
sd-bus: fix parsing of KDBUS_CMD_LIST
2015-07-30sd-bus: fix parsing of KDBUS_CMD_LISTDavid Herrmann
We *must not* assume that an entry returned by KDBUS_CMD_LIST only carries a single KDBUS_ITEM_OWNED_NAME. Similarly, we already parse multiple such items for message-metadata, so make sure we support the same on KDBUS_CMD_LIST. By relying on the kernel to return all names separately, we limit the kernel API significantly. Stop this and let the kernel decide how to return its data.
2015-07-30tree-wide: use free_and_strdup()Daniel Mack
Use free_and_strdup() where appropriate and replace equivalent, open-coded versions.
2015-07-29Merge pull request #779 from poettering/fflush-and-checkDaniel Mack
tree-wide: port everything over to fflush_and_check()
2015-07-29Merge pull request #764 from ssahani/vxlan1Tom Gundersen
networkd: Add VXLAN Netlink attributes
2015-07-29tree-wide: port everything over to fflush_and_check()Lennart Poettering
Some places invoked fflush() directly with their own manual error checking, let's unify all that by using fflush_and_check(). This also unifies the general error paths of fflush()+rename() file writers.
2015-07-29sd-bus: fix encoding/decoding gvariant root containerDavid Herrmann
The gvariant root container contains a 'variant' at the end, which embeds the whole message body. This variant *must* contain a structure so we are compatible to dbus1. Otherwise, it could encode at most 1 type, instead of a full signature. Our gvariant message parser already parses the variant-content as a structure, so we're mostly good. However, it does *not* include the opening and closing parantheses, nor does it parse them. This patch fixes the decoder to verify a message contains the parantheses, and also make the encoder add those parantheses into the marshaled message.
2015-07-29sd-bus: fix marshaling of unary typeDavid Herrmann
The unary type has a fixed size of 1 in gvariant. Make sure we properly encode it as such. Right now, we encode/decode it as empty sequence.
2015-07-29sd-bus: drop redundant codeDavid Herrmann
If c->item_size is 0, the next item to parse in a structure is empty. However, this also implies that the signature must be empty. The latter case is already handled just fine by enter_struct_or_dict_entry() so there is no reason to handle the same case in the caller.
2015-07-29sd-bus: don't assert() on valid signaturesDavid Herrmann
Right now sd_bus_message_skip() will abort execution if passed a signature of the unary type "()". Regardless whether this should be supported or not, we really must not abort. Drop the incorrect assertion and add a test-case for this.
2015-07-29sd-netlink: introduce api for new NL type NLA_FLAGSusant Sahani
2015-07-29sd-netlink: add support for new type NETLINK_TYPE_FLAGSusant Sahani
NETLINK_TYPE_FLAG is NLA_FLAG. This new type will be used in NLA_FLAG for example IFLA_VXLAN_GBP and IFLA_VXLAN_REMCSUM_NOPARTIAL
2015-07-29sd-netlink: add support for vxlan attributesSusant Sahani