Commit graph

15748 commits

Author SHA1 Message Date
Lennart Poettering 26f417d3e8 util: don't send SIGCONT following a SIGCONT or SIGKILL in kill_and_sigcont() 2016-07-20 11:14:48 +02:00
Lennart Poettering 801a884d1e logind: minor coding style improvements 2016-07-20 11:14:18 +02:00
Lennart Poettering 069a92c658 Merge pull request #3685 from kinvolk/alessandro/inaccessible-paths
namespace: unify limit behavior on non-directory paths
2016-07-19 21:17:49 +02:00
Lennart Poettering 0d23bc57da sd-journal: suppress empty lines
Let's make sure our logging APIs is in sync with how stdout/stderr logging
works.
2016-07-19 17:51:20 +02:00
Alessandro Puccetti 2a624c36e6 doc,core: Read{Write,Only}Paths= and InaccessiblePaths=
This patch renames Read{Write,Only}Directories= and InaccessibleDirectories=
to Read{Write,Only}Paths= and InaccessiblePaths=, previous names are kept
as aliases but they are not advertised in the documentation.

Renamed variables:
`read_write_dirs` --> `read_write_paths`
`read_only_dirs` --> `read_only_paths`
`inaccessible_dirs` --> `inaccessible_paths`
2016-07-19 17:22:02 +02:00
Alessandro Puccetti c4b4170746 namespace: unify limit behavior on non-directory paths
Despite the name, `Read{Write,Only}Directories=` already allows for
regular file paths to be masked. This commit adds the same behavior
to `InaccessibleDirectories=` and makes it explicit in the doc.
This patch introduces `/run/systemd/inaccessible/{reg,dir,chr,blk,fifo,sock}`
{dile,device}nodes and mounts on the appropriate one the paths specified
in `InacessibleDirectories=`.

Based on Luca's patch from https://github.com/systemd/systemd/pull/3327
2016-07-19 17:22:02 +02:00
Lennart Poettering 8980058a37 journalctl: make sure that journalctl's --all switch also has an effect on json output
With this change, binary record data is formatted as string if --all is
specified when using json output. This is inline with the effect of --all on
the other available output modes.

Fixes: #3416
2016-07-19 14:21:49 +02:00
Lennart Poettering c24f1f9df1 sd-journal: when formatting log messages, implicitly strip trailing whitespace
When converting log messages from human readable text into binary records to
send off to journald in sd_journal_print(), strip trailing whitespace in the
log message. This way, handling of logs made via syslog(), stdout/stderr and
sd_journal_print() are treated the same way: trailing (but not leading)
whitespace is automatically removed, in particular \n and \r. Note that in case
of syslog() and stdout/stderr based logging the stripping takes place
server-side though, while for the native protocol based transport this takes
place client-side. This is because in the former cases conversion from
free-form human-readable strings into structured, binary log records takes
place on the server-side while for journal-native logging it happens on the
client side, and after conversion into binary records we probably shouldn't
alter the data anymore.

See: #3416
2016-07-19 14:21:49 +02:00
Harald Hoyer 340defcd06 kernel-install: recognize /boot/efi mountpoint (#3751)
install everything in /boot/efi, if this is a mountpoint
2016-07-19 12:10:09 +02:00
Thomas Hindoe Paaboel Andersen 12c40d4cc4 resolved: replace bitwise and with logical and 2016-07-18 22:42:13 +02:00
Thomas Hindoe Paaboel Andersen ba19c6e181 treewide: remove unused variables 2016-07-18 22:32:08 +02:00
Thomas Hindoe Paaboel Andersen 65a6195e76 basic: fix whitespace 2016-07-18 22:14:23 +02:00
Thomas Hindoe Paaboel Andersen 82edec5451 network: fix indentation 2016-07-18 22:09:57 +02:00
Jan Janssen 03e749af53 sd-boot: Fix waiting for keyboard input (#3735)
WaitForKeyEx may never return on some UEFI systems depending
on firmware, hardware configuration and the phase of the moon.
Use ConIn->WaitForKey unconditionally instead.

Fixes #3632
2016-07-18 15:19:32 -04:00
tblume 201b13c81e nspawn: decrease mkdir error logging in /sys to debug priority (#3748)
Such mkdir errors happen for example when trying to mkdir /sys/fs/selinux.

/sys is documented to be readonly in the container, so mkdir errors below /sys
can be expected.
They shouldn't be logged as warnings since they lead users to think that
there is something wrong.
2016-07-18 12:23:08 +02:00
Lennart Poettering b6070695c8 Merge pull request #3745 from keszybz/fix-make-nulstr-confusion
Fix make nulstr confusion
2016-07-18 11:12:47 +02:00
Daniel Mack d909beef0a Merge pull request #3746 from keszybz/trivial-fixes
Trivial fixes
2016-07-18 09:54:06 +02:00
Zbigniew Jędrzejewski-Szmek fc549b9605 Drop parentheses in two places 2016-07-17 19:58:07 -04:00
Zbigniew Jędrzejewski-Szmek 96ace31dcd systemd-resolve: remove spurious newline with no global settings 2016-07-17 19:58:02 -04:00
Zbigniew Jędrzejewski-Szmek 7b7c1aacf6 systemd-resolve: use plural "DNS Servers"
Usually multiple DNS servers are configured, and it looks strange to have
singular in the heading.
2016-07-17 19:58:02 -04:00
Zbigniew Jędrzejewski-Szmek b60df13b39 basic/strv: add an extra NUL after strings in strv_make_nulstr
strv_make_nulstr was creating a nulstr which was not a valid nulstr,
because it was missing the terminating NUL. This didn't cause any issues,
because strv_parse_nulstr correctly parsed the result, using the
separately specified length.

But it's confusing to have something called nulstr which really isn't.
It is likely that somebody will try to use strv_make_nulstr() in
some other place, incorrectly.

This patch changes strv_parse_nulstr() to produce a valid nulstr, and
changes the output length parameter to be the minimum number of bytes
which can be later on parsed by strv_parse_nulstr(). This allows the
only user in ask-password-api to be slightly simplified.

Based-on-patch-by: Jean-Sébastien Bour <jean-sebastien@bour.name>

Fixes #3689.
2016-07-17 15:34:57 -04:00
Jean-Sébastien Bour f41794d036 basic/strv: exhibit strv_make_nulstr missing final NUL char (systemd/systemd#3689) 2016-07-17 18:14:59 +02:00
Lukáš Nykrýn ccc2c98e1b manager: don't skip sigchld handler for main and control pid for services (#3738)
During stop when service has one "regular" pid one main pid and one
control pid and the sighld for the regular one is processed first the
unit_tidy_watch_pids will skip the main and control pid and does not
remove them from u->pids(). But then we skip the sigchld event because we
already did one in the iteration and there are two pids in u->pids.

v2: Use general unit_main_pid() and unit_control_pid() instead of
reaching directly to service structure.
2016-07-16 15:04:13 -04:00
Susant Sahani 2f27e2c556 networkd: fix for 3692 (#3699)
We should look that the kind is invalid rather than pointer is NULL.
2016-07-15 18:50:51 +02:00
Zbigniew Jędrzejewski-Szmek 2ed968802c tree-wide: get rid of selinux_context_t (#3732)
9eb9c93275
deprecated selinux_context_t. Replace with a simple char* everywhere.

Alternative fix for #3719.
2016-07-15 18:44:02 +02:00
Stef Walter 8d00539d99 udev: Line buffer 'udev monitor' output (#3733)
Callers of the 'udev monitor' tool expect to see output when
an event occurs. The stdio buffering defeats that. This patch
switches it to line buffering.
2016-07-15 12:24:34 +02:00
Zbigniew Jędrzejewski-Szmek 1071fd0823 macros: provide %_systemdgeneratordir and %_systemdusergeneratordir (#3672)
... as requested in
https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/DJ7HDNRM5JGBSA4HL3UWW5ZGLQDJ6Y7M/.
Adding the macro makes it marginally easier to create generators
for outside projects.

I opted for "generatordir" and "usergeneratordir" to match
%unitdir and %userunitdir. OTOH, "_systemd" prefix makes it obvious
that this is related to systemd. "%_generatordir" would be to generic
of a name.
2016-07-15 09:35:49 +02:00
Daniel Mack a34349e733 network-ndisc: avoid VLAs (#3725)
Do not allocate objects of dynamic and potentially large size on the stack
to avoid both clang compilation errors and unpredictable runtime behavior
on exotic platforms. Use the heap for that instead.

While at it, refactor the code a bit. Access 's->domain' via
NDISC_DNSSL_DOMAIN(), and refrain from allocating 'x' independently, but
rather reuse 's' if we're dealing with a new entry to the set.

Fixes #3717
2016-07-14 22:56:11 -04:00
Zbigniew Jędrzejewski-Szmek 20f873deb2 Merge pull request #3709 from poettering/journald-shutdown-sync
journald-related shutdown fixes for slow I/O
2016-07-14 21:47:49 -04:00
Andreas Pokorny d3a37494e6 Fix tablet detection, by replicating decision tree of non-multi-touch axes (#3724)
Signed-off-by: Andreas Pokorny <andreas.pokorny@canonical.com>
2016-07-14 22:42:10 +02:00
Valentin Vidić 0a86e68147 basic/mount-util: recognize ocfs2 as network fs (#3713) 2016-07-14 07:34:36 +02:00
Lennart Poettering 2e79d1828a shutdown: already sync IO before we enter the final killing spree
This way, slow IO journald has to wait for can't cause it to reach the killing
spree timeout and is hit by SIGKILL in addition to SIGTERM.
2016-07-12 17:38:19 +02:00
Lennart Poettering d450612953 shutdown: use 90s SIGKILL timeout
There's really no reason to use 10s here, let's instead default to 90s like we
do for everything else.

The SIGKILL during the final killing spree is in most regards the fourth level
of a safety net, after all: any normal service should have already been stopped
during the normal service shutdown logic, first via SIGTERM and then SIGKILL,
and then also via SIGTERM during the finall killing spree before we send
SIGKILL. And as a fourth level safety net it should only be required in
exceptional cases, which means it's safe to rais the default timeout, as normal
shutdowns should never be delayed by it.

Note that journald excludes itself from the normal service shutdown, and relies
on the final killing spree to terminate it (this is because it wants to cover
the normal shutdown phase's complete logging). If the system's IO is
excessively slow, then the 10s might not be enough for journald to sync
everything to disk and logs might get lost during shutdown.
2016-07-12 17:32:30 +02:00
Michael Biebl 595bfe7df2 Various fixes for typos found by lintian (#3705) 2016-07-12 12:52:11 +02:00
Luca Bruno 391b81cd03 seccomp: only abort on syscall name resolution failures (#3701)
seccomp_syscall_resolve_name() can return a mix of positive and negative
(pseudo-) syscall numbers, while errors are signaled via __NR_SCMP_ERROR.
This commit lets the syscall filter parser only abort on real parsing
failures, letting libseccomp handle pseudo-syscall number on its own
and allowing proper multiplexed syscalls filtering.
2016-07-12 11:55:26 +02:00
Torstein Husebø 61233823aa treewide: fix typos and remove accidental repetition of words 2016-07-11 16:18:43 +02:00
Michal Sekletar 905c37e60e udevadm: explicitly relabel /etc/udev/hwdb.bin after rename (#3686)
This is basically the same change as ea68351.
2016-07-08 17:43:05 +02:00
Evgeny Vereshchagin 224d3d8266 Merge pull request #3680 from joukewitteveen/pam-env
Follow up on #3503 (pass service env vars to PAM sessions)
2016-07-08 17:33:12 +03:00
Jouke Witteveen 84eada2f7f execute: Do not alter call-by-ref parameter on failure
Prevent free from being called on (a part of) the call-by-reference
variable env when setup_pam fails.
2016-07-08 09:42:48 +02:00
David Michael 4f952a3f07 core: queue loading transient units after setting their properties (#3676)
The unit load queue can be processed in the middle of setting the
unit's properties, so its load_state would no longer be UNIT_STUB
for the check in bus_unit_set_properties(), which would cause it to
incorrectly return an error.
2016-07-08 05:43:01 +02:00
Daniel Mack 78a4ee591a cgroup: fix memory cgroup limit regression on kernel 3.10 (#3673)
Commit da4d897e ("core: add cgroup memory controller support on the unified
hierarchy (#3315)") changed the code in src/core/cgroup.c to always write
the real numeric value from the cgroup parameters to the
"memory.limit_in_bytes" attribute file.

For parameters set to CGROUP_LIMIT_MAX, this results in the string
"18446744073709551615" being written into that file, which is UINT64_MAX.
Before that commit, CGROUP_LIMIT_MAX was special-cased to the string "-1".

This causes a regression on CentOS 7, which is based on kernel 3.10, as the
value is interpreted as *signed* 64 bit, and clamped to 0:

[root@n54 ~]# echo 18446744073709551615 >/sys/fs/cgroup/memory/user.slice/memory.limit_in_bytes
[root@n54 ~]# cat /sys/fs/cgroup/memory/user.slice/memory.limit_in_bytes
0

[root@n54 ~]# echo -1 >/sys/fs/cgroup/memory/user.slice/memory.limit_in_bytes
[root@n54 ~]# cat /sys/fs/cgroup/memory/user.slice/memory.limit_in_bytes
9223372036854775807

Hence, all units that are subject to the limits enforced by the memory
controller will crash immediately, even though they have no actual limit
set. This happens to for the user.slice, for instance:

[  453.577153] Hardware name: SeaMicro SM15000-64-CC-AA-1Ox1/AMD Server CRB, BIOS Estoc.3.72.19.0018 08/19/2014
[  453.587024]  ffff880810c56780 00000000aae9501f ffff880813d7fcd0 ffffffff816360fc
[  453.594544]  ffff880813d7fd60 ffffffff8163109c ffff88080ffc5000 ffff880813d7fd28
[  453.602120]  ffffffff00000202 fffeefff00000000 0000000000000001 ffff880810c56c03
[  453.609680] Call Trace:
[  453.612156]  [<ffffffff816360fc>] dump_stack+0x19/0x1b
[  453.617324]  [<ffffffff8163109c>] dump_header+0x8e/0x214
[  453.622671]  [<ffffffff8116d20e>] oom_kill_process+0x24e/0x3b0
[  453.628559]  [<ffffffff81088dae>] ? has_capability_noaudit+0x1e/0x30
[  453.634969]  [<ffffffff811d4155>] mem_cgroup_oom_synchronize+0x575/0x5a0
[  453.641721]  [<ffffffff811d3520>] ? mem_cgroup_charge_common+0xc0/0xc0
[  453.648299]  [<ffffffff8116da84>] pagefault_out_of_memory+0x14/0x90
[  453.654621]  [<ffffffff8162f4cc>] mm_fault_error+0x68/0x12b
[  453.660233]  [<ffffffff81642012>] __do_page_fault+0x3e2/0x450
[  453.666017]  [<ffffffff816420a3>] do_page_fault+0x23/0x80
[  453.671467]  [<ffffffff8163e308>] page_fault+0x28/0x30
[  453.676656] Task in /user.slice/user-0.slice/user@0.service killed as a result of limit of /user.slice/user-0.slice/user@0.service
[  453.688477] memory: usage 0kB, limit 0kB, failcnt 7
[  453.693391] memory+swap: usage 0kB, limit 9007199254740991kB, failcnt 0
[  453.700039] kmem: usage 0kB, limit 9007199254740991kB, failcnt 0
[  453.706076] Memory cgroup stats for /user.slice/user-0.slice/user@0.service: cache:0KB rss:0KB rss_huge:0KB mapped_file:0KB swap:0KB inactive_anon:0KB active_anon:0KB inactive_file:0KB active_file:0KB unevictable:0KB
[  453.725702] [ pid ]   uid  tgid total_vm      rss nr_ptes swapents oom_score_adj name
[  453.733614] [ 2837]     0  2837    11950      899      23        0             0 (systemd)
[  453.741919] Memory cgroup out of memory: Kill process 2837 ((systemd)) score 1 or sacrifice child
[  453.750831] Killed process 2837 ((systemd)) total-vm:47800kB, anon-rss:3188kB, file-rss:408kB

Fix this issue by special-casing the UINT64_MAX case again.
2016-07-07 19:29:35 -07:00
Jouke Witteveen 1280503b7e execute: Cleanup the environment early
By cleaning up before setting up PAM we maintain control of overriding
behavior in setting variables. Otherwise, pam_putenv is in control.
This also makes sure we use a cleaned up environment in replacing
variables in argv.
2016-07-07 14:15:50 +02:00
Daniel Mack 79c954405f basic: log: Increase static buffer for source file location (#3674)
Commit d054f0a4 ("tree-wide: use xsprintf() where applicable") used a
semantic patch approach to change a number of locations from

  snprintf(buf, sizeof(buf), FMT, ...)

to

  xsprintf(buf, FMT, ...)

The problem is that xsprintf() wraps the snprintf() in an
assert_message_se(), so if snprintf() reports an overflow of the
destination buffer, the binary will now terminate.

This hit a user running a version of systemd that was built from a
deeply nested system path.

Fix this by

a) Switching back to snprintf() for this particular case. We should really
rather truncate the location string than crash in such situations.

b) Increasing the size of that static string buffer, to make the event more
unlikely.
2016-07-07 07:30:34 +03:00
Michał Bartoszkiewicz a17402291b systemd-run: really make -E an alias for --setenv (#3654)
systemd-run --help says:
  -E --setenv=NAME=VALUE          Set environment
2016-07-05 10:23:23 -07:00
Torstein Husebø 6dd6a9c493 treewide: fix typos 2016-07-04 17:10:23 +02:00
Evgeny Vereshchagin 57681e84ce tests: fix memory leak in test_strv_fnmatch (#3653)
==1447== 4 bytes in 1 blocks are definitely lost in loss record 1 of 1
==1447==    at 0x4C2BBAD: malloc (vg_replace_malloc.c:299)
==1447==    by 0x5350F19: strdup (in /usr/lib64/libc-2.23.so)
==1447==    by 0x4E9D435: strv_new_ap (strv.c:166)
==1447==    by 0x4E9D5FA: strv_new (strv.c:199)
==1447==    by 0x10E665: test_strv_fnmatch (test-strv.c:693)
==1447==    by 0x10EAD5: main (test-strv.c:763)
==1447==
2016-07-04 10:11:07 +02:00
Lennart Poettering b1e67dfe31 Merge pull request #3641 from 0xAX/unset-cloexec-for-stdfs
basic/fd-util: introduce stdio_unset_cloexec() function
2016-07-02 15:22:14 -07:00
Alexander Kuleshov 913f38e440 treewide: use stdio_unset_cloexec() function 2016-07-02 23:42:01 +06:00
Alexander Kuleshov 3b9a1d87cc basic/fd-util: introduce stdio_unset_cloexec() function
There are some places in the systemd which are use the same pattern:

    fd_cloexec(STDIN_FILENO, false);
    fd_cloexec(STDOUT_FILENO, false);
    fd_cloexec(STDERR_FILENO, false);

to unset CLOEXEC for standard file descriptors. This patch introduces
the stdio_unset_cloexec() function to hide this and make code cleaner.
2016-07-02 23:38:47 +06:00
Lennart Poettering e71af79316 Merge pull request #3637 from dobyrch/calendar-ranges
Allow date and time ranges in OnCalendar
2016-07-02 09:03:20 -07:00