Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 16:14:59 +0000 (17:14 +0100)]
Merge pull request #8184 from poettering/color-ask-pw
Trivial merge conflict resolved locally.
Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 15:15:45 +0000 (16:15 +0100)]
Merge pull request #8125 from poettering/cgroups-migrate
Trivial merge conflict resolved locally.
Jakub Filak [Thu, 15 Feb 2018 11:12:46 +0000 (12:12 +0100)]
coredump: accept hostname on command line (#8033)
This commint adds a new command line parameter to sytemd-coredump. The
parameter should be mappend to core_pattern's placeholder %h - hostname.
The field _HOSTNAME holds the name from the kernel's namespaces which might be
different then the one comming from process' namespaces.
It is true that the real hostname is usually available in the field
COREDUMP_ENVIRON (environment variables) but I believe it is more reliable to
use the value passed by kernel.
----
The length of iovec is no longer static and hence I corrected the declarations
of the functions set_iovec_field and set_iovec_field_free.
Thank you @yuwata and @poettering!
Thomas Haller [Thu, 15 Feb 2018 09:49:55 +0000 (10:49 +0100)]
dhcp6: fix uninitialized variable in returning from client_parse_message() (#8187)
Compiler warns about this with -Werror=maybe-uninitialized.
Fixes:
3bc424a3cc0bacc688ec2f4f93a5560fb4ca393b
Lennart Poettering [Wed, 14 Feb 2018 18:56:24 +0000 (19:56 +0100)]
mkosi: add pcre2 to our build deps, as we can now link to it
Lennart Poettering [Wed, 14 Feb 2018 17:41:37 +0000 (18:41 +0100)]
ask-password-api: many fixes to ask_password_tty()
A couple of fixes:
1. always bzero_explicit() away what we remove from the passphrase
buffer. The UTF-8 code assumes the string remains NUL-terminated, and
we hence should enforce that. memzero() would do too here, but let's
be paranoid after all this is key material.
2. when clearing '*' characters from string, do so counting UTF-8
codepoints properly. We already have code in place to count UTF-8
codepoints when generating '*' characters, hence we should take the
same care when clearing them again.
3. Treat NUL on input as an alternative terminator to newline or EOF.
4. When removing characters from the password always also reset the
"codepoint" index properly.
Lennart Poettering [Wed, 14 Feb 2018 17:41:03 +0000 (18:41 +0100)]
utf8: add utf8_n_codepoints() for counting complete utf8 codepoints in a string
Lennart Poettering [Wed, 14 Feb 2018 16:30:37 +0000 (17:30 +0100)]
terminal-util: make resolve_dev_console() less weird
Let's normalize the behaviour: return a negative errno style error code,
and return the resolved string directly as argument.
Lennart Poettering [Wed, 14 Feb 2018 13:56:17 +0000 (14:56 +0100)]
terminal-util: modernize get_kernel_consoles() a bit
Also, make sure when we run in a container, we don't use the data from
/sys at all, but immediately fall back to /dev/console itself.
Lennart Poettering [Wed, 14 Feb 2018 13:30:30 +0000 (14:30 +0100)]
tty-ask-password-agent: reenable color for boot-time password prompt
The password prompt used to be highlighted, and that was a good thing.
Let's fix things to make the prompt highlighted again.
Fixes: #3853
Lennart Poettering [Wed, 14 Feb 2018 13:28:17 +0000 (14:28 +0100)]
terminal-util: add some explanatory comments
Lennart Poettering [Wed, 14 Feb 2018 13:28:00 +0000 (14:28 +0100)]
update TODO
Lennart Poettering [Wed, 14 Feb 2018 13:27:31 +0000 (14:27 +0100)]
process: shortcut getenv_for_pid() for our own process
Lucas Werkmeister [Wed, 14 Feb 2018 13:11:24 +0000 (14:11 +0100)]
man: make systemd-socket-activate point to systemd-run (#8151)
Now that systemd-run also supports socket units, it makes sense to link
to that command from the systemd-socket-activate manpage.
Boucman [Wed, 14 Feb 2018 13:10:07 +0000 (14:10 +0100)]
Allow timers to trigger timers (#8043)
Unlike any other unit type, it makes sense for a timer to start another
timer. It is an easy way to crate logical "and" between time conditions
for instance, every day but no less than 5' after boot can easily be
implemented by a OnBootSec triggering an OnCalendar.
This is particulary usefull with Persistant timers which tend to all fire
together at startup
Davide Cavalca [Wed, 14 Feb 2018 13:08:50 +0000 (05:08 -0800)]
meson: factor out daemon/event/id128 sources into variables (#8170)
Piotr Drąg [Wed, 14 Feb 2018 13:06:14 +0000 (14:06 +0100)]
po: update Polish translation (#8169)
Zbigniew Jędrzejewski-Szmek [Wed, 14 Feb 2018 12:52:17 +0000 (13:52 +0100)]
Merge pull request #8144 from poettering/journal-inotify-fixes
various journal fixes
Jan Synacek [Wed, 14 Feb 2018 10:34:47 +0000 (11:34 +0100)]
man: link latest FHS spec in file-hierarchy(7) (#8178)
Sylvain Plantefève [Tue, 13 Feb 2018 19:45:54 +0000 (20:45 +0100)]
po: update French translation
Zbigniew Jędrzejewski-Szmek [Wed, 14 Feb 2018 08:34:46 +0000 (09:34 +0100)]
Lennart Poettering [Tue, 13 Feb 2018 23:13:26 +0000 (00:13 +0100)]
ask-password: pretty flags enum definition a bit
Lennart Poettering [Tue, 13 Feb 2018 23:10:00 +0000 (00:10 +0100)]
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.
Lennart Poettering [Tue, 13 Feb 2018 23:02:23 +0000 (00:02 +0100)]
ask-password: derive pollfd array from enum
It's prettier that way!
Lennart Poettering [Tue, 13 Feb 2018 22:57:57 +0000 (23:57 +0100)]
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.
Lennart Poettering [Tue, 13 Feb 2018 22:57:40 +0000 (23:57 +0100)]
ask-password: let's use structure initialization properly
Lennart Poettering [Tue, 13 Feb 2018 22:57:13 +0000 (23:57 +0100)]
ask-password: let's (void) cast where appropriate
Lennart Poettering [Tue, 13 Feb 2018 22:56:57 +0000 (23:56 +0100)]
ask-password: bypass clean-up if we don't need it
Lennart Poettering [Tue, 13 Feb 2018 22:55:58 +0000 (23:55 +0100)]
ask-password: don't use ttyfd if it is not set
Lennart Poettering [Tue, 13 Feb 2018 22:55:19 +0000 (23:55 +0100)]
tty-ask-password-agent: show right TTY path in error message
Lennart Poettering [Tue, 13 Feb 2018 22:53:59 +0000 (23:53 +0100)]
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.
Lennart Poettering [Tue, 13 Feb 2018 22:53:34 +0000 (23:53 +0100)]
terminal-util: minor, trivial fixes and improvements
Lennart Poettering [Tue, 13 Feb 2018 22:50:26 +0000 (23:50 +0100)]
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...
Lennart Poettering [Tue, 13 Feb 2018 20:24:37 +0000 (21:24 +0100)]
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.
Lennart Poettering [Tue, 13 Feb 2018 18:17:17 +0000 (19:17 +0100)]
tty-ask-password-agent: make code a tiny bit shorter
Alan Jenkins [Tue, 13 Feb 2018 18:04:31 +0000 (18:04 +0000)]
manager: avoid infinite loop for unexpected waitid() error (#8168)
I think if we log the error as being _ignored_, we should also consider
the event as handled and clear it. This was the behaviour prior to
575b300b (PR #7968).
I don't think we particularly wanted to change behaviour and keep retrying.
Sometimes that's useful, other times you cause more problems by filling the
logs.
Plus a nearby typo fix.
AsciiWolf [Tue, 13 Feb 2018 03:05:22 +0000 (04:05 +0100)]
l10n: update POTFILES.in (#8163)
itsbill [Mon, 12 Feb 2018 14:47:08 +0000 (09:47 -0500)]
tmpfiles: age root-owned read-only files, by default (#7917)
[zj: The note in NEWS was added in
82c8e3e6503a40684cf265842bb1c26a8f7681b5
and released as part of systemd-237.]
Lennart Poettering [Wed, 7 Feb 2018 22:03:13 +0000 (23:03 +0100)]
update TODO
Lennart Poettering [Wed, 7 Feb 2018 21:52:52 +0000 (22:52 +0100)]
core: add new new bus call for migrating foreign processes to scope/service units
This adds a new bus call to service and scope units called
AttachProcesses() that moves arbitrary processes into the cgroup of the
unit. The primary user for this new API is systemd itself: the systemd
--user instance uses this call of the systemd --system instance to
migrate processes if itself gets the request to migrate processes and
the kernel refuses this due to access restrictions.
The primary use-case of this is to make "systemd-run --scope --user …"
invoked from user session scopes work correctly on pure cgroupsv2
environments. There, the kernel refuses to migrate processes between two
unprivileged-owned cgroups unless the requestor as well as the ownership
of the closest parent cgroup all match. This however is not the case
between the session-XYZ.scope unit of a login session and the
user@ABC.service of the systemd --user instance.
The new logic always tries to move the processes on its own, but if
that doesn't work when being the user manager, then the system manager
is asked to do it instead.
The new operation is relatively restrictive: it will only allow to move
the processes like this if the caller is root, or the UID of the target
unit, caller and process all match. Note that this means that
unprivileged users cannot attach processes to scope units, as those do
not have "owning" users (i.e. they have now User= field).
Fixes: #3388
Lennart Poettering [Wed, 7 Feb 2018 21:47:26 +0000 (22:47 +0100)]
core: in bus_init_system() make sure we setup the system bus even if we inherit the API bus
This corrects the control flow: when we reuse the API bus as system bus,
let's definitely invoke bus_init_system() too, so that it is called
regardless how we acquired the bus object.
(Note that this doesn't actually change anything, as we only inherit the
bus like this in system mode, and bus_init_system() doesn't do anything
in system bus, besides writing a log message)
Lennart Poettering [Wed, 7 Feb 2018 21:44:18 +0000 (22:44 +0100)]
bus: in bus_foreach_bus() don't bother with api_bus if it is NULL
Let's better be safe than sorry, and validate that api_bus is not NULL
before we send messages to it. Of course, strictly speaking this
shouldn't actually be necessary, as the tracker object should not exist
without the bus, but let's be extra sure.
Lennart Poettering [Wed, 7 Feb 2018 21:40:41 +0000 (22:40 +0100)]
bus: when destroying a bus, also destroy per-unit bus track objects associated with it
Let's not keep the old bus object pinned this way, let's destroy all
relevant trackers for units, the way we already destroy them for jobs.
Lennart Poettering [Wed, 7 Feb 2018 21:36:51 +0000 (22:36 +0100)]
core: delay bus name synchronization after reload/reexec into a later event loop iteration
Previously, we'd synchronize bus names immediately when we succeeded
connecting to the bus, potentially even before coldplugging the units.
This was problematic, as synchronizing bus names meant invoking the
per-unit name change handler function which might change the unit's
state — which will result in consistency when done before we coldplug
things.
With this change we instead enqueue a job for the event loop to resync
the names in a later loop iteration, i.e. at a point where we know
coldplugging has finished.
Lennart Poettering [Wed, 7 Feb 2018 21:30:17 +0000 (22:30 +0100)]
core: set a description on private bus connections
Let's make things easier to debug
Lennart Poettering [Wed, 7 Feb 2018 21:28:42 +0000 (22:28 +0100)]
sd-bus: synthesize a description for user/system bus if otherwise unset
Let's make debugging easier, by synthesizing a name when we have some
indication what kind of bus this is.
Lennart Poettering [Wed, 7 Feb 2018 17:13:31 +0000 (18:13 +0100)]
core: generalize how we acquire the Unit objects for unit names in bus calls
This splits out the code that translates a unit name into a Unit* object
from method_get_unit(), and reuses it all other functions that operate
similar to it. This effectively means all those calls now optionally
take an empty unit string which now means the same as the client's unit.
This useful behaviour of the GetUnit() bus call is thus extended to all
other matching bus calls.
Similar, the same logic from method_load_unit() is also generalized and
reused wherever appropriate.
Lennart Poettering [Wed, 7 Feb 2018 17:11:18 +0000 (18:11 +0100)]
user-util: also consider /bin/false and /bin/true as non-shell
Lennart Poettering [Wed, 7 Feb 2018 15:30:11 +0000 (16:30 +0100)]
core: update dbus policy file
This patch does four things:
1. Adds more comments that clarify the order in which things appear in
the file
2. All entries are placed in the order in which their SD_BUS_METHOD()
macros appear in the C vtables.
3. A couple of missing entries are added that should be open to all or
do polkit
4. Corrects the interface name for the GetProcesses() calls. They belong
to the per-unit interface, not to Unit
Lennart Poettering [Wed, 7 Feb 2018 14:08:18 +0000 (15:08 +0100)]
core: simplify manager_recheck_journal() a bit
No need for an if check if we just pass along a bool anyway.
Lennart Poettering [Wed, 7 Feb 2018 14:07:00 +0000 (15:07 +0100)]
core: tweak manager_journal_is_running() a bit more
Let's also use the journal if it is currently reloading. In that state
it should also be able to process our requests. Moreover, we might
otherwise end up disconnecting/reconnecting from the journal without
really any need to hence, relax the check accordingly.
Lennart Poettering [Wed, 7 Feb 2018 14:06:15 +0000 (15:06 +0100)]
manager: tweak manager_journal_is_running() a bit regarding test mode
In test mode, let's not consider the journal to be up ever: we want all
output to go to stderr.
Lennart Poettering [Wed, 7 Feb 2018 13:52:22 +0000 (14:52 +0100)]
core: rework how we connect to the bus
This removes the current bus_init() call, as it had multiple problems:
it munged handling of the three bus connections we care about (private,
"api" and system) into one, even though the conditions when which was
ready are very different. It also added redundant logging, as the
individual calls it called all logged on their own anyway.
The three calls bus_init_api(), bus_init_private() and bus_init_system()
are now made public. A new call manager_dbus_is_running() is added that
works much like manager_journal_is_running() and is a lot more careful
when checking whether dbus is around. Optionally it checks the unit's
deserialized_state rather than state, in order to accomodate for cases
where we cant to connect to the bus before deserializing the
"subscribed" list, before coldplugging the units.
manager_recheck_dbus() is added, that works a lot like
manager_recheck_journal() and is invoked in unit_notify(), i.e. when
units change state.
All in all this should make handling a bit more alike to journal
handling, and it also fixes one major bug: when running in user mode
we'll now connect to the system bus early on, without conditionalizing
this in anyway.
Lennart Poettering [Wed, 7 Feb 2018 14:00:32 +0000 (15:00 +0100)]
dbus: split up bus_done() into seperate functions
No functional changes, but let's make this a bit more finegrained.
(The individual functions are exported, which is used in a later commit)
Lennart Poettering [Wed, 7 Feb 2018 09:39:56 +0000 (10:39 +0100)]
bpf-firewall: fix warning text
I figure saying "systemd" here was a typo, and it should have been
"system". (Yes, it becomes very hard after a while typing "system"
correctly if you type "systemd" so often.) That said, "systemd" in some
ways is actually more correct, since BPF might be available for the
system instance but not in the user instance.
Either way, talking of "this systemd" is weird, let's reword this to be
"this manager", to emphasize that it's the local instance of systemd
where BPF is not available, but that it might be available otherwise.
Lennart Poettering [Wed, 7 Feb 2018 09:39:49 +0000 (10:39 +0100)]
mkosi: update to fedora 27, it's released since a while
Lennart Poettering [Tue, 6 Feb 2018 14:59:55 +0000 (15:59 +0100)]
process-util: be more careful in is_kernel_thread()
This reworks is_kernel_thread() a bit. Instead of checking whether
/proc/$pid/cmdline is entirely empty we now parse the 'flags' field from
/proc/$pid/stat and check the PF_KTHREAD flag, which directly encodes
whether something is a kernel thread.
Why all this? With current kernels userspace processes can set their
command line to empty too (through PR_SET_MM_ARG_START and friends), and
could potentially confuse us. Hence, let's use a more reliable way to
detect kernels like this.
Lennart Poettering [Tue, 6 Feb 2018 12:09:52 +0000 (13:09 +0100)]
core: fold manager_set_exec_params() into unit_set_exec_params()
Let's simplify things a bit: we so far called both functions every
single time, let's just merge one into the other, so that we have fewer
functions to call.
Lennart Poettering [Tue, 6 Feb 2018 10:57:35 +0000 (11:57 +0100)]
cgroup: add a new "can_delegate" flag to the unit vtable, and set it for scope and service units only
Currently we allowed delegation for alluntis with cgroup backing
except for slices. Let's make this a bit more strict for now, and only
allow this in service and scope units.
Let's also add a generic accessor unit_cgroup_delegate() for checking
whether a unit has delegation turned on that checks the new bool first.
Also, when doing transient units, let's explcitly refuse turning on
delegation for unit types that don#t support it. This is mostly
cosmetical as we wouldn't act on the delegation request anyway, but
certainly helpful for debugging.
Peter Portante [Sun, 28 Jan 2018 21:48:04 +0000 (16:48 -0500)]
journalctl: Periodically call sd_journal_process in journalctl
If `journalctl` take a long time to process messages, and during that
time journal file rotation occurs, a `journalctl` client will keep
those rotated files open until it calls `sd_journal_process()`, which
typically happens as a result of calling `sd_journal_wait()` below in
the "following" case. By periodically calling `sd_journal_process()`
during the processing loop we shrink the window of time a client
instance has open file descriptors for rotated (deleted) journal
files.
(Lennart: slightly reworked version, that dropped some of the commenting
which was solved otherwise)
Lennart Poettering [Fri, 9 Feb 2018 21:38:46 +0000 (22:38 +0100)]
sd-journal: make sure it's safe to call sd_journal_process() before the first sd_journal_wait()
In that case we have no inotify fd yet, and there's nothing to process
hence. Let's make the call a NOP.
(Previously, without this change we'd end up trying to read off inotify
fd -1, which is quite a problem... 😢)
Lennart Poettering [Fri, 9 Feb 2018 08:53:52 +0000 (09:53 +0100)]
coredump,journal: when vacuuming use new unlinkat_deallocate() calls
This ensures that clients can't keep all files pinned interfering with
our vacuuming logic.
This should fix the last issue pointed out in #7998 and #8032
Fixes: #7998
Lennart Poettering [Fri, 9 Feb 2018 08:52:36 +0000 (09:52 +0100)]
rm-rf: make flags fields easier to read
Lennart Poettering [Fri, 9 Feb 2018 08:50:31 +0000 (09:50 +0100)]
fs-util: add new unlinkat_deallocate() helper
This new helper not only removes a file from a directory but also
ensures its space on disk is deallocated, by either punching a hole over
the full file or truncating the file afterwards if the file's link
counter is 0. This is useful in "vacuuming" algorithms to ensure that
client's can't keep the disk space the vacuuming is supposed to recover
pinned simply by keeping an fd open to it.
Lennart Poettering [Fri, 9 Feb 2018 08:50:13 +0000 (09:50 +0100)]
copy: wrap some unlink() calls in (void) casts
Lennart Poettering [Thu, 8 Feb 2018 19:11:43 +0000 (20:11 +0100)]
sd-journal: properly handle inotify queue overflow
This adds proper handling of IN_Q_OVERFLOW: when the inotify queue runs
over we'll reiterate all directories we are looking at. At the same time
we'll mark all files and directories we encounter that way with a
generation counter we first increased. All files and directories not
marked like this are then unloaded.
With this logic we do the best when the inotify queue overflows: we
synchronize our in-memory state again with what's on disk.
This contains some refactoring of the directory logic, to share more
code between uuid directories and "root" directories and generally make
things a bit more readable by splitting things up into smaller bits.
See: #7998 #8032
Lennart Poettering [Thu, 8 Feb 2018 19:10:51 +0000 (20:10 +0100)]
sd-journal: use more appropriate API to validate 128bit ids
We have id128_is_valid(), let's use it.
Lennart Poettering [Thu, 8 Feb 2018 17:58:35 +0000 (18:58 +0100)]
tree-wide: use path_hash_ops instead of string_hash_ops whenever we key by a path
Let's make use of our new hash_ops!
Lennart Poettering [Thu, 8 Feb 2018 17:31:15 +0000 (18:31 +0100)]
hash-func: add generic hash_ops implementation for hashing paths
This is similar to string_hash_ops but operates one file system paths
specifically. It will ensure that "/foo//bar" and "///foo/bar" are
considered to be the same path for hashmap purposes.
This makes use of the existing path_compare() API, and adds a matching
hashing function for it.
Note that relative and absolute paths will hash to different values,
however whether the path is suffixed with a slash or not is not
detected. This matches the existing path_compare() behaviour, and
follows the logic that on Linux there can't be two different objects at
path /foo/bar and /foo/bar/ either.
Lennart Poettering [Thu, 8 Feb 2018 16:37:56 +0000 (17:37 +0100)]
hash-funcs: remove redundant definition of devt_hash_ops
We should assign a value only in the .c file, not in both the .c and .h
file.
Lennart Poettering [Thu, 8 Feb 2018 16:14:37 +0000 (17:14 +0100)]
journal: move code that checks for network fs to stat-util.[ch]
We have similar code in stat-util.[ch] and managing this at a central
place almost definitely is the better choice.
Yu Watanabe [Sat, 10 Feb 2018 03:47:12 +0000 (12:47 +0900)]
Merge pull request #8143 from yuwata/drop-unused-func
Drop several unused functions
Yu Watanabe [Fri, 9 Feb 2018 08:52:05 +0000 (17:52 +0900)]
socket-util: drop getnameinfo_pretty()
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 19:10:00 +0000 (20:10 +0100)]
Revert "Periodically call sd_journal_process in journalctl" (#8147)
This reverts commit
992149c07e3ecfbfe4067641e92a6923e7aacda4.
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
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 12:31:37 +0000 (13:31 +0100)]
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.
Lennart Poettering [Fri, 9 Feb 2018 16:53:28 +0000 (17:53 +0100)]
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.
Simon Fowler [Fri, 9 Feb 2018 16:37:39 +0000 (02:37 +1000)]
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.
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 16:09:42 +0000 (17:09 +0100)]
Merge pull request #8066 from LittleCVR/udevadm-trigger-and-settle
udevadm: allow trigger command to be synchronous
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 16:08:23 +0000 (17:08 +0100)]
Merge pull request #8134 from keszybz/unit-load-paths
Various fixes to unit load paths, and systemd-analyze load-paths verb to list them
Lennart Poettering [Fri, 9 Feb 2018 16:05:17 +0000 (17:05 +0100)]
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
Oleander Reis [Fri, 9 Feb 2018 16:03:09 +0000 (17:03 +0100)]
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
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 21:20:19 +0000 (22:20 +0100)]
analyze: slight simplification
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 21:20:01 +0000 (22:20 +0100)]
analyze: remove implicit conversions of numbers to booleans
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 15:33:28 +0000 (16:33 +0100)]
man: make Notes section in systemd.geneator(5) toplevel
This is mostly a indentation change and rewrapping.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 15:23:43 +0000 (16:23 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 13:36:17 +0000 (14:36 +0100)]
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
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 13:12:13 +0000 (14:12 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 12:57:05 +0000 (13:57 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 12:54:37 +0000 (13:54 +0100)]
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.
Zbigniew Jędrzejewski-Szmek [Thu, 8 Feb 2018 11:09:28 +0000 (12:09 +0100)]
shell-completion: add --global and unit-paths
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 11:27:27 +0000 (12:27 +0100)]
analyze: add unit-paths verb
Lennart Poettering [Fri, 9 Feb 2018 11:17:26 +0000 (12:17 +0100)]
Merge pull request #8083 from shawnl/close-ssh
sd-bus: cleanup ssh sessions (Closes: #8076)
Zbigniew Jędrzejewski-Szmek [Fri, 9 Feb 2018 11:04:03 +0000 (12:04 +0100)]
udevadm: check for oom and other style fixes
Mao [Thu, 1 Feb 2018 09:33:13 +0000 (17:33 +0800)]
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.
Lennart Poettering [Fri, 9 Feb 2018 10:39:26 +0000 (11:39 +0100)]
Merge pull request #8142 from yuwata/sd-bus-memleak
Fix potential memory leaks and several code style updates
Yu Watanabe [Fri, 9 Feb 2018 07:58:56 +0000 (16:58 +0900)]
fs-util: drop readlink_and_make_absolute_root()
Yu Watanabe [Fri, 9 Feb 2018 07:49:54 +0000 (16:49 +0900)]
fs-util: drop readlink_and_canonicalize()
Yu Watanabe [Fri, 9 Feb 2018 07:36:37 +0000 (16:36 +0900)]
core: remove unnecessary initialization
Yu Watanabe [Fri, 9 Feb 2018 07:33:30 +0000 (16:33 +0900)]
udev: use "#pragma once"
Yu Watanabe [Fri, 9 Feb 2018 07:19:11 +0000 (16:19 +0900)]
sd-bus: explicitly convert int to bool