Commit graph

12286 commits

Author SHA1 Message Date
Daniel Mack 106784ebb7 resolved: use switch-case statements for protocol details
With more protocols to come, switch repetitive if-else blocks with a
switch-case statements.
2015-08-25 14:25:56 +02:00
Daniel Mack 8326c7f789 resolved: remove runtime check for previously asserted condition 2015-08-25 10:18:45 +02:00
Lennart Poettering 9318cdd374 resolved: change error code when trying to resolve direct LLMNR PTR RRs
If we try to resoolve an LLMNR PTR RR we shall connect via TCP directly
to the specified IP address. We already refuse to do this if the address
to resolve is of a different address family as the transaction's scope.
The error returned was EAFNOSUPPORT. Let's change this to ESRCH which is
how we indicate "not server available" when connecting for LLMNR or DNS,
since that's what this really is: we have no server we could connect to
in this address family.

This allows us to ensure that no server errors are always handled the same
way.
2015-08-24 23:47:28 +02:00
Lennart Poettering 3fa4999b5d resolve-host: support parsing numeric interface names
If the user specifies an interface by its ifindex we should handle this
nicely. Hence let's try to parse the ifindex as a number before we try
to resolve it as an interface name.
2015-08-24 23:46:24 +02:00
Lennart Poettering d634711b26 resolved: remove duplicate handling of "no servers" query result
So far we handled immediate "no server" query results differently from
"no server" results we ran into during operation: the former would cause
the dns_query_go() call to fail with ESRCH, the later would result in
the query completion callback to be called.

Remove the duplicate codepaths, by always going through the completion
callback. This allows us to remove quite a number of lines for handling
the ESRCH.

This commit should not alter behaviour at all.
2015-08-24 23:44:33 +02:00
Lennart Poettering da0c630e14 resolved: replace transaction list by hashmap
Right now we keep track of ongoing transactions in a linked listed for
each scope. Replace this by a hashmap that is indexed by the RR key.
Given that all ongoing transactions will be placed in pretty much the
same scopes usually this should optimize behaviour.

We used to require a list here, since we wanted to do "superset" query
checks, but this became obsolete since transactions are now single-key
instead of multi-key.
2015-08-24 23:15:51 +02:00
Tom Gundersen 53496ca9ad Merge pull request #1012 from gentoo-root/master
sd-device: fix enumeration of devices without subsystem
2015-08-24 18:37:02 +02:00
David Herrmann 1105ea51a8 sd-bus: don't list activators as proper peers
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-24 13:41:03 +02:00
David Herrmann f2196cf2e2 Revert "sd-bus: include queried path in GetManagedObjects"
This reverts commit 92d16a53e3. 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-24 12:56:37 +02:00
Maxim Mikityanskiy 9a9c7dc2cb sd-device: fix enumeration of devices without subsystem
Prior to commit c32eb440ba, 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 96df036fe3,
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-22 11:33:32 +03:00
Tom Gundersen 72aa2c2a20 Merge pull request #1010 from poettering/resolved-question-key
only maintain one question RR key per transaction and other fixes
2015-08-22 01:57:58 +02:00
Lennart Poettering 26b1c471cd resolved: always split up questions into per-RR transactions
We do so for Unicast DNS and LLMNR anyway, let's also do this for mDNS,
and simplify things.
2015-08-21 23:01:42 +02:00
Lennart Poettering f52e61da04 resolved: only maintain one question RR key per transaction
Let's simplify things and only maintain a single RR key per transaction
object, instead of a full DnsQuestion. Unicast DNS and LLMNR don't
support multiple questions per packet anway, and Multicast DNS suggests
coalescing questions beyond a single dns query, across the whole system.
2015-08-21 22:55:01 +02:00
Lennart Poettering 9e08a6e0ce resolved: add extra check for family when doing LLMNR TCP connections
It shouldn't happen that we try to resolve IPv4 addresses via LLMNR on
IPv6 and vice versa, but let's explicitly verify that we don't turn an
IPv4 LLMNR lookup into an IPv6 TCP connection.
2015-08-21 22:51:05 +02:00
Lennart Poettering 0a18f3e59f resolved: add reference to negative caching RFC 2015-08-21 22:47:06 +02:00
Thomas Hindoe Paaboel Andersen 62f176068c remove unused variables 2015-08-21 22:19:10 +02:00
Tom Gundersen 932b06b8ff Merge pull request #1005 from poettering/resolved-refuse-compression
Don't do name compression when passing RRs across the bus
2015-08-21 16:23:02 +02:00
Lennart Poettering 09b1fe142b resolve-host: Minor wording improvement 2015-08-21 16:06:25 +02:00
Lennart Poettering f6a5fec6b9 resolved: when passing RRs across the bus, make sure not to use name compression
We explicitly need to turn off name compression when marshalling or
demarshalling RRs for bus transfer, since they otherwise refer to packet
offsets that reference packets that are not transmitted themselves.
2015-08-21 16:04:59 +02:00
Lennart Poettering 149730fc75 core: downgrade "Module inserted" message for kmod to DEBUG
Closes #919.
2015-08-21 15:28:01 +02:00
Tom Gundersen ef7051360a Merge pull request #1002 from poettering/resolved-various
resolved: synthesize more RRs locally and other fixes
2015-08-21 15:26:45 +02:00
Lennart Poettering 78c6a153c4 resolved: rework synthesizing logic
With this change we'll now also generate synthesized RRs for the local
LLMNR hostname (first label of system hostname), the local mDNS hostname
(first label of system hostname suffixed with .local), the "gateway"
hostname and all the reverse PTRs. This hence takes over part of what
nss-myhostname already implemented.

Local hostnames resolve to the set of local IP addresses. Since the
addresses are possibly on different interfaces it is necessary to change
the internal DnsAnswer object to track per-RR interface indexes, and to
change the bus API to always return the interface per-address rather than
per-reply. This change also patches  the existing clients for resolved
accordingly (nss-resolve + systemd-resolve-host).

This also changes the routing logic for queries slightly: we now ensure
that the local hostname is never resolved via LLMNR, thus making it
trustable on the local system.
2015-08-21 12:41:08 +02:00
Lennart Poettering 8013e860b6 resolved: make DnsQuestion logic handle NULL arrays as empty arrays
Following our usual logic of treating NULL arrays as empty arrays (for
example, see strv.c) do the same for questions too.
2015-08-21 12:41:08 +02:00
Lennart Poettering a8f6397f53 resolved: minor typo comment fix 2015-08-21 12:41:08 +02:00
Lennart Poettering 9ca45586e6 dns-domain: add call for concatenating two domain names
This is specifically useful for appending the mDNS ".local" suffix to a
single-label hostname in the most correct way. (used in later commit)
2015-08-21 12:41:07 +02:00
Lennart Poettering 46a5e0e742 hostname-util: introduce new is_gateway_hostname() call
This moves is_gateway() from nss-myhostname into the basic APIs, and
makes it more like is_localhost(). Also, we rename it to
is_gateway_hostname() to make it more expressive.

Sharing this function in src/basic/ allows us to reuse the function for
routing name requests in resolved (in a later commit).
2015-08-21 12:07:13 +02:00
Patrik Flykt 07bdc70d16 network: Save DNS and NTP data for a DHCPv6 link
Append DNS and NTP data obtained via DHCPv6 when the Link is saved.
2015-08-21 11:23:22 +03:00
Patrik Flykt b729fa14aa network: Add function to serialize an IPv6 address 2015-08-21 11:23:22 +03:00
Patrik Flykt bc152ff879 test-dhcp6-client: Add tests for DNS and NTP options
Test option setting and getting in test_advertise_option(). Verify
that the information provided in DHCPv6 Reply messages is also
available in the Information and Solicit callbacks.
2015-08-21 11:23:22 +03:00
Patrik Flykt 41e4615d4f sd-dhcp6: Support deprecated SNTP Configuration Option
Although the SNTP option specified in RFC 4075 has been deprecated, some
servers are still sending NTP information with this option. Use the SNTP
information provided only if the NTP option is not present.

Update the test case as SNTP information is also requested.
2015-08-21 11:23:22 +03:00
Patrik Flykt 6599680e2d sd-dhcp6: Add support for DHCPv6 NTP Server Option
Support NTP server and multicast addresses and NTP server domain names
as specified in RFC 5908.
2015-08-21 11:23:22 +03:00
Patrik Flykt 5da1b97f3c sd-dhcp6: Add support for DHCPv6 DNS Domain Search List option
Support DHCPv6 DNS search list option as specified in RFC 3646. This
option contains a list of DNS search domains encoded without compression
as specified in Section 8. of RFC 3315.
2015-08-21 11:23:22 +03:00
Patrik Flykt 7bd8e95d44 sd-dhcp6: Add support for DHCPv6 DNS Recursive Name Server option
Support DHCPv6 DNS server option as specified in RFC 3646. This option
contains a list of IPv6 DNS server addresses.
2015-08-21 11:23:21 +03:00
Patrik Flykt f96ccab7e0 dhcp6-option: Add helper function for uncompressed domain names
Add a helper function containing a modified version of dns_packet_read_name()
that does not use DnsPacket to extract a string array of domain names from
the provided option data. The domain names are stored uncompressed as defined
in Section 8. of RFC 3315.
2015-08-21 11:23:21 +03:00
Patrik Flykt b553817ccf dhcp6-option: Add helper function for fetching IPv6 addresses
Add a helper function that extracts a block of IPv6 addresses from
the provided option data.
2015-08-21 11:23:21 +03:00
Patrik Flykt 9d89d1ae71 sd-dhcp6-client: Save a DHCPv6 lease also with Information Reply
As the lease structure contains interesting information, save it also
for the Information Reply.
2015-08-21 11:23:21 +03:00
Patrik Flykt 4e3e6679e8 sd-dhcp6-client: Fix unreferencing DHCPv6 lease on client reset
When the DHCPv6 client is started by the library user or stopped for
any reason, unref the DHCPv6 lease when resetting the DHCPv6 client
data structure. This makes the DHCPv6 client always start from a clean
state and not keep unnecessary an lease structure around when stopped.

If this is not done, a previously existing lease information can be
interpreted to be from another server when restarting DHCPv6.
2015-08-21 11:23:21 +03:00
Lennart Poettering bdeb9e603a timedatectl: when no timezone is set consider UTC the default
This fixes #993, and ensures that the libc does not consider any
old timezone information into account, that was set earlier.
2015-08-20 12:18:26 +02:00
David Herrmann 2c04e5c7e5 Merge pull request #990 from owtaylor/issue-989
Issue 989 - logind: VT is not properly reset on session close
2015-08-19 16:40:54 +02:00
Dimitri John Ledkov 8c4fa32acf timedatectl: assert timezone is not null in setenv() call.
setenv is declared as:

extern int setenv (const char *__name, const char *__value, int __replace)
     __THROW __nonnull ((2));

And i->timezone can be NULL, if for example /etc/localtime is
missing. Previously that worked, but now result in a libc dumping
core, as seen with gcc 2.22, due to:

https://sourceware.org/ml/glibc-cvs/2015-q2/msg00075.html
2015-08-19 10:04:00 +00:00
Owen W. Taylor 128df4cfe9 logind: get a fresh file descriptor to clean up a VT
When the controlling process exits, any existing file descriptors
for that FD will be marked as hung-up and ioctls on them will
file with EIO. To work around this, open a new file descriptor
for the VT we want to clean up.

Thanks to Ray Strode for help in sorting out the problem and
coming up with a fix!

https://github.com/systemd/systemd/issues/989
2015-08-18 15:26:11 -04:00
Owen W. Taylor 2235695335 logind: use open_terminal() instead of open()
The open_terminal() function adds retries in case a terminal
is in the process of being closed when we open it, and should
generally be used to open a terminal. We especially need it
for code that a subsequent commit adds that reopens the terminal
at session shut-down time; such races would be more likely in
that case.

Found by Ray Strode.
2015-08-18 15:25:57 -04:00
Daniel Mack 91a8a10809 journal: fix json output of unicode characters 2015-08-18 16:26:11 +02:00
Thomas Hindoe Paaboel Andersen b2b46f91db journal: remove error check that never happens
remove_directory will always return 0 so this can never happen.
Besides that, d->path and d are freed so we would end up with
a null pointer dereference anyway.
2015-08-18 00:11:16 +02:00
Lennart Poettering f90c90b4a1 Merge pull request #977 from richardmaw-codethink/machinectl-userns-login-v2
Fix machinectl login with containers in user namespaces (v2)
2015-08-17 15:12:15 +02:00
Lennart Poettering aaa2a3abf9 Merge pull request #976 from elfring/Remove_unnecessary_checks2
Delete unnecessary checks before some function calls
2015-08-17 11:30:31 +02:00
Lennart Poettering 22175a39e8 Merge pull request #958 from stefwalter/fix-journalctl-f-regression
Regression: 'journalctl -f -t unmatched' doesn't block properly
2015-08-17 11:19:14 +02:00
Richard Maw 671c341958 namespace helpers: Allow entering a UID namespace
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-17 08:52:13 +00:00
Markus Elfring 3e044c492e Bug #944: Deletion of unnecessary checks before a few calls of systemd functions
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-17 10:45:30 +02:00
Daniel Mack e503467fa0 Merge pull request #953 from poettering/ebadf
tree-wide: generate EBADF when we get invalid fds
2015-08-17 10:10:04 +02:00