summaryrefslogtreecommitdiffstats
path: root/src/nss-resolve (follow)
Commit message (Collapse)AuthorAgeFilesLines
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+2
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* util: split out errno related stuffLennart Poettering2019-03-141-2/+2
|
* nss: unportect errno before writing to NSS' *errnopLennart Poettering2019-02-081-0/+8
| | | | Fixes: #11321
* Revert "nss: prevent PROTECT_ERRNO from squashing changes to *errnop"Zbigniew Jędrzejewski-Szmek2019-01-101-8/+8
| | | | | | | This reverts commit b26c90411343d74b15deb24bd87077848e316dab. I don't see anythign wrong, but Ubuntu autopkgtest CI started failing fairly consistently since this was merged. Let's see if reverting fixes things.
* nss: prevent PROTECT_ERRNO from squashing changes to *errnopSam Morris2019-01-101-8/+8
| | | | | | | glibc passes in &errno for errnop, which means PROTECT_ERRNO ends up squashing our intentional changes to *errnop. Fixes #11321.
* Merge pull request #9504 from poettering/nss-deadlockZbigniew Jędrzejewski-Szmek2018-07-261-0/+29
|\ | | | | some nss deadlock love
| * nss: never become IPC clients for services that are about to be startedLennart Poettering2018-07-201-0/+29
| | | | | | | | | | | | | | This is an attempt to automatically detect and avoid certain kinds of NSS deadlocks as discussed in this thread: https://lists.freedesktop.org/archives/systemd-devel/2018-July/040975.html
* | nss: do not modify errno when NSS_STATUS_NOTFOUND or NSS_STATUS_SUCCESSYu Watanabe2018-07-251-48/+39
|/ | | | | | | | | This also adds PROTECT_ERRNO for all nss module functions. C.f. glibc NSS documents https://www.gnu.org/software/libc/manual/html_node/NSS-Modules-Interface.html and discussion in https://sourceware.org/bugzilla/show_bug.cgi?id=23410. Fixes #9585.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-142-4/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* resolve: Adjust and unify D-Bus call timeout (#7847)ott2018-01-231-5/+4
| | | | | | | | | | | | | | DNS queries have a timeout of DNS_TRANSACTION_ATTEMPTS_MAX * DNS_TIMEOUT_MAX_USEC = 120 s. Calls to the ResolveHostname method of the org.freedesktop.resolve1.Manager interface have various call timeouts that are smaller than 120 s. So it seems correct to adjust the call timeout to the maximum query timeout and to unify the call timeout among all callers. A timeout of 120 s might seem large, in particular since BIND does seem to have a query timeout of 10 s. However, it seems match the timeout value of 120 s of Unbound. Moreover, the query and timeout handling of resolve have problems and might be improved in the future, so this change is at best an interim solution.
* Add SPDX license headers to various assorted filesZbigniew Jędrzejewski-Szmek2017-11-191-0/+2
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* tree-wide: use IN_SET macro (#6977)Yu Watanabe2017-10-041-1/+1
|
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* nss-resolve: drop the internal fallback to libnss_dns (#5945)Zbigniew Jędrzejewski-Szmek2017-05-121-62/+14
| | | | | | | | | | | | | | | | | | | If we could not communicate with systemd-resolved, we would call into libnss_dns. libnss_dns would return NOTFOUND for stuff like "localhost" and other names resolved by nss-myhostname, which we would fall under the !UNAVAIL= condition and cause resolution to fail. So the following recommended configuration in nsswitch.conf would not work: hosts: resolve [!UNAVAIL=return] dns myhostname Remove the internal fallback code completely so that the fallback logic can be configured in nsswitch.conf. Tested with hosts: resolve [!UNAVAIL=return] myhostname and hosts: resolve [!UNAVAIL=return] dns myhostname Fixes #5742.
* nss-resolve: Fix assertion in ifindex_to_scopeid. (#5360)Maarten de Vries2017-02-161-1/+1
|
* nss-resolve: report ERANGE for small buffers. (#5359)Maarten de Vries2017-02-161-6/+6
| | | | | | | | | | | | | The correct error code to report when a provided buffer is too small is ERANGE. This is recognized by glibc, which will then try again with a larger buffer. The old behaviour of reporting ENOMEM has no special meaning for glibc. The error will simply be propagated to the application, and a later retry will trigger the same error again. Additionally, h_errnop must be set to NETDB_INTERNAL to have glibc look at errnop for details. More information at: https://www.gnu.org/software/libc/manual/html_node/NSS-Modules-Interface.html
* nss-resolve: don't set scopeindex for non-link-local addressesLennart Poettering2017-02-091-1/+15
| | | | | | | Apparently some apps don't like that. And given that this isn't necessary for link-local addresses, let's suppress this information. Fixes: #4465
* nss-resolve: be a bit more careful with returning NSS_STATUS_NOTFOUNDLennart Poettering2016-10-241-7/+12
| | | | | | | | | | | | | | | | | | | | | Let's tighten the cases when our module returns NSS_STATUS_NOTFOUND. Let's do so only if we actually managed to talk to resolved. In all other cases stick to NSS_STATUS_UNAVAIL as before, as it clearly indicates that our module or the system is borked, and the "dns" fallback should really take place. In particular this fixes the 2nd-level fallback from our own dlopen() based fallback handling. In this case we really should return UNAVAIL so that the caller can apply its own fallback still. Fix-up for d7247512a904f1dd74125859d8da66166c2a6933. Note that our own dlopen() based fallback is pretty much redundant now if nsswitch.conf is configured like this: hosts: files mymachines resolve [!UNAVAIL=return] dns myhostname In a future release we should probably drop our internal fallback then, in favour of this nsswitch.conf-based one.
* nss-resolve: return NOTFOUND instead of UNAVAIL on resolution errorsMartin Pitt2016-10-011-3/+6
| | | | | | | | | | | | | | | | It needs to be possible to tell apart "the nss-resolve module does not exist" (which can happen when running foreign-architecture programs) from "the queried DNS name failed DNSSEC validation" or other errors. So return NOTFOUND for these cases too, and only keep UNAVAIL for the cases where we cannot handle the given address family. This makes it possible to configure a fallback to "dns" without breaking DNSSEC, with "resolve [!UNAVAIL=return] dns". Add this to the manpage. This does not change behaviour if resolved is not running, as that already falls back to the "dns" glibc module. Fixes #4157
* nss-resolve: simplify error handlingMartin Pitt2016-10-011-3/+1
| | | | | | Handle general errors from the resolved call in _nss_resolve_gethostbyaddr2_r() the same say as in the other variants: Just "goto fail" as that does exactly the same.
* Move nss typedefs into nss-util.hZbigniew Jędrzejewski-Szmek2016-04-031-54/+25
| | | | In preparation for subsequent changes.
* tree-wide: make ++/-- usage consistent WRT spacingVito Caputo2016-02-231-1/+1
| | | | | | Throughout the tree there's spurious use of spaces separating ++ and -- operators from their respective operands. Make ++ and -- operator consistent with the majority of existing uses; discard the spaces.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* nss-resolve: also fall back to nss-dns if dbus doesn't workLennart Poettering2016-01-271-73/+75
| | | | Fixes #1692
* nss: block various signals while running NSS lookupsLennart Poettering2016-01-271-0/+7
| | | | | | | Let's make sure our poll() calls don't get interrupted where they shouldn't (SIGALRM, ...), but allow them to be interrupted where they should (SIGINT, ...). Fixes #1965
* nss-resolve: fix gethostbyaddr h_aliasesSamu Kallio2016-01-261-1/+1
| | | | | Fix the comparison to include the first alias, which will otherwise be left as a bogus pointer.
* nss-resolve: link lessZbigniew Jędrzejewski-Szmek2015-11-281-1/+0
| | | | | This reduces libraries reported by ldd by liblzma, liblz4, libgcrypt, libgpg-error, libacl, libidn, libseccomp.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-271-9/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-241-6/+8
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* resolved: rework synthesizing logicLennart Poettering2015-08-211-46/+35
| | | | | | | | | | | | | | | | | | | 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.
* sd-bus: introduce new sd_bus_flush_close_unref() callLennart Poettering2015-07-031-3/+3
| | | | | | | | | | | | | | | | sd_bus_flush_close_unref() is a call that simply combines sd_bus_flush() (which writes all unwritten messages out) + sd_bus_close() (which terminates the connection, releasing all unread messages) + sd_bus_unref() (which frees the connection). The combination of this call is used pretty frequently in systemd tools right before exiting, and should also be relevant for most external clients, and is hence useful to cover in a call of its own. Previously the combination of the three calls was already done in the _cleanup_bus_close_unref_ macro, but this was only available internally. Also see #327
* tree-wide: remove spurious spaceThomas Hindoe Paaboel Andersen2015-06-081-7/+7
|
* remove unused includesThomas Hindoe Paaboel Andersen2015-02-231-5/+0
| | | | | | This patch removes includes that are not used. The removals were found with include-what-you-use which checks if any of the symbols from a header is in use.
* sd-bus: move common errors src/shared/bus-errors.h → ↵Lennart Poettering2014-12-101-1/+1
| | | | | | src/libsystemd/sd-bus/bus-common-errors.h Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
* nss: remove dead codeThomas Hindoe Paaboel Andersen2014-09-191-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | c > 0 is already guaranteed from earlier checks. We go from ms = ALIGN(l+1) + sizeof(char*) + (c > 0 ? c : 1) * ALIGN(alen) + (c > 0 ? c+1 : 2) * sizeof(char*); to ms = ALIGN(l+1) + sizeof(char*) + c * ALIGN(alen) + (c+1) * sizeof(char*); to ms = ALIGN(l+1) + c * ALIGN(alen) + (c+2) * sizeof(char*); Found by coverity. Fixes: CID#1237570 and CID#1237610
* nss-resolve: remove dead codeThomas Hindoe Paaboel Andersen2014-09-171-5/+0
| | | | | | ifindex < 0 was already checked before entering the loop Found by coverity. Fixes: CID#1237609
* resolved: allow passing on which protocol, family and interface to look ↵Lennart Poettering2014-08-141-30/+48
| | | | | | something up Also, return on which protocol/family/interface we found something.
* bus: always explicitly close bus from main programsLennart Poettering2014-08-041-3/+3
| | | | | | | | | | | | | | Since b5eca3a2059f9399d1dc52cbcf9698674c4b1cf0 we don't attempt to GC busses anymore when unsent messages remain that keep their reference, when they otherwise are not referenced anymore. This means that if we explicitly want connections to go away, we need to close them. With this change we will no do so explicitly wherver we connect to the bus from a main program (and thus know when the bus connection should go away), or when we create a private bus connection, that really should go away after our use. This fixes connection leaks in the NSS and PAM modules.
* nss: always explicitly reset all error variablesLennart Poettering2014-08-011-0/+15
| | | | | | | glibc appears to be broken if we don't explicitly reset all error variables, let's work around that. https://bugzilla.redhat.com/show_bug.cgi?id=1125975
* nss-resolve: fallback to the class NSS "dns" module if we cannot contact ↵Lennart Poettering2014-08-011-0/+87
| | | | | | resolved That way DNS resolution works both with and without resolved running.
* resolved: fix bus signatures to follow family as int changeLennart Poettering2014-07-181-2/+2
|
* change type for address family to "int"Lennart Poettering2014-07-181-16/+14
| | | | | | | | Let's settle on a single type for all address family values, even if UNIX is very inconsitent on the precise type otherwise. Given that socket() is the primary entrypoint for the sockets API, and that uses "int", and "int" is relatively simple and generic, we settle on "int" for this.
* shared: rename PROTO_ADDRESS_SIZE() to FAMILY_ADDRESS_SIZE()Lennart Poettering2014-07-181-3/+3
| | | | | We mostly use "family" to refer to AF_INET, AF_INET6, etc, let's use this terminology here, too
* resolved: properly pass canonical name information to resolving clientLennart Poettering2014-07-161-41/+58
| | | | Also, hook up nss-resolve to make use of this information
* resolved: add small NSS module that uses resolved to resolve DNS namesLennart Poettering2014-07-163-0/+605