Commit graph

1291 commits

Author SHA1 Message Date
Lennart Poettering 747a8a74c0 resolved: rename dns_stream_on_packet() → on_stream_packet()
Let's name this similar to on_stream_complete(). Moreover we shouldn't
invade dns_stream's namespace if we are a consumer of it.
2018-12-07 17:16:29 +01:00
Lennart Poettering 65b0179a25 resolved: use structured initialization for DnsServer allocation 2018-12-07 17:16:29 +01:00
Lennart Poettering 94fdb4d9d1 resolved: exit early on failure 2018-12-07 17:16:29 +01:00
Lennart Poettering 97d5d9055f resolved: don't read packet from DnsStream on on_stream_complete() of DnsTransaction
We register an on_packet() handler anyway, which is called first.
There's hence no need to check in on_stream_complete() again, as it is
already taken by that time.
2018-12-07 17:16:29 +01:00
Lennart Poettering aa337a5e72 resolved: add new accessor dns_stream_take_read_packet() for taking read packet from stream
This ensures the packet is complete when it is taken out, and resets
n_read so that we can start reading the next one.
2018-12-07 17:16:29 +01:00
Lennart Poettering 56e267dee2 resolved: remove redundant code 2018-12-07 17:16:29 +01:00
Lennart Poettering 499aa1d31b resolved: add some assert()s 2018-12-07 17:16:29 +01:00
Lennart Poettering e6dc55566b resolved: be more careful with types in dns_stream_writev()
Let's not name a variable of type ssize_t "r". We usually use "r" for
return values of API calls that return some kind of error as in int.
This creates a lot of confusion if used differently here, which actually
resulted in connect()'s return value being assigned to this mistyped "r"
by accident.

Let's rename the variable "m" hence, and not use it for connect() return
values.
2018-12-07 17:16:29 +01:00
Lennart Poettering b27a32a0de resolved: line split dns_stream_new() function signature 2018-12-07 17:16:29 +01:00
Lennart Poettering 08e254c818 resolved: reorder things, to place registration of DnsStream in Manager close to each other 2018-12-07 17:16:29 +01:00
Lennart Poettering 898892e825 resolved: ensure DnsStream.fd is initialized before first error path 2018-12-07 17:16:29 +01:00
Lennart Poettering b2cf6704e7 resolved: simplify on_stream_io() a bit 2018-12-07 17:16:29 +01:00
Yu Watanabe e1eb35db1e
Merge pull request #11056 from poettering/resolved-ifindex
resolved: request incoming ifindex for DNS UDP packets, too
2018-12-06 19:29:42 +01:00
Alexey Bogdanenko 487e33242f test-resolved: fix error code check in assertion
If file "/etc/hosts" does not exist, fopen fails and sets errno to ENOENT
("No such file or directory"). So errno should be compared with ENOENT.

This mistake causes test test-resolved-etc-hosts to fail when run on Debian
image built with mkosi.debian included in the repo. The image does not include
"/etc/hosts" file as it is not created by debootstrap, see debootstrap manpage
https://manpages.debian.org/stretch/debootstrap/debootstrap.8.en.html.
2018-12-06 17:23:05 +01:00
Yu Watanabe ef118d00eb util: drop missing.h from socket-util.h 2018-12-06 13:31:16 +01:00
Lennart Poettering ec4b9671b3 resolvectl: color "comment" output grey
Let's de-emphasize the "comment" output a bit, by making it grey.
2018-12-05 18:46:23 +01:00
Lennart Poettering 38585af313 resolvectl: add some basic highlighting to query output
Let's highlight the actual payload the user requested.
2018-12-05 18:46:23 +01:00
Lennart Poettering 0889b81554 resolvectl: when doing reverse lookups, show ifindex as "comment" too in output
Similar as before: don't output ifindex twice on the same address, and
show it as comment only.

Do this for reverse lookup output and all other output too.
2018-12-05 18:46:23 +01:00
Lennart Poettering ff4a77c3ce resolvectl: fix interface output when resolving hostnames→addresses
We already used in_addr_ifindex_to_string() which internally appends the
ifindex to the address with % if necessary. It's simply wrong to attach the
intreface a second time with % then. Also, it breaks stuff that cannot
deal with that. Hence, let's reformat this, and add the ifindex as a
comment to the output, and drop the second % suffix.
2018-12-05 18:46:23 +01:00
Lennart Poettering df87a53df0 resolvectl: remove allow_loopback parameter from ifname_mangle()
All our bus calls validate whether the specified device is a loopback
device anyway on the server side. Let's hence simplify the client,
there's no value in optimizing error paths after all. But there is value
in simpler code.
2018-12-05 18:46:23 +01:00
Lennart Poettering d129304919 resolvectl: for our per-link verbs alternatively accept interface name in -i
it's a bit confusing that we take two interfaces for verbs such as "dns"
or "domain": once after the verb, and once as --interface=. While
there's logic behind it, let's make this least surprising: if either is
specified be happy.

This means "resolvectl -i foo dns" is now equivalent to "resolvectl dns
foo …". Note that this is a tweak only, to minimize surprises. We don't
document this alternative syntax, and shouldn't to keep things simple.
2018-12-05 18:46:23 +01:00
Lennart Poettering a77081e30f resolvectl: rework ifname_mangle()
Let's compare the ifname passed in with what is set already if there is
something set already. Complain in that case. This makes commands such
as "resolvectl -i foo dns bar" less weird, as we'll refuse the duplicate
ifname specifications.

Also, free the old arg_ifname right before assigning the new, instead of
doing so in advance.
2018-12-05 18:46:23 +01:00
Lennart Poettering c9e6918257 resolved: request incoming ifindex for DNS UDP packets, too
This information is useful to pass back to the caller, as it tells us
where we found the answer.

(While we are at it, fix the socket level for the RECVERR logic)

Fixes: #9778
2018-12-05 18:46:23 +01:00
Lennart Poettering ee589a1882
Merge pull request #11041 from yuwata/update-missing-v2
missing: separate missing.h more
2018-12-04 16:19:02 +01:00
Yu Watanabe 36dd5ffd5d util: drop missing.h from util.h 2018-12-04 10:00:34 +01:00
Yu Watanabe f2a3de0116 tree-wide: add whitespace between type and variable name 2018-12-04 09:29:54 +01:00
Lennart Poettering 76b31bbb24
Merge pull request #10920 from yuwata/hashmap-destructor
hashmap: make hashmap_free() call destructors of key or value
2018-12-03 17:59:44 +01:00
Lennart Poettering 29e719ced0 resolved: sort headers again 2018-12-02 13:22:29 +01:00
Lennart Poettering 686d13b9f2 util-lib: split out env file parsing code into env-file.c
It's quite complex, let's split this out.

No code changes, just some file rearranging.
2018-12-02 13:22:29 +01:00
Lennart Poettering a12a00c857 resolved: remove duplicate #include 2018-12-02 13:22:29 +01:00
Lennart Poettering e4de72876e util-lib: split out all temporary file related calls into tmpfiles-util.c
This splits out a bunch of functions from fileio.c that have to do with
temporary files. Simply to make the header files a bit shorter, and to
group things more nicely.

No code changes, just some rearranging of source files.
2018-12-02 13:22:29 +01:00
Lennart Poettering ee228be10c util-lib: don't include fileio.h from fileio-label.h
There's no reason for doing that, hence simply don't.
2018-12-02 13:22:29 +01:00
Yu Watanabe 7a08d314f2 tree-wide: make hash_ops typesafe 2018-12-02 07:53:27 +01:00
Lennart Poettering 5dd9527883 tree-wide: remove various unused functions
All found with "cppcheck --enable=unusedFunction".
2018-12-02 13:35:34 +09:00
Aleksei Timofeyev 09e5c07fbd resolved: add missed io-util.h header to resolved-dnstls-openssl.c
Regression after commit 5cfa2c3dc0
2018-12-01 12:49:01 +01:00
Zbigniew Jędrzejewski-Szmek 62a85ee0a9 tree-wide: rename path_join_many() to path_join()
$ git grep -e path_join_many -l|xargs sed -r -i 's/path_join_many/path_join/g'

The two test functions are merged into one.
2018-11-30 10:59:47 +01:00
Zbigniew Jędrzejewski-Szmek 30016f21b3 tree-wide: replace path_join with path_join_many 2018-11-30 10:40:38 +01:00
Victor Tapia e6eed94459 resolved: Increase size of TCP stub replies
DNS_PACKET_PAYLOAD_SIZE_MAX is limiting the size of the stub replies to
512 with EDNS off or 4096 with EDNS on, without checking the protocol
used. This makes TCP replies for clients without EDNS support to be
limited to 512, making the truncate flag useless if the query result is
bigger than 512 bytes.

This commit increases the size of TCP replies to DNS_PACKET_SIZE_MAX

Fixes: #10816
2018-11-28 14:06:36 +01:00
Lennart Poettering cb3108669d tree-wide: more IOVEC_MAKE() conversions 2018-11-28 13:08:19 +09:00
Lennart Poettering 5cfa2c3dc0 tree-wide: use IOVEC_MAKE() at many places 2018-11-27 10:12:27 +01:00
Yu Watanabe f6aa61909e resolvectl: use static destructor and define main through macro 2018-11-23 06:22:30 +09:00
Zbigniew Jędrzejewski-Szmek baaa35ad70 coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.

I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
2018-11-22 10:54:38 +01:00
Zbigniew Jędrzejewski-Szmek 294bf0c34a Split out pretty-print.c and move pager.c and main-func.h to shared/
This is high-level functionality, and fits better in shared/ (which is for
our executables), than in basic/ (which is also for libraries).
2018-11-20 18:40:02 +01:00
Lennart Poettering 6bf3c61c57 log: introduce new helper call log_setup_service()
Let's reduce the common boilerplate and have a single setup function
used by all service code to setup logging.
2018-11-20 11:18:22 +01:00
Lennart Poettering f20db19954 cocci: simplify some if checks 2018-11-16 16:05:29 +01:00
Zbigniew Jędrzejewski-Szmek cd5a29ce98
Merge pull request #10742 from poettering/c-utf8
default to C.UTF-8 locale, and many improvements to env var file parsing/kernel cmdline parsing
2018-11-15 12:47:17 +01:00
Lennart Poettering 13df9c398d fileio: automatically add NULL sentinel to parse_env_file()
Let's modernize things a bit.
2018-11-14 17:01:55 +01:00
Lennart Poettering aa8fbc74e3 fileio: drop "newline" parameter for env file parsers
Now that we don't (mis-)use the env file parser to parse kernel command
lines there's no need anymore to override the used newline character
set. Let's hence drop the argument and just "\n\r" always. This nicely
simplifies our code.
2018-11-14 17:01:54 +01:00
Zbigniew Jędrzejewski-Szmek fde32028a4 Move LONG_LINE_MAX definition to fileio.h
All users of the macro (except for one, in serialize.c), use the macro in
connection with read_line(), so they must include fileio.h.  Let's not play
libc games and require multiple header file to be included for the most common
use of a function.

The removal of def.h includes is not exact. I mostly went over the commits that
switch over to use read_line() and add def.h at the same time and reverted the
addition of def.h in those files.
2018-11-14 16:25:32 +01:00
Zbigniew Jędrzejewski-Szmek 0221d68a13 basic/pager: convert the pager options to a flags argument
Pretty much everything uses just the first argument, and this doesn't make this
common pattern more complicated, but makes it simpler to pass multiple options.
2018-11-14 16:25:11 +01:00