Commit graph

15621 commits

Author SHA1 Message Date
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
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
Zbigniew Jędrzejewski-Szmek dce588ec9d Merge pull request #3511 from andir/networkd-vrf
networkd: add support for vrf interfaces (#3316)
2016-06-16 09:15:45 -04:00
Lennart Poettering 616aab6085 Merge pull request #3481 from poettering/relative-memcg
various changes, most importantly regarding memory metrics
2016-06-16 13:56:23 +02:00
Zbigniew Jędrzejewski-Szmek 732cd53eeb Merge pull request #3537 from poettering/journal-stream-env
Permit services to detect whether their stdout/stderr is connected to the journal.
2016-06-15 21:30:59 -04:00
Andreas Rammhold 6cb955c6a1 networkd: vrf: add support for enslaving devices to VRFs 2016-06-16 00:25:06 +02:00
Andreas Rammhold 20897a0d6e networkd: added support for vrf interfaces (#3316) 2016-06-16 00:25:06 +02:00
Zbigniew Jędrzejewski-Szmek a1feacf77f load-fragment: ignore ENOTDIR/EACCES errors (#3510)
If for whatever reason the file system is "corrupted", we want
to be resilient and ignore the error, as long as we can load the units
from a different place.

Arch bug https://bugs.archlinux.org/task/49547.

A user had an ntfs symlink (essentially a file) instead of a directory after
restoring from backup. We should just ignore that like we would treat a missing
directory, for general resiliency.

We should treat permission errors similarly. For example an unreadable
/usr/local/lib directory would prevent (user) instances of systemd from
loading any units. It seems better to continue.
2016-06-15 23:02:27 +02:00
Lennart Poettering 7bce046bcf core: set $JOURNAL_STREAM to the dev_t/ino_t of the journal stream of executed services
This permits services to detect whether their stdout/stderr is connected to the
journal, and if so talk to the journal directly, thus permitting carrying of
metadata.

As requested by the gtk folks: #2473
2016-06-15 23:00:27 +02:00
Lennart Poettering fd1f9c89f7 execute: minor coding style improvements 2016-06-15 22:51:01 +02:00
Zbigniew Jędrzejewski-Szmek 33d52725f5 systemctl: also fall back to ListUnitsFiltered on access denied
When running systemctl from git on systemd from systemd-229-8.fc24.x86_64,
ListUnitsByPatterns results in org.freedesktop.DBus.Error.AccessDenied.
2016-06-15 10:03:33 -04:00
Zbigniew Jędrzejewski-Szmek 193edd61c3 systemctl: do not open pager twice
Second attempt had no effect anyway.
2016-06-15 09:44:07 -04:00
Kai Ruhnau 77d4acf332 socket-util: Run the fallback when the kernel complains about the null buffer (#3541)
Calling recv with a NULL buffer returns EFAULT instead of EOPNOTSUPP on
older kernels (3.14).

Fixes #3407

Signed-off-by: Kai Ruhnau <kai.ruhnau@target-sg.com>
2016-06-15 12:33:24 +02:00
Zbigniew Jędrzejewski-Szmek 7d38158b5d Merge pull request #3540 from poettering/resolved-various
three resolved fixes
2016-06-14 21:08:36 -04:00
Lennart Poettering 8e38570ebe tree-wide: htonl() is weird, let's use htobe32() instead (#3538)
Super-important change, yeah!
2016-06-15 01:26:01 +02:00
Lennart Poettering 69281c49eb util-lib: rework get_process_cmdline() (#3529)
This reworks get_process_cmdline() quite substantially, fixing the following:

- Fixes:
  a4e3bf4d7a (r66837630)

- The passed max_length is also applied to the "comm" name, if comm_fallback is
  set.

- The right thing happens if max_length == 1 is specified

- when the cmdline "foobar" is abbreviated to 6 characters the result is not
  "foobar" instead of "foo...".

- trailing whitespace are removed before the ... suffix is appended. The 7
  character abbreviation of "foo barz" is hence "foo..." instead of "foo ...".

- leading whitespace are suppressed from the cmdline

- a comprehensive test case is added
2016-06-14 17:52:29 -04:00
Lennart Poettering 94831eaeec resolved: in the ResolveHostname() bus call, accept IP addresses with scope
When we get a literal IP address as string that includes a zone suffix, process
this properly and return the parsed ifindex back to the client, and include it
in the canonical name in case of a link-local IP address.
2016-06-14 23:37:16 +02:00
Lennart Poettering 97ebebbc9c resolved: make sure we initialize the ifindex of direct zone answers properly
Previously, after checking the local zone for a reply and finding one we'd not
initialize the answer ifindex from that. Let's fix that.
2016-06-14 23:28:54 +02:00
Lennart Poettering 145fab1eae resolve: port resolve tool to in_addr_ifindex_{from_string_auto|to_string}()
We can reuse some code here, so let's do it.
2016-06-14 23:27:30 +02:00
Zbigniew Jędrzejewski-Szmek 19a29798bc udevadm: trivial simplification 2016-06-14 17:12:23 -04:00
Lennart Poettering 3f71dec5d7 unit: properly comment generated comments in unit files
Fix-up for 2a9a6f8ac0
2016-06-14 20:01:45 +02:00
Lennart Poettering a48072b703 sd-ndisc: add missing cast
Apparently newer gcc versions are a bit more forgiving when assigning an
"unsigned char*" pointer to something of a different type. Let's add the
missing cast so that old gcc versions are fine, too.
2016-06-14 20:01:45 +02:00
Lennart Poettering d58d600efd systemctl: allow percent-based MemoryLimit= settings via systemctl set-property
The unit files already accept relative, percent-based memory limit
specification, let's make sure "systemctl set-property" support this too.

Since we want the physical memory size of the destination machine to apply we
pass the percentage in a new set of properties that only exist for this
purpose, and can only be set.
2016-06-14 20:01:45 +02:00
Lennart Poettering d8cf2ac79b util: introduce physical_memory_scale() to unify how we scale by physical memory
The various bits of code did the scaling all different, let's unify this,
given that the code is not trivial.
2016-06-14 20:01:45 +02:00
Lennart Poettering 799ec13412 core: make sure to use "infinity" in unit files, not "max"
THe latter is a kernelism, we only understand "infinity".
2016-06-14 19:50:38 +02:00
Lennart Poettering cd0a7a8e58 core: when receiving a memory limit via the bus, refuse 0
When parsing unit files we already refuse unit memory limits of zero, let's
also refuse it when the value is set via the bus.
2016-06-14 19:50:38 +02:00