Commit graph

881 commits

Author SHA1 Message Date
Susant Sahani 10452f7c93 core: introduce parse_ip_port (#4825)
1. Listed in TODO.
2. Tree wide replace safe_atou16 with parse_ip_port incase
   it's used for ports.
2016-12-06 12:21:45 +01:00
Torstein Husebø 06bf09af67 treewide: fix typos (#4802) 2016-12-02 09:20:26 -05:00
Zbigniew Jędrzejewski-Szmek c58bd76a6a tree-wide: make invocations of extract_first_word more uniform (#4627)
extract_first_words deals fine with the string being NULL, so drop the upfront
check for that.
2016-11-11 18:58:41 +01:00
Christian Hesse 01e1bb7f9c resolved: unlink private resolv.conf on exit
This fixes the logic with systemd-nspawn which checks for private
resov.conf to decide whether or not to mount it into the container.
2016-11-10 14:23:33 +01:00
Christian Hesse 604c941520 resolved: use macro for private resolve.conf
Use the macro from header file to have a single definition of the path.
2016-11-10 14:23:33 +01:00
Lennart Poettering 493fd52f1a Merge pull request #4510 from keszybz/tree-wide-cleanups
Tree wide cleanups
2016-11-03 13:59:20 -06:00
Lennart Poettering 413b05ccac resolved: properly check for the root domain
Fix-up for #4164
2016-10-24 19:04:43 +02:00
Zbigniew Jędrzejewski-Szmek 605405c6cc tree-wide: drop NULL sentinel from strjoin
This makes strjoin and strjoina more similar and avoids the useless final
argument.

spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c)

git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/'

This might have missed a few cases (spatch has a really hard time dealing
with _cleanup_ macros), but that's no big issue, they can always be fixed
later.
2016-10-23 11:43:27 -04:00
Zbigniew Jędrzejewski-Szmek 6b430fdb7c tree-wide: use mfree more 2016-10-16 23:35:39 -04:00
Thomas H. P. Andersen f68c9dd5c6 resolve: remove unsed counter (#4349)
It was introduced but never used in 45ec7efb.
2016-10-11 13:51:03 -04:00
Thomas H. P. Andersen 01b0669e9a resolved: initialize variable (#4338)
r was not initialized and would be used if "tcp" was the only option
used for the stub. We should initialize it to 0 to indicate that no
error happened in the udp case.
2016-10-10 20:12:40 -04:00
Zbigniew Jędrzejewski-Szmek 0f4db364c9 resolved: also disable stub listener on EPERM
When running in a user namespace without private networking, resolved would
fail to start. There isn't much difference between EADDRINUSE and EPERM,
so treat them the same, except for the warning message text.
2016-10-09 21:22:23 -04:00
Zbigniew Jędrzejewski-Szmek 424e490b94 resolved: simplify error handling in manager_dns_stub_{udp,tcp}_fd()
Make sure an error is always printed… When systemd-resolved is started in a
user namespace without private network, it would fail on setsockopt, but the
error wouldn't be particularly informative:
"Failed to start manager: permission denied."
2016-10-09 21:22:23 -04:00
Stefan Schweter a60f4d0b44 systemd-resolve: use sha256 for local-part of openpgp key (#4193) 2016-10-08 13:59:34 +02:00
Lennart Poettering 3157b2d9d2 Merge pull request #4061 from dm0-/coreos-1545
resolved: add an option to disable the stub resolver
2016-10-07 23:38:03 +02:00
David Michael 1ae4329575 resolved: add an option to control the DNS stub listener 2016-10-07 12:14:38 -07:00
Lennart Poettering 7429b2eb83 tree-wide: drop some misleading compiler warnings
gcc at some optimization levels thinks thes variables were used without
initialization. it's wrong, but let's make the message go anyway.
2016-10-06 19:04:10 +02:00
Lennart Poettering 6f21e066f6 resolved: properly handle BADCOOKIE DNS error
Add this new error code (documented in RFC7873) to our list of known errors.
2016-10-06 19:04:09 +02:00
Martin Pitt b9fe94cad9 resolved: don't query domain-limited DNS servers for other domains (#3621)
DNS servers which have route-only domains should only be used for
the specified domains. Routing queries about other domains there is a privacy
violation, prone to fail (as that DNS server was not meant to be used for other
domains), and puts unnecessary load onto that server.

Introduce a new helper function dns_server_limited_domains() that checks if the
DNS server should only be used for some selected domains, i. e. has some
route-only domains without "~.". Use that when determining whether to query it
in the scope, and when writing resolv.conf.

Extend the test_route_only_dns() case to ensure that the DNS server limited to
~company does not appear in resolv.conf. Add test_route_only_dns_all_domains()
to ensure that a server that also has ~. does appear in resolv.conf as global
name server. These reproduce #3420.

Add a new test_resolved_domain_restricted_dns() test case that verifies that
domain-limited DNS servers are only being used for those domains. This
reproduces #3421.

Clarify what a "routing domain" is in the manpage.

Fixes #3420
Fixes #3421
2016-09-30 09:30:08 +02:00
Zbigniew Jędrzejewski-Szmek 43688c49d1 tree-wide: rename config_parse_many to …_nulstr
In preparation for adding a version which takes a strv.
2016-09-16 10:32:03 -04:00
David Michael 07f264e40a resolved: directly include some required headers instead of inheriting 2016-08-31 15:33:21 -07:00
David Michael 082d0c5ced resolved: remove unused prototype 2016-08-31 13:18:59 -07:00
Lennart Poettering f07529fe7d resolved: include d.f.ip6.arpa in default NTA list
Fixes: #4049
2016-08-31 20:12:11 +02:00
Zbigniew Jędrzejewski-Szmek 90b4a64d77 nspawn,resolve: short --help output to fit within 80 columns
make dist-check-help FTW!
2016-08-04 09:03:42 -04:00
Thomas Hindoe Paaboel Andersen 12c40d4cc4 resolved: replace bitwise and with logical and 2016-07-18 22:42:13 +02:00
Zbigniew Jędrzejewski-Szmek 96ace31dcd systemd-resolve: remove spurious newline with no global settings 2016-07-17 19:58:02 -04:00
Zbigniew Jędrzejewski-Szmek 7b7c1aacf6 systemd-resolve: use plural "DNS Servers"
Usually multiple DNS servers are configured, and it looks strange to have
singular in the heading.
2016-07-17 19:58:02 -04:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Martin Pitt 94363cbbf3 resolved: add test for route-only domain filtering (#3609)
With commit 6f7da49d00 route-only domains do not get put into resolv.conf's
"search" list any more. Add a comment about the tri-state, to clarify its
semantics and why we are passing a bool parameter into an int type. Also add a
test case for it.
2016-06-28 18:18:27 +02:00
Martin Pitt 54522e941d Merge pull request #3594 from poettering/resolved-servfail
resolved fixes for handling SERVFAIL errors from servers
2016-06-24 08:01:49 +02:00
Martin Pitt ceeddf79b8 resolved: add option to disable caching (#3592)
In some cases, caching DNS results locally is not desirable, a it makes DNS
cache poisoning attacks a tad easier and also allows users on the system to
determine whether or not a particular domain got visited by another user. Thus
provide a new "Cache" resolved.conf option to disable it.
2016-06-24 07:54:28 +02:00
Lennart Poettering b3c6b00a93 resolved: when processing auxiliary DNSSEC transactions, accept those with SERVFAIL
Some upstream DNS servers return SERVFAIL if we ask them for DNSSEC RRs, which
some forwarding DNS servers pass on to us as SERVFAIL (other though as
NOERROR...). This is should not be considered a problem, as long as the domain
in question didn't have DNSSEC enabled. Hence: when making use of auxiliary
transactions accept those that return SERVFAIL.
2016-06-23 23:46:56 +02:00
Lennart Poettering 6ff01a0d64 resolved: when caching replies, check rcode earlier
This way we don't log complaints about packets without SOA in case we are not
caching it anyway because the rcode is not SUCCESS or NXDOMAIN...
2016-06-23 23:36:10 +02:00
Lennart Poettering d001e0a3af resolved: rework SERVFAIL handling
There might be two reasons why we get a SERVFAIL response from our selected DNS
server: because this DNS server itself is bad, or because the DNS server
actually serving the zone upstream is bad. So far we immediately downgraded our
server feature level when getting SERVFAIL, under the assumption that the first
case is the only possible case. However, this meant we'd downgrade immediately
even if we encountered the second case described above.

With this commit handling of SERVFAIL is reworked. As soon as we get a SERVFAIL
on a transaction we retry the transaction with a lower feature level, without
changing the feature level tracked for the DNS server itself. If that fails
too, we downgrade further, and so on. If during this downgrading the SERVFAIL
goes away we assume that the DNS server we are talking to is bad, but the zone
is fine and propagate the detected feature level to the information we track
about the DNS server. Should the SERVFAIL not go away this way we let the
transaction fail and accept the SERVFAIL.
2016-06-23 23:24:38 +02:00
Lennart Poettering b30bf55d5c resolved: respond to local resolver requests on 127.0.0.53:53
In order to improve compatibility with local clients that speak DNS directly
(and do not use NSS or our bus API) listen locally on 127.0.0.53:53 and process
any queries made that way.

Note that resolved does not implement a full DNS server on this port, but
simply enough to allow normal, local clients to resolve RRs through resolved.
Specifically it does not implement queries without the RD bit set (these are
requests where recursive lookups are explicitly disabled), and neither queries
with DNSSEC DO set in combination with DNSSEC CD (i.e. DNSSEC lookups with
validation turned off). It also refuses zone transfers and obsolete RR types.
All lookups done this way will be rejected with a clean error code, so that the
client side can repeat the query with a reduced feature set.

The code will set the DNSSEC AD flag however, depending on whether the data
resolved has been validated (or comes from a local, trusted source).

Lookups made via this mechanisms are propagated to LLMNR and mDNS as necessary,
but this is only partially useful as DNS packets cannot carry IP scope data
(i.e. the ifindex), and hence link-local addresses returned cannot be used
properly (and given that LLMNR/mDNS are mostly about link-local communication
this is quite a limitation). Also, given that DNS tends to use IDNA for
non-ASCII names, while LLMNR/mDNS uses UTF-8 lookups cannot be mapped 1:1.

In general this should improve compatibility with clients bypassing NSS but
it is highly recommended for clients to instead use NSS or our native bus API.

This patch also beefs up the DnsStream logic, as it reuses the code for local
TCP listening. DnsStream now provides proper reference counting for its
objects.

In order to avoid feedback loops resolved will no silently ignore 127.0.0.53
specified as DNS server when reading configuration.

resolved listens on 127.0.0.53:53 instead of 127.0.0.1:53 in order to leave
the latter free for local, external DNS servers or forwarders.

This also changes the "etc.conf" tmpfiles snippet to create a symlink from
/etc/resolv.conf to /usr/lib/systemd/resolv.conf by default, thus making this
stub the default mode of operation if /etc is not populated.
2016-06-21 14:15:23 +02:00
Lennart Poettering 2a3900d7e4 resolved: use DNS_{QUESTION|ANSWER}_FOREACH macros at two more places 2016-06-21 13:20:48 +02:00
Lennart Poettering f2ed4c696a resolved: extend dns_packet_append_opt() so that it can set the extended rcode
We don't make use of this yet, but later work will.
2016-06-21 13:20:48 +02:00
Lennart Poettering f471bc11c6 resolved: add dns_packet_add_{question,answer}() helper
And make use of it at a couple of places.
2016-06-21 13:20:48 +02:00
Lennart Poettering 501e8eb054 resolved: add dns_answer_is_empty() and dns_question_is_empty() helpers
And make use of them at a few places.
2016-06-21 13:20:48 +02:00
Lennart Poettering 17c8de633f resolved: when using the ResolveRecord() bus call, adjust TTL for caching time
When we return the full RR wire data, let's make sure the TTL included in it is
adjusted by the time the RR sat in the cache.

As an optimization we do this only for ResolveRecord() and not for
ResolveHostname() and friends, since adjusting the TTL means copying the RR
object, and we don#t want to do that if there's no reason to.
(ResolveHostname() and friends don't return the TTL hence there's no reason to
in that case)
2016-06-21 13:20:48 +02:00
Lennart Poettering 6ebd1e33e6 resolved: explicitly refuse zone transfers using the bus API 2016-06-21 13:20:48 +02:00
Lennart Poettering 0a0fc27b80 resolved: drop unused permit_domain_search variable from Manager object 2016-06-21 13:20:48 +02:00
Lennart Poettering 943ef07ce0 resolved: make sure DNS configuration pushed in by the user stays around on restarts
Let's make sure that all settings pushed in stay around when systemd-resolved
is restarted.
2016-06-21 13:20:48 +02:00
Lennart Poettering b6274a0e9e resolved: fix negated boolean function
It's weird having a "negative" function link_is_unmanaged(), let's invert it
and get rid of the negation this way, by renaming it to link_is_managed().

Internally we stored this as a positive boolean already, hence let's do this
for the function too.
2016-06-21 13:20:48 +02:00
Lennart Poettering 55e99f2064 resolved: rework link_update_dns_servers() a bit
Let's split the code from the inner loop out, into its own function
link_update_dns_server_one(). This matches how things are already handled for
the search domain logic. Also, this is preparation for a later commit that
persists DNS server data pushed in via the bus.
2016-06-21 13:20:48 +02:00
Lennart Poettering 39f259e0b8 resolved: make use of set_put_strdupv() where appropriate 2016-06-21 13:20:48 +02:00
Lennart Poettering 6f7da49d00 resolved: make sure that route-only domains are never added to /etc/resolv.conf
After all, /etc/resolv.conf doesn't know the concept of "route-only domains",
hence the domains should really not appear there.
2016-06-21 13:20:47 +02:00
Lennart Poettering be371fe039 resolve: add "systemd-resolve --status" command
The new command shows the per-link and global DNS configuration currently in
effect. This is useful to quickly see the DNS settings resolved acquired from
networkd and that was pushed into it via the bus APIs.
2016-06-21 13:20:47 +02:00
Lennart Poettering a37129796c resolved: export the effective per-link DNSSEC setting, not the internal one
Internally, we store the per-link DNSSEC setting as -1 (invalid) if there's no
link-specific setting configured, and the global setting should be used. When
exporting this one the bus we really should export the effective DNSSEC
setting however, i.e. return the global one if there's non set per-link.
2016-06-21 13:20:47 +02:00
Lennart Poettering 476798b17d resolved: export global NTAs on the bus
We export them per-link, hence let's export the global NTAs too.
2016-06-21 13:20:47 +02:00