]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
7 years agodissect: add small "systemd-dissect" tool as wrapper around dissect-image.c
Lennart Poettering [Fri, 2 Dec 2016 18:32:09 +0000 (19:32 +0100)] 
dissect: add small "systemd-dissect" tool as wrapper around dissect-image.c

This adds a small tool that may be used to look into OS images, and mount them
to any place. This is mostly a friendlier version of test-dissect-image.c. I am
not sure this should really become a proper command of systemd, hence for now
do not install it into bindir, but simply libexecdir.

This tool is already pretty useful since you can mount image files with it,
honouring the various partitions correctly. I figure this is going to become
more interesting if the dissctor learns luks and verity support.

7 years agoutil-lib: drop unnecessary NULL check
Lennart Poettering [Fri, 2 Dec 2016 16:01:19 +0000 (17:01 +0100)] 
util-lib: drop unnecessary NULL check

DEFINE_TRIVIAL_CLEANUP_FUNC() already does that check, no need to duplicate it.

7 years agomachined: add API for querying the OS release of a machine image
Lennart Poettering [Thu, 1 Dec 2016 22:24:20 +0000 (23:24 +0100)] 
machined: add API for querying the OS release of a machine image

This adds a bus call GetImageOSRelease() to the Manager interface that
retrieves the /etc/os-release file of a machine image. It matches the existing
GetMachineOSRelease() call, however operates on a disk image rather than a
running container.

The backend for this call on .raw images is implemented via the generalized
image dissector, which makes this scheme relatively easy to implement.

7 years agoutil-lib: add easy helpers for temporary directories that rmdir()ed via _cleanup_
Lennart Poettering [Thu, 1 Dec 2016 22:19:31 +0000 (23:19 +0100)] 
util-lib: add easy helpers for temporary directories that rmdir()ed via _cleanup_

This adds mkdtemp_malloc() that is a combination of mkdtemp() plus strdup(). It
initializes its return paremeter only if the temporary directory could be
created successfully, so that the parameter is exactly non-NULL when the
directory exists.

rmdir_and_free() and rmdir_and_freep() are also added, and the latter may be
used inside of _cleanup_ for such a directory string variable, to automatically
rmdir() the directory if it is non-NULL when the scope exits.

rmdir_and_free() is similar to the existing rm_rf_and_free() however, is only
removes a single directory and does not operate recursively.

7 years agonspawn: port nspawn to new generalized image dissection code
Lennart Poettering [Thu, 1 Dec 2016 19:26:09 +0000 (20:26 +0100)] 
nspawn: port nspawn to new generalized image dissection code

Let's make use of the new internal API. This mostly doesn't change anything for
the caller, however, "systemd-nspawn --image=/dev/sda7" works now as the new
code can handle disk images with no partition tables, and make any detected
images directly the root.

7 years agoutil-lib: split out image dissecting code and loopback code from nspawn
Lennart Poettering [Thu, 1 Dec 2016 19:25:26 +0000 (20:25 +0100)] 
util-lib: split out image dissecting code and loopback code from nspawn

This adds two new APIs to systemd:

- loop-util.h is a simple internal API for allocating, setting up and releasing
  loopback block devices.

- dissect-image.h is an internal API for taking apart disk images and figuring
  out what the purpose of each partition is.

Both APIs are basically refactored versions of similar code in nspawn.  This
rework should permit us to reuse this in other places than just nspawn in the
future. Specifically: to implement RootImage= in the service image, similar to
RootDirectory=, but operating on a disk image; to unify the gpt-auto-discovery
generator code with the discovery logic in nspawn; to add new API to machined
for determining the OS version of a disk image (i.e. not just running
containers). This PR does not make any such changes however, it just provides
the new reworked API.

The reworked code is also slightly more powerful than the nspawn original one.
When pointing it to an image or block device with a naked file system (i.e. no
partition table) it will simply make it the root device.

7 years agolibudev: set errno if udev_new() fails
Lennart Poettering [Thu, 1 Dec 2016 17:15:43 +0000 (18:15 +0100)] 
libudev: set errno if udev_new() fails

All other constructors in libudev do that, let's also do this for udev_new().

7 years agodhcp: bind udp sockets to interfaces (#4822)
27o [Wed, 7 Dec 2016 01:00:05 +0000 (02:00 +0100)] 
dhcp: bind udp sockets to interfaces (#4822)

7 years agoMerge pull request #4841 from hadess/oke-barcode-reader
Peter Hutterer [Tue, 6 Dec 2016 21:12:13 +0000 (07:12 +1000)] 
Merge pull request #4841 from hadess/oke-barcode-reader

hwdb: Add fixed layout for a few devices

7 years agocalendarspec: always interpret missing seconds as :00 (#4813)
Doug Christman [Tue, 6 Dec 2016 19:41:15 +0000 (14:41 -0500)] 
calendarspec: always interpret missing seconds as :00 (#4813)

"*:*" should be equivalent to "*-*-* *:*:00" (minutely)
rather than running every microsecond.

Fixes #4804

7 years agoservice: go through stop_post on failure (#4770) 4843/head
Jouke Witteveen [Tue, 6 Dec 2016 12:30:28 +0000 (13:30 +0100)] 
service: go through stop_post on failure (#4770)

7 years agoman: fix $SERVICE_RESULT/$EXIT_CODE/$EXIT_STATUS documentation
Jouke Witteveen [Tue, 6 Dec 2016 12:01:35 +0000 (13:01 +0100)] 
man: fix $SERVICE_RESULT/$EXIT_CODE/$EXIT_STATUS documentation

Note that any exit code is available through $EXIT_STATUS and not through
$EXIT_CODE. This mimics siginfo.

7 years agonetworkd: Use dhcp correct type for IP port (#4840)
Susant Sahani [Tue, 6 Dec 2016 11:22:33 +0000 (16:52 +0530)] 
networkd: Use dhcp correct type for IP port (#4840)

Fixes: #4839
7 years agocore: introduce parse_ip_port (#4825)
Susant Sahani [Tue, 6 Dec 2016 11:21:45 +0000 (16:51 +0530)] 
core: introduce parse_ip_port (#4825)

1. Listed in TODO.
2. Tree wide replace safe_atou16 with parse_ip_port incase
   it's used for ports.

7 years agohwdb: Add fixed layout for another Yubikey 4841/head
Bastien Nocera [Tue, 6 Dec 2016 11:14:40 +0000 (12:14 +0100)] 
hwdb: Add fixed layout for another Yubikey

7 years agohwdb: Add fixed layout for OKE barcode reader
Bastien Nocera [Tue, 6 Dec 2016 10:42:23 +0000 (11:42 +0100)] 
hwdb: Add fixed layout for OKE barcode reader

7 years agotime-util: accept "µs" as time unit, in addition to "us" (#4836)
Lennart Poettering [Tue, 6 Dec 2016 09:51:26 +0000 (10:51 +0100)] 
time-util: accept "µs" as time unit, in addition to "us" (#4836)

Let's accept "µs" as alternative time unit for microseconds. We already accept
"us" and "usec" for them, lets extend on this and accept the proper scientific
unit specification too.

We will never output this as time unit, but it's fine to accept it, after all
we are pretty permissive with time units already.

7 years agorules: consider MMC device partitions with partition number > 9 (#4831)
Kieran Colford [Tue, 6 Dec 2016 09:46:13 +0000 (04:46 -0500)] 
rules: consider MMC device partitions with partition number > 9 (#4831)

Add entries for extra partitions found on MMC devices (common in Chromebooks).

7 years agoMerge pull request #4838 from phomes/misc-cleanup2
Evgeny Vereshchagin [Tue, 6 Dec 2016 03:51:55 +0000 (06:51 +0300)] 
Merge pull request #4838 from phomes/misc-cleanup2

Misc cleanups

7 years agocore: remove unused variable 4838/head
Thomas Hindoe Paaboel Andersen [Mon, 5 Dec 2016 23:07:34 +0000 (00:07 +0100)] 
core: remove unused variable

7 years agoudev: remove duplicate flag
Thomas Hindoe Paaboel Andersen [Mon, 5 Dec 2016 22:55:18 +0000 (23:55 +0100)] 
udev: remove duplicate flag

One SA_RESTART is enough. Fall out from
e28c7cd0665364bb910fe2cead882623c23c28ac

7 years agoman: Document return value of event source prepare callback (#4834)
Martin Ejdestig [Mon, 5 Dec 2016 22:42:41 +0000 (23:42 +0100)] 
man: Document return value of event source prepare callback (#4834)

7 years agonspawn: don't hide --bind=/tmp/* mounts (#4824)
Evgeny Vereshchagin [Mon, 5 Dec 2016 17:14:05 +0000 (20:14 +0300)] 
nspawn: don't hide --bind=/tmp/* mounts (#4824)

Fixes #4789

7 years agonetworkd: link_enter_configured remove assert (#4800)
Susant Sahani [Mon, 5 Dec 2016 14:31:48 +0000 (20:01 +0530)] 
networkd: link_enter_configured remove assert (#4800)

When we are in link_enter_configured we assume that the
link->state should be LINK_STATE_SETTING_ROUTES but in some
situation it's LINK_STATlE_SETTING_ADDRESSES.

Just ignore the wrong state.

Also since the return value not used any where
make link_enter_configured return type void.

Fixes: #4746
7 years agojournal: make sure to initially populate the space info cache (#4807)
Franck Bui [Fri, 2 Dec 2016 17:40:10 +0000 (18:40 +0100)] 
journal: make sure to initially populate the space info cache (#4807)

Make sure to populate the cache in cache_space_refresh() at least once
otherwise it's possible that the system boots fast enough (and the journal
flush service is finished) before the invalidate cache timeout (30 us) has
expired.

Fixes: #4790
7 years agocgroup: properly check for ignore-notfound paths (#4803)
Dave Reisner [Fri, 2 Dec 2016 14:23:23 +0000 (09:23 -0500)] 
cgroup: properly check for ignore-notfound paths (#4803)

Follow-up to #4687 and e7330dfe14b1965f.

7 years agotreewide: fix typos (#4802)
Torstein Husebø [Fri, 2 Dec 2016 14:20:26 +0000 (15:20 +0100)] 
treewide: fix typos (#4802)

7 years agoMerge pull request #4228 from dm0-/coreos-1554
Zbigniew Jędrzejewski-Szmek [Fri, 2 Dec 2016 14:14:27 +0000 (09:14 -0500)] 
Merge pull request #4228 from dm0-/coreos-1554

networkd: support marking links unmanaged

7 years agoMerge pull request #4797 from keszybz/pylint
Martin Pitt [Fri, 2 Dec 2016 07:48:37 +0000 (08:48 +0100)] 
Merge pull request #4797 from keszybz/pylint

Python cleanups based on pylint advice

7 years agopython: use raw strings for regexp patterns 4797/head
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 23:29:54 +0000 (18:29 -0500)] 
python: use raw strings for regexp patterns

Behaviour is not changed, because "unknown" escapes like \s or \d were not
substituted, but it's much nicer to use raw strings to avoid ambiguity.

7 years agohwdb_parse: adjust indentation and imports following pylint advice
Zbigniew Jędrzejewski-Szmek [Fri, 2 Dec 2016 00:10:01 +0000 (19:10 -0500)] 
hwdb_parse: adjust indentation and imports following pylint advice

(This commit is separate to make it easy to export to libinput.)

7 years agopython: adjust imports, indentation, unused variables following pylint advice
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 22:30:31 +0000 (17:30 -0500)] 
python: adjust imports, indentation, unused variables following pylint advice

7 years agoacpi-update.py: there is no "Error" class
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 22:23:53 +0000 (17:23 -0500)] 
acpi-update.py: there is no "Error" class

Evidently this code path was never hit, because we'd crash with NameError.
The exception message also seems bogus. So just replace the whole thing
with the standard exception for invalid input.

7 years agoSpot inconsistent quoting (just one single quote) (#4732)
Tobias Stoeckmann [Thu, 1 Dec 2016 23:46:36 +0000 (00:46 +0100)] 
Spot inconsistent quoting (just one single quote) (#4732)

It is possible to specify only one quote in udev rules, which is not
detected as an invalid quoting (" instead of "" for empty string).

Technically this doesn't lead to a bug, because the string ends in two
terminating nul characters at this position, but a user should still be
reminded that his configuration is invalid.

7 years agonetworkd: VXLAN add better explanation for ARPProxy (#4781)
Susant Sahani [Thu, 1 Dec 2016 23:05:10 +0000 (04:35 +0530)] 
networkd: VXLAN add better explanation for ARPProxy (#4781)

This closes #4768

7 years agonetworkd: support marking links unmanaged 4228/head
David Michael [Tue, 27 Sep 2016 22:18:14 +0000 (15:18 -0700)] 
networkd: support marking links unmanaged

7 years agonetworkd-test: define a utility class to simplify tests
David Michael [Thu, 3 Nov 2016 23:27:55 +0000 (16:27 -0700)] 
networkd-test: define a utility class to simplify tests

7 years agorules: add persistent links for nbd devices (#4785)
Martin Pitt [Thu, 1 Dec 2016 21:22:47 +0000 (22:22 +0100)] 
rules: add persistent links for nbd devices (#4785)

https://bugs.debian.org/837999

7 years agohwdb: fix detection of assignments with no key
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 16:32:41 +0000 (11:32 -0500)] 
hwdb: fix detection of assignments with no key

The code was trying to detect an empty key, but property lines always
start with a space, so the condition was wrong.

Now:
[/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:14] Empty key in " =NO_NAME", ignoring
[/tmp/tmp.YWeKax4fMI/etc/udev/hwdb.d/10-bad.hwdb:15] Empty value in " NO_VALUE=", ignoring

7 years agohwdb: improve and test syntax error messages
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 15:55:32 +0000 (10:55 -0500)] 
hwdb: improve and test syntax error messages

Since syntax error are non-fatal, downgrade them to warnings.
Use log_syntax to have uniform formatting including the line number.
State machine states like DATA and MATCH are internal, user-facing
messages should use the names from hwdb(7): match, property, record.
Also change "key/value" to "key-value", since there's no alternative
here, both parts must be present.

[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:2] Property expected, ignoring record with no properties
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:5] Property expected, ignoring record with no properties
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:9] Property expected, ignoring record with no properties
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:11] Key/value pair expected but got " NO_VALUE", ignoring
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:18] Property or empty line expected, got "BAD:7:match at wrong place", ignoring record
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:22] Property or empty line expected, got "BAD:8:match at wrong place", ignoring record
[/tmp/tmp.KFwEhm74n4/etc/udev/hwdb.d/10-bad.hwdb:23] Match expected but got indented property " Z=z", ignoring line

squash! hwdb: improve syntax error messages

7 years agohwdb-test: properly print error output from systemd-hwdb update
Zbigniew Jędrzejewski-Szmek [Wed, 30 Nov 2016 03:41:52 +0000 (22:41 -0500)] 
hwdb-test: properly print error output from systemd-hwdb update

Because -e was set, we'd exit immediately when systemd-hwdb failed and the
captured error output was never printed. We want to test two things:
that 0 is returned, and that nothing is printed to stderr (to catch
syntax errors in the hwdb).

v2: stop capturing stderr to a variable
v3: capture stderr to a variable and test both error types separately

7 years agoUpdate boot.c (#4780)
Yassine Imounachen [Thu, 1 Dec 2016 14:58:58 +0000 (14:58 +0000)] 
Update boot.c (#4780)

7 years agoMerge pull request #4694 from poettering/chase-everywhere
Zbigniew Jędrzejewski-Szmek [Thu, 1 Dec 2016 14:29:14 +0000 (09:29 -0500)] 
Merge pull request #4694 from poettering/chase-everywhere

tree-wide: stop using canonicalize_file_name(), use chase_symlinks() …

7 years agoMerge pull request #4778 from whot/xkb-fixed-layout
Martin Pitt [Thu, 1 Dec 2016 13:32:32 +0000 (14:32 +0100)] 
Merge pull request #4778 from whot/xkb-fixed-layout

Xkb fixed layout

7 years agoutil-lib: rename CHASE_NON_EXISTING → CHASE_NONEXISTENT 4694/head
Lennart Poettering [Thu, 1 Dec 2016 11:49:23 +0000 (12:49 +0100)] 
util-lib: rename CHASE_NON_EXISTING → CHASE_NONEXISTENT

As suggested by @keszybz

7 years agonspawn: improve log messages
Lennart Poettering [Thu, 1 Dec 2016 11:40:23 +0000 (12:40 +0100)] 
nspawn: improve log messages

When complaining about the inability to resolve a path, show the full path, not
just the relative one.

As suggested by @keszybz.

7 years agonspawn: optionally, automatically allocated --bind=/--overlay source from /var/tmp
Lennart Poettering [Wed, 30 Nov 2016 17:57:42 +0000 (18:57 +0100)] 
nspawn: optionally, automatically allocated --bind=/--overlay source from /var/tmp

This extends the --bind= and --overlay= syntax so that an empty string as source/upper
directory is taken as request to automatically allocate a temporary directory
below /var/tmp, whose lifetime is bound to the nspawn runtime. In combination
with the "+" path extension this permits a switch "--overlay=+/var::/var" in
order to use the container's shipped /var, combine it with a writable temporary
directory and mount it to the runtime /var of the container.

7 years agonspawn: permit prefixing of source paths in --bind= and --overlay= with "+"
Lennart Poettering [Wed, 30 Nov 2016 15:02:47 +0000 (16:02 +0100)] 
nspawn: permit prefixing of source paths in --bind= and --overlay= with "+"

If a source path is prefixed with "+" it is taken relative to the container's
root directory instead of the host. This permits easily establishing bind and
overlay mounts based on data from the container rather than the host.

This also reworks custom_mounts_prepare(), and turns it into two functions: one
custom_mount_check_all() that remains in nspawn.c but purely verifies the
validity of the custom mounts configured. And one called
custom_mount_prepare_all() that actually does the preparation step, sorts the
custom mounts, resolves relative paths, and allocates temporary directories as
necessary.

7 years agotree-wide: set SA_RESTART for signal handlers we install
Lennart Poettering [Wed, 30 Nov 2016 14:07:43 +0000 (15:07 +0100)] 
tree-wide: set SA_RESTART for signal handlers we install

We already set it in most cases, but make sure to set it in all others too, and
document that that's a good idea.

7 years agonspawn: add ability to configure overlay mounts to .nspawn files
Lennart Poettering [Tue, 29 Nov 2016 22:55:04 +0000 (23:55 +0100)] 
nspawn: add ability to configure overlay mounts to .nspawn files

Fixes: #4634
7 years agohwdb: add XKB_FIXED_LAYOUT/VARIANT to the keyboard hwdb 4778/head
Peter Hutterer [Tue, 22 Nov 2016 05:21:24 +0000 (15:21 +1000)] 
hwdb: add XKB_FIXED_LAYOUT/VARIANT to the keyboard hwdb

Yubikeys and other pseudo keyboards require that they are in the US layout,
otherwise the data they send is invalid. Add two new keys to signal this to
processes that handles (XKB) layouts.

7 years agohwdb: fix comment referring to rules file
Peter Hutterer [Tue, 22 Nov 2016 04:54:06 +0000 (14:54 +1000)] 
hwdb: fix comment referring to rules file

60-keyboard.rules was renamed to 60-evdev.rules in 51c0c2869

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
7 years agonspawn: split out overlayfs argument parsing into a function of its own
Lennart Poettering [Tue, 29 Nov 2016 22:47:58 +0000 (23:47 +0100)] 
nspawn: split out overlayfs argument parsing into a function of its own

Add overlay_mount_parse() similar in style to tmpfs_mount_parse() and
bind_mount_parse().

7 years agonspawn: use -ENOMEM instead of log_oom() in one case
Lennart Poettering [Tue, 29 Nov 2016 22:47:24 +0000 (23:47 +0100)] 
nspawn: use -ENOMEM instead of log_oom() in one case

The function is of the "library" kind and doesn't log ENOMEM in all other
cases, hence fix the one outlier.

7 years agonspawn: make use of CHASE_NON_EXISTING when locking image
Lennart Poettering [Tue, 29 Nov 2016 17:16:43 +0000 (18:16 +0100)] 
nspawn: make use of CHASE_NON_EXISTING when locking image

If --template= is used on an image, then the image might not exist initially.
We can use CHASE_NON_EXISTING to properly lock the image already before it
exists. Let's do so.

7 years agonspawn: use the new CHASE_NON_EXISTING flag when resolving mount points
Lennart Poettering [Tue, 29 Nov 2016 17:13:11 +0000 (18:13 +0100)] 
nspawn: use the new CHASE_NON_EXISTING flag when resolving mount points

This restores the ability to implicitly create files/directories to mount
specified mount points on.

7 years agofs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()
Lennart Poettering [Tue, 29 Nov 2016 17:02:45 +0000 (18:02 +0100)] 
fs-util: add new CHASE_NON_EXISTING flag to chase_symlinks()

This new flag controls whether to consider a problem if the referenced path
doesn't actually exist. If specified it's OK if the final file doesn't exist.

Note that this permits one or more final components of the path not to exist,
but these must not contain "../" for safety reasons (or, to be extra safe,
neither "./" and a couple of others, i.e. what path_is_safe() permits).

This new flag is useful when resolving paths before issuing an mkdir() or
open(O_CREAT) on a path, as it permits that the file or directory is created
later.

The return code of chase_symlinks() is changed to return 1 if the file exists,
and 0 if it doesn't. The latter is only returned in case CHASE_NON_EXISTING is
set.

7 years agofs-util: add flags parameter to chase_symlinks()
Lennart Poettering [Tue, 29 Nov 2016 15:49:30 +0000 (16:49 +0100)] 
fs-util: add flags parameter to chase_symlinks()

Let's remove chase_symlinks_prefix() and instead introduce a flags parameter to
chase_symlinks(), with a flag CHASE_PREFIX_ROOT that exposes the behaviour of
chase_symlinks_prefix().

7 years agofs-util: change chase_symlinks() behaviour in regards to escaping the root dir
Lennart Poettering [Tue, 29 Nov 2016 14:54:42 +0000 (15:54 +0100)] 
fs-util: change chase_symlinks() behaviour in regards to escaping the root dir

Previously, we'd generate an EINVAL error if it is attempted to escape a root
directory with relative ".." symlinks. With this commit this is changed so that
".." from the root directory is a NOP, following the kernel's own behaviour
where /.. is equivalent to /.

As suggested by @keszybz.

7 years agotest-fs-util: add a test case with repeated ".." parts that would escape the root
Zbigniew Jędrzejewski-Szmek [Sun, 27 Nov 2016 03:18:58 +0000 (22:18 -0500)] 
test-fs-util: add a test case with repeated ".." parts that would escape the root

7 years agonspawn: use chase_symlinks() on all paths specified via --tmpfs=, --bind= and so on
Lennart Poettering [Fri, 25 Nov 2016 18:01:36 +0000 (19:01 +0100)] 
nspawn: use chase_symlinks() on all paths specified via --tmpfs=, --bind= and so on

Fixes: #2860
7 years agofs-util: add chase_symlinks_prefix() and extend comments
Lennart Poettering [Fri, 25 Nov 2016 17:59:39 +0000 (18:59 +0100)] 
fs-util: add chase_symlinks_prefix() and extend comments

chase_symlinks() currently expects a fully qualified, absolute path, relative
to the host's root as first argument. Which is useful in many ways, and similar
to the paths unlink(), rename(), open(), … expect. Sometimes it's however
useful to first prefix the specified path with the specified root directory.
Add a new call chase_symlinks_prefix() for this, that is a simple wrapper.

7 years agonspawn: coding style: don't mix variable declarations and function calls
Lennart Poettering [Fri, 25 Nov 2016 17:59:06 +0000 (18:59 +0100)] 
nspawn: coding style: don't mix variable declarations and function calls

7 years agonspawn: use realloc_multiply() where it makes sense
Lennart Poettering [Fri, 25 Nov 2016 17:58:31 +0000 (18:58 +0100)] 
nspawn: use realloc_multiply() where it makes sense

7 years agonspawn: accept --ephemeral --template= as alternative for --ephemeral --directory=
Lennart Poettering [Fri, 25 Nov 2016 00:00:31 +0000 (01:00 +0100)] 
nspawn: accept --ephemeral --template= as alternative for --ephemeral --directory=

As suggested in PR #3667.

This PR simply ensures that --template= can be used as alternative to
--directory= when --ephemeral is used, following the logic that for ephemeral
options the source directory is actually a template.

This does not deprecate usage of --directory= with --ephemeral, as I am not
convinced the old logic wouldn't make sense.

Fixes: #3667
7 years agonspawn: properly handle image/directory paths that are symlinks
Lennart Poettering [Thu, 24 Nov 2016 20:03:36 +0000 (21:03 +0100)] 
nspawn: properly handle image/directory paths that are symlinks

This resolves any paths specified on --directory=, --template=, and --image=
before using them. This makes sure nspawn can be used correctly on symlinked
images and directory trees.

Fixes: #2001
7 years agotree-wide: stop using canonicalize_file_name(), use chase_symlinks() instead
Lennart Poettering [Fri, 18 Nov 2016 20:35:21 +0000 (21:35 +0100)] 
tree-wide: stop using canonicalize_file_name(), use chase_symlinks() instead

Let's use chase_symlinks() everywhere, and stop using GNU
canonicalize_file_name() everywhere. For most cases this should not change
behaviour, however increase exposure of our function to get better tested. Most
importantly in a few cases (most notably nspawn) it can take the correct root
directory into account when chasing symlinks.

7 years agocore: make unit_free() accept NULL pointers
Lennart Poettering [Mon, 28 Nov 2016 18:41:20 +0000 (19:41 +0100)] 
core: make unit_free() accept NULL pointers

We generally try to make our destructors robust regarding NULL pointers, much
in the same way as glibc's free(). Do this also for unit_free().

Follow-up for #4748.

7 years agol10n: update line numbers in Czech translation (#4776)
AsciiWolf [Wed, 30 Nov 2016 20:59:19 +0000 (21:59 +0100)] 
l10n: update line numbers in Czech translation (#4776)

7 years agoman: describe overriding of entries in hwdb files
Zbigniew Jędrzejewski-Szmek [Wed, 30 Nov 2016 03:29:31 +0000 (22:29 -0500)] 
man: describe overriding of entries in hwdb files

7 years agohwdb: rename err to r and use _cleanup_ in two more places
Zbigniew Jędrzejewski-Szmek [Wed, 30 Nov 2016 01:44:22 +0000 (20:44 -0500)] 
hwdb: rename err to r and use _cleanup_ in two more places

7 years agohwdb: simplify error handling in trie_store
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 20:27:40 +0000 (15:27 -0500)] 
hwdb: simplify error handling in trie_store

fclose() can also set errno, so the attempts to protect errno that the
code made were not successful. Simplify things by immediately saving
errno to r.

7 years agosd-hwdb: drop caching of search string
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 20:17:19 +0000 (15:17 -0500)] 
sd-hwdb: drop caching of search string

We have only two callers, and for neither this "optimization" is useful.
So let's drop it an save some code and a malloc.

7 years agohwdb, sd-hwdb: rework priority comparison when loading properties
Zbigniew Jędrzejewski-Szmek [Wed, 30 Nov 2016 01:26:35 +0000 (20:26 -0500)] 
hwdb, sd-hwdb: rework priority comparison when loading properties

We cannot compare filenames directly, because paths are not sortable
lexicographically, e.g. /etc/udev is "later" (has higher priority)
than /usr/lib/udev.

The on-disk format is changed to have a separate field for "file priority",
which is stored when writing the binary file, and then loaded and used in
comparisons. For data in the previous format (as generated by systemd 232),
this information is not available, and we use a trick where the offset into the
string table is used as a proxy for priority. Most of the time strings are
stored in the order in which the files were processed. This is not entirely
reliable, but is good enough to properly order /usr/lib and /etc/, which are
the two most common cases. This hack is included because it allows proper
parsing of files until the binary hwdb is regenerated.

Instead of adding a new field, I reduced the size of line_number from 64 to 32
bits, and added a 16 bit priority field, and 16 bits of padding. Adding a new
field of 16 bytes would significantly screw up alignment and increase file
size, and line number realistically don't need more than ~20 bits.

Fixes #4750.

7 years agohwdb: remove path comparison which broke overriding of properties
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 19:46:40 +0000 (14:46 -0500)] 
hwdb: remove path comparison which broke overriding of properties

Partial fix for #4750.

We would compare strings like "/usr/lib/udev/hwdb.d/something.hwdb" and
"/etc/udev/hwdb.db/something.hwdb" and conclude that the first has higher
priority. Since we process files in order (higher priority later), no
comparison is necessary when loading.

This partially undoes 3a04b789c6f17dff2000a3cdbeaaf86baa604524
(not in spirit, but in the implementation).

7 years agosystemctl: fix 'is-enabled' exit status on failure when executed in chroot (#4773)
Franck Bui [Wed, 30 Nov 2016 17:27:42 +0000 (18:27 +0100)] 
systemctl: fix 'is-enabled' exit status on failure when executed in chroot (#4773)

7 years agoAs per use case we should allow ForwardDelaySec to be set as 0 (#4765)
Susant Sahani [Wed, 30 Nov 2016 10:54:42 +0000 (16:24 +0530)] 
As per use case we should allow ForwardDelaySec to be set as 0 (#4765)

So let's set ForwardDelaySec to USEC_INFINITY .

Reference:
https://wiki.linuxfoundation.org/networking/bridge#does-dhcp-work-overthrough-a-bridge

7 years agoMerge pull request #4772 from martinpitt/hwdb
Martin Pitt [Wed, 30 Nov 2016 09:25:09 +0000 (10:25 +0100)] 
Merge pull request #4772 from martinpitt/hwdb

parse_hwdb: fix to work with pyparsing 2.1.10

7 years agohwdb/parse_hwdb.py: open files with UTF-8 mode 4772/head
Martin Pitt [Thu, 24 Nov 2016 09:38:01 +0000 (10:38 +0100)] 
hwdb/parse_hwdb.py: open files with UTF-8 mode

pyparsing uses the system locale by default, which in the case of 'C' (in lots
of build environment) will fail with a UnicodeDecodeError. Explicitly open it
with UTF-8 encoding to guard against this.

7 years agoparse_hwdb: fix to work with pyparsing 2.1.10
Martin Pitt [Wed, 30 Nov 2016 08:20:15 +0000 (09:20 +0100)] 
parse_hwdb: fix to work with pyparsing 2.1.10

pyparsing 2.1.10 fixed the handling of LineStart to really just apply to line
starts and not ignore whitespace and comments any more. Adjust EMPTYLINE to
this.

Many thanks to Paul McGuire for pointing this out!

7 years agotest: retry checking for transient hostname in hostnamectl (#4769)
Martin Pitt [Wed, 30 Nov 2016 07:02:49 +0000 (08:02 +0100)] 
test: retry checking for transient hostname in hostnamectl (#4769)

Sometimes setting the transient hostname does not happen synchronously, so
retry up to five times. It is not yet clear whether this is legitimate
behaviour or an underlying bug, but this will at least show whether the wrong
transient hostname is just a race condition or permanently wrong.

Fixes #4753

7 years agoTwo small cleanups
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 19:42:57 +0000 (14:42 -0500)] 
Two small cleanups

7 years agoMerge pull request #4745 from joukewitteveen/notify
Evgeny Vereshchagin [Wed, 30 Nov 2016 00:22:07 +0000 (03:22 +0300)] 
Merge pull request #4745 from joukewitteveen/notify

Improvements for notify services (including #4212)

7 years agoservice: new NotifyAccess= value for control processes (#4212) 4745/head
Jouke Witteveen [Thu, 24 Nov 2016 09:56:32 +0000 (10:56 +0100)] 
service: new NotifyAccess= value for control processes (#4212)

Setting NotifyAccess=exec allows notifications coming directly from any
control process.

7 years agoNEWS: mention more aggressive failing of notify services
Jouke Witteveen [Mon, 28 Nov 2016 17:54:37 +0000 (18:54 +0100)] 
NEWS: mention more aggressive failing of notify services

7 years agobus-util: add protocol error type explanation
Jouke Witteveen [Tue, 29 Nov 2016 08:36:20 +0000 (09:36 +0100)] 
bus-util: add protocol error type explanation

7 years agocgroup: support prefix "-" in cgroups whitelisting entries (#4687)
Dongsu Park [Tue, 29 Nov 2016 19:16:55 +0000 (20:16 +0100)] 
cgroup: support prefix "-" in cgroups whitelisting entries (#4687)

So far systemd-nspawn container has been creating files under
/run/systemd/inaccessible, no matter whether it's running in user
namespace or not. That's fine for regular files, dirs, socks, fifos.
However, it's not for block and character devices, because kernel
doesn't allow them to be created under user namespace. It results
in warnings at booting like that:

====
  Couldn't stat device /run/systemd/inaccessible/chr
  Couldn't stat device /run/systemd/inaccessible/blk
====

Thus we need to have the cgroups whitelisting handler to silently ignore
a file, when the device path is prefixed with "-". That's exactly the
same convention used in directives like ReadOnlyPaths=. Also insert the
prefix "-" to inaccessible entries.

7 years agonetworkctl: install zsh completion from #3062 (#4767)
Gabriel Rauter [Tue, 29 Nov 2016 18:00:38 +0000 (19:00 +0100)] 
networkctl: install zsh completion from #3062 (#4767)

zsh autocompletion provided by #3062 will be installed when networkd is
enabled.

7 years agoima: Write the policy filename into IMA's sysfs policy file (#4766)
Stefan Berger [Tue, 29 Nov 2016 15:47:20 +0000 (10:47 -0500)] 
ima: Write the policy filename into IMA's sysfs policy file (#4766)

IMA validates file signatures based on the security.ima xattr. As of
Linux-4.7, instead of copying the IMA policy into the securityfs policy,
the IMA policy pathname can be written, allowing the IMA policy file
signature to be validated.

This patch modifies the existing code to first attempt to write the
pathname, but on failure falls back to copying the IMA policy contents.

7 years agosd-id128: add new sd_id128_get_machine_app_specific() API 4686/head
Lennart Poettering [Thu, 17 Nov 2016 16:07:46 +0000 (17:07 +0100)] 
sd-id128: add new sd_id128_get_machine_app_specific() API

This adds an API for retrieving an app-specific machine ID to sd-id128.
Internally it calculates HMAC-SHA256 with an 128bit app-specific ID as payload
and the machine ID as key.

(An alternative would have been to use siphash for this, which is also
cryptographically strong. However, as it only generates 64bit hashes it's not
an obvious choice for generating 128bit IDs.)

Fixes: #4667
7 years agocore: add "khash" API to src/basic/ (as wrapper around kernel AF_ALG)
Lennart Poettering [Thu, 17 Nov 2016 16:03:21 +0000 (17:03 +0100)] 
core: add "khash" API to src/basic/ (as wrapper around kernel AF_ALG)

Let's take inspiration from bluez's ELL library, and let's move our
cryptographic primitives away from libgcrypt and towards the kernel's AF_ALG
cryptographic userspace API.

In the long run we should try to remove the dependency on libgcrypt, in favour
of using only the kernel's own primitives, however this is unlikely to happen
anytime soon, as the kernel does not provide Elliptic Curve APIs to userspace
at this time, and we need them for the DNSSEC cryptographic.

This commit only covers hashing for now, symmetric encryption/decryption or
even asymetric encryption/decryption is not available for now.

"khash" is little more than a lightweight wrapper around the kernel's AF_ALG
socket API.

7 years agoMerge pull request #4763 from keszybz/offline-update-loop
Lennart Poettering [Tue, 29 Nov 2016 13:14:43 +0000 (14:14 +0100)] 
Merge pull request #4763 from keszybz/offline-update-loop

A fix for offline update loop

7 years agoservice: prevent registering control pids as the main pid
Jouke Witteveen [Sat, 26 Nov 2016 09:16:47 +0000 (10:16 +0100)] 
service: prevent registering control pids as the main pid

We assume a process can be only one of the two in service_sigchld_event.

7 years agoservice: only fail notify services on empty cgroup during start
Jouke Witteveen [Thu, 24 Nov 2016 20:05:47 +0000 (21:05 +0100)] 
service: only fail notify services on empty cgroup during start

We stay in the SERVICE_START while no READY=1 notification message has
been received. When we are in the SERVICE_START_POST state, we have
already received a ready notification. Hence we should not fail when the
cgroup becomes empty in that state.

7 years agounits: add system-update-cleanup.service to guard against offline-update loops 4763/head
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 06:29:02 +0000 (01:29 -0500)] 
units: add system-update-cleanup.service to guard against offline-update loops

Note: the name is "system-update-cleanup.service" rather than
"system-update-done.service", because it should not run normally, and also
because there's already "systemd-update-done.service", and having them named
so similarly would be confusing.

In https://bugzilla.redhat.com/show_bug.cgi?id=1395686 the system repeatedly
entered system-update.target on boot. Because of a packaging issue, the tool
that created the /system-update symlink could be installed without the service
unit that was supposed to perform the upgrade (and remove the symlink). In
fact, if there are no units in system-update.target, and /system-update symlink
is created, systemd always "hangs" in system-update.target. This is confusing
for users, because there's no feedback what is happening, and fixing this
requires starting an emergency shell somehow, and also knowing that the symlink
must be removed. We should be more resilient in this case, and remove the
symlink automatically ourselves, if there are no upgrade service to handle it.

This adds a service which is started after system-update.target is reached and
the symlink still exists. It nukes the symlink and reboots the machine. It
should subsequently boot into the default default.target.

This is a more general fix for
https://bugzilla.redhat.com/show_bug.cgi?id=1395686 (the packaging issue was
already fixed).

7 years agoman: update the description of offline updates
Zbigniew Jędrzejewski-Szmek [Tue, 29 Nov 2016 06:19:24 +0000 (01:19 -0500)] 
man: update the description of offline updates

- use "service" instead of "script", because various offline updaters that we have
  aren't really scripts, e.g. dnf-plugin-system-upgrade, packagekit-offline-update,
 fwupd-offline-update.
- strongly recommend After=sysinit.target, Wants=sysinit.target
- clarify a bit what should happen when multiple update services are started
- replace links to the wiki with refs to the man page that replaced it.

7 years agoMerge pull request #4761 from fsateler/python3
Martin Pitt [Mon, 28 Nov 2016 20:10:57 +0000 (21:10 +0100)] 
Merge pull request #4761 from fsateler/python3

Explicitly use python3 everywhere

7 years agonetworkd: move event loop handling out of the manager (#4723)
Tom Gundersen [Mon, 28 Nov 2016 19:42:40 +0000 (20:42 +0100)] 
networkd: move event loop handling out of the manager (#4723)

This will allow us to have several managers sharing an event loop
and running in parallel, as if they were running in separate processes.

The long term-aim is to allow networkd to be split into separate
processes, so restructure the code to make this simpler.

For now we drop the exit-on-idle logic, as this was anyway severely
restricted at the moment. Once split, we will revisit this as it may
then make more sense again.

7 years agoUse python3 explicitly in all python scripts 4761/head
Felipe Sateler [Sun, 21 Aug 2016 23:25:37 +0000 (20:25 -0300)] 
Use python3 explicitly in all python scripts

7 years agobuild-sys: explicitly require python3
Felipe Sateler [Sun, 21 Aug 2016 21:20:05 +0000 (18:20 -0300)] 
build-sys: explicitly require python3

Otherwise python programs might be run with python2