]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
7 years agobpf: reset "extra" IP accounting counters when turning off IP accounting for a unit 8205/head
Lennart Poettering [Wed, 21 Feb 2018 14:22:31 +0000 (15:22 +0100)] 
bpf: reset "extra" IP accounting counters when turning off IP accounting for a unit

We maintain an "extra" set of IP accounting counters that are used when
we systemd is reloaded to carry over the counters from the previous run.
Let's reset these to zero whenever IP accounting is turned off. If we
don't do this then turning off IP accounting and back on later wouldn't
reset the counters, which is quite surprising and different from how our
CPU time counting works.

7 years agobpf: rework how we keep track and attach cgroup bpf programs
Lennart Poettering [Tue, 20 Feb 2018 18:28:24 +0000 (19:28 +0100)] 
bpf: rework how we keep track and attach cgroup bpf programs

So, the kernel's management of cgroup/BPF programs is a bit misdesigned:
if you attach a BPF program to a cgroup and close the fd for it it will
stay pinned to the cgroup with no chance of ever removing it again (or
otherwise getting ahold of it again), because the fd is used for
selecting which BPF program to detach. The only way to get rid of the
program again is to destroy the cgroup itself.

This is particularly bad for root the cgroup (and in fact any other
cgroup that we cannot realistically remove during runtime, such as
/system.slice, /init.scope or /system.slice/dbus.service) as getting rid
of the program only works by rebooting the system.

To counter this let's closely keep track to which cgroup a BPF program
is attached and let's implicitly detach the BPF program when we are
about to close the BPF fd.

This hence changes the bpf_program_cgroup_attach() function to track
where we attached the program and changes bpf_program_cgroup_detach() to
use this information. Moreover bpf_program_unref() will now implicitly
call bpf_program_cgroup_detach().

In order to simplify things, bpf_program_cgroup_attach() will now
implicitly invoke bpf_program_load_kernel() when necessary, simplifying
the caller's side.

Finally, this adds proper reference counting to BPF programs. This
is useful for working with two BPF programs in parallel: the BPF program
we are preparing for installation and the BPF program we so far
installed, shortening the window when we detach the old one and reattach
the new one.

7 years agobpf-program: make bpf_program_load_kernel() idempotent
Lennart Poettering [Tue, 20 Feb 2018 18:19:57 +0000 (19:19 +0100)] 
bpf-program: make bpf_program_load_kernel() idempotent

Let's "seal" off the BPF program as soo as bpf_program_load_kernel() is
called, which allows us to make it idempotent: since the program can't
be modified anymore after being turned into a kernel object it's safe to
shortcut behaviour if called multiple times.

7 years agotest: don't complain if bpffs is world-writable
Lennart Poettering [Fri, 16 Feb 2018 15:45:38 +0000 (16:45 +0100)] 
test: don't complain if bpffs is world-writable

Apparently, world-writable bpffs is intended by the kernel folks, hence
let's make sure we don't choke on it on our tests.

7 years agonamespace: protect bpf file system as part of ProtectKernelTunables=
Lennart Poettering [Fri, 16 Feb 2018 15:24:19 +0000 (16:24 +0100)] 
namespace: protect bpf file system as part of ProtectKernelTunables=

It also exposes kernel objects, let's better include this in
ProtectKernelTunables=.

7 years agomount-setup: always use the same source as fstype for the API VFS we mount
Lennart Poettering [Fri, 16 Feb 2018 14:49:32 +0000 (15:49 +0100)] 
mount-setup: always use the same source as fstype for the API VFS we mount

So far, for all our API VFS mounts we used the fstype also as mount
source, let's do that for the cgroupsv2 mounts too. The kernel doesn't
really care about the source for API VFS, but it's visible to the user,
hence let's clean this up and follow the rule we otherwise follow.

7 years agobpf: use BPF_F_ALLOW_MULTI flag if it is available
Lennart Poettering [Fri, 16 Feb 2018 14:35:49 +0000 (15:35 +0100)] 
bpf: use BPF_F_ALLOW_MULTI flag if it is available

This new kernel 4.15 flag permits that multiple BPF programs can be
executed for each packet processed: multiple per cgroup plus all
programs defined up the tree on all parent cgroups.

We can use this for two features:

1. Finally provide per-slice IP accounting (which was previously
   unavailable)

2. Permit delegation of BPF programs to services (i.e. leaf nodes).

This patch beefs up PID1's handling of BPF to enable both.

Note two special items to keep in mind:

a. Our inner-node BPF programs (i.e. the ones we attach to slices) do
   not enforce IP access lists, that's done exclsuively in the leaf-node
   BPF programs. That's a good thing, since that way rules in leaf nodes
   can cancel out rules further up (i.e. for example to implement a
   logic of "disallow everything except httpd.service"). Inner node BPF
   programs to accounting however if that's requested. This is
   beneficial for performance reasons: it means in order to provide
   per-slice IP accounting we don't have to add up all child unit's
   data.

b. When this code is run on pre-4.15 kernel (i.e. where
   BPF_F_ALLOW_MULTI is not available) we'll make IP acocunting on slice
   units unavailable (i.e. revert to behaviour from before this commit).
   For leaf nodes we'll fallback to non-ALLOW_MULTI mode however, which
   means that BPF delegation is not available there at all, if IP
   fw/acct is turned on for the unit. This is a change from earlier
   behaviour, where we use the BPF_F_ALLOW_OVERRIDE flag, so that our
   fw/acct would lose its effect as soon as delegation was turned on and
   some client made use of that. I think the new behaviour is the safer
   choice in this case, as silent bypassing of our fw rules is not
   possible anymore. And if people want proper delegation then the way
   out is a more modern kernel or turning off IP firewalling/acct for
   the unit algother.

7 years agobpf: mount bpffs by default on boot
Lennart Poettering [Fri, 16 Feb 2018 13:59:26 +0000 (14:59 +0100)] 
bpf: mount bpffs by default on boot

We make heavy use of BPF functionality these days, hence expose the BPF
file system too by default now. (Note however, that we don't actually
make use bpf file systems object yet, but we might later on too.)

7 years agobpf-program: optionally take fd of program to detach
Lennart Poettering [Fri, 16 Feb 2018 13:58:12 +0000 (14:58 +0100)] 
bpf-program: optionally take fd of program to detach

This is useful for BPF_F_ALLOW_MULTI programs, where the kernel requires
us to specify the fd.

7 years agobpf: beef up bpf detection, check if BPF_F_ALLOW_MULTI is supported
Lennart Poettering [Fri, 16 Feb 2018 10:55:33 +0000 (11:55 +0100)] 
bpf: beef up bpf detection, check if BPF_F_ALLOW_MULTI is supported

This improves the BPF/cgroup detection logic, and looks whether
BPF_ALLOW_MULTI is supported. This flag allows execution of multiple
BPF filters in a recursive fashion for a whole cgroup tree. It enables
us to properly report IP accounting for slice units, as well as
delegation of BPF support to units without breaking our own IP
accounting.

7 years agobpf: add new bpf.h header copy from 4.15 kernel
Lennart Poettering [Fri, 16 Feb 2018 10:53:06 +0000 (11:53 +0100)] 
bpf: add new bpf.h header copy from 4.15 kernel

7 years agotest: fix test for TemporaryFileSystem= (#8241)
Yu Watanabe [Wed, 21 Feb 2018 15:43:35 +0000 (00:43 +0900)] 
test: fix test for TemporaryFileSystem= (#8241)

This makes test-execute work on SELinux enabled systems.

Fixes the issue reported at
https://github.com/systemd/systemd/pull/7908#discussion_r169583540

7 years agomissing_syscall: when adding syscall replacements, use different names (#8229)
Zbigniew Jędrzejewski-Szmek [Wed, 21 Feb 2018 13:04:50 +0000 (14:04 +0100)] 
missing_syscall: when adding syscall replacements, use different names (#8229)

In meson.build we check that functions are available using:
    meson.get_compiler('c').has_function('foo')
which checks the following:
- if __stub_foo or __stub___foo are defined, return false
- if foo is declared (a pointer to the function can be taken), return true
- otherwise check for __builtin_memfd_create

_stub is documented by glibc as
   It defines a symbol '__stub_FUNCTION' for each function
   in the C library which is a stub, meaning it will fail
   every time called, usually setting errno to ENOSYS.

So if __stub is defined, we know we don't want to use the glibc version, but
this doesn't tell us if the name itself is defined or not. If it _is_ defined,
and we define our replacement as an inline static function, we get an error:

In file included from ../src/basic/missing.h:1358:0,
                 from ../src/basic/util.h:47,
                 from ../src/basic/calendarspec.h:29,
                 from ../src/basic/calendarspec.c:34:
../src/basic/missing_syscall.h:65:19: error: static declaration of 'memfd_create' follows non-static declaration
 static inline int memfd_create(const char *name, unsigned int flags) {
                   ^~~~~~~~~~~~
.../usr/include/bits/mman-shared.h:46:5: note: previous declaration of 'memfd_create' was here
 int memfd_create (const char *__name, unsigned int __flags) __THROW;
     ^~~~~~~~~~~~

To avoid this problem, call our inline functions different than glibc,
and use a #define to map the official name to our replacement.

Fixes #8099.

v2:
- use "missing_" as the prefix instead of "_"

v3:
- rebase and update for statx()

  Unfortunately "statx" is also present in "struct statx", so the define
  causes issues. Work around this by using a typedef.

I checked that systemd compiles with current glibc
(glibc-devel-2.26-24.fc27.x86_64) if HAVE_MEMFD_CREATE, HAVE_GETTID,
HAVE_PIVOT_ROOT, HAVE_SETNS, HAVE_RENAMEAT2, HAVE_KCMP, HAVE_KEYCTL,
HAVE_COPY_FILE_RANGE, HAVE_BPF, HAVE_STATX are forced to 0.

Setting HAVE_NAME_TO_HANDLE_AT to 0 causes an issue, but it's not because of
the define, but because of struct file_handle.

7 years agoMerge pull request #8235 from keszybz/skip-nobody-test
Evgeny Vereshchagin [Wed, 21 Feb 2018 09:19:02 +0000 (12:19 +0300)] 
Merge pull request #8235 from keszybz/skip-nobody-test

Skip tests for nobody if necessary

7 years agotest-user-util: skip most tests for nobody if synthentization is off 8235/head
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 16:13:41 +0000 (17:13 +0100)] 
test-user-util: skip most tests for nobody if synthentization is off

When synthetisation is turned off, there's just too many ways those tests can
go wrong. We are not interested in verifying that the db on disk is correct,
let's just skip all checks.

In the first version of this patch, I recorded if we detected a mismatch during
configuration and only skipped tests in that case, but actually it is possible
to change the host configuration between our configuration phase and running
of the tests. It's just more robust to skip always. (This is particularly true
if tests are installed.)

7 years agoMerge pull request #7908 from yuwata/rfe-7895
Alan Jenkins [Wed, 21 Feb 2018 08:57:11 +0000 (08:57 +0000)] 
Merge pull request #7908 from yuwata/rfe-7895

core: add TemporaryFileSystem= setting and 'tmpfs' option to ProtectHome=

7 years agotests: stop using `nobody` in test-udev.pl (#8239)
Evgeny Vereshchagin [Wed, 21 Feb 2018 07:34:42 +0000 (10:34 +0300)] 
tests: stop using `nobody` in test-udev.pl (#8239)

`nobody` is a special user, whose credentials should be extracted with
`get_user_creds`. `getpwnam` called in `test-udev.pl` is a bit different,
which causes the test to fail with the following error:
```
device '/devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0/block/sda' expecting node/link 'node'
  expected permissions are: nobody::0600
  created permissions are : 65534:0:0600
permissions: error
add:         ok
remove:      ok
```
The ideal fix would probably be to implement `get_user_creds` in Perl, but in this
PR the issue is simply got around by using `daemon` instead of `nobody`.

Closes https://github.com/systemd/systemd/issues/8196.

7 years agodoc: update TRANSIENT-SETTINGS.md 7908/head
Yu Watanabe [Tue, 13 Feb 2018 11:29:34 +0000 (20:29 +0900)] 
doc: update TRANSIENT-SETTINGS.md

7 years agocore: add DBus API for TemporaryFileSystem=
Yu Watanabe [Tue, 20 Feb 2018 08:57:40 +0000 (17:57 +0900)] 
core: add DBus API for TemporaryFileSystem=

7 years agocore: add new option 'tmpfs' to ProtectHome=
Yu Watanabe [Wed, 21 Feb 2018 00:13:11 +0000 (09:13 +0900)] 
core: add new option 'tmpfs' to ProtectHome=

This make ProtectHome= setting can take 'tmpfs'. This is mostly
equivalent to `TemporaryFileSystem=/home /run/user /root`.

7 years agotest: add tests for TemporaryFileSystem=
Yu Watanabe [Tue, 20 Feb 2018 07:50:12 +0000 (16:50 +0900)] 
test: add tests for TemporaryFileSystem=

7 years agoman: add documents for TemporaryFileSystem=
Yu Watanabe [Wed, 21 Feb 2018 00:10:27 +0000 (09:10 +0900)] 
man: add documents for TemporaryFileSystem=

7 years agocore: add new setting TemporaryFileSystem=
Yu Watanabe [Wed, 21 Feb 2018 00:17:52 +0000 (09:17 +0900)] 
core: add new setting TemporaryFileSystem=

This introduces a new setting TemporaryFileSystem=. This is useful
to hide files not relevant to the processes invoked by unit, while
necessary files or directories can be still accessed by combining
with Bind{,ReadOnly}Paths=.

7 years agocore/namespace: make '-' prefix in Bind{,ReadOnly}Paths= work
Yu Watanabe [Wed, 21 Feb 2018 00:07:56 +0000 (09:07 +0900)] 
core/namespace: make '-' prefix in Bind{,ReadOnly}Paths= work

Each path in `Bind{ReadOnly}Paths=` accept '-' prefix. However,
the prefix is completely ignored.
This makes it work as expected.

7 years agonspawn: remove unnecessary mount option parsing logic
Yu Watanabe [Wed, 14 Feb 2018 05:25:22 +0000 (14:25 +0900)] 
nspawn: remove unnecessary mount option parsing logic

7 years agomount-util: call mount_option_mangle() in mount_verbose()
Yu Watanabe [Thu, 15 Feb 2018 00:43:02 +0000 (09:43 +0900)] 
mount-util: call mount_option_mangle() in mount_verbose()

7 years agotest: add tests for mount_option_mangle()
Yu Watanabe [Thu, 15 Feb 2018 00:36:18 +0000 (09:36 +0900)] 
test: add tests for mount_option_mangle()

7 years agomount-util: add mount_option_mangle()
Yu Watanabe [Thu, 15 Feb 2018 00:32:04 +0000 (09:32 +0900)] 
mount-util: add mount_option_mangle()

This is used in the later commits.

7 years agocore: simplify DBus API for BindPaths=
Yu Watanabe [Wed, 21 Feb 2018 00:06:32 +0000 (09:06 +0900)] 
core: simplify DBus API for BindPaths=

7 years agocore: fix DBus API for AppArmorProfile= and SmackProcessLabel=
Yu Watanabe [Tue, 13 Feb 2018 05:16:35 +0000 (14:16 +0900)] 
core: fix DBus API for AppArmorProfile= and SmackProcessLabel=

7 years agocore/execute: clear bind_mounts
Yu Watanabe [Tue, 13 Feb 2018 05:22:23 +0000 (14:22 +0900)] 
core/execute: clear bind_mounts

7 years agocore/execute: simplify compile_bind_mounts()
Yu Watanabe [Mon, 12 Feb 2018 07:16:58 +0000 (16:16 +0900)] 
core/execute: simplify compile_bind_mounts()

It is not necessary to re-assign error code.

7 years agonspawn: fix indentation
Yu Watanabe [Mon, 12 Feb 2018 08:23:35 +0000 (17:23 +0900)] 
nspawn: fix indentation

7 years agocore/namespace: remove unused argument
Yu Watanabe [Tue, 13 Feb 2018 05:21:13 +0000 (14:21 +0900)] 
core/namespace: remove unused argument

7 years agocore/namespace: use free_and_replace()
Yu Watanabe [Mon, 12 Feb 2018 05:27:49 +0000 (14:27 +0900)] 
core/namespace: use free_and_replace()

7 years agocore/namespace: fix comment
Yu Watanabe [Wed, 14 Feb 2018 04:29:13 +0000 (13:29 +0900)] 
core/namespace: fix comment

7 years agocore/namespace: merge PRIVATE_VAR_TMP into PRIVATE_TMP
Yu Watanabe [Mon, 19 Feb 2018 06:19:41 +0000 (15:19 +0900)] 
core/namespace: merge PRIVATE_VAR_TMP into PRIVATE_TMP

7 years agocore/namespace: make arguments const if possible
Yu Watanabe [Sat, 10 Feb 2018 10:24:57 +0000 (19:24 +0900)] 
core/namespace: make arguments const if possible

7 years agojournalctl: improve hint about lack of access for --user-unit=...
Zbigniew JÄ\99drzejewski-Szmek [Mon, 19 Feb 2018 21:40:26 +0000 (22:40 +0100)] 
journalctl: improve hint about lack of access for --user-unit=...

When running journalctl --user-unit=foo as an unprivileged user we could get
the usual hint:
Hint: You are currently not seeing messages from the system and other users.
      Users in groups 'adm', 'systemd-journal', 'wheel' can see all messages.
      ...
But with --user-unit our filter is:
(((_UID=0 OR _UID=1000) AND OBJECT_SYSTEMD_USER_UNIT=foo.service) OR
 ((_UID=0 OR _UID=1000) AND COREDUMP_USER_UNIT=foo.service) OR
 (_UID=1000 AND USER_UNIT=foo.service) OR
 (_UID=1000 AND _SYSTEMD_USER_UNIT=foo.service))
so we would never see messages from other users.

We could still see messages from the system. In fact, on my machine the
only messages with OBJECT_SYSTEMD_USER_UNIT= are from the system:
journalctl  $(journalctl -F OBJECT_SYSTEMD_USER_UNIT|sed 's/.*/OBJECT_SYSTEMD_USER_UNIT=\0/')

Thus, a more correct hint is that we cannot see messages from the system.
Make it so.

Fixes #7887.

7 years agotest-user-util: print function delimiters
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 21:10:45 +0000 (22:10 +0100)] 
test-user-util: print function delimiters

This makes it easier to see what is going on. Crashes may happen in a
nested test_{uid,gid}_to_name_one() function, and the default backtrace
doesn't show the actual string being tested.

7 years agoMerge pull request #8222 from poettering/journal-by-inode
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 20:36:25 +0000 (21:36 +0100)] 
Merge pull request #8222 from poettering/journal-by-inode

make sure we detect journal rotation even on inotify q overrun

7 years agoTODO: drop one item
Zbigniew Jędrzejewski-Szmek [Tue, 20 Feb 2018 13:53:09 +0000 (14:53 +0100)] 
TODO: drop one item

C.f. 7cb609115c532c3591d43a604d67d72e508ba5d9.

7 years agoxattr-util: use crtime/btime if statx() is available for implementation of fd_setcrti... 8222/head
Lennart Poettering [Tue, 20 Feb 2018 11:48:33 +0000 (12:48 +0100)] 
xattr-util: use crtime/btime if statx() is available for implementation of fd_setcrtime() and friends

The Linux kernel exposes the birth time now for files through statx()
hence make use of it where available. We keep the xattr logic in place
for this however, since only a subset of file systems on Linux currently
expose the birth time. NFS and tmpfs for example do not support it. OTOH
there are other file systems that do support the birth time but might
not support xattrs (smb…), hence make the best of the two, in particular
in order to deal with journal files copied between file system types and
to maintain compatibility with older file systems that are updated to
newer version of the file system.

7 years agoxattr-util: support AT_EMPTY_PATH in fgetxattrat_fake()
Lennart Poettering [Tue, 20 Feb 2018 11:46:14 +0000 (12:46 +0100)] 
xattr-util: support AT_EMPTY_PATH in fgetxattrat_fake()

Let's expose fstatat() like behaviour if AT_EMPTY_PATH is defined.

Also, check the specified flags returning EINVAL on the flags we don't
emulate.

7 years agojournal-file: fix typo in log message
Lennart Poettering [Tue, 20 Feb 2018 10:40:07 +0000 (11:40 +0100)] 
journal-file: fix typo in log message

7 years agoio-util: add an unlikely decorator for a test that should never hold
Lennart Poettering [Mon, 19 Feb 2018 17:37:50 +0000 (18:37 +0100)] 
io-util: add an unlikely decorator for a test that should never hold

7 years agotree-wide: make use of fsync_directory_of_file() all over the place
Lennart Poettering [Mon, 19 Feb 2018 17:24:36 +0000 (18:24 +0100)] 
tree-wide: make use of fsync_directory_of_file() all over the place

Let's make use this at various places we call fsync(), to make things
fully reliable, as the kernel devs suggest to first fsync() files and
then fsync() the directories they are located in.

7 years agofs-util: move fsync_directory_of_file() into generic code
Lennart Poettering [Mon, 19 Feb 2018 17:23:38 +0000 (18:23 +0100)] 
fs-util: move fsync_directory_of_file() into generic code

This function used by the journal code is pretty useful generically,
let's move it to fs-util.c to make it useful for other code too.

7 years agostat-util: unify code that checks whether something is a regular file
Lennart Poettering [Mon, 19 Feb 2018 17:01:05 +0000 (18:01 +0100)] 
stat-util: unify code that checks whether something is a regular file

Let's add a common implementation for regular file checks, that are
careful to return the right error code (EISDIR/EISLNK/EBADFD) when we
are encountering a wrong file node.

7 years agosd-journal: when picking up a new file, compare inode/device info with previous open...
Lennart Poettering [Mon, 19 Feb 2018 16:42:47 +0000 (17:42 +0100)] 
sd-journal: when picking up a new file, compare inode/device info with previous open file by same name

Let's make sure we aren't confused if a journal file is replaced by a
different one (for example due to rotation) if we are in a q overflow:
let's compare the inode/device information, and if it changed replace
any open file object as needed.

Fixes: #8198
7 years agosd-journal: rename add_file() → add_file_by_name()
Lennart Poettering [Mon, 19 Feb 2018 16:40:01 +0000 (17:40 +0100)] 
sd-journal: rename add_file() → add_file_by_name()

Let's be more careful with the naming, and indicate that the function
is about *named* journal files, and will validate the name as needed.
(in opposition to add_any_file() which doesn't care about names)

7 years agojournal-file: add O_NONBLOCK for paranoia when opening journal files
Lennart Poettering [Mon, 19 Feb 2018 16:37:47 +0000 (17:37 +0100)] 
journal-file: add O_NONBLOCK for paranoia when opening journal files

7 years agojournal-file: refuse opening non-regular journal files
Lennart Poettering [Mon, 19 Feb 2018 16:35:36 +0000 (17:35 +0100)] 
journal-file: refuse opening non-regular journal files

Let's check the file node type when we open/stat journal files: refuse
anything that is not a regular file...

7 years agocore: change KeyringMode= to "shared" by default for non-service units in the system...
Lennart Poettering [Tue, 20 Feb 2018 07:53:34 +0000 (08:53 +0100)] 
core: change KeyringMode= to "shared" by default for non-service units in the system manager (#8172)

Before this change all unit types would default to "private" in the
system service manager and "inherit" to in the user service manager.

With this change this is slightly altered: non-service units of the
system service manager are now run with KeyringMode=shared. This appears
to be the more appropriate choice as isolation is not as desirable for
mount tools, which regularly consume key material. After all mounts are
a shared resource themselves as they appear system-wide hence it makes a
lot of sense to share their key material too.

Fixes: #8159
7 years agohwdb: add axis override for Dell Inspiron MM061 touchpad (#8226)
Peter Hutterer [Tue, 20 Feb 2018 07:27:48 +0000 (17:27 +1000)] 
hwdb: add axis override for Dell Inspiron MM061 touchpad (#8226)

https://bugzilla.redhat.com/show_bug.cgi?id=1545389

7 years agomeson: Multi-lines string should use ''' with meson (#8225)
Alexis Jeandet [Tue, 20 Feb 2018 01:36:41 +0000 (02:36 +0100)] 
meson: Multi-lines string should use ''' with meson (#8225)

This breaks with latest version of meson:
https://hephaistos.lpp.polytechnique.fr/teamcity/viewLog.html?buildId=11653&buildTypeId=mesonbuild_SystemdNightly&tab=buildLog&state=1059#_state=1059&guest=true

7 years agoMerge pull request #8223 from jwrdegoede/hwdb-keyboard-touchpad-toggle
Yu Watanabe [Tue, 20 Feb 2018 01:34:53 +0000 (10:34 +0900)] 
Merge pull request #8223 from jwrdegoede/hwdb-keyboard-touchpad-toggle

hwdb: 60-keyboard add mapping for the touchpad-toggle hotkey on 2 laptops

7 years agohwdb: Logitech M305 Wireless Optical Mouse dpi data (#8217)
Daniel Mouritzen [Tue, 20 Feb 2018 01:33:10 +0000 (02:33 +0100)] 
hwdb: Logitech M305 Wireless Optical Mouse dpi data (#8217)

Closes #8208

7 years agohwdb: Add quirk to fix mapping of T-bao Tbook air touchpad toggle key 8223/head
Hans de Goede [Mon, 19 Feb 2018 17:24:09 +0000 (18:24 +0100)] 
hwdb: Add quirk to fix mapping of T-bao Tbook air touchpad toggle key

The touchpad toggle key (Fn + Esc) on the T-bao Tbook air sends CTRL +
META + scancode 0x76 without this quirk. With this quirk it sends CTRL +
META + F21, with F21 mapping to XF86TouchpadToggle, which is what we want.

Note that the CTRL + META modifiers being send together with the F21 are
still somewhat unusual, userspace will need to be thought to deal with
this as there is nothing we can do about this at the hwdb level. Note at
least one other laptop also sends CTRL + META + F21 instead of just F21.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
7 years agohwdb: Add quirk to fix mapping of VIOS LTH17 touchpad toggle key
Hans de Goede [Mon, 19 Feb 2018 17:11:30 +0000 (18:11 +0100)] 
hwdb: Add quirk to fix mapping of VIOS LTH17 touchpad toggle key

The touchpad toggle key (Fn + F6) on the VIOS LTH17 sends CTRL + META + F24
without this quirk. With this quirk it sends CTRL + META + F21, with F21
mapping to XF86TouchpadToggle, which is what we want.

Note that the CTRL + META modifiers being send together with the F21 are
still somewhat unusual, userspace will need to be thought to deal with
this as there is nothing we can do about this at the hwdb level. Note at
least one other laptop also sends CTRL + META + F21 instead of just F21.

7 years agoMerge pull request #8199 from keszybz/small-things
Lennart Poettering [Mon, 19 Feb 2018 15:55:10 +0000 (16:55 +0100)] 
Merge pull request #8199 from keszybz/small-things

Sundry small cleanups

7 years agotests: add a simple test for utf8_n_codepoints() 8199/head
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 09:34:00 +0000 (10:34 +0100)] 
tests: add a simple test for utf8_n_codepoints()

7 years agoSome comment adjustments
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 09:27:47 +0000 (10:27 +0100)] 
Some comment adjustments

Follow up for review of #8184.

7 years agocore: drop obsolete comment
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 09:23:16 +0000 (10:23 +0100)] 
core: drop obsolete comment

https://github.com/systemd/systemd/pull/8125#pullrequestreview-96894581

7 years agopid1: do not initialize join_controllers by default
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 09:17:46 +0000 (10:17 +0100)] 
pid1: do not initialize join_controllers by default

We're moving towards unified cgroup hierarchy where this is not necessary.
This makes main.c a bit simpler.

7 years agoMove config_parse_join_controllers to shared, add test
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 08:56:29 +0000 (09:56 +0100)] 
Move config_parse_join_controllers to shared, add test

config_parse_join_controllers would free the destination argument on failure,
which is contrary to our normal style, where failed parsing has no effect.
Moving it to shared also allows a test to be added.

7 years agoshared/conf-parser: define a macro for the repeating argument set
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 08:29:57 +0000 (09:29 +0100)] 
shared/conf-parser: define a macro for the repeating argument set

The arguments have to be indentical everywhere, so let's use a macro to
make things more readable. But only in the headers, in the .c files let's
keep them verbose so that it's easy to see the argument list.

7 years agotest-process-util: one more (void)
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 06:03:13 +0000 (07:03 +0100)] 
test-process-util: one more (void)

7 years agoAdd some handling to remaining unlinkat calls
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 06:00:22 +0000 (07:00 +0100)] 
Add some handling to remaining unlinkat calls

Coverity now started warning about this ("Calling unlinkat without checking
return value (as is done elsewhere 12 out of 15 times).", and it is right:
most of the time we should at list print a log message so people can figure
out something is wrong when this happens.

v2:
- use warning level in journald too (this is unlikely to happen ever, so it
  should be safe to something that is visible by default).

7 years agobootspec: accept tab as the separataor in sd-boot config (#8165)
Yu Watanabe [Mon, 19 Feb 2018 13:26:01 +0000 (22:26 +0900)] 
bootspec: accept tab as the separataor in sd-boot config (#8165)

In the parse logic `line_get_key_value()` in sd-boot treats spaces
and tabs are valid spacing between key and value in the line.
So, let's use the same logic for `bootctl` and the others which read
sd-boot configs.

Fixes #8154.

7 years agomeson: apply defaults if /etc/login.defs doesn't exist
Caio Marcelo de Oliveira Filho [Mon, 19 Feb 2018 02:33:16 +0000 (18:33 -0800)] 
meson: apply defaults if /etc/login.defs doesn't exist

Apply defaults for system_{uid,gid}_max even if the /etc/login.defs file
doesn't exist (e.g. in Clear Linux with no changes).

awk returns an empty string in case the file doesn't exist, causing meson to
fail in to_int(). So set the default if output is empty. This makes the BEGIN{}
blocks unnecessary, so remove them.

7 years agojob: truncate unit description
Iago López Galeiras [Fri, 16 Feb 2018 13:32:44 +0000 (14:32 +0100)] 
job: truncate unit description

The comment above says we're truncating the string but that's not true,
an assert will fail in xsprintf if the description is longer than
LINE_MAX.

Let's use snprintf instead of xsprintf to make sure it's truncated.
We'll cast its result to void to tell static checkers we're fine with
truncation.

7 years agopo: update Serbian translation
Марко М. Костић (Marko M. Kostić) [Sun, 18 Feb 2018 21:04:22 +0000 (22:04 +0100)] 
po: update Serbian translation

7 years agomeson: use multiline string syntax (#8214)
Caio Marcelo de Oliveira Filho [Mon, 19 Feb 2018 09:37:19 +0000 (01:37 -0800)] 
meson: use multiline string syntax (#8214)

The single quote working with multiple lines is likely to be unintended. With
current versions of meson, it also causes error messages after it to report the
wrong line number. Use the documented syntax instead.

7 years agoMerge pull request #8202 from keszybz/avoid-msgmerge
Michael Biebl [Sun, 18 Feb 2018 18:56:50 +0000 (19:56 +0100)] 
Merge pull request #8202 from keszybz/avoid-msgmerge

Replace msgmerge use by gettext-domain= references

7 years agomeson: fix systemd-pot target when polkit-devel is not installed 8202/head
Zbigniew Jędrzejewski-Szmek [Sun, 18 Feb 2018 16:39:08 +0000 (17:39 +0100)] 
meson: fix systemd-pot target when polkit-devel is not installed

To successfully extract strings from our .policy files, gettext needs
polkit.{its,loc} files provided by policykit-devel. When that package is not
installed, systemd-pot would fail to extract strings:

[0/1] Running external command systemd-pot.
xgettext: warning: file 'src/core/org.freedesktop.systemd1.policy.in.in' extension 'policy' is unknown; will try C
xgettext: warning: file 'src/hostname/org.freedesktop.hostname1.policy.in' extension 'policy' is unknown; will try C
...

We now don't need the .its and .loc files for normal building, but they are
still useful when generating the .pot file, because that way we avoid the
dependency on sufficiently new polkit. We just need to tell i18n to pass their
location to xgettext.

7 years agol10n: Update POTFILES.in and POTFILES.skip
Michael Biebl [Fri, 16 Feb 2018 13:25:32 +0000 (14:25 +0100)] 
l10n: Update POTFILES.in and POTFILES.skip

We no longer use .in suffixes for .policy files.

Follow-up for commit 9b3cff199dd3827a9f2df9a7f5874d6ef18880f2 and
70886abbde59a45cfabe0769c0cdb3af1e5f7790.

7 years agotests: reset _found at the end of each iteration (#8195)
Evgeny Vereshchagin [Fri, 16 Feb 2018 13:26:26 +0000 (16:26 +0300)] 
tests: reset _found at the end of each iteration (#8195)

This makes `inst_rules` really print all rules it skips.

7 years agomkosi: remove intltool from deps
Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 20:38:15 +0000 (21:38 +0100)] 
mkosi: remove intltool from deps

intltool is unnecessary since c81217920effddc93fb780cf8f9eb699d6fe1319.
But we still need gettext, because we use msgformat to generate .mo files.
(I tried to make meson depend on it, at least in Fedora:
 https://bugzilla.redhat.com/show_bug.cgi?id=1545926, but that didn't fly,
 and in Debian at least meson also has no dependency on the tools used by
 its i18n module, so we need to add our own dependency anyway.)

Closes #8192.

7 years agomeson: drop unnecessary "transformation" of policy files
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 11:48:55 +0000 (12:48 +0100)] 
meson: drop unnecessary "transformation" of policy files

Those files don't contain any @variables@, so the configuration step was just
copying them to build/. Let's avoid that, and fix their suffixes while at it.

7 years agomeson: drop double .in suffix for o.fd.systemd1.policy file
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 11:37:42 +0000 (12:37 +0100)] 
meson: drop double .in suffix for o.fd.systemd1.policy file

This file is now undergoing just one transformation, so drop the unnecessary
suffix.

7 years agoGettextize policy files
Gunnar Hjalmarsson [Thu, 15 Feb 2018 20:21:58 +0000 (21:21 +0100)] 
Gettextize policy files

* Don't merge translations into the files
* Add gettext-domain="systemd" to description and message

Closes #8162, replaces #8118.

7 years agologin,user-sessions: always warn when we fail to remove nologin file
Zbigniew Jędrzejewski-Szmek [Fri, 16 Feb 2018 05:58:33 +0000 (06:58 +0100)] 
login,user-sessions: always warn when we fail to remove nologin file

This usually is very annoying to users who then cannot log in, so
make sure we always warn if that happens (selinux, or whatever other reason).

This reverts a790812cb349c5cef95d1b4a20fc80ca08d3a145.

7 years agotest/test-functions: Debian/Ubuntu, now ship 95-dm-notify.rules, copy it
Dimitri John Ledkov [Wed, 14 Feb 2018 20:34:55 +0000 (20:34 +0000)] 
test/test-functions: Debian/Ubuntu, now ship 95-dm-notify.rules, copy it

This fixes cryptsetup tests on recent Ubuntu/Debian systems (current
development series).

Bug-Launchpad: https://launchpad.net/bugs/1749432

7 years agoMerge pull request #8175 from keszybz/gc-cleanup
Lennart Poettering [Thu, 15 Feb 2018 16:47:37 +0000 (17:47 +0100)] 
Merge pull request #8175 from keszybz/gc-cleanup

Garbage collection cleanup

7 years agoMerge pull request #8188 from keszybz/coverity-fixes
Lennart Poettering [Thu, 15 Feb 2018 16:23:03 +0000 (17:23 +0100)] 
Merge pull request #8188 from keszybz/coverity-fixes

Coverity fixes

7 years agoMerge pull request #8150 from poettering/memory-accounting-by-default
Lennart Poettering [Thu, 15 Feb 2018 16:22:36 +0000 (17:22 +0100)] 
Merge pull request #8150 from poettering/memory-accounting-by-default

pid1: turn memory accounting on by default now

7 years agoMerge pull request #8184 from poettering/color-ask-pw
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.

7 years agoMerge pull request #8125 from poettering/cgroups-migrate
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.

7 years agomachined: change check_gc to may_gc everywhere 8175/head
Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 12:15:45 +0000 (13:15 +0100)] 
machined: change check_gc to may_gc everywhere

7 years agologind: change check_gc to may_gc everywhere
Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 12:14:35 +0000 (13:14 +0100)] 
logind: change check_gc to may_gc everywhere

7 years agopid1: also show gc status for jobs like we do for units
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 23:52:21 +0000 (00:52 +0100)] 
pid1: also show gc status for jobs like we do for units

7 years agopid1: rename job_check_gc to job_may_gc
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 23:39:06 +0000 (00:39 +0100)] 
pid1: rename job_check_gc to job_may_gc

The reasoning is the same as for unit_can_gc.

v2:
- rename can_gc to may_gc

7 years agopid1: properly remove references to the unit from gc queue during final cleanup
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 22:57:43 +0000 (23:57 +0100)] 
pid1: properly remove references to the unit from gc queue during final cleanup

When various references to the unit were dropped during cleanup in unit_free(),
add_to_gc_queue() could be called on this unit. If the unit was previously in
the gc queue (at the time when unit_free() was called on it), this wouldn't
matter, because it'd have in_gc_queue still set even though it was already
removed from the queue. But if it wasn't set, then the unit could be added to
the queue. Then after unit_free() would deallocate the unit, we would be left
with a dangling pointer in gc_queue.

A unit could be added to the gc queue in two places called from unit_free():
in the job_install calls, and in unit_ref_unset(). The first was OK, because
it was above the LIST_REMOVE(gc_queue,...) call, but the second was not, because
it was after that. Move the all LIST_REMOVE() calls down.

7 years agopid1: free basic unit information at the very end, before freeing the unit
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 23:01:05 +0000 (00:01 +0100)] 
pid1: free basic unit information at the very end, before freeing the unit

We would free stuff like the names of the unit first, and then recurse
into other structures to remove the unit from there. Technically this
was OK, since the code did not access the name, but this makes debugging
harder. And if any log messages are added in any of those functions, they
are likely to access u->id and such other basic information about the unit.
So let's move the removal of this "basic" information towards the end
of unit_free().

7 years agopid1: fix collection of cycles of units which reference one another
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 13:37:11 +0000 (14:37 +0100)] 
pid1: fix collection of cycles of units which reference one another

A .socket will reference a .service unit, by registering a UnitRef with the
.service unit. If this .service unit has the .socket unit listed in Wants or
Sockets or such, a cycle will be created. We would not free this cycle
properly, because we treated any unit with non-empty refs as uncollectable. To
solve this issue, treats refs with UnitRef in u->refs_by_target similarly to
the refs in u->dependencies, and check if the "other" unit is known to be
needed. If it is not needed, do not treat the reference from it as preventing
the unit we are looking at from being freed.

7 years agopid1: include the source unit in UnitRef
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 12:12:43 +0000 (13:12 +0100)] 
pid1: include the source unit in UnitRef

No functional change.

The source unit manages the reference. It allocates the UnitRef structure and
registers it in the target unit, and then the reference must be destroyed
before the source unit is destroyed. Thus, is should be OK to include the
pointer to the source unit, it should be live as long as the reference exists.

v2:
- rename refs to refs_by_target

7 years agopid1: rename unit_check_gc to unit_may_gc
Zbigniew Jędrzejewski-Szmek [Tue, 13 Feb 2018 09:50:13 +0000 (10:50 +0100)] 
pid1: rename unit_check_gc to unit_may_gc

"check" is unclear: what is true, what is false? Let's rename to "can_gc" and
revert the return value ("positive" values are easier to grok).

v2:
- rename from unit_can_gc to unit_may_gc

7 years agocoredump: accept hostname on command line (#8033)
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!

7 years agomeson: add -Dmemory-accounting-default=true|false 8150/head
Zbigniew Jędrzejewski-Szmek [Thu, 15 Feb 2018 10:43:08 +0000 (11:43 +0100)] 
meson: add -Dmemory-accounting-default=true|false

This makes it easy to set the default for distributions and users which want to
default to off because they primarily use older kernels.