Commit graph

15645 commits

Author SHA1 Message Date
Tom Gundersen a2c28c6451 Merge pull request #3549 from poettering/resolved-more
resolved: more fixes, among them "systemctl-resolve --status" to see DNS configuration in effect, and a local DNS stub listener on 127.0.0.53
2016-06-24 01:26:25 +02:00
Harald Hoyer 3ade16c9c8 fstab-generator: ignore root=/dev/nfs (#3591)
root=/dev/nfs is a legacy option for the kernel to handle root on NFS.

Documentation for this kernel command line option
can be found in the kernel source tree:

Documentation/filesystems/nfs/nfsroot.txt
2016-06-23 18:47:03 +02:00
Ronny Chevalier 48a97bb4dc Merge pull request #3583 from poettering/restrict-realtime
add new RestrictRealtime= option to services (and other fixes)
2016-06-23 13:11:58 +01:00
Ronny Chevalier 2bb6c19f52 Merge pull request #3581 from dobyrch/master
systemctl:  Add missing "/" to files created by 'edit --runtime'
2016-06-23 10:15:40 +01:00
Lennart Poettering 4b7abb5b11 build-sys: move fdset.[ch] src/basic → src/shared (#3580)
It makes use of the sd_listen_fds() call, and as such should live in
src/shared, as the distinction between src/basic and src/shared is that the
latter may use libsystemd APIs, the former does not.

Note that btrfs-util.[ch] and log.[ch] also include header files from
libsystemd, but they only need definitions, they do not invoke any function
from it. Hence they may stay in src/basic.
2016-06-23 05:10:53 +03:00
Lennart Poettering f4170c671b execute: add a new easy-to-use RestrictRealtime= option to units
It takes a boolean value. If true, access to SCHED_RR, SCHED_FIFO and
SCHED_DEADLINE is blocked, which my be used to lock up the system.
2016-06-23 01:45:45 +02:00
Lennart Poettering abd84d4d83 execute: be a little less drastic when MemoryDenyWriteExecute= hits
Let's politely refuse with EPERM rather than kill the whole thing right-away.
2016-06-23 01:35:04 +02:00
Lennart Poettering 686d9ba614 execute: set PR_SET_NO_NEW_PRIVS also in case the exec memory protection is used
This was forgotten when MemoryDenyWriteExecute= was added: we should set NNP in
all cases when we set seccomp filters.
2016-06-23 01:33:07 +02:00
Lennart Poettering 03857c43ce execute: use the return value of setrlimit_closest() properly
It's a function defined by us, hence we should look for the error in its return
value, not in "errno".
2016-06-23 01:31:24 +02:00
Lennart Poettering fc40065bcd core: when writing transient unit files, make sure all lines end with a newline
This is a fix-up for 2a9a6f8ac0 which covered
non-transient units, but missed the case for transient units.
2016-06-23 01:29:33 +02:00
Douglas Christman 79d4ace11e systemctl: Add missing "/" to files created by 'edit --runtime' 2016-06-22 15:09:33 -04:00
Elias Probst 1e9707d495 machinectl: do not escape the unit name (#3554)
Otherwise starting a machine named `foo-bar-baz` will end up in
machinectl attempting to start the service unit
`systemd-nspawn@foo\x2dbar\x2dbaz` instead of
`systemd-nspawn@foo-bar-baz`.
2016-06-22 17:10:52 +02:00
Minkyung 2787d83c28 watchdog: Support changing watchdog_usec during runtime (#3492)
Add sd_notify() parameter to change watchdog_usec during runtime.

Application can change watchdog_usec value by
sd_notify like this. Example. sd_notify(0, "WATCHDOG_USEC=20000000").

To reset watchdog_usec as configured value in service file,
restart service.

Notice.
sd_event is not currently supported. If application uses
sd_event_set_watchdog, or sd_watchdog_enabled, do not use
"WATCHDOG_USEC" option through sd_notify.
2016-06-22 13:26:05 +02:00
Lennart Poettering 98471bf0fa Merge pull request #3526 from fbuihuu/fix-console-log-color
Fix console log color
2016-06-22 12:34:25 +02:00
Franck Bui 3a18b60489 pid1: initialize status color mode after setting up TERM
Also we had to connect PID's stdio to null later since colors_enabled()
assume that stdout is connected to the console.
2016-06-22 08:29:02 +02:00
Franck Bui 32391275c0 pid1: initialize TERM environment variable correctly
When systemd is started by the kernel, the kernel set the TERM
environment variable unconditionnally to "linux" no matter the console
device used. This might be an issue for dumb devices with no colors
support.

This patch uses default_term_for_tty() for getting a more accurate
value. But it makes sure to keep the user preferences (if any) which
might be passed via the kernel command line. For that purpose /proc
should be mounted.
2016-06-22 08:28:55 +02:00
Ian Lee 7351ded5b9 Do not ellipsize cgroups when showing slices in --full mode (#3560)
Do not ellipsize cgroups when showing slices in --full mode
2016-06-21 16:10:31 +02:00
Lennart Poettering 4e68ec1866 tmpfiles: make sure to always initialize "r" correctly. 2016-06-21 14:15:23 +02:00
Lennart Poettering 3f0083a264 tree-wide: some work-arounds for gcc false positives regarding uninitialized variables 2016-06-21 14:15:23 +02:00
Lennart Poettering b30bf55d5c resolved: respond to local resolver requests on 127.0.0.53:53
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-21 14:15:23 +02:00
Lennart Poettering 2a3900d7e4 resolved: use DNS_{QUESTION|ANSWER}_FOREACH macros at two more places 2016-06-21 13:20:48 +02:00
Lennart Poettering f2ed4c696a resolved: extend dns_packet_append_opt() so that it can set the extended rcode
We don't make use of this yet, but later work will.
2016-06-21 13:20:48 +02:00
Lennart Poettering f471bc11c6 resolved: add dns_packet_add_{question,answer}() helper
And make use of it at a couple of places.
2016-06-21 13:20:48 +02:00
Lennart Poettering 501e8eb054 resolved: add dns_answer_is_empty() and dns_question_is_empty() helpers
And make use of them at a few places.
2016-06-21 13:20:48 +02:00
Lennart Poettering 17c8de633f resolved: when using the ResolveRecord() bus call, adjust TTL for caching time
When we return the full RR wire data, let's make sure the TTL included in it is
adjusted by the time the RR sat in the cache.

As an optimization we do this only for ResolveRecord() and not for
ResolveHostname() and friends, since adjusting the TTL means copying the RR
object, and we don#t want to do that if there's no reason to.
(ResolveHostname() and friends don't return the TTL hence there's no reason to
in that case)
2016-06-21 13:20:48 +02:00
Lennart Poettering 6ebd1e33e6 resolved: explicitly refuse zone transfers using the bus API 2016-06-21 13:20:48 +02:00
Lennart Poettering 0a0fc27b80 resolved: drop unused permit_domain_search variable from Manager object 2016-06-21 13:20:48 +02:00
Lennart Poettering 43dcc86a13 sd-bus: make sure bus_map_all_properties() handle booleans right
sd-bus generally exposes bools as "int" instead of "bool" in the public API.
This is relevant when unmarshaling booleans, as the relevant functions expect
an int* pointer and no bool* pointer. Since sizeof(bool) is not necessarily the
same as sizeof(int) this is problematic and might result in memory corruption.

Let's fix this, and make sure bus_map_all_properties() handles booleans as
ints, as the rest of sd-bus, and make all users of it expect the right thing.
2016-06-21 13:20:48 +02:00
Lennart Poettering 943ef07ce0 resolved: make sure DNS configuration pushed in by the user stays around on restarts
Let's make sure that all settings pushed in stay around when systemd-resolved
is restarted.
2016-06-21 13:20:48 +02:00
Lennart Poettering d97c5aeab8 set: add new set_put_strsplit() call
It's like set_put_strdup(), but splits up a string via an extract_first_word()
loop.
2016-06-21 13:20:48 +02:00
Lennart Poettering b6274a0e9e resolved: fix negated boolean function
It's weird having a "negative" function link_is_unmanaged(), let's invert it
and get rid of the negation this way, by renaming it to link_is_managed().

Internally we stored this as a positive boolean already, hence let's do this
for the function too.
2016-06-21 13:20:48 +02:00
Lennart Poettering 55e99f2064 resolved: rework link_update_dns_servers() a bit
Let's split the code from the inner loop out, into its own function
link_update_dns_server_one(). This matches how things are already handled for
the search domain logic. Also, this is preparation for a later commit that
persists DNS server data pushed in via the bus.
2016-06-21 13:20:48 +02:00
Lennart Poettering 39f259e0b8 resolved: make use of set_put_strdupv() where appropriate 2016-06-21 13:20:48 +02:00
Lennart Poettering 6f7da49d00 resolved: make sure that route-only domains are never added to /etc/resolv.conf
After all, /etc/resolv.conf doesn't know the concept of "route-only domains",
hence the domains should really not appear there.
2016-06-21 13:20:47 +02:00
Lennart Poettering 35ca4ce022 string-table: make sure DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() handles NULL strings nicely
xyz_from_string() functions defined with DEFINE_STRING_TABLE_LOOKUP() properly
handle NULL strings already. make sure the equivalent functions defined with
DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN() do the same.
2016-06-21 13:20:47 +02:00
Lennart Poettering be371fe039 resolve: add "systemd-resolve --status" command
The new command shows the per-link and global DNS configuration currently in
effect. This is useful to quickly see the DNS settings resolved acquired from
networkd and that was pushed into it via the bus APIs.
2016-06-21 13:20:47 +02:00
Lennart Poettering a37129796c resolved: export the effective per-link DNSSEC setting, not the internal one
Internally, we store the per-link DNSSEC setting as -1 (invalid) if there's no
link-specific setting configured, and the global setting should be used. When
exporting this one the bus we really should export the effective DNSSEC
setting however, i.e. return the global one if there's non set per-link.
2016-06-21 13:20:47 +02:00
Lennart Poettering 476798b17d resolved: export global NTAs on the bus
We export them per-link, hence let's export the global NTAs too.
2016-06-21 13:20:47 +02:00
Lennart Poettering 5733d88dc1 networkd: fix bad memory access when parsing DNSSECNegativeTrustAnchors= 2016-06-21 13:20:47 +02:00
Evgeny Vereshchagin eee0a1e48e core: log the right set of the supported controllers (#3558)
Jun 16 05:12:08 systemd[1]: Controller 'io' supported: yes
Jun 16 05:12:08 systemd[1]: Controller 'memory' supported: yes
Jun 16 05:12:08 systemd[1]: Controller 'pids' supported: yes

instead of

Jun 16 04:06:50 systemd[1]: Controller 'memory' supported: yes
Jun 16 04:06:50 systemd[1]: Controller 'devices' supported: yes
Jun 16 04:06:50 systemd[1]: Controller 'pids' supported: yes
2016-06-20 20:40:46 +02:00
Franck Bui 8ce0611e42 Revert "do not pass-along the environment from the kernel or initrd"
This reverts commit ce8aba5681.

We should pass an environment as close as possible to what we originally
got.
2016-06-20 18:55:09 +02:00
Franck Bui affd7ed1a9 pid1: reconnect to the console before being re-executed
When re-executed, reconnect the console to PID1's stdios as it was the case
when PID1 was initially started by the kernel.
2016-06-20 18:40:51 +02:00
Evgeny Vereshchagin b3d69149bd tests: don't run test_get_process_cmdline_harder under valgrind
See https://github.com/systemd/systemd/pull/3555#issuecomment-226564908
2016-06-19 23:47:46 +00:00
Evgeny Vereshchagin b774852ae6 tests: fix memory leak in test-keymap-util
Fixes:
==27917== 3 bytes in 1 blocks are definitely lost in loss record 1 of 1
==27917==    at 0x4C28BF6: malloc (vg_replace_malloc.c:299)
==27917==    by 0x55083D9: strdup (in /usr/lib64/libc-2.22.so)
==27917==    by 0x1140DA: find_converted_keymap (keymap-util.c:524)
==27917==    by 0x110844: test_find_converted_keymap (test-keymap-util.c:52)
==27917==    by 0x1124FE: main (test-keymap-util.c:213)
==27917==
2016-06-19 15:04:52 +00:00
Dave Reisner 222953e87f Ensure kdbus isn't used (#3501)
Delete the dbus1 generator and some critical wiring. This prevents
kdbus from being loaded or detected. As such, it will never be used,
even if the user still has a useful kdbus module loaded on their system.

Sort of fixes #3480. Not really, but it's better than the current state.
2016-06-18 17:24:23 -04:00
Lennart Poettering b09df4e21d process-util: fix two bugs in get_process_cmdline() (#3555)
See:

https://github.com/systemd/systemd/pull/3529#issuecomment-226421007
2016-06-16 16:46:44 -04:00
Lennart Poettering 749a1d0684 Merge pull request #3546 from keszybz/systemctl-fixes
Systemctl fixes
2016-06-16 18:40:53 +02:00
Lennart Poettering 5278bbfe0c resolved: when restarting a transaction make sure to not touch it anymore (#3553)
dns_transaction_maybe_restart() is supposed to return 1 if the the transaction
has been restarted and 0 otherwise. dns_transaction_process_dnssec() relies on
this behaviour. Before this change in case of restart we'd call
dns_transaction_go() when restarting the lookup, returning its return value
unmodified. This is wrong however, as that function returns 1 if the
transaction is pending, and 0 if it completed immediately, which is a very
different set of return values. Fix this, by always returning 1 on redirection.

The wrong return value resulted in all kinds of bad memory accesses as we might
continue processing a transaction that was redirected and completed immediately
(and thus freed).

This patch also adds comments to the two functions to clarify the return values
for the future.

Most likely fixes: #2942 #3475 #3484
2016-06-16 18:37:11 +02:00
Zbigniew Jędrzejewski-Szmek d2ad7e1ba5 systemctl: delay pager/polkit agent opening as much as possible
In https://github.com/systemd/systemd/issues/3543, we would open the pager
before starting ssh, and the pipe fd was "leaked" into the ssh child as the
stderr fd. Previous commit fixes bus-socket to nullify stderr before launching
the child, but it seems reasonable to also delay starting the pager.
If we are going to croak when trying to open the transport, it seems better
to do this before starting the pager.

This commit would also fix #3543 on its own.
2016-06-16 09:30:18 -04:00
Lennart Poettering cf647b69ba systemctl: make sure we terminate the bus connection first, and then close the pager (#3550)
If "systemctl -H" is used, let's make sure we first terminate the bus
connection, and only then close the pager. If done in this order ssh will get
an EOF on stdin (as we speak D-Bus through ssh's stdin/stdout), and then
terminate. This makes sure the standard error we were invoked on is released by
ssh, and only that makes sure we don't deadlock on the pager which waits for
all clients closing its input pipe.

(Similar fixes for the various other xyzctl tools that support both pagers and
-H)

Fixes: #3543
2016-06-16 09:29:16 -04:00