summaryrefslogtreecommitdiff
path: root/src/resolve/resolved.c
AgeCommit message (Collapse)AuthorFilesLines
2019-03-27headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek1-0/+4
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.
2019-01-08timesyncd,resolved,machinectl: drop calls to sd_event_get_exit_code()Zbigniew Jędrzejewski-Szmek1-3/+1
In all three cases, sd_event_loop() will return the exit code anyway. If sd_event_loop() returns negative, failure is logged and results in an immediate return. Otherwise, we don't care if sd_event_loop() returns 0 or positive, because the return value feeds into DEFINE_MAIN_FUNCTION(), which doesn't make the distinction.
2018-12-08resolve: define main through macroYu Watanabe1-45/+26
2018-11-20log: introduce new helper call log_setup_service()Lennart Poettering1-3/+1
Let's reduce the common boilerplate and have a single setup function used by all service code to setup logging.
2018-08-29resolve: update comment, avoid alarming wrongnessAlan Jenkins1-1/+1
`systemd-resolved.service` runs as `User=systemd-resolved`, and uses certain Capabilit{y,ies} magic. By my understanding, this means it is started with a number of "privileges". Indeed, `capabilities(7)` explains > Linux divides the privileges traditionally > associated with superuser into distinct units, known as capabilities, > which can be independently enabled and disabled." This situation appears to contradict our current code comment which said > If we are not running as root we assume all privileges are already dropped. This appears to be a confusion in the comment only. The rest of the code tells a much clearer story. (Don't ask me if the story is correct. `capabilities(7)` scares me). Let's tweak the comment to make it consistent and avoid worrying readers about this.
2018-08-20user-util: rework get_user_creds()Lennart Poettering1-1/+1
Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
2018-06-28resolve: warn when our stub listener is disabled but resolv.conf uses itYu Watanabe1-0/+2
Closes #9450.
2018-06-20tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek1-3/+0
Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
2018-06-14tree-wide: beautify remaining copyright statementsLennart Poettering1-1/+1
Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
2018-06-14tree-wide: drop 'This file is part of systemd' blurbLennart Poettering1-2/+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.
2018-04-06tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek1-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.
2018-03-23tree-wide: warn when a directory path already exists but has bad mode/owner/typeZbigniew Jędrzejewski-Szmek1-1/+1
When we are attempting to create directory somewhere in the bowels of /var/lib and get an error that it already exists, it can be quite hard to diagnose what is wrong (especially for a user who is not aware that the directory must have the specified owner, and permissions not looser than what was requested). Let's print a warning in most cases. A warning is appropriate, because such state is usually a sign of borked installation and needs to be resolved by the adminstrator. $ build/test-fs-util Path "/tmp/test-readlink_and_make_absolute" already exists and is not a directory, refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but has mode 0775 that is too permissive (0755 was requested), refusing. (or) Directory "/tmp/test-readlink_and_make_absolute" already exists, but is owned by 1001:1000 (1000:1000 was requested), refusing. Assertion 'mkdir_safe(tempdir, 0755, getuid(), getgid(), MKDIR_WARN_MODE) >= 0' failed at ../src/test/test-fs-util.c:320, function test_readlink_and_make_absolute(). Aborting. No functional change except for the new log lines.
2018-03-22basic/mkdir: convert bool flag to enumZbigniew Jędrzejewski-Szmek1-1/+1
In preparation for subsequent changes...
2017-11-19Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek1-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.
2017-10-24resolved: create private stub resolve file for /etc/resolv.conf integration ↵Dimitri John Ledkov1-4/+0
(#7014) This creates a second private resolve.conf file which lists the stub resolver and the resolved acquired search domains. This runtime file should be used as a symlink target for /etc/resolv.conf such that non-nss based applications can resolve search domains. Fixes: #7009
2017-10-06mkdir: introduce follow_symlink flag to mkdir_safe{,_label}()Yu Watanabe1-1/+1
2017-10-05resolved: add support for explicitly forgetting everything we learnt about ↵Lennart Poettering1-1/+1
DNS server feature levels This adds "systemd-resolve --reset-server-features" for explicitly forgetting what we learnt. This might be useful for debugging purposes, and to force systemd-resolved to restart its learning logic for all DNS servers.
2017-08-10units: make use of the new !! ExecStart= prefix in systemd-resolved.serviceLennart Poettering1-7/+12
Let's make use of !! to run resolved with ambient capabilities on systems supporting them.
2016-12-02treewide: fix typos (#4802)Torstein Husebø1-1/+1
2016-11-10resolved: unlink private resolv.conf on exitChristian Hesse1-0/+4
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-06-21resolved: respond to local resolver requests on 127.0.0.53:53Lennart Poettering1-1/+12
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-10resolved: flush all caches if SIGUSR2 is receivedLennart Poettering1-1/+1
2016-06-06resolved: also rewrite private /etc/resolv.conf when configuration is ↵Lennart Poettering1-5/+2
changed via bus calls This also moves log message generation into manager_write_resolv_conf(), so that it is shorter to invoke the function, given that we have to invoke it at a couple of additional places now. Fixes: #3225
2016-03-01selinux: always try to load the full selinux dbZbigniew Jędrzejewski-Szmek1-1/+1
https://github.com/systemd/systemd/pull/2508#issuecomment-190901170 Maybe fixes https://bugzilla.redhat.com/show_bug.cgi?id=1308771.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack1-2/+0
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2016-01-28resolved: emit full path to file we failed to writeZbigniew Jędrzejewski-Szmek1-1/+1
Otherwise it's unclear if it's /etc/resolv.conf or some other file that is meant.
2016-01-05resolved,networkd: add a per-interface DNSSEC settingLennart Poettering1-6/+0
This adds a DNSSEC= setting to .network files, and makes resolved honour them.
2015-11-25resolved: make sure FallbackDNS= overrides built-in servers, doesn't extend themLennart Poettering1-2/+4
Closes #342.
2015-11-25resolved: split out all code dealing with /etc/resolv.conf into its own .c fileLennart Poettering1-0/+1
No functional changes.
2015-10-27src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → ↵Lennart Poettering1-1/+1
capability-util.[ch] The files are named too generically, so that they might conflict with the upstream project headers. Hence, let's add a "-util" suffix, to clarify that this are just our utility headers and not any official upstream headers.
2015-10-26util-lib: split out user/group/uid/gid calls into user-util.[ch]Lennart Poettering1-5/+6
2015-08-26resolved: dump cache and zone contents to syslog on SIGUSR1Lennart Poettering1-1/+1
2015-06-15everywhere: port everything to sigprocmask_many() and friendsLennart Poettering1-1/+1
This ports a lot of manual code over to sigprocmask_many() and friends. Also, we now consistly check for sigprocmask() failures with assert_se(), since the call cannot realistically fail unless there's a programming error. Also encloses a few sd_event_add_signal() calls with (void) when we ignore the return values for it knowingly.
2015-05-29util: split out signal-util.[ch] from util.[ch]Lennart Poettering1-0/+1
No functional changes.
2015-02-23remove unused includesThomas Hindoe Paaboel Andersen1-1/+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.
2014-12-28tmpfiles: add new line type 'v' for creating btrfs subvolumesLennart Poettering1-0/+1
2014-11-28treewide: no need to negate errno for log_*_errno()Michal Schmidt1-8/+8
It corrrectly handles both positive and negative errno values.
2014-11-28treewide: auto-convert the simple cases to log_*_errno()Michal Schmidt1-8/+8
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
2014-11-25resolved: fix typo in sd_notify() callTom Gundersen1-1/+1
2014-10-23mac: rename apis with mac_{selinux/smack}_ prefixWaLyong Cho1-1/+1
2014-10-17resolve: add missing headerLukasz Skalski1-0/+1
Change-Id: I64f7c6b446f6d92057c35cc3d4e29bd2bad8f75b
2014-10-13resolved: apply label to /run/systemd/resolve/resolv.confZbigniew Jędrzejewski-Szmek1-2/+8
Under an SELinux system, we want the file that is created to have a proper context, different from the default for files in /run. This is so that the policy can give access to almost everyone to this file.
2014-08-21notify: send STOPPING=1 from our daemonsLennart Poettering1-1/+3
2014-08-12resolved: return exit code of event loopLennart Poettering1-0/+2
2014-08-04resolved: when there's already somebody listening on the LLMNR ports, simple ↵Lennart Poettering1-0/+6
disable LLMNR and warn, but continue This allows us to run resolved inside an nspawn container that shares the network namespace with the host, if there's already an instance running.
2014-08-01resolved: rename resolved.h to resolved-manager.hLennart Poettering1-1/+1
After all it pretty much exlcusively containers definitions about the "Manager" object, hence let's call this the most obvious way.
2014-08-01resolved: beef up DNS server configuration logicLennart Poettering1-11/+8
We now maintain two lists of DNS servers: system servers and fallback servers. system servers are used in combination with any per-link servers. fallback servers are only used if there are no system servers or per-link servers configured. The system server list is supposed to be populated from a foreign tool's /etc/resolv.conf (not implemented yet). Also adds a configuration switch for LLMNR, that allows configuring whether LLMNR shall be used simply for resolving or also for responding.
2014-07-16resolved: add a DNS client stub resolverLennart Poettering1-19/+16
Let's turn resolved into a something truly useful: a fully asynchronous DNS stub resolver that subscribes to network changes. (More to come: caching, LLMNR, mDNS/DNS-SD, DNSSEC, IDN, NSS module)
2014-07-07resolved: make sure SIGTER/SIGINT actually can be caught and processedLennart Poettering1-0/+2
2014-06-03resolved: run as unpriviliged "systemd-resolve" userTom Gundersen1-2/+18
This service is not yet network facing, but let's prepare nonetheless. Currently all caps are dropped, but some may need to be kept in the future.