Commit graph

162 commits

Author SHA1 Message Date
Wouter Wijngaards
e4e00db42e
Merge pull request #151 from Maryse47/systemd_fix
Fixes for systemd units
2020-01-30 14:09:29 +01:00
W.C.A. Wijngaards
20a2574da1 - Update contrib/fastrpz.patch for clean diff with current code. 2020-01-30 13:05:35 +01:00
Maryse47
9aa4b5a7a6 unbound.service.in: don't write pidfile at start
Pidfiles aren't needed while running unbound through systemd.
The PID of the unbound daemon can still be obtained with:
'systemctl show --property MainPID --value unbound'.

While disabling pidfiles we can also drop CAP_CHOWN and writable
/run directory.
2020-01-28 19:03:18 +01:00
Maryse47
939cf38576 unbound.service.in: drop CAP_IPC_LOCK
CAP_IPC_LOCK controls whether a process can lock pages into physical
memory (for instance to prevent passwords or private keys from
being swapped to disk), e.g. mmap() with the MAP_LOCKED flag or
shmctl() with the SHM_LOCK command, neither of which seem to be
used by unbound.
2020-01-28 18:42:41 +01:00
Maryse47
c0789a8785 unbound.service.in: allow CAP_CHOWN
CAP_CHOWN is needed for changing onwership of pidfile before
dropping privileges and truncate pidfile on exit.
2020-01-27 18:31:10 +01:00
Ralph Dolmans
1d0fc2d179
Merge pull request #148 from pettai/morestats
Add some TLS stats to unbound_munin_
2020-01-27 16:04:00 +01:00
Ralph Dolmans
7e200ce90e
Merge branch 'master' into edmonds/libbsd-support 2020-01-27 15:37:33 +01:00
Maryse47
cfce0a5e60 unbound.service.in: add StateDirectory
State directory will be created under /var/lib/unbound and will be
useful for writing various files managed at runtime like trust
anchors updates there instead of in ConfigureDirectory which could
be made read-only next. For this chroot needs to be disabled.
2020-01-27 13:46:31 +01:00
Maryse47
72bfa5a48c Move unbound_nochroot.service to unbound_portable.service
The real purpose of this service is to make it work with
https://systemd.io/PORTABLE_SERVICES/ which are incompatible with
chroot workarounds from original unbound.service.

The service content is identical to unbound.service with exception
for chroot related rules which were modified as needed.
2020-01-27 13:44:47 +01:00
Maryse47
1464bedce2 unbound.service.in: add RuntimeDirectory and ConfigurationDirectory
Adding 'RuntimeDirectory' is needed when pidfile path is set to
subdirectory under /run.

Adding ConfigurationDirectory may help in some non-standard setups.

Also add more descriptions about used rules to avoid user confusion
about they meaning and purpose.
2020-01-27 13:44:46 +01:00
W.C.A. Wijngaards
0ae684830a Merge branch 'master' of github.com:NLnetLabs/unbound 2020-01-27 09:29:18 +01:00
Robert Edmonds
394f9403df contrib/libunbound.pc.in: Embed the correct crypto dependencies
This commit removes the hardcoded dependency in the libunbound
pkg-config .pc file on the libcrypto and libssl modules and instead
populates the .pc file based on which crypto library was selected at
configure time.

Note that the .pc file specifies pkg-config module names for the
"Requires" line and this can vary from the library filename (e.g. "nss"
is the pkg-config module name vs. "nss3" being the library name).
2020-01-26 22:30:31 -05:00
Robert Edmonds
36b5d74fc4 contrib/libunbound.pc.in: Only specify -lunbound for Libs
According to the pkg-config manpage, the "Libs" line in a .pc file
should give the link flags "specific to your package", and specifically
says not to include link flags for dependencies:

    Libs:  This line should give the link flags specific to your
           package.  Don't add any flags for required packages;
           pkg-config will add those automatically.
2020-01-26 22:06:58 -05:00
Steven Chamberlain
f6b4f2a149 Allow use of libbsd functions with configure option --with-libbsd
Add a new configure option `--with-libbsd', which allows to use libbsd's
portable implementations of:

    strlcpy strlcat arc4random arc4random_uniform reallocarray

instead of the embedded code copies in contrib/, which will be
difficult to maintain in the long term.

Also patch util/random.c so that, when building with libbsd and without
OpenSSL, arc4random can still be used as the PRNG.  Otherwise, building
with libnettle would need a kernel-specific getentropy implementation,
and libbsd does not export one.

[edmonds@debian.org: Imported patch description from BTS, refreshed
patch against Unbound 1.9.6.]
2020-01-26 19:09:43 -05:00
W.C.A. Wijngaards
61456ff81d Changelog and contrib/README note for PR#150.
- Merge PR#150 from Frzk: Systemd unit without chroot.  It add
  contrib/unbound_nochroot.service.in, a systemd file for use with
  chroot: "", see comments in the file, it uses systemd protections
  instead.
2020-01-23 16:16:52 +01:00
François KUBLER
016f742f16 Added a new unit file to run unbound with systemd and without chroot.
See https://github.com/NLnetLabs/unbound/pull/149
2020-01-23 15:46:53 +01:00
frpet
05cb07093d Update unbound_munin_
Add TLS (DoT) counters
2020-01-23 08:23:16 +01:00
Maryse47
89d98564c3
unbound.service.in: stop binding pidfile inside chroot dir
Apparently pidfile isn't used inside chroot and binding it may cause some weird failures with older systemd.

Fixes https://github.com/NLnetLabs/unbound/issues/138
2020-01-08 15:21:22 +00:00
W.C.A. Wijngaards
ff7d68ca53 - unbound-fuzzers.tar.bz2: three programs for fuzzing, that are 1:1
replacements for unbound-fuzzme.c that gets created after applying
  the contrib/unbound-fuzzme.patch.  They are contributed by
  Eric Sesterhenn from X41 D-Sec.
2019-12-05 09:10:49 +01:00
W.C.A. Wijngaards
6e8b4a7796 - update contrib/fastrpz.patch to apply more cleanly. 2019-12-04 11:41:13 +01:00
W.C.A. Wijngaards
f887552763 - Fix Config Injection in create_unbound_ad_servers.sh,
reported by X41 D-Sec.
2019-11-20 12:02:19 +01:00
W.C.A. Wijngaards
d4c904d091 - contrib/fastrpz.patch updated to apply for current code. 2019-11-13 11:40:56 +01:00
W.C.A. Wijngaards
e6a179e27a - drop-tld.diff: adds option drop-tld: yesno that drops 2 label
queries, to stop random floods.  Apply with
  patch -p1 < contrib/drop-tld.diff and compile.
  From Saksham Manchanda (Secure64).  Please note that we think this
  will drop DNSKEY and DS lookups for tlds and hence break DNSSEC
  lookups for downstream clients.
2019-10-22 10:32:37 +02:00
Pascal Ernster
11f22074a9
Drop CAP_KILL, use + prefix for ExecReload= instead
CAP_KILL seems a bit too much privileges for the sole purpose of being able to make ExecReload= work.
Use the + prefix on ExecReload= instead to run "/bin/kill -HUP $MAINPID" with full privileges, ignoring the restrictions from CapabilityBoundingSet=.

See https://www.freedesktop.org/software/systemd/man/systemd.service.html#ExecStart= for further details about the + prefix in ExecReload=.
2019-09-26 08:41:37 +00:00
sam-lunt
6943cab670
Add kill capability to systemd service file
The ExecReload command calls kills on a process owned by the unbound user (or whatever user is configured). To do so, it needs the CAP_KILL capability.
2019-09-21 14:36:12 -05:00
Maryse47
acdd4058d2
unbound.service.in: do not fork into the background
This is needed when unbound config doesn't set "do-daemonize: no" by itself otherwise starting service fails with:
 systemd[1]: unbound.service: Got notification message from PID <PID>, but reception only permitted for main PID which is currently not known

https://github.com/NLnetLabs/unbound/blob/release-1.9.3/doc/example.conf.in#L236
2019-09-20 10:07:37 +00:00
Wouter Wijngaards
e1e71eac3e
Merge pull request #81 from Maryse47/urandom
Consistently use /dev/urandom instead of /dev/random in scripts and docs
2019-09-20 07:44:22 +02:00
Pascal Ernster
ae2d5276d2
Downgrade CAP_NET_ADMIN to CAP_NET_RAW in unbound.service
Since kernel 3.2, CAP_NET_RAW instead of CAP_NET_ADMIN is sufficient to allow for the usage of the IP_TRANSPARENT socket option. CAP_NET_ADMIN allows far more mayhem then CAP_NET_RAW, so prefer the safer, more restrictive solution.
2019-09-20 04:47:56 +00:00
Maryse47
ce0e9bef45 Consistently use /dev/urandom instead of /dev/random in scripts and docs
Unbound code call /dev/urandom (see below)  but various docs and scripts
mention /dev/random which may be confusing.

https://github.com/NLnetLabs/unbound/blob/release-1.9.3/compat/arc4random.c#L107
https://github.com/NLnetLabs/unbound/blob/release-1.9.3/compat/getentropy_linux.c#L251
https://github.com/NLnetLabs/unbound/blob/release-1.9.3/compat/getentropy_osx.c
https://github.com/NLnetLabs/unbound/blob/release-1.9.3/compat/getentropy_solaris.c#L116
2019-09-19 17:40:49 +02:00
Maryse47
ff8fd0be5c Improvements and fixes for systemd unbound.service
1. Remove `ProtectKernelTunables=true`: This prevents various with socket options from working as shown below.
`unbound[] warning: so-rcvbuf 1048576 was not granted. Got 425984. To fix: start with root permissions(linux) or sysctl bigger net.core.rmem_max(linux) or kern.ipc.maxsockbuf(bsd) values.`

2. Add `CAP_NET_ADMIN` to available caps which is needed for `ip-transparent: yes` config option to work as shown below.
`unbound[] warning: setsockopt(.. IP_TRANSPARENT ..) failed: Operation not permitted`

3. Make `ReadWritePaths` less permissive: `UNBOUND_SYSCONF_DIR` equals to `sysconfdir` which usually equals to `/etc` and `UNBOUND_LOCALSTATE_DIR` equals to `localstatedir` which usually equals to `/var`. Allowing write access for those dirs shouldn't be needed. The only dirs unbound should be allow to write to are `/run` ( for pidfile), `@UNBOUND_RUN_DIR@` (for chroot) and `@UNBOUND_CHROOT_DIR@` in case it differs from the previous one.

4. Bind-mount `/run/systemd/notify`, `UNBOUND_PIDFILE`, `/dev/log`, `/dev/urandom` in order to use them inside chroot.

5. Add few extra hardening options: `RestrictNamespaces`, `LockPersonality` and `RestrictSUIDSGID` should be safe to use.
2019-09-18 21:48:12 +02:00
W.C.A. Wijngaards
a374dfb669 - Fix contrib/fastrpz.patch asprintf return value checks. 2019-08-23 08:41:46 +02:00
W.C.A. Wijngaards
e35d5f5a2d delete duplicate file. 2019-08-22 13:32:34 +02:00
W.C.A. Wijngaards
334e2b1e35 updated fastrpz.patch to apply cleanly. 2019-08-22 13:31:09 +02:00
W.C.A. Wijngaards
c602ba7319 - Fixup contrib/fastrpz.patch 2019-08-16 12:37:13 +02:00
W.C.A. Wijngaards
f46c238552 - contrib/fastrpz.patch updated for code changes, and with git diff. 2019-05-02 11:17:41 +02:00
Wouter Wijngaards
33a814683b - Fix #14: contrib/unbound.init: Fix wrong comparison judgment
before copying.


git-svn-id: file:///svn/unbound/trunk@5124 be551aaa-1e26-0410-a405-d3ace91eadb9
2019-02-27 06:58:10 +00:00
Wouter Wijngaards
8fffdca2a6 - Set ub_ctx_set_tls call signature in ltrace config file for
libunbound in contrib/libunbound.so.conf.


git-svn-id: file:///svn/unbound/trunk@5090 be551aaa-1e26-0410-a405-d3ace91eadb9
2019-01-31 09:16:15 +00:00
Wouter Wijngaards
b005fcd87b - updated contrib/fastrpz.patch to cleanly diff.
git-svn-id: file:///svn/unbound/trunk@5075 be551aaa-1e26-0410-a405-d3ace91eadb9
2019-01-25 12:50:45 +00:00
Wouter Wijngaards
ec84fd2ca6 - Add contrib/unbound-fuzzme.patch from Jacob Hoffman-Andrews,
the patch adds a program used for fuzzing.


git-svn-id: file:///svn/unbound/trunk@5028 be551aaa-1e26-0410-a405-d3ace91eadb9
2019-01-07 15:01:24 +00:00
Wouter Wijngaards
f95f98b12a - Update contrib fastrpz patch for latest release.
git-svn-id: file:///svn/unbound/trunk@4988 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-11-27 15:47:52 +00:00
Wouter Wijngaards
83a186f6cc Remove unused diagnostic pragmas that themselves generate warnings
git-svn-id: file:///svn/unbound/trunk@4927 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-10-02 12:17:11 +00:00
Wouter Wijngaards
2598f9bb18 line fixup
git-svn-id: file:///svn/unbound/trunk@4926 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-10-02 12:13:19 +00:00
Wouter Wijngaards
ba28c48efc Remove unused variable from contrib fastrpz/rpz.c
git-svn-id: file:///svn/unbound/trunk@4925 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-10-02 12:12:29 +00:00
Wouter Wijngaards
98234d1017 - updated contrib/fastrpz.patch to apply for this version
git-svn-id: file:///svn/unbound/trunk@4924 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-10-02 12:00:06 +00:00
Wouter Wijngaards
966a958ca5 Fixup fastrpz.patch
git-svn-id: file:///svn/unbound/trunk@4920 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-10-02 10:34:00 +00:00
Wouter Wijngaards
00982fc3db - Fixed unused return value warnings in contrib/fastrpz.patch for
asprintf.


git-svn-id: file:///svn/unbound/trunk@4891 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-09-11 13:19:55 +00:00
Wouter Wijngaards
f2b12c0761 - Fix contrib/fastrpz.patch.
git-svn-id: file:///svn/unbound/trunk@4856 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-08-16 10:29:00 +00:00
Wouter Wijngaards
070019c9be - Fix #4142: unbound.service.in: improvements and fixes.
Add unit dependency ordering (based on systemd-resolved).
  Add 'CAP_SYS_RESOURCE' to 'CapabilityBoundingSet' (fixes warnings
  about missing privileges during startup). Add 'AF_INET6' to
  'RestrictAddressFamilies' (without it IPV6 can't work). From
  Guido Shanahan.


git-svn-id: file:///svn/unbound/trunk@4834 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-08-07 08:30:22 +00:00
Wouter Wijngaards
bca54a8b25 - Patch, do not export python from pkg-config, from Petr Menšík.
git-svn-id: file:///svn/unbound/trunk@4758 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-06-27 06:07:31 +00:00
Wouter Wijngaards
f64a897cbc - Fix contrib/libunbound.pc for libssl libcrypto references,
from https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=226914


git-svn-id: file:///svn/unbound/trunk@4682 be551aaa-1e26-0410-a405-d3ace91eadb9
2018-05-11 11:52:19 +00:00