platform/upstream/systemd.git
7 years agoman: make /etc/nsswitch.conf documentation for nss-resolve match example
Lennart Poettering [Fri, 18 Nov 2016 16:31:49 +0000 (17:31 +0100)]
man: make /etc/nsswitch.conf documentation for nss-resolve match example

Fixes: #4683

7 years agodhcp4: filter bogus DNS/NTP server addresses silently
Lennart Poettering [Fri, 18 Nov 2016 16:19:44 +0000 (17:19 +0100)]
dhcp4: filter bogus DNS/NTP server addresses silently

if we receive a bogus lease with a DNS/NTP server within local scope let's
politely ignore.

Fixes: #4524

7 years agonetworkd: do not automatically propagate bogus DNS/NTP servers
Lennart Poettering [Fri, 18 Nov 2016 16:11:12 +0000 (17:11 +0100)]
networkd: do not automatically propagate bogus DNS/NTP servers

Never propagate DNS/NTP servers on the local link via the DHCP server. The
DNS/NTP servers 0.0.0.0 and 127.0.0.1 only make sense in the local context,
hence never propagate them automatically to other hosts.

Fixes: #4524

7 years agonetworkd: rename link_push_dns_to_dhcp_server() → link_push_uplink_dns_to_dhcp_server()
Lennart Poettering [Fri, 18 Nov 2016 16:07:52 +0000 (17:07 +0100)]
networkd: rename link_push_dns_to_dhcp_server() → link_push_uplink_dns_to_dhcp_server()

Let's clarify that this is only relevant for pushing uplink DNS config data,
not in any other context.

(Same for NTP)

7 years agonetworkd: store DNS servers configured per-network as parsed addresses
Lennart Poettering [Fri, 18 Nov 2016 16:04:26 +0000 (17:04 +0100)]
networkd: store DNS servers configured per-network as parsed addresses

DNS servers must be specified as IP addresses, hence let's store them as that
internally, so that they are guaranteed to be fully normalized always, and
invalid data cannot be stored.

7 years agonetworkd: minor word extraction fixes
Lennart Poettering [Fri, 18 Nov 2016 16:03:13 +0000 (17:03 +0100)]
networkd: minor word extraction fixes

Let's make the loops around extract_first_word() be more alike.

7 years agonetworkd: reorder fields in Network struct a bit
Lennart Poettering [Fri, 18 Nov 2016 16:01:32 +0000 (17:01 +0100)]
networkd: reorder fields in Network struct a bit

Let's reorder them a bit, so that stuff that belongs together semantically is
placed together (in particular, move the various DHCP "use" booleans together).

7 years agonetworkd: validate NTP server strings configured in .network files
Lennart Poettering [Fri, 18 Nov 2016 16:00:25 +0000 (17:00 +0100)]
networkd: validate NTP server strings configured in .network files

Let's be a bit stricter, and make sure users only configure proper DNS names or
IP addresses, but not any other strings.

7 years agoshared: add new API to validate a string as hostname or IP address
Lennart Poettering [Fri, 18 Nov 2016 15:55:01 +0000 (16:55 +0100)]
shared: add new API to validate a string as hostname or IP address

7 years agobasic: make sure in_addr_from_string() can take NULL arguments
Lennart Poettering [Fri, 18 Nov 2016 15:48:19 +0000 (16:48 +0100)]
basic: make sure in_addr_from_string() can take NULL arguments

This way, we can use it for validating IP address strings.

7 years agobasic: add explicit ipv4-specific in_addr classification calls
Lennart Poettering [Fri, 18 Nov 2016 12:13:28 +0000 (13:13 +0100)]
basic: add explicit ipv4-specific in_addr classification calls

This adds in4_addr_is_localhost() and in4_addr_is_link_local() that only take
an IPv4 "struct in_addr", to match in_addr_is_localhost() and
in_addr_is_link_local() that that a "union in_addr_union".

This matches the existing in4_addr_is_null() call that already exists.

For IPv6 glibc already exports a set of macros, hence we don't add similar
functions in6_addr_is_localhost(). We also drop in6_addr_is_null() as
IN6_IS_ADDR_UNSPECIFIED() already provides that.

7 years agonetworkd: rework how we set the hostname on the dhcp4 client
Lennart Poettering [Fri, 18 Nov 2016 12:02:57 +0000 (13:02 +0100)]
networkd: rework how we set the hostname on the dhcp4 client

Let's split out the code into its own little function and let's use
gethostname_strict() which already filters out localhost for us.

7 years agosd-dhcp: permit unsetting the hostname again
Lennart Poettering [Fri, 18 Nov 2016 11:33:14 +0000 (12:33 +0100)]
sd-dhcp: permit unsetting the hostname again

Let's handle NULL hostnames (for unsetting it) before we validate the name.

7 years agoMerge pull request #4701 from martinpitt/networkd-polkit
Lennart Poettering [Mon, 21 Nov 2016 17:24:51 +0000 (18:24 +0100)]
Merge pull request #4701 from martinpitt/networkd-polkit

hostnamed: allow networkd to set the transient hostname

7 years agotests: check transient hostname with and without static hostname
Martin Pitt [Mon, 21 Nov 2016 11:53:24 +0000 (12:53 +0100)]
tests: check transient hostname with and without static hostname

We expect a static hostname to win over a transient one, so test both cases.

7 years agoMerge pull request #4691 from keszybz/test-suite-fixes
Evgeny Vereshchagin [Sun, 20 Nov 2016 16:38:58 +0000 (19:38 +0300)]
Merge pull request #4691 from keszybz/test-suite-fixes

Test suite fixes

7 years agohostnamed: allow networkd to set the transient hostname
Martin Pitt [Fri, 18 Nov 2016 15:17:01 +0000 (16:17 +0100)]
hostnamed: allow networkd to set the transient hostname

systemd-networkd runs as user "systemd-network" and thus is not privileged to
set the transient hostname:

  systemd-networkd[516]: ens3: Could not set hostname: Interactive authentication required.

Standard polkit *.policy files do not have a syntax for granting privileges to
a user, so ship a pklocalauthority (for polkit < 106) and a JavaScript rules
file (for polkit >= 106) that grants the "systemd-network" system user that
privilege.

Add DnsmasqClientTest.test_transient_hostname() test to networkd-test.py to
cover this. Make do_test() a bit more flexible by interpreting "coldplug==None"
as "test sets up the interface by itself". Change DnsmasqClientTest to set up
test_eth42 with a fixed MAC address so that we can configure dnsmasq to send a
special host name for that.

Fixes #4646

7 years agotest: clean up "dummy0" interface after each test case in networkd-test.py
Martin Pitt [Sun, 20 Nov 2016 09:08:23 +0000 (10:08 +0100)]
test: clean up "dummy0" interface after each test case in networkd-test.py

7 years agotest-functions: also add qemu define for ppc64
Zbigniew Jędrzejewski-Szmek [Sun, 20 Nov 2016 03:45:23 +0000 (22:45 -0500)]
test-functions: also add qemu define for ppc64

7 years agohwdb: keyboard: Ignore brightness hotkey presses on MSI VR420 (model MS-1422) (#4696)
Hans de Goede [Sat, 19 Nov 2016 15:07:41 +0000 (16:07 +0100)]
hwdb: keyboard: Ignore brightness hotkey presses on MSI VR420 (model MS-1422) (#4696)

Add MSI VR420 (model MS-1422) to the list of MSI models which need to
ignore brightness hotkey presses, as these are already reported through
the acpi-video interface.

link: https://bugzilla.redhat.com/show_bug.cgi?id=1270124
Reported-by: David Dreggors <dadreggors@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
7 years agoMerge pull request #4395 from s-urbaniak/rw-support
Lennart Poettering [Fri, 18 Nov 2016 11:36:46 +0000 (12:36 +0100)]
Merge pull request #4395 from s-urbaniak/rw-support

nspawn: R/W support for /sysfs, /proc, and /proc/sys/net

7 years agoMerge pull request #4538 from fbuihuu/confirm-spawn-fixes
Lennart Poettering [Fri, 18 Nov 2016 10:08:06 +0000 (11:08 +0100)]
Merge pull request #4538 from fbuihuu/confirm-spawn-fixes

Confirm spawn fixes/enhancements

7 years agotests/TEST-13-NSPAWN-SMOKE: add SYSTEMD_NSPAWN_API_VFS_WRITABLE
Evgeny Vereshchagin [Sat, 5 Nov 2016 02:46:22 +0000 (02:46 +0000)]
tests/TEST-13-NSPAWN-SMOKE: add SYSTEMD_NSPAWN_API_VFS_WRITABLE

https://github.com/systemd/systemd/pull/4395

7 years agonspawn: R/W support for /sys, and /proc/sys
Sergiusz Urbaniak [Fri, 14 Oct 2016 12:00:15 +0000 (14:00 +0200)]
nspawn: R/W support for /sys, and /proc/sys

This commit adds the possibility to leave /sys, and /proc/sys read-write.
It introduces a new (undocumented) env var SYSTEMD_NSPAWN_API_VFS_WRITABLE
to enable this feature.

If set to "yes", /sys, and /proc/sys will be read-write.
If set to "no", /sys, and /proc/sys will be read-only.
If set to "network" /proc/sys/net will be read-write. This is useful in
use-cases, where systemd-nspawn is used in an external network
namespace.

This adds the possibility to start privileged containers which need more
control over settings in the /proc, and /sys filesystem.

This is also a follow-up on the discussion from
https://github.com/systemd/systemd/pull/4018#r76971862 where an
introduction of a simple env var to enable R/W support for those
directories was already discussed.

7 years agotest-ipcrm: skip test if nfsnobody is missing
Zbigniew Jędrzejewski-Szmek [Fri, 18 Nov 2016 01:57:22 +0000 (20:57 -0500)]
test-ipcrm: skip test if nfsnobody is missing

7 years agobasic/process-util: we need to take the shorter of two strings
Zbigniew Jędrzejewski-Szmek [Fri, 18 Nov 2016 01:57:22 +0000 (20:57 -0500)]
basic/process-util: we need to take the shorter of two strings

==30496== Conditional jump or move depends on uninitialised value(s)
==30496==    at 0x489F654: memcmp (vg_replace_strmem.c:1091)
==30496==    by 0x49BF203: getenv_for_pid (process-util.c:678)
==30496==    by 0x4993ACB: detect_container (virt.c:442)
==30496==    by 0x182DFF: test_get_process_comm (test-process-util.c:98)
==30496==    by 0x185847: main (test-process-util.c:368)
==30496==

7 years agotest-process-util: bind mount fails under selinux, skip test
Zbigniew Jędrzejewski-Szmek [Fri, 18 Nov 2016 01:57:22 +0000 (20:57 -0500)]
test-process-util: bind mount fails under selinux, skip test

7 years agoMerge pull request #4671 from poettering/namespace-bind
Zbigniew Jędrzejewski-Szmek [Fri, 18 Nov 2016 00:40:57 +0000 (19:40 -0500)]
Merge pull request #4671 from poettering/namespace-bind

rework service namespace handling a bit

7 years agobasic/env-uil: fix assertion failure in strv_env_replace (#4688)
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2016 21:25:01 +0000 (16:25 -0500)]
basic/env-uil: fix assertion failure in strv_env_replace (#4688)

free_and_replace sets the setcond argument to NULL (it's designed
to be used with _clenaup_ macros), and we don't want that here.

Fixes #4684.

7 years agocore: in confirm spawn, suggest 'f' when user selects 'n' choice
Franck Bui [Thu, 17 Nov 2016 17:22:43 +0000 (18:22 +0100)]
core: in confirm spawn, suggest 'f' when user selects 'n' choice

7 years agocore: confirm_spawn: always accept units with same_pgrp set for now
Franck Bui [Mon, 14 Nov 2016 16:37:40 +0000 (17:37 +0100)]
core: confirm_spawn: always accept units with same_pgrp set for now

For some reasons units remaining in the same process group as PID 1
(same_pgrp=true) fail to acquire the console even if it's not taken by anyone.

So always accept for units with same_pgrp set for now.

7 years agocore: include the unit name when notifying that a confirmation question timed out
Franck Bui [Thu, 10 Nov 2016 09:07:42 +0000 (10:07 +0100)]
core: include the unit name when notifying that a confirmation question timed out

7 years agocore: add 'c' in confirmation_spawn to resume the boot process
Franck Bui [Tue, 15 Nov 2016 08:29:04 +0000 (09:29 +0100)]
core: add 'c' in confirmation_spawn to resume the boot process

7 years agocore: add 'j' in confirmation_spawn to list the jobs that are in progress
Franck Bui [Sun, 13 Nov 2016 15:28:04 +0000 (16:28 +0100)]
core: add 'j' in confirmation_spawn to list the jobs that are in progress

7 years agocore: add 'D' in confirmat spawn to show a full dump of the unit to spawn
Franck Bui [Sat, 12 Nov 2016 14:08:29 +0000 (15:08 +0100)]
core: add 'D' in confirmat spawn to show a full dump of the unit to spawn

7 years agocore: add 'i' in confirm spawn to give a short summary of the unit to spawn
Franck Bui [Sat, 12 Nov 2016 13:55:12 +0000 (14:55 +0100)]
core: add 'i' in confirm spawn to give a short summary of the unit to spawn

7 years agocore: rework the confirmation spawn prompt
Franck Bui [Mon, 7 Nov 2016 16:14:59 +0000 (17:14 +0100)]
core: rework the confirmation spawn prompt

Previously it was "[Yes, Fail, Skip]" which is pretty misleading because it
suggests that the whole word needs to be entered instead of a single char.

Also this won't fit well when we'll extend the number of choices.

This patch addresses this by changing the choice hint with "[y, f, s – h for help]"
so it's now clear that a single letter has to be entered.

It also introduces a new choice 'h' which describes all possible choices since
a single letter can be not descriptive enough for new users.

It also allow to stick with the same hint string regardless of how
many choices we will support.

7 years agocore: limit the length of the confirmation question
Franck Bui [Mon, 7 Nov 2016 16:14:59 +0000 (17:14 +0100)]
core: limit the length of the confirmation question

When "confirmation_spawn=1", the confirmation question can look like:

  Execute /usr/bin/kmod static-nodes --format=tmpfiles --output=/run/tmpfiles.d/kmod.conf? [Yes, No, Skip]

which is pretty verbose and might not fit in the console width size (which is
usually 80 chars) and thus question will be splitted into 2 consecutive lines.

However since the question is now refreshed every 2 secs, the reprinted
question will overwrite the second line of the previous one...

To prevent this, this patch makes sure that the command line won't be longer
than 60 chars by ellipsizing it if the command is longer:

  Execute /usr/bin/kmod static-nodes --format=tmpfiles --output=/ru…nf? [Yes, No, View, Skip]

A following patch will introduce a new choice that will allow the user to get
details on the command to be executed so it will still be possible to see the
full command line.

7 years agocore: reprint the question every 2 sec in ask_char()
Franck Bui [Mon, 7 Nov 2016 16:14:59 +0000 (17:14 +0100)]
core: reprint the question every 2 sec in ask_char()

ask_char() now reprints the question every 2sec automatically.

It prefixes its output with '\r' to to bring the cursor to the
beginning of the terminal line, and then print the message, redoing it
every 2sec.

As long as nothing interferes with out output this logic will have no
visible effect as we constantly overprint the visible text with the
exact same text.

However, if something is dumped in the middle, then our question won't
get lost, as we'll ask soon again.

This is useful if the question is asked to a terminal that is also
used to dump some other status messages/logs. For example when
confirmation messages are enabled during the boot
(systemd.confirm_spawn=1), the question can easily be lost if the
kernel logs are also enabled and both use the same console.

Idea suggested by Lennart Poettering.

7 years agocore: in confirm_spawn, the meaning of 'n' and 's' choices are confusing
Franck Bui [Sun, 13 Nov 2016 08:32:52 +0000 (09:32 +0100)]
core: in confirm_spawn, the meaning of 'n' and 's' choices are confusing

Before this patch we had:

 - "no" which gives "failing execution" but the command is actually assumed as
   succeed.

 - "skip" which gives "skipping", but the command is assumed to have failed,
   which ends up with "Failed to start ..." on the console.

Now we have:

 - "fail" which gives "failing execution" and the command is indeed assumed as
   failed.

 - "skip" which gives "skipping execution" and the command is assumed as
   succeed.

7 years agocore: rework ask_for_confirmation()
Franck Bui [Wed, 2 Nov 2016 12:51:02 +0000 (13:51 +0100)]
core: rework ask_for_confirmation()

Now the reponses are handled by ask_for_confirmation() as well as the report of
any errors occuring during the process of retrieving the confirmation response.

One benefit of this is that there's no need to open/close the console one more
time when reporting error/status messages.

The caller now just needs to care about the return values whose meanings are:

 - don't execute and pretend that the command failed
 - don't execute and pretend that the command succeeed
 - positive answer, execute the command

Also some slight code reorganization and introduce write_confirm_error() and
write_confirm_error_fd(). write_confim_message becomes unneeded.

7 years agocore: allow to redirect confirmation messages to a different console
Franck Bui [Wed, 2 Nov 2016 09:38:22 +0000 (10:38 +0100)]
core: allow to redirect confirmation messages to a different console

It's rather hard to parse the confirmation messages (enabled with
systemd.confirm_spawn=true) amongst the status messages and the kernel
ones (if enabled).

This patch gives the possibility to the user to redirect the confirmation
message to a different virtual console, either by giving its name or its path,
so those messages are separated from the other ones and easier to read.

7 years agocore: prevent the cylon when confirmation_spawn=yes (#2194)
Franck Bui [Wed, 2 Nov 2016 09:50:20 +0000 (10:50 +0100)]
core: prevent the cylon when confirmation_spawn=yes (#2194)

When booting with systemd.confirm_spawn=true, the eye of cylon
animation kicks in pretty quickly so user doesn't have any chance to
answer the questions which services to start before the confirmation
message is screwed by the cylon.

This basically breaks the confirm_spawn functionality completely.

This patch prevents the cylon animation to kick in when
confirmation_spawn=yes.

Fixes: #2194

7 years agoupdate TODO
Lennart Poettering [Mon, 14 Nov 2016 19:47:45 +0000 (20:47 +0100)]
update TODO

7 years agonamespace: clarify that /proc/apm is obsolete, but leave it blocked
Lennart Poettering [Thu, 17 Nov 2016 17:10:01 +0000 (18:10 +0100)]
namespace: clarify that /proc/apm is obsolete, but leave it blocked

7 years agonamespace: reindent namespace tables
Lennart Poettering [Thu, 17 Nov 2016 17:06:05 +0000 (18:06 +0100)]
namespace: reindent namespace tables

Let's align all our BindMount tables, let's use the same column widths in all
of them, and let's make them not any wider than necessary.

This only changes whitespace, not contents of any of the tables.

7 years agonamespace: simplify, optimize and extend handling of mounts for namespace
Lennart Poettering [Tue, 15 Nov 2016 00:42:54 +0000 (01:42 +0100)]
namespace: simplify, optimize and extend handling of mounts for namespace

This changes a couple of things in the namespace handling:

It merges the BindMount and TargetMount structures. They are mostly the same,
hence let's just use the same structue, and rely on C's implicit zero
initialization of partially initialized structures for the unneeded fields.

This reworks memory management of each entry a bit. It now contains one "const"
and one "malloc" path. We use the former whenever we can, but use the latter
when we have to, which is the case when we have to chase symlinks or prefix a
root directory. This means in the common case we don't actually need to
allocate any dynamic memory. To make this easy to use we add an accessor
function bind_mount_path() which retrieves the right path string from a
BindMount structure.

While we are at it, also permit "+" as prefix for dirs configured with
ReadOnlyPaths= and friends: if specified the root directory of the unit is
implicited prefixed.

This also drops set_bind_mount() and uses C99 structure initialization instead,
which I think is more readable and clarifies what is being done.

This drops append_protect_kernel_tunables() and
append_protect_kernel_modules() as append_static_mounts() is now simple enough
to be called directly.

Prefixing with the root dir is now done in an explicit step in
prefix_where_needed(). It will prepend the root directory on each entry that
doesn't have it prefixed yet. The latter is determined depending on an extra
bit in the BindMount structure.

7 years agocore: monitor the inotify file descriptor not the console one in acquire_terminal()
Franck Bui [Wed, 2 Nov 2016 15:24:57 +0000 (16:24 +0100)]
core: monitor the inotify file descriptor not the console one in acquire_terminal()

When waiting for the terminal to be release in acquire_terminal(), we
were monitoring the terminal fd instead of the inotify descriptor.

Therefore any write accesses would wake up the waiting process instead
of being wake up when the tty is closed only.

7 years agoMerge pull request #4681 from keszybz/shortening
Martin Pitt [Thu, 17 Nov 2016 07:20:01 +0000 (08:20 +0100)]
Merge pull request #4681 from keszybz/shortening

Shortening

7 years agoMerge pull request #4678 from poettering/gc-device
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2016 02:16:13 +0000 (21:16 -0500)]
Merge pull request #4678 from poettering/gc-device

Automatically GC device jobs when there's no need to keep them in the job queue anymore.
Implement systemctl list-jobs --before/--after.
Allow systemd-run -p After/Before/Wants/Requires= ...

7 years agocore/dbus-job, systemctl: shorten some code
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2016 02:01:11 +0000 (21:01 -0500)]
core/dbus-job, systemctl: shorten some code

7 years agosystemctl: shorter list-jobs --before/--after output a bit
Zbigniew Jędrzejewski-Szmek [Thu, 17 Nov 2016 01:51:47 +0000 (20:51 -0500)]
systemctl: shorter list-jobs --before/--after output a bit

(before)$ systemctl list-jobs  --before --after
 JOB UNIT                                          TYPE  STATE
8769 foobar.device                                 start running
        A job waits for this job: 8669 (run-rb6da596d0cfa4e36b7c594cd973e795a.service/start)
8669 run-rb6da596d0cfa4e36b7c594cd973e795a.service start waiting
        This job waits for a job: 8769 (foobar.device/start)

2 jobs listed.

(after)$ systemctl list-jobs  --before --after
 JOB UNIT                                          TYPE  STATE
8769 foobar.device                                 start running
        waiting for job 8669 (run-rb6da596d0cfa4e36b7c594cd973e795a.service/start)
8669 run-rb6da596d0cfa4e36b7c594cd973e795a.service start waiting
        blocking job 8769 (foobar.device/start)

2 jobs listed.

7 years agohwdb: fix airplane mode trigger when switching from laptop to desktop on HP Pavilion...
Francesco Brozzu [Wed, 16 Nov 2016 21:57:20 +0000 (22:57 +0100)]
hwdb: fix airplane mode trigger when switching from laptop to desktop on HP Pavilion x360 13 (#4680)

7 years agoupdate TODO
Lennart Poettering [Wed, 16 Nov 2016 14:03:08 +0000 (15:03 +0100)]
update TODO

7 years agosystemctl: show waiting jobs when "systemctl list-jobs --after/--before" is called
Lennart Poettering [Wed, 16 Nov 2016 15:44:05 +0000 (16:44 +0100)]
systemctl: show waiting jobs when "systemctl list-jobs --after/--before" is called

Let's expose the new bus functions we added in the previous commit in
systemctl.

7 years agocore: add bus calls for determining jobs waiting for other jobs
Lennart Poettering [Wed, 16 Nov 2016 15:07:32 +0000 (16:07 +0100)]
core: add bus calls for determining jobs waiting for other jobs

This should make it easier to debug job deadlocks.

7 years agosystem-run: add support for configuring unit dependencies with --property=
Lennart Poettering [Wed, 16 Nov 2016 13:44:04 +0000 (14:44 +0100)]
system-run: add support for configuring unit dependencies with --property=

Support on the server side has already been in place for quite some time, let's
also add support on the client side for this.

7 years agosystemctl: add env var to force connection to system manager via the bus
Lennart Poettering [Wed, 16 Nov 2016 13:31:03 +0000 (14:31 +0100)]
systemctl: add env var to force connection to system manager via the bus

Sometimes it is useful for debugging purposes to force systemctl to connect to
PID 1 via the bus instead of direct connection, even if the direct connection
is possible.

7 years agocore: GC redundant device jobs from the run queue
Lennart Poettering [Tue, 15 Nov 2016 18:32:50 +0000 (19:32 +0100)]
core: GC redundant device jobs from the run queue

In contrast to all other unit types device units when queued just track
external state, they cannot effect state changes on their own. Hence unless a
client or other job waits for them there's no reason to keep them in the job
queue. This adds a concept of GC'ing jobs of this type as soon as no client or
other job waits for them anymore.

To ensure this works correctly we need to track which clients actually
reference a job (i.e. which ones enqueued it). Unfortunately that's pretty
nasty to do for direct connections, as sd_bus_track doesn't work for
them. For now, work around this, by simply remembering in a boolean that a job
was requested by a direct connection, and reset it when we notice the direct
connection is gone. This means the GC logic works fine, except that jobs are
not immediately removed when direct connections disconnect.

In the longer term, a rework of the bus logic should fix this properly. For now
this should be good enough, as GC works for fine all cases except this one, and
thus is a clear improvement over the previous behaviour.

Fixes: #1921

7 years agocore: rename "clients" field of Job structure to "bus_track"
Lennart Poettering [Tue, 15 Nov 2016 18:29:50 +0000 (19:29 +0100)]
core: rename "clients" field of Job structure to "bus_track"

Let's make semantics of this field more similar to the same functionality in
the Unit object, in particular as we add new functionality to it later on.

7 years agocore: drop n_in_gc_queue field of Manager structure
Lennart Poettering [Tue, 15 Nov 2016 18:23:29 +0000 (19:23 +0100)]
core: drop n_in_gc_queue field of Manager structure

We count the units in the GC queue with this, but actually never make use of
it, hence drop it.

7 years agocore: a few small coding style/modernization updates for job.c
Lennart Poettering [Tue, 15 Nov 2016 18:19:57 +0000 (19:19 +0100)]
core: a few small coding style/modernization updates for job.c

7 years agoshared: split out code for adding multiple names to sd_bus_track object
Lennart Poettering [Tue, 15 Nov 2016 18:18:36 +0000 (19:18 +0100)]
shared: split out code for adding multiple names to sd_bus_track object

Let's introduce a new call bus_track_add_name_many() that adds a string list to
a tracking object.

7 years agoMerge pull request #4658 from endocode/djalal/sandbox-various-fixes-v1
Djalal Harouni [Tue, 15 Nov 2016 19:45:27 +0000 (20:45 +0100)]
Merge pull request #4658 from endocode/djalal/sandbox-various-fixes-v1

core: improve the logic that implies no new privileges and documentation fixes

7 years agotests: add UNIFIED_CGROUP_HIERARCHY=[default|hybrid] (#4675)
Evgeny Vereshchagin [Tue, 15 Nov 2016 16:38:04 +0000 (19:38 +0300)]
tests: add UNIFIED_CGROUP_HIERARCHY=[default|hybrid] (#4675)

This will simplify testing a bit.
Mainly for https://github.com/systemd/systemd/pull/4670

7 years agobus-util: print RestrictNamespaces= as a string
Djalal Harouni [Tue, 15 Nov 2016 14:15:37 +0000 (15:15 +0100)]
bus-util: print RestrictNamespaces= as a string

Allow all callers that want to print RestrictNamespaces= returned from D-Bus
as a string instead of a u64 value.

7 years agotest: add tests for RestrictNamespaces=
Djalal Harouni [Tue, 15 Nov 2016 14:50:19 +0000 (15:50 +0100)]
test: add tests for RestrictNamespaces=

7 years agocore:gperf: pass the exec_context struct directly to parse restrict namespaces
Djalal Harouni [Mon, 14 Nov 2016 08:12:21 +0000 (09:12 +0100)]
core:gperf: pass the exec_context struct directly to parse restrict namespaces

The RestrictNamespaces= takes yes, no or a list of namespaces types,
therefor config_parse_restrict_namespaces() is a bit complex and it
operates on the ExecContext, fix this by passing the offset of
ExecContext directly otherwise restricting namespaces won't work.

7 years agodoc: move ProtectKernelModules= documentation near ProtectKernelTunalbes=
Djalal Harouni [Mon, 14 Nov 2016 07:32:06 +0000 (08:32 +0100)]
doc: move ProtectKernelModules= documentation near ProtectKernelTunalbes=

7 years agocore: property is RestrictNamespaces with s
Djalal Harouni [Mon, 14 Nov 2016 07:24:41 +0000 (08:24 +0100)]
core: property is RestrictNamespaces with s

7 years agodoc: note when no new privileges is implied
Djalal Harouni [Mon, 14 Nov 2016 09:02:00 +0000 (10:02 +0100)]
doc: note when no new privileges is implied

7 years agocore: improve the logic that implies no new privileges
Djalal Harouni [Tue, 15 Nov 2016 09:15:27 +0000 (10:15 +0100)]
core: improve the logic that implies no new privileges

The no_new_privileged_set variable is not used any more since commit
9b232d3241fcfbf60af that fixed another thing. So remove it. Also no
need to check if we are under user manager, remove that part too.

7 years agoMerge pull request #4665 from teg/networkd-split-1
David Herrmann [Mon, 14 Nov 2016 11:08:38 +0000 (12:08 +0100)]
Merge pull request #4665 from teg/networkd-split-1

networkd: split sources into subdirectories

7 years agonspawn: restart the whole systemd-nspawn@.service unit on container reboot (#4613)
Zbigniew Jędrzejewski-Szmek [Mon, 14 Nov 2016 10:49:49 +0000 (05:49 -0500)]
nspawn: restart the whole systemd-nspawn@.service unit on container reboot (#4613)

Since 133 is now used in a few places, add a #define for it.
Also make the status message a bit informative.

Another issue introduced in b006762. The logic was borked, we were supposed
to return 0 to break the loop, and 133 to restart the container, not the other
way around.

But this doesn't seem to work, reboot fails with:
Nov 08 00:41:32 laptop systemd-nspawn[26564]: Failed to register machine: Machine 'fedora-rawhide' already exists
So actually the version before this patch worked better, since 133 > 0 and we'd
at least loop internally.

7 years agolink: fix offload features initialization (#4639)
Maks Naumov [Mon, 14 Nov 2016 10:33:43 +0000 (12:33 +0200)]
link: fix offload features initialization (#4639)

8 years agonetworkd: clean up main header file a bit
Tom Gundersen [Sun, 13 Nov 2016 03:59:06 +0000 (04:59 +0100)]
networkd: clean up main header file a bit

Rename networkd.h to networkd-manager.h, to more accurately describe what it
contains.

8 years agonetworkd: netdev - move to separate subdirectory
Tom Gundersen [Sun, 13 Nov 2016 01:01:19 +0000 (02:01 +0100)]
networkd: netdev - move to separate subdirectory

This could (and should) be made into a separate daemon, at least move
the sourcefiles out for now.

8 years agonetworkd-wait-online: move to separate subdirectory
Tom Gundersen [Sun, 13 Nov 2016 00:29:28 +0000 (01:29 +0100)]
networkd-wait-online: move to separate subdirectory

Also clean up the header files a bit.

8 years agonetworkd: network - apply() does not need to take the manager object
Tom Gundersen [Wed, 28 Sep 2016 10:32:31 +0000 (12:32 +0200)]
networkd: network - apply() does not need to take the manager object

8 years agoMerge pull request #4659 from keszybz/ctrl-alt-del-twice
Michael Biebl [Sat, 12 Nov 2016 18:47:32 +0000 (19:47 +0100)]
Merge pull request #4659 from keszybz/ctrl-alt-del-twice

build-sys: do not install ctrl-alt-del.target symlink twice

8 years agobuild-sys: do not install ctrl-alt-del.target symlink twice
Zbigniew Jędrzejewski-Szmek [Sat, 12 Nov 2016 15:05:24 +0000 (10:05 -0500)]
build-sys: do not install ctrl-alt-del.target symlink twice

It was a harmless but pointless duplication. Fixes #4655.

Note: in general we try to install as little as possible in
/etc/systemd/{system,user}. We only install .wants links there for units which
are "user configurable", i.e. which have an [Install] section. Most our units
and aliases are not user configurable, do not have an [Install] section, and
must be symlinked statically during installation. A few units do have an
[Install] section, and are enabled through symlinks in /etc/ during
installation using GENERAL_ALIASES. It *would* be possible to not create those
symlinks, and instead require 'systemctl preset' to be invoked after
installation, but GENERAL_ALIASES works well enough.

8 years agoman: add Itanium root GUID to table (#4656)
Lucas Werkmeister [Sat, 12 Nov 2016 03:25:32 +0000 (04:25 +0100)]
man: add Itanium root GUID to table (#4656)

This GUID was added in #2263, but the manpage was not updated.

8 years agosystemctl: resolve symlinks when finding unit paths (#4545)
Felipe Sateler [Sat, 12 Nov 2016 02:28:06 +0000 (23:28 -0300)]
systemctl: resolve symlinks when finding unit paths (#4545)

Otherwise we think the alias is the real unit, and may edit/cat the
wrong unit.

Before this patch:
 $ systemctl edit autovt@ # creates dropin in /etc/systemd/system/autovt@.service.d
 $ systemctl cat autovt@ | grep @.service
 # /lib/systemd/system/autovt@.service
 # that serial gettys are covered by serial-getty@.service, not this
 # /etc/systemd/system/autovt@.service.d/override.conf
 $ systemctl cat getty@ | grep @.service
 # /lib/systemd/system/getty@.service
 # that serial gettys are covered by serial-getty@.service, not this

After this patch
 $ systemctl edit autovt@ # creates dropin in /etc/systemd/system/getty@.service.d
 $ systemctl cat autovt@ | grep @.service
 # /usr/lib/systemd/system/getty@.service
 # that serial gettys are covered by serial-getty@.service, not this
 # /etc/systemd/system/getty@.service.d/override.conf
 systemctl cat getty@ | grep @.service
 # /usr/lib/systemd/system/getty@.service
 # that serial gettys are covered by serial-getty@.service, not this
 # /etc/systemd/system/getty@.service.d/override.conf

8 years agoMerge pull request #4652 from mbiebl/configure-bzip2
Djalal Harouni [Fri, 11 Nov 2016 23:49:20 +0000 (00:49 +0100)]
Merge pull request #4652 from mbiebl/configure-bzip2

various small cleanups in our configure help output

8 years agounits: disable /sys/fs/fuse/connections in private user namespaces (#4592)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 18:00:33 +0000 (13:00 -0500)]
units: disable /sys/fs/fuse/connections in private user namespaces (#4592)

The mount fails, even though CAP_SYS_ADMIN is granted.

Only file systems with FU_USERNS_MOUNT in .fs_flags may be mounted in userns,
and the patch to add that fusectl was rejected [1]. It would be nice if we
could check if the kernel has FU_USERNS_MOUNT for a given fs type, since this
could change over time, but this information doesn't seem to be exported.
So let's just skip this mount in userns to avoid an error during boot.

[1] https://patchwork.kernel.org/patch/2828269/

8 years agotree-wide: make invocations of extract_first_word more uniform (#4627)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 17:58:41 +0000 (12:58 -0500)]
tree-wide: make invocations of extract_first_word more uniform (#4627)

extract_first_words deals fine with the string being NULL, so drop the upfront
check for that.

8 years agotimesyncd: clear ADJ_MAXERROR to keep STA_UNSYNC cleared after jump adjust (#4626)
akochetkov [Fri, 11 Nov 2016 17:50:46 +0000 (20:50 +0300)]
timesyncd: clear ADJ_MAXERROR to keep STA_UNSYNC cleared after jump adjust (#4626)

NTP use jump adjust if system has incorrect time read from RTC during boot.
It is desireble to update RTC time as soon as NTP set correct system time.
Sometimes kernel failed to update RTC due to STA_UNSYNC get set before RTC
update finised. In that case RTC time wouldn't be updated within long time.
The commit makes RTC updates stable.

When NTP do jump time adjust using ADJ_SETOFFSET it clears STA_UNSYNC flag.
If don't clear ADJ_MAXERROR, STA_UNSYNC will be set again by kernel within
1 second (by second_overflow() function). STA_UNSYNC flag prevent RTC updates
in kernel. Sometimes the kernel is able to update RTC withing 1 second,
but sometimes it falied.

8 years agobuild-sys: use lowercase consistently in AS_HELP_STRING
Michael Biebl [Fri, 11 Nov 2016 16:02:26 +0000 (17:02 +0100)]
build-sys: use lowercase consistently in AS_HELP_STRING

We were using a mix of upper and lowercase. Since autoconf's own help
output uses lowercase, use that as well.

8 years agobasic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 15:54:54 +0000 (10:54 -0500)]
basic/virt: fix userns check on CONFIG_USER_NS=n kernel (#4651)

ENOENT should be treated as "false", but because of the broken errno check it
was treated as an error. So ConditionVirtualization=user-namespaces probably
returned the correct answer, but only by accident.

Fixes #4608.

8 years agobuild-sys: replace obsolete AC_HELP_STRING with AS_HELP_STRING
Michael Biebl [Fri, 11 Nov 2016 15:41:26 +0000 (16:41 +0100)]
build-sys: replace obsolete AC_HELP_STRING with AS_HELP_STRING

The AC_HELP_STRING autoconf macro is obsolete. Use AS_HELP_STRING instead.

8 years agobuild-sys: fix help text of bzip2 configure check
Michael Biebl [Fri, 11 Nov 2016 15:34:49 +0000 (16:34 +0100)]
build-sys: fix help text of bzip2 configure check

The bzip2 support is enabled by default unless requested otherwise via
--disable-bzip2. Make the help text reflect that.

Fixes: #4636

8 years agofstab-generator: add x-systemd.mount-timeout (#4603)
Christian Hesse [Fri, 11 Nov 2016 14:08:57 +0000 (15:08 +0100)]
fstab-generator: add x-systemd.mount-timeout (#4603)

This adds a new systemd fstab option x-systemd.mount-timeout. The option
adds a timeout value that specifies how long systemd waits for the mount
command to finish. It allows to mount huge btrfs volumes without issues.

This is equivalent to adding option TimeoutSec= to [Mount] section in a
mount unit file.

fixes #4055

8 years agotest-nss: allow the module and names/addresses to be specified (#4258)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 12:39:20 +0000 (07:39 -0500)]
test-nss: allow the module and names/addresses to be specified (#4258)

Useful for testing a single module. If nothing is specified, behaviour is the
same as before.

$ ./test-nss myhostname 192.168.0.14 localhost
======== myhostname ========
_nss_myhostname_gethostbyname4_r("localhost") → status=NSS_STATUS_SUCCESS
                   pat=buffer+0x38 errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost" AF_INET 127.0.0.1 %lo
        "localhost" AF_INET6 ::1 %lo

_nss_myhostname_gethostbyname3_r("localhost", AF_INET) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET 127.0.0.1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", AF_INET6) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET6 ::1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", *) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "localhost"
        AF_INET 127.0.0.1
        canonical: "localhost"

_nss_myhostname_gethostbyname3_r("localhost", AF_UNIX) → status=NSS_STATUS_UNAVAIL
                   errno=97/EAFNOSUPPORT h_errno=4/No address associated with name ttl=2147483647

_nss_myhostname_gethostbyname2_r("localhost", AF_INET) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyname2_r("localhost", AF_INET6) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET6 ::1

_nss_myhostname_gethostbyname2_r("localhost", *) → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyname2_r("localhost", AF_UNIX) → status=NSS_STATUS_UNAVAIL
                   errno=97/EAFNOSUPPORT h_errno=4/No address associated with name

_nss_myhostname_gethostbyname_r("localhost") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "localhost"
        AF_INET 127.0.0.1

_nss_myhostname_gethostbyaddr2_r("192.168.0.14") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error) ttl=0
        "laptop"
        AF_INET 192.168.0.14
        AF_INET 192.168.122.1
        AF_INET 169.254.209.76

_nss_myhostname_gethostbyaddr_r("192.168.0.14") → status=NSS_STATUS_SUCCESS
                   errno=0/--- h_errno=0/Resolver Error 0 (no error)
        "laptop"
        AF_INET 192.168.0.14
        AF_INET 192.168.122.1
        AF_INET 169.254.209.76

8 years agoman: update machine-id(5) with a note about privacy (#4645)
Zbigniew Jędrzejewski-Szmek [Fri, 11 Nov 2016 12:31:52 +0000 (07:31 -0500)]
man: update machine-id(5) with a note about privacy (#4645)

8 years agoMerge pull request #4647 from evverx/arch-testsuite
Djalal Harouni [Fri, 11 Nov 2016 10:07:40 +0000 (11:07 +0100)]
Merge pull request #4647 from evverx/arch-testsuite

tests: fix kernel/initrd searching (Arch)

8 years agotests: fix kernel/initrd searching (Arch)
Evgeny Vereshchagin [Fri, 11 Nov 2016 02:45:38 +0000 (13:45 +1100)]
tests: fix kernel/initrd searching (Arch)

We can run
sudo make run

instead of the
sudo make run KERNEL_BIN=/boot/vmlinuz-linux INITRD=/boot/initramfs-linux.img

See https://github.com/systemd/systemd/issues/4607

8 years agonetworkd: support setting dhcp client listen port (#4631)
Susant Sahani [Thu, 10 Nov 2016 23:34:19 +0000 (05:04 +0530)]
networkd: support setting dhcp client listen port (#4631)

Allow setting custom port for the DHCP client to listen on in networkd.

[DHCP]
ListenPort=6677

8 years agoMerge pull request #4635 from eworm-de/resolved
Zbigniew Jędrzejewski-Szmek [Thu, 10 Nov 2016 23:31:46 +0000 (18:31 -0500)]
Merge pull request #4635 from eworm-de/resolved

resolved: unlink /run/systemd/resolve/resolv.conf upon exit

8 years agoman: mention start rate limiting in Restart= doc (#4637)
Lucas Werkmeister [Thu, 10 Nov 2016 23:20:44 +0000 (00:20 +0100)]
man: mention start rate limiting in Restart= doc (#4637)

8 years agoMerge pull request #4104 from ssahani/ethtool_xlink_settings
Zbigniew Jędrzejewski-Szmek [Thu, 10 Nov 2016 22:09:44 +0000 (17:09 -0500)]
Merge pull request #4104 from ssahani/ethtool_xlink_settings

Link: port to new ethtool ETHTOOL_xLINKSETTINGS