1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-28 11:55:23 +03:00
Commit Graph

23747 Commits

Author SHA1 Message Date
Lennart Poettering
37ade12837 dns-domain: change error codes when dealing with too short buffers to ENOBUFS
Some calls used ENOBUFS to indicate too-short result buffers, others
used ENOSPC. Let's unify this on ENOBUFS.
2015-11-30 19:42:35 +01:00
Lennart Poettering
50dee79bfb dns-domain: check resulting domain name length in dns_name_to_wire_format()
Let's better be safe than sorry.
2015-11-30 19:42:35 +01:00
Lennart Poettering
c6cefd13eb dns-domain: make sure dns_name_to_wire_format() may properly encode the root domain
The root domain consists of zero labels, and we should be able to encode
that.
2015-11-30 19:42:35 +01:00
Lennart Poettering
1dfbf0007a dns-domain: don't accept overly long hostnames
Make sure dns_name_normalize(), dns_name_concat(), dns_name_is_valid()
do not accept/generate invalidly long hostnames, i.e. longer than 253
characters.
2015-11-30 19:42:35 +01:00
Lennart Poettering
3b37fa7352 dns-domain: be more strict when encoding/decoding labels
Labels of zero length are not OK, refuse them early on. The concept of a
"zero-length label" doesn't exist, a zero-length full domain name
however does (representing the root domain). See RFC 2181, Section 11.
2015-11-30 19:37:41 +01:00
Lennart Poettering
bca27e1729 Merge pull request #2068 from grawity/cgls-error-v2
cgls: add a better error message for missing cgroupfs [v2]
2015-11-30 19:32:19 +01:00
David Herrmann
de418eb91c Merge pull request #2053 from poettering/selinux-fix
Two unrelated fixes
2015-11-30 19:30:03 +01:00
Mantas Mikulėnas
e97a84757f cgls: add a better error message for missing cgroupfs 2015-11-30 19:06:43 +02:00
Lennart Poettering
a00405285e Merge pull request #2063 from keszybz/issue-1977-2
journal: clean up permission setting and acl adjustements on user journals
2015-11-30 17:53:39 +01:00
Zbigniew Jędrzejewski-Szmek
afae249efa tmpfiles: set acls on system.journal explicitly
https://github.com/systemd/systemd/issues/1397
2015-11-29 23:38:09 -05:00
Zbigniew Jędrzejewski-Szmek
57d5b3130c tmpfiles: also set acls on /var/log/journal
This way, directories created later for containers or for
journald-remote, will be readable by adm & wheel groups by default,
similarly to /var/log/journal/%m itself.

https://github.com/systemd/systemd/issues/1971
2015-11-29 18:37:01 -05:00
Ronny Chevalier
3a89c3a0fc Merge pull request #2058 from phomes/unused-variable2
tree-wide: remove unused variables
2015-11-29 15:43:02 +01:00
Thomas Hindoe Paaboel Andersen
ae96c4eb2c tree-wide: remove unused variables 2015-11-29 08:59:40 +01:00
Zbigniew Jędrzejewski-Szmek
6debb39826 acl-util: only set the mask if not present
When we have non-owner user or group entries, we need the mask
for the acl to be valid. But acl_calc_mask() calculates the mask
to include all permissions, even those that were masked before.
Apparently this happens when we inherit *:r-x permissions from
a parent directory — the kernel sets *:r-x, mask:r--, effectively
masking the executable bit. acl_calc_mask() would set the mask:r-x,
effectively enabling the bit. To avoid this, be more conservative when
to add the mask entry: first iterate over all entries, and do nothing
if a mask.

This returns the code closer to J.A.Steffens' original version
in v204-90-g23ad4dd884.

Should fix https://github.com/systemd/systemd/issues/1977.
2015-11-28 18:48:03 -05:00
Zbigniew Jędrzejewski-Szmek
5bb5b236fe test-acl-util: add new test
For now, only add_acls_for_user is tested. When run under root, it
actually sets the acls. When run under non-root, it sets the acls for
the user, which does nothing, but at least calls the functions.
2015-11-28 18:47:34 -05:00
Zbigniew Jędrzejewski-Szmek
5c3bde3fa8 journal: move the gist of server_fix_perms to acl-util.[hc]
Most of the function is moved to acl-util.c to make it possible to
add tests in subsequent commit.

Setting of the mode in server_fix_perms is removed:
- we either just created the file ourselves, and the permission be better right,
- or the file was already there, and we should not modify the permissions.

server_fix_perms is renamed to server_fix_acls to better reflect new
meaning, and made static because it is only used in one file.
2015-11-27 23:32:32 -05:00
Lennart Poettering
20ba6c2ebe libsystemd: make sure we prefix even the dirty secrets in our API with "_sd_"
This renames __useless_struct_to_allow_trailing_semicolon__ everywhere
to _sd_useless_struct_to_allow_trailing_semicolon_, to follow our usual
rule of prefixing stuff from public headers that should be considered
internal with "_sd_".

While we are at it, also to be safe: when the struct is used in the C++
protector macros make sure to use two different names depending on
whether it appears in the C++ or C side of things. After all, there
might be compilers that don't consider C++ and C structs the same.

See https://github.com/systemd/systemd/pull/2052#discussion_r46067059
2015-11-27 20:33:04 +01:00
Lennart Poettering
6355e75610 selinux: split up mac_selinux_have() from mac_selinux_use()
Let's distuingish the cases where our code takes an active role in
selinux management, or just passively reports whatever selinux
properties are set.

mac_selinux_have() now checks whether selinux is around for the passive
stuff, and mac_selinux_use() for the active stuff. The latter checks the
former, plus also checks UID == 0, under the assumption that only when
we run priviliged selinux management really makes sense.

Fixes: #1941
2015-11-27 20:28:13 +01:00
David Herrmann
564c44436c Merge pull request #2052 from poettering/export-cleanup
Make gcc cleanup helper calls public in most of our sd-xyz APIs
2015-11-27 20:26:33 +01:00
Lennart Poettering
e900a84679 Merge pull request #2043 from teg/resolved-edns0-5
resolved: add edns0 support
2015-11-27 19:29:04 +01:00
Lennart Poettering
9ead3519c5 resolved: add one more comment with a link to the matching RFC 2015-11-27 19:23:46 +01:00
Lennart Poettering
6b25959dfa util-lib: move nss-util.h from shared/ to basic/
The header file defines some helpers for GLIBC NSS and doesn't include
anything else but glibc headers, hence there's little reason to keep it
in shared/.

See: #2008
2015-11-27 19:23:29 +01:00
Lennart Poettering
4afd3348c7 tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easy
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.
2015-11-27 19:19:36 +01:00
Daniel Mack
f5edf80e29 Merge pull request #2049 from evverx/journal-test-dont-run-on-incomplete-setup
tests: don't run test on incomplete setup; use sync
2015-11-27 15:26:21 +01:00
Evgeny Vereshchagin
e8e5a6e255 tests: use sync instead of flush
flush doesn't sync a journal -> tests sometimes fail
2015-11-27 13:55:23 +00:00
Daniel Mack
23ede49ee2 Merge pull request #2048 from poettering/fork-errno
core:execute: fix fork() fail handling in exec_spawn()
2015-11-27 14:35:56 +01:00
Evgeny Vereshchagin
c7bb28732f tests: don't run test on incomplete setup
This is a follow-up commit for
https://github.com/systemd/systemd/pull/1937

See https://github.com/systemd/systemd/pull/2030
2015-11-27 13:29:51 +00:00
lc85446
74129a1276 core:execute: fix fork() fail handling in exec_spawn()
If pid < 0 after fork(), 0 is always returned because r =
    exec_context_load_environment() has exited successfully.

    This will make the caller of exec_spawn() not able to handle
    the fork() error case and make systemd abort assert() possibly.
2015-11-27 14:15:33 +01:00
Lennart Poettering
59a99b2007 Merge pull request #1833 from utezduyar/drop-warning-on-preset
drop warning if setting preset worked anyways
2015-11-27 14:06:36 +01:00
Lennart Poettering
d353a16d1f Merge pull request #1937 from evverx/fix-stdout-parsing
Fix stdout stream parsing
2015-11-27 14:03:49 +01:00
Lennart Poettering
97839ed6b7 Merge pull request #2017 from haraldh/nobinddevice2
core: Do not bind a mount unit to a device, if it was from mountinfo
2015-11-27 14:02:25 +01:00
Lennart Poettering
2281b56044 Merge pull request #1828 from fbuihuu/set-property-on-inactive-unit
core: allow 'SetUnitProperties()' to run on inactive units too
2015-11-27 14:00:57 +01:00
Lennart Poettering
a8273d1253 Merge pull request #1989 from keszybz/filetriggers-v2
Return of the file triggers
2015-11-27 13:52:43 +01:00
Lennart Poettering
6182e51efa Merge pull request #2040 from keszybz/randomized-delay
core: rename Random* to RandomizedDelay*
2015-11-27 13:48:12 +01:00
Daniel Mack
ab57824597 Merge pull request #2046 from evverx/rlimit-parsing
Fix rlimit parsing
2015-11-27 12:45:04 +01:00
Evgeny Vereshchagin
fdbbadbd0d core: dump rlim_cur too 2015-11-27 11:26:55 +00:00
Evgeny Vereshchagin
0316f2aeeb core: fix rlimit parsing
* refuse limits if soft > hard
* print an actual value instead of (null)

see https://github.com/systemd/systemd/pull/1994#issuecomment-159999123
2015-11-27 11:26:37 +00:00
Daniel Mack
c9ff64f725 Merge pull request #2030 from evverx/dont-run-tests-on-incomplete-setup
tests: don't run tests on incomplete setup
2015-11-27 12:22:12 +01:00
David Herrmann
ff7d5a5c7c Merge pull request #2044 from grawity/patch-1
resolved: fix typo in in_addr_is_localhost()
2015-11-27 10:35:34 +01:00
Martin Pitt
827661914a Merge pull request #2029 from teg/network-fixes
Network fixes
2015-11-27 10:20:18 +01:00
Mantas Mikulėnas
db15affc05 resolved: fix typo in in_addr_is_localhost() 2015-11-27 08:36:37 +02:00
Zbigniew Jędrzejewski-Szmek
e0d8c8015a Merge commit 'pr/2036^^' 2015-11-26 21:24:08 -05:00
Tom Gundersen
d74fb368b1 resolved: announce support for large UDP packets
This is often needed for proper DNSSEC support, and even to handle AAAA records
without falling back to TCP.

If the path between the client and server is fully compliant, this should always
work, however, that is not the case, and overlarge packets will get mysteriously
lost in some cases.

For that reason, we use a similar fallback mechanism as we do for palin EDNS0,
EDNS0+DO, etc.:

The large UDP size feature is different from the other supported feature, as we
cannot simply verify that it works based on receiving a reply (as the server
will usually send us much smaller packets than what we claim to support, so
simply receiving a reply does not mean much).

For that reason, we keep track of the largest UDP packet we ever received, as this
is the smallest known good size (defaulting to the standard 512 bytes). If
announcing the default large size of 4096 fails (in the same way as the other
features), we fall back to the known good size. The same logic of retrying after a
grace-period applies.
2015-11-27 01:35:47 +01:00
Tom Gundersen
7586f4d172 resolved: set the DNSSEC OK (DO) flag
This indicates that we can handle DNSSEC records (per RFC3225), even if
all we do is silently drop them. This feature requires EDNS0 support.

As we do not yet support larger UDP packets, this feature increases the
risk of getting truncated packets.

Similarly to how we fall back to plain UDP if EDNS0 fails, we will fall
back to plain EDNS0 if EDNS0+DO fails (with the same logic of remembering
success and retrying after a grace period after failure).
2015-11-27 01:35:34 +01:00
Tom Gundersen
9c5e12a431 resolved: implement minimal EDNS0 support
This is a minimal implementation of RFC6891. Only default values
are used, so in reality this will be a noop.

EDNS0 support is dependent on the current server's feature level,
so appending the OPT pseudo RR is done when the packet is emitted,
rather than when it is assembled. To handle different feature
levels on retransmission, we strip off the OPT RR again after
sending the packet.

Similarly, to how we fall back to TCP if UDP fails, we fall back
to plain UDP if EDNS0 fails (but if EDNS0 ever succeeded we never
fall back again, and after a timeout we will retry EDNS0).
2015-11-27 01:35:34 +01:00
Tom Gundersen
dc913c9a1f resolved: rr - add OPT pseudo-rr support
Needed for EDNS0.
2015-11-27 01:35:34 +01:00
Tom Gundersen
4e0b8b17a7 resolved: degrade the feature level on explicit failure
Previously, we would only degrade on packet loss, but when adding EDNS0 support,
we also have to handle the case where the server replies with an explicit error.
2015-11-27 01:35:33 +01:00
Tom Gundersen
be808ea083 resolved: fallback to TCP if UDP fails
This is inspired by the logic in BIND [0], follow-up patches
will implement the reset of that scheme.

If we get a server error back, or if after several attempts we don't
get a reply at all, we switch from UDP to TCP for the given
server for the current and all subsequent requests. However, if
we ever successfully received a reply over UDP, we never fall
back to TCP, and once a grace-period has passed, we try to upgrade
again to using UDP. The grace-period starts off at five minutes
after the current feature level was verified and then grows
exponentially to six hours. This is to mitigate problems due
to temporary lack of network connectivity, but at the same time
avoid flooding the network with retries when the feature attempted
feature level genuinely does not work.

Note that UDP is likely much more commonly supported than TCP,
but depending on the path between the client and the server, we
may have more luck with TCP in case something is wrong. We really
do prefer UDP though, as that is much more lightweight, that is
why TCP is only the last resort.

[0]: <https://kb.isc.org/article/AA-01219/0/Refinements-to-EDNS-fallback-behavior-can-cause-different-outcomes-in-Recursive-Servers.html>
2015-11-27 01:35:33 +01:00
Tom Gundersen
90c739259f Merge pull request #2042 from poettering/resolved-various-3
resolved: Flush caches more agressively, fixes #2038
2015-11-27 01:18:38 +01:00
Lennart Poettering
daa27350c3 update TODO 2015-11-27 00:46:51 +01:00