Commit graph

26854 commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 61755fdae0 journald: do not create split journals for dynamic users
Dynamic users should be treated like system users, and their logs
should end up in the main system journal.
2016-08-18 23:34:40 -04:00
Zbigniew Jędrzejewski-Szmek 986a34a683 core/dynamic-users: warn when creation of symlinks for dynamic users fails
Also return the first error, since it's most likely to be interesting.
If unlink fails, symlink will usually return EEXIST.
2016-08-18 23:09:29 -04:00
Tejun Heo f50582649f logind: update empty and "infinity" handling for [User]TasksMax (#3835)
The parsing functions for [User]TasksMax were inconsistent.  Empty string and
"infinity" were interpreted as no limit for TasksMax but not accepted for
UserTasksMax.  Update them so that they're consistent with other knobs.

* Empty string indicates the default value.
* "infinity" indicates no limit.

While at it, replace opencoded (uint64_t) -1 with CGROUP_LIMIT_MAX in TasksMax
handling.

v2: Update empty string to indicate the default value as suggested by Zbigniew
    Jędrzejewski-Szmek.

v3: Fixed empty UserTasksMax handling.
2016-08-18 22:57:53 -04:00
Zbigniew Jędrzejewski-Szmek da983f8852 Merge pull request #3986 from whot/wip/click-wheel-angle-horiz
Add udev property for horizontal wheel click angles
2016-08-18 22:53:12 -04:00
Zbigniew Jędrzejewski-Szmek 57e3375f83 Merge pull request #3865 from poettering/remove-ipc
add RemoveIPC= service file setting
2016-08-18 22:52:13 -04:00
Zbigniew Jędrzejewski-Szmek bd64d82c1c Revert "pid1: reconnect to the console before being re-executed"
This reverts commit affd7ed1a9.

> So it looks like make_console_stdio() has bad side effect. More specifically it
> does a TIOCSCTTY ioctl (via acquire_terminal()) which sees to disturb the
> process which was using/owning the console.

Fixes #3842.
https://bugs.debian.org/834367
https://bugzilla.redhat.com/show_bug.cgi?id=1367766
2016-08-18 22:30:15 -04:00
Zbigniew Jędrzejewski-Szmek 206fc4b284 systemd: warn when setrlimit fails
This should make it easier to figure things out.
2016-08-18 22:29:56 -04:00
Peter Hutterer 5fc9e4abb4 hwdb: add a udev property for a wheel click angle on horiz wheels
The Logitech MX Master has a horizontal scroll wheel with a different click
angle than the vertical one. Add a new property for this case, we can't add
values to the normal one without risking upsetting existing parsers.

Fixes #3947
2016-08-19 11:57:36 +10:00
Peter Hutterer bbb040884d libudev: fix typo in comment 2016-08-19 11:43:58 +10:00
Lennart Poettering 2ae0858e6c hostnamectl: rework pretty hostname validation (#3985)
Rework 17eb9a9ddb a bit.

Let's make sure we don't clobber the input parameter args[1], following our
coding style to not clobber parameters unless explicitly indicated. (in
particular, as we don't want to have our changes appear in the command line
shown in "ps"...)

No functional change.
2016-08-18 21:16:16 -04:00
Lennart Poettering 6e32c03ed8 nss-mymachines: avoid connecting to dbus from inside dbus-daemon
Inspired from the new logic in nss-systemd let's make sure we don't end up
deadlocking in nss-mymachines either in case dbus-daemon tries to a look up a
name and we want to connect to the bus.

This case is much simpler though, as there's no point in resolving virtual
machine UIDs by dbus-daemon as those should never be able to connect to the
host's busses.
2016-08-19 00:52:00 +02:00
Lennart Poettering fd63e712b2 core: bypass dynamic user lookups from dbus-daemon
dbus-daemon does NSS name look-ups in order to enforce its bus policy. This
might dead-lock if an NSS module use wants to use D-Bus for the look-up itself,
like our nss-systemd does. Let's work around this by bypassing bus
communication in the NSS module if we run inside of dbus-daemon. To make this
work we keep a bit of extra state in /run/systemd/dynamic-uid/ so that we don't
have to consult the bus, but can still resolve the names.

Note that the normal codepath continues to be via the bus, so that resolving
works from all mount namespaces and is subject to authentication, as before.

This is a bit dirty, but not too dirty, as dbus daemon is kinda special anyway
for PID 1.
2016-08-19 00:50:24 +02:00
Lennart Poettering 8a384842b2 clean-ipc: debug log about all remove IPC objects 2016-08-19 00:37:25 +02:00
Lennart Poettering 00d9ef8560 core: add RemoveIPC= setting
This adds the boolean RemoveIPC= setting to service, socket, mount and swap
units (i.e.  all unit types that may invoke processes). if turned on, and the
unit's user/group is not root, all IPC objects of the user/group are removed
when the service is shut down. The life-cycle of the IPC objects is hence bound
to the unit life-cycle.

This is particularly relevant for units with dynamic users, as it is essential
that no objects owned by the dynamic users survive the service exiting. In
fact, this patch adds code to imply RemoveIPC= if DynamicUser= is set.

In order to communicate the UID/GID of an executed process back to PID 1 this
adds a new "user lookup" socket pair, that is inherited into the forked
processes, and closed before the exec(). This is needed since we cannot do NSS
from PID 1 due to deadlock risks, However need to know the used UID/GID in
order to clean up IPC owned by it if the unit shuts down.
2016-08-19 00:37:25 +02:00
Lennart Poettering 51d73fd96a core: move obsolete properties to the end of vtables
This makes it easier to discern the relevant and obsolete parts of the vtables,
and in particular helps when comparing introspection data with the actual
vtable definitions.
2016-08-18 22:49:48 +02:00
Lennart Poettering 92b25bcabb core: make use of uid_is_valid() when checking for UID validity 2016-08-18 22:49:48 +02:00
Lennart Poettering 3db99289c1 clean-ipc: shorten code a bit 2016-08-18 22:49:48 +02:00
Lennart Poettering 91f2048c41 clean-ipc: don't filter out '.' and '..' twice 2016-08-18 22:49:48 +02:00
Lennart Poettering b4c990e91b unit: remove orphaned cgroup_netclass_id field 2016-08-18 22:49:48 +02:00
Lennart Poettering 450442cf93 add a new tool for creating transient mount and automount units
This adds "systemd-mount" which is for transient mount and automount units what
"systemd-run" is for transient service, scope and timer units.

The tool allows establishing mounts and automounts during runtime. It is very
similar to the usual /bin/mount commands, but can pull in additional
dependenices on access (for example, it pulls in fsck automatically), an take
benefit of the automount logic.

This tool is particularly useful for mount removable file systems (such as USB
sticks), as the automount logic (together with automatic unmount-on-idle), as
well as automatic fsck on first access ensure that the removable file system
has a high chance to remain in a fully clean state even when it is unplugged
abruptly, and returns to a clean state on the next re-plug.

This is a follow-up for #2471, as it adds a simple client-side for the
transient automount logic added in that PR.

In later work it might make sense to invoke this tool automatically from udev
rules in order to implement a simpler and safer version of removable media
management á la udisks.
2016-08-18 22:41:19 +02:00
Lennart Poettering ad2c17019a run: various minor improvements
Let's improve the --help text a bit, and other changes.
2016-08-18 22:23:31 +02:00
Lennart Poettering 8673cf13c0 bus-util: unify loop around bus_append_unit_property_assignment()
This is done exactly the same way a couple of times at various places, let's
unify this into one version.
2016-08-18 22:23:31 +02:00
Michael Chapman a0d95bbc38 networkd: use RT_TABLE_MAIN by default
The default route table used by sd-netlink (and iproute2) is
RT_TABLE_MAIN, not RT_TABLE_DEFAULT. Ensure networkd has the same idea.
2016-08-18 17:54:12 +10:00
Michael Chapman 3bdccf69ca networkd: do not touch link_messages when expiring routes
link_messages is used during link configuration to advance the link
state machine through SETTING_ADDRESSES -> SETTING_ROUTES -> CONFIGURED.

If a route expires in the middle of this, it is possible for
link_messages to hit zero inside route_expire_callback, rather than in
route_handler or address_handler where it would trigger the next step in
configuration. Should this happen, the link will not complete
configuration, and it may not have its static routes configured.

Since route_expire_callback does not need to do anything once the
expired route has been removed from the kernel, it is safe to simply not
account for the netlink request.
2016-08-18 17:53:53 +10:00
Tejun Heo 5da38d0768 core: use the unified hierarchy for the systemd cgroup controller hierarchy
Currently, systemd uses either the legacy hierarchies or the unified hierarchy.
When the legacy hierarchies are used, systemd uses a named legacy hierarchy
mounted on /sys/fs/cgroup/systemd without any kernel controllers for process
management.  Due to the shortcomings in the legacy hierarchy, this involves a
lot of workarounds and complexities.

Because the unified hierarchy can be mounted and used in parallel to legacy
hierarchies, there's no reason for systemd to use a legacy hierarchy for
management even if the kernel resource controllers need to be mounted on legacy
hierarchies.  It can simply mount the unified hierarchy under
/sys/fs/cgroup/systemd and use it without affecting other legacy hierarchies.
This disables a significant amount of fragile workaround logics and would allow
using features which depend on the unified hierarchy membership such bpf cgroup
v2 membership test.  In time, this would also allow deleting the said
complexities.

This patch updates systemd so that it prefers the unified hierarchy for the
systemd cgroup controller hierarchy when legacy hierarchies are used for kernel
resource controllers.

* cg_unified(@controller) is introduced which tests whether the specific
  controller in on unified hierarchy and used to choose the unified hierarchy
  code path for process and service management when available.  Kernel
  controller specific operations remain gated by cg_all_unified().

* "systemd.legacy_systemd_cgroup_controller" kernel argument can be used to
  force the use of legacy hierarchy for systemd cgroup controller.

* nspawn: By default nspawn uses the same hierarchies as the host.  If
  UNIFIED_CGROUP_HIERARCHY is set to 1, unified hierarchy is used for all.  If
  0, legacy for all.

* nspawn: arg_unified_cgroup_hierarchy is made an enum and now encodes one of
  three options - legacy, only systemd controller on unified, and unified.  The
  value is passed into mount setup functions and controls cgroup configuration.

* nspawn: Interpretation of SYSTEMD_CGROUP_CONTROLLER to the actual mount
  option is moved to mount_legacy_cgroup_hierarchy() so that it can take an
  appropriate action depending on the configuration of the host.

v2: - CGroupUnified enum replaces open coded integer values to indicate the
      cgroup operation mode.
    - Various style updates.

v3: Fixed a bug in detect_unified_cgroup_hierarchy() introduced during v2.

v4: Restored legacy container on unified host support and fixed another bug in
    detect_unified_cgroup_hierarchy().
2016-08-17 17:44:36 -04:00
Lennart Poettering 622a0f628c Merge pull request #3946 from keszybz/open-journal-root
Make journalctl more flexible
2016-08-17 20:28:45 +02:00
Felipe Sateler 7532e6d4f4 sysv-generator: better error reporting (#3977)
Currently in the journal you get messages without context like:
systemd-sysv-generator[$pid]: Failed to build name: Invalid argument

When parsing the init script, show the file and line number where the
error was found. At the same time, add more context information if
available.

Thus turning the message into something like:
systemd-sysv-generator[$pid]: [/etc/init.d/root-system-proofd:13] Could not build name for facility $network,: Invalid argument
2016-08-17 20:11:27 +02:00
Vito Caputo 105bdb46b4 journal: ensure open journals from find_journal() (#3973)
If journals get into a closed state like when rotate fails due to
ENOSPC, when space is made available it currently goes unnoticed leaving
the journals in a closed state indefinitely.

By calling system_journal_open() on entry to find_journal() we ensure
the journal has been opened/created if possible.

Also moved system_journal_open() up to after open_journal(), before
find_journal().

Fixes https://github.com/systemd/systemd/issues/3968
2016-08-17 14:51:07 +02:00
Michal Sekletar a5110c9030 rules: introduce disk/by-id (model_serial) symlinks for NVMe drives (#3974)
$ ls -l /dev/disk/by-id/nvme*
lrwxrwxrwx. 1 root root 13 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780 -> ../../nvme0n1
lrwxrwxrwx. 1 root root 15 Aug 17 04:25 /dev/disk/by-id/nvme-HUSPR3216AHP301_STM0001B6780-part1 -> ../../nvme0n1p1

https://github.com/systemd/systemd/issues/1453
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=779ff75617099f4defe14e20443b95019a4c5ae8
2016-08-17 14:10:28 +02:00
Ronny Chevalier 71156dc854 Merge pull request #3960 from keszybz/efi-option-description
build-sys: clarify that --disable-efi is about sd-boot and bootctl
2016-08-16 21:22:50 +02:00
Daniel Hahler b2fe35fe58 zsh: _journalctl: also handle --root arg and --key=value style (#3956)
This will now also handle `journalctl --directory=/var/log/journal`
properly.
2016-08-16 12:47:39 -04:00
Daniel Hahler ba89f80620 zsh: _journalctl: do not complete exclusive modes (#3957)
After `journalctl -D /var/log/journal` "--directory", "--file",
"--machine" and "--root" should not be available for completion, because
they are exclusive.  But multiple `--file` arguments are allowed.
2016-08-16 12:42:41 -04:00
Michael Chapman 856e309d7b networkd: avoid NULL pointer dereference in route_add
If no result parameter is provided, do not attempt to write the
found/newly-created route to it. This is presently not an issue as all
callers currently provide a non-NULL result parameter, however we should
do this for symmetry with address_add and future code robustness.
2016-08-16 19:07:42 +10:00
Tejun Heo ca2f6384aa core: rename cg_unified() to cg_all_unified()
A following patch will update cgroup handling so that the systemd controller
(/sys/fs/cgroup/systemd) can use the unified hierarchy even if the kernel
resource controllers are on the legacy hierarchies.  This would require
distinguishing whether all controllers are on cgroup v2 or only the systemd
controller is.  In preparation, this patch renames cg_unified() to
cg_all_unified().

This patch doesn't cause any functional changes.
2016-08-15 18:13:36 -04:00
Zbigniew Jędrzejewski-Szmek 5f9a610ad2 Merge pull request #3905 from htejun/cgroup-v2-cpu
core: add cgroup CPU controller support on the unified hierarchy

(zj: merging not squashing to make it clear against which upstream this patch was developed.)
2016-08-14 18:03:35 -04:00
Zbigniew Jędrzejewski-Szmek 05b2a8fd7a man: explain that *KeyIgnoreInhibited only apply to a subset of locks
Follow-up for #3924.
2016-08-14 16:29:04 -04:00
Zbigniew Jędrzejewski-Szmek aa43d4bb89 build-sys: clarify that --disable-efi is about sd-boot and bootctl
If wasn't obvious what the effect of --disable-efi was without
going through Makefile.am.

Fixes #3959.
2016-08-14 15:25:08 -04:00
Zbigniew Jędrzejewski-Szmek 04d0f7e9f9 units: do not start load-random-seed in containers (#3941)
Random numbers are provided by the host kernel, we don't need to do anything.

https://bugzilla.redhat.com/show_bug.cgi?id=1329124
2016-08-13 17:15:19 +02:00
Zbigniew Jędrzejewski-Szmek 2d891284c7 hwdb: normalize spacing in 60-keyboard.hwdb (#3954) 2016-08-13 17:14:58 +02:00
Daniel Hahler e09d0d46c2 zsh: _systemctl: do not attempt to use "--system" by default (#3951)
In 68c4f6d the following was added:

    local -a _modes; _modes=("--user" "--system")
    local _sys_service_mgr=${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}

With the following comment:

> If neither are on the line, --system is set; for system services to be
> completed.

But it does not work as documented:

    % _modes=(--user --system)
    % words=()
    % echo ${${words:*_modes}[(R)(${(j.|.)_modes})]:---system}

However, it should not use `--system` in that case anyway, so this patch
removes the part that should cause a default to be used and adds some
comments.
2016-08-13 10:42:55 -04:00
Daniel Hahler d551b8fcf7 zsh: _journalctl: improve support for handling mode args (#3952)
This only completes fields from `journalctl --user` in _journal_fields when `--user`
is used.

It also changes $_sys_service_mgr to include both `--system` and `--user`,
because `journalctl` behaves different from `systemctl` in this regard.
No attempt is made to filter out invalid combinations, e.g. when using both
`--directory` and `--system` (see https://github.com/systemd/systemd/issues/3949).
2016-08-13 10:41:22 -04:00
Zbigniew Jędrzejewski-Szmek 0a1750934f journalctl: allow --root argument for journal watching
It is useful to look at a (possibly inactive) container or other os tree
with --root=/path/to/container. This is similar to specifying
--directory=/path/to/container/var/log/journal --directory=/path/to/container/run/systemd/journal
(if using --directory multiple times was allowed), but doesn't require
as much typing.
2016-08-12 00:38:03 -04:00
Zbigniew Jędrzejewski-Szmek 16fefe9080 sd-journal: fix sd_journal_open_directory with SD_JOURNAL_OS_ROOT
The directory argument that is given to sd_j_o_d was ignored when
SD_JOURNAL_OS_ROOT was given, and directories relative to the root of the host
file system were used. With that flag, sd_j_o_d should do the same as
sd_j_open_container: use the path as "prefix", i.e. the directory relative to
which everything happens.

Instead of touching sd_j_o_d, journal_new is fixed to do what sd_j_o_c
was doing, and treat the specified path as prefix when SD_JOURNAL_OS_ROOT is
specified.
2016-08-12 00:38:03 -04:00
Zbigniew Jędrzejewski-Szmek 10752e829b sd-journal: allow SYSTEM and CURRENT_USER flags with sd_j_open_directory[_fd]
There is no reason not to. This makes journalctl -D ... --system work,
useful for example when viewing files from a deactivated container.
2016-08-12 00:38:03 -04:00
Zbigniew Jędrzejewski-Szmek 1aaa68f535 sd-journal: split out flags into separate defines for legibility
… in preparation for future changes.
2016-08-12 00:38:03 -04:00
Zbigniew Jędrzejewski-Szmek 9c5077fed4 Merge pull request #3942 from blueyed/zsh-respect-user-more
zsh completion: handle --user mode when filtering by state and in journalctl commands
2016-08-11 15:39:15 -04:00
Daniel Hahler 21d84318c3 zsh: _journalctl: handle --user in _journal_none
This uses the same mechanism from _systemctl to inject `--user` into the
`journalctrl -F _EXE` call to list executables.
Before this patch the "commands" section would list executables from
system units always.
2016-08-11 18:52:13 +02:00
Daniel Hahler 56ef545c24 zsh: _filter_units_by_property: respect --user
Use `$_sys_service_mgr` to handle `--user`, so that `systemctl --user
stop` will correctly filter the active (user) units.  Before this patch,
only user units that also exist as system units and are stoppable there
would be listed.
2016-08-11 18:46:31 +02:00
Zbigniew Jędrzejewski-Szmek 29df65f913 man: add "timeout" to status table (#3919) 2016-08-11 10:51:49 +02:00
Zbigniew Jędrzejewski-Szmek 6998b54093 coredump: treat RLIMIT_CORE below page size as disabling coredumps (#3932)
The kernel treats values below a certain threshold (minfmt->min_coredump
which is initialized do ELF_EXEC_PAGESIZE, which varies between architectures,
but is usually the same as PAGE_SIZE) as disabling coredumps [1].
Any core image below ELF_EXEC_PAGESIZE will yield an invalid backtrace anyway [2],
so follow the kernel and not try to parse or store such images.

[1] https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/fs/coredump.c#n660
[2] systemd-coredump[16260]: Process 16258 (sleep) of user 1002 dumped core.
                                Stack trace of thread 16258:
                                #0  0x00007f1d8b3d3810 n/a (n/a)

https://bugzilla.redhat.com/show_bug.cgi?id=1309172#c19
2016-08-11 10:51:00 +02:00