Commit Graph

32169 Commits

Author SHA1 Message Date
Lennart Poettering 6b7b0f3947 update TODO 2018-02-14 14:28:00 +01:00
Lennart Poettering e70f445306 process: shortcut getenv_for_pid() for our own process 2018-02-14 14:27:31 +01:00
Lennart Poettering f612f8fb93 ask-password: pretty flags enum definition a bit 2018-02-14 00:13:26 +01:00
Lennart Poettering daa557208d tty-ask-password-agent: don't open terminal multiple times
We already have the terminal open, hence pass the fd we got to
ask_password_tty(), so that it doesn't have to reopen it a second time.

This is mostly an optimization, but it has the nice benefit of making us
independent from RLIMIT_NOFILE issues and so on, as we don't need to
allocate another fd needlessly.
2018-02-14 00:11:16 +01:00
Lennart Poettering 088dcd8e41 ask-password: derive pollfd array from enum
It's prettier that way!
2018-02-14 00:03:05 +01:00
Lennart Poettering c9eb4a0054 ask-password: round up when determining sleep time
We should rather sleep to much than too little. This otherwise might
result in a busy loop, because we slept too little and then recheck
again coming to the conclusion we need to go to sleep again, and so on.
2018-02-14 00:03:05 +01:00
Lennart Poettering 70dee4755a ask-password: let's use structure initialization properly 2018-02-14 00:03:04 +01:00
Lennart Poettering ac7a9674e4 ask-password: let's (void) cast where appropriate 2018-02-14 00:03:04 +01:00
Lennart Poettering a497a2966e ask-password: bypass clean-up if we don't need it 2018-02-13 23:56:57 +01:00
Lennart Poettering 0f13392851 ask-password: don't use ttyfd if it is not set 2018-02-13 23:55:58 +01:00
Lennart Poettering befd657b00 tty-ask-password-agent: show right TTY path in error message 2018-02-13 23:55:19 +01:00
Lennart Poettering 5439206bc7 tty-ask-password-agent: assing sendto() result to a ssize_t variable, not an int
We should be careful with these types, and if we do convert between
"int" and "ssize_t" we should do so explicitly rather than implicitly.
Otherwise this just looks like a bug.
2018-02-13 23:53:59 +01:00
Lennart Poettering 87964ec7d1 terminal-util: minor, trivial fixes and improvements 2018-02-13 23:53:34 +01:00
Lennart Poettering c6063244db terminal-util: when making /dev/null or the console stdio, forget cached terminal features
Let's forget all relevant terminal features we learnt when we make a
console or /dev/null stdin/stdout/stderr.

Also, while we are at it, let's drop the various _unlikely_ and
_likely_ annotiations around the terminal feature caches. In many cases
we call the relevant functions only once in which cases the annotations
are likely to do just harm and no good. After all we can't know if the
specific code will call us just once or many times...
2018-02-13 23:50:26 +01:00
Lennart Poettering 8854d79504 terminal-util: rework acquire_terminal()
This modernizes acquire_terminal() in a couple of ways:

1. The three boolean arguments are replaced by a flags parameter, that
   should be more descriptive in what it does.

2. We now properly handle inotify queue overruns

3. We use _cleanup_ for closing the fds now, to shorten the code quite a
   bit.

Behaviour should not be altered by this.
2018-02-13 21:24:37 +01:00
Lennart Poettering 149bc84aac tty-ask-password-agent: make code a tiny bit shorter 2018-02-13 19:17:17 +01:00
AsciiWolf 372771c8d3 l10n: update POTFILES.in (#8163) 2018-02-13 12:05:22 +09:00
itsbill a083b4875e tmpfiles: age root-owned read-only files, by default (#7917)
[zj: The note in NEWS was added in 82c8e3e650
and released as part of systemd-237.]
2018-02-12 15:47:08 +01:00
Yu Watanabe b8e2400586
Merge pull request #8143 from yuwata/drop-unused-func
Drop several unused functions
2018-02-10 12:47:12 +09:00
Yu Watanabe 92db49a0c2 socket-util: drop getnameinfo_pretty() 2018-02-10 11:10:07 +09:00
Zbigniew Jędrzejewski-Szmek aa9122bf3d Revert "Periodically call sd_journal_process in journalctl" (#8147)
This reverts commit 992149c07e.

https://github.com/systemd/systemd/pull/8144#issuecomment-364464627
$ (set -o pipefail; sudo ./build/journalctl --no-pager | wc -l; echo $?)
Failed to process inotify events: Bad file descriptor
1025
1
2018-02-09 20:10:00 +01:00
Zbigniew Jędrzejewski-Szmek cadc80b873 basic/socket-util: drop use of NI_IDN_USE_STD3_ASCII_RULES
The only use of socknameinfo_pretty() is in src/journal-remote/journal-remote.c,
to determine the output filename.

Replaces #8120.
2018-02-09 19:29:51 +01:00
Lennart Poettering 7fe2903c23 fd-util: move certain fds above fd #2 (#8129)
This adds some paranoia code that moves some of the fds we allocate for
longer periods of times to fds > 2 if they are allocated below this
boundary. This is a paranoid safety thing, in order to avoid that
external code might end up erroneously use our fds under the assumption
they were valid stdin/stdout/stderr. Think: some app closes
stdin/stdout/stderr and then invokes 'fprintf(stderr, …' which causes
writes on our fds.

This both adds the helper to do the moving as well as ports over a
number of users to this new logic. Since we don't want to litter all our
code with invocations of this I tried to strictly focus on fds we keep
open for long periods of times only and only in code that is frequently
loaded into foreign programs (under the assumptions that in our own
codebase we are smart enough to always keep stdin/stdout/stderr
allocated to avoid this pitfall). Specifically this means all code used
by NSS and our sd-xyz API:

1. our logging APIs
2. sd-event
3. sd-bus
4. sd-resolve
5. sd-netlink

This changed was inspired by this:

https://github.com/systemd/systemd/issues/8075#issuecomment-363689755

This shows that apparently IRL there are programs that do close
stdin/stdout/stderr, and we should accomodate for that.

Note that this won't fix any bugs, this just makes sure that buggy
programs are less likely to interfere with out own code.
2018-02-09 17:53:28 +01:00
Simon Fowler e25937a3ed Suspend on lid close based on power status. (#8016)
This change adds support for controlling the suspend-on-lid-close
behaviour based on the power status as well as whether the machine is
docked or has an external monitor. For backwards compatibility the new
configuration file variable is ignored completely by default, and must
be set explicitly before being considered in any decisions.
2018-02-09 17:37:39 +01:00
Zbigniew Jędrzejewski-Szmek 9e42c9373c
Merge pull request #8066 from LittleCVR/udevadm-trigger-and-settle
udevadm: allow trigger command to be synchronous
2018-02-09 17:09:42 +01:00
Zbigniew Jędrzejewski-Szmek 91761b1846
Merge pull request #8134 from keszybz/unit-load-paths
Various fixes to unit load paths, and systemd-analyze load-paths verb to list them
2018-02-09 17:08:23 +01:00
Lennart Poettering 73969ab61c service: relax PID file symlink chain checks a bit (#8133)
Let's read the PID file after all if there's a potentially unsafe
symlink chain in place. But if we do, then refuse taking the PID if its
outside of the cgroup.

Fixes: #8085
2018-02-09 17:05:17 +01:00
Oleander Reis 2d06ddb7b4 man:systemd.service(5): fix description of specifiers in command lines (#8146)
Command lines now accept specifiers within the first argument.

see issues #3061, #679 and pr #4835
2018-02-09 17:03:09 +01:00
Zbigniew Jędrzejewski-Szmek 230cc99a0f analyze: slight simplification 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek baa4880bac analyze: remove implicit conversions of numbers to booleans 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 80efdacd08 man: make Notes section in systemd.geneator(5) toplevel
This is mostly a indentation change and rewrapping.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek b82f27e7a3 man: document unit load paths
So far we didn't document control, transient, dbus config, or generator paths.
But those paths are visible to users, and they need to understand why systemd
loads units from those paths, and how the precedence hierarchy looks.
The whole thing is a bit messy, since the list of paths is quite long.
I made the tables a bit shorter by combining rows for the alternatives
where $XDG_* is set and the fallback.

In various places, tags are split like <element
  param="blah">
this. This is necessary to keep everyting in one logical XML line so that
docbook renders the table properly.

Replaces #8050.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 0d6671b2ef shared/path-lookup: rename user control dirs to "user.control"
$ diff -u <(old/systemd-analyze --user unit-paths) <(new/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:36:34.190046129 +0100
+++ /proc/self/fd/15	2018-02-08 14:36:34.190046129 +0100
@@ -1,5 +1,5 @@
-/home/zbyszek/.config/systemd/system.control
-/run/user/1000/systemd/system.control
+/home/zbyszek/.config/systemd/user.control
+/run/user/1000/systemd/user.control
 /run/user/1000/systemd/transient
 ...

Strictly speaking, online upgrades of user instances through daemon-reexec will
be broken. We can get away with this since
a) reexecs of the user instance are not commonly done, at least package upgrade
   scripts don't do this afawk.
b) cgroups aren't delegateable on cgroupsv1 there's little reason to use "systemctl
   set-property" for --user mode
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7e684baf90 shared/path-lookup: rearrange paths in --global mode to match --user mode
It's not good if the paths are in different order. With --user, we expect
more paths, but it must be a strict superset, and the order for the ones
that appear in both sets must be the same.

$  diff -u <(build/systemd-analyze --global unit-paths) <(build/systemd-analyze --user unit-paths)|colordiff
--- /proc/self/fd/14	2018-02-08 14:11:45.425353107 +0100
+++ /proc/self/fd/15	2018-02-08 14:11:45.426353116 +0100
@@ -1,6 +1,17 @@
+/home/zbyszek/.config/systemd/system.control
+/run/user/1000/systemd/system.control
+/run/user/1000/systemd/transient
+/run/user/1000/systemd/generator.early
+/home/zbyszek/.config/systemd/user
 /etc/systemd/user
+/run/user/1000/systemd/user
 /run/systemd/user
+/run/user/1000/systemd/generator
+/home/zbyszek/.local/share/systemd/user
+/home/zbyszek/.local/share/flatpak/exports/share/systemd/user
+/var/lib/flatpak/exports/share/systemd/user
 /usr/local/share/systemd/user
 /usr/share/systemd/user
 /usr/local/lib/systemd/user
 /usr/lib/systemd/user
+/run/user/1000/systemd/generator.late

A test is added so that we don't regress on this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 7b6344d35f path-lookup: include paths from --global in --user search path too
This doesn't matter that much, because set-property --global does not work,
so at least those paths wouldn't be used automatically. It is still possible
to create such snippets manually, so we better fix this.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek c59479e790 path-lookup: fix confusion between persistent_control and persistent_config
persistent_config would not appear in the search path at all, hence
those overrides would not work at all.
2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek ecd3717a74 shell-completion: add --global and unit-paths 2018-02-09 12:27:34 +01:00
Zbigniew Jędrzejewski-Szmek 31a5924ed8 analyze: add unit-paths verb 2018-02-09 12:27:27 +01:00
Lennart Poettering af77d6f8da
Merge pull request #8083 from shawnl/close-ssh
sd-bus: cleanup ssh sessions (Closes: #8076)
2018-02-09 12:17:26 +01:00
Zbigniew Jędrzejewski-Szmek 6bcc09bea1 udevadm: check for oom and other style fixes 2018-02-09 12:04:03 +01:00
Mao 792cc203a6 udevadm: allow trigger command to be synchronous
There are cases that we want to trigger and settle only specific
commands. For example, let's say at boot time we want to make sure all
the graphics devices are working correctly because it's critical for
booting, but not the USB subsystem (we'll trigger USB events later). So
we do:

  udevadm trigger --action="add" --subsystem-match="graphics"
  udevadm settle

However, we cannot block the kernel from emitting kernel events from
discovering USB devices. So if any of the USB kernel event was emitted
before the settle command, the settle command would still wait for the
entire queue to complete. And if the USB event takes a long time to be
processed, the system slows down.

The new `settle` option allows the `trigger` command to wait for only
the triggered events, and effectively solves this problem.
2018-02-09 11:59:03 +01:00
Lennart Poettering 8c2dbc8779
Merge pull request #8142 from yuwata/sd-bus-memleak
Fix potential memory leaks and several code style updates
2018-02-09 11:39:26 +01:00
Yu Watanabe 01e4793de6 fs-util: drop readlink_and_make_absolute_root() 2018-02-09 16:58:56 +09:00
Yu Watanabe 842e456e79 fs-util: drop readlink_and_canonicalize() 2018-02-09 16:49:54 +09:00
Yu Watanabe f2e18ef1a3 core: remove unnecessary initialization 2018-02-09 16:36:37 +09:00
Yu Watanabe 43beb0cf68 udev: use "#pragma once" 2018-02-09 16:33:30 +09:00
Yu Watanabe e5c8029e13 sd-bus: explicitly convert int to bool 2018-02-09 16:22:00 +09:00
Yu Watanabe cad4fb19c8 sd-bus: use free_and_replace() 2018-02-09 16:21:51 +09:00
Yu Watanabe b4ca3f45dc sd-bus: avoid potential memory leaks 2018-02-09 16:21:29 +09:00
Lucas Werkmeister 3c84514d07 man: fix capability name in man:systemd-tmpfiles(8) (#8139)
CAP_ADMIN does not exist (the closest existing capability name would be
CAP_SYS_ADMIN), and according to man:open(2) and man:capabilities(7),
the capability required to specify O_NOATIME is actually CAP_FOWNER.
2018-02-09 11:05:49 +09:00