]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
6 years agorules: add a missing comma in 70-uaccess.rules since it improves readability
Franck Bui [Fri, 23 Feb 2018 15:49:17 +0000 (16:49 +0100)] 
rules: add a missing comma in 70-uaccess.rules since it improves readability

rule-syntax-check.py failed with the following error:

$ ./test/rule-syntax-check.py ./src/login/70-uaccess.rules
Invalid line ./src/login/70-uaccess.rules:31: SUBSYSTEM=="sound", TAG+="uaccess"   OPTIONS+="static_node=snd/timer", OPTIONS+="static_node=snd/seq"
  clause: TAG+="uaccess"   OPTIONS+="static_node=snd/timer"

The comma is actually optional but the script makes it mandatory which seems a
good thing since it improves readability.

6 years agoMerge pull request #8252 from keszybz/set-property-man
Lennart Poettering [Fri, 23 Feb 2018 11:20:38 +0000 (12:20 +0100)] 
Merge pull request #8252 from keszybz/set-property-man

set-property man-page adjust-ments

6 years agoudev: don't assign INPUT_ID_MOUSE to a touchpad/joystick/touchscreen (#8259)
Peter Hutterer [Fri, 23 Feb 2018 08:36:45 +0000 (18:36 +1000)] 
udev: don't assign INPUT_ID_MOUSE to a touchpad/joystick/touchscreen (#8259)

If a touchpad has MT axes only but not ABS_X/ABS_Y (DualShock 4 controller),
then we hit both the conditions is_touchpad and the later check for
!has_abs_axes here, assigning is_mouse and ID_INPUT_MOUSE later.

This is a bug, we historically only assigned either of of the pointing device
tags ID_INPUT_MOUSE/TOUCHPAD/JOYSTICK/TOUCHSCREEN, never multiple of them.

Note that we cannot just check for has_abs_axes and has_mt_coordinates because
the apple touch mouse has both. We really need to check if the device has
already been assigned something else.

https://bugs.freedesktop.org/show_bug.cgi?id=105050

6 years agoAdd missing double quote from log message (#8257)
antizealot1337 [Thu, 22 Feb 2018 23:18:29 +0000 (18:18 -0500)] 
Add missing double quote from log message (#8257)

6 years agologin: fix user@.service case, so we don't allow nested sessions (#8051)
Alan Jenkins [Thu, 22 Feb 2018 20:38:44 +0000 (20:38 +0000)] 
login: fix user@.service case, so we don't allow nested sessions (#8051)

> logind sessions are mostly bound to the audit session concept, and audit
> sessions remain unaffected by "su", in fact they are defined to be
> "sealed off", i.e. in a way that if a process entered a session once, it
> will always stay with it, and so will its children, i.e. the only way to
> get a new session is by forking off something off PID 1 (or something
> similar) that never has been part of a session.

The code had a gap.  user@.service is a special case PAM session which does
not create a logind session.  Let's remember to check for it.

Fixes #8021

6 years agoFix format-truncation compile failure by typecasting USB IDs (#8250)
Patrick Uiterwijk [Thu, 22 Feb 2018 18:41:30 +0000 (19:41 +0100)] 
Fix format-truncation compile failure by typecasting USB IDs (#8250)

This patch adds safe_atoux16 for parsing an unsigned hexadecimal 16bit int, and
uses that for parsing USB device and vendor IDs.

This fixes a compile error with gcc-8 because while we know that USB IDs are 2 bytes,
the compiler does not know that.

../src/udev/udev-builtin-hwdb.c:80:38: error: '%04X' directive output may be
truncated writing between 4 and 8 bytes into a region of size between 2 and 6
[-Werror=format-truncation=]

Signed-off-by: Adam Williamson <awilliam@redhat.com>
Signed-off-by: Patrick Uiterwijk <puiterwijk@redhat.com>
6 years agolibsystemd-network: fix endianness in ARP BPF filter (#8255)
Beniamino Galvani [Thu, 22 Feb 2018 17:09:33 +0000 (18:09 +0100)] 
libsystemd-network: fix endianness in ARP BPF filter (#8255)

Commit f11cba7479fe ("libsystemd-network: fix unaligned loads (issue #7654)")
changed the way in which the MAC address is read to use native endiannes:

 htobe32(*((uint32_t *)x)  ->  unaligned_read_ne32(x)

This is wrong because loads done with BPF_LD + BPF_ABS are big-endian, as it
can be seen for the ethertype and arp-operation loads above in the
filter.  Also, the same commit changed:

 htobe32(*((unsigned int *)x) -> unaligned_read_be32(x)

in _bind_raw_socket(), which is the correct form.

The commit broke IPv4LL in presence of loops, as the sender now considers its
own packets as conflicting.

Fixes: f11cba7479fe29a9dab9e3151bbca4302d173811
6 years agoMerge pull request #8251 from Shuangistan/pr_virt_qnx
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 16:06:29 +0000 (17:06 +0100)] 
Merge pull request #8251 from Shuangistan/pr_virt_qnx

6 years agoman: add bhyve description for ConditionVirtualization= 8251/head
Shuang Liu [Thu, 22 Feb 2018 13:46:48 +0000 (14:46 +0100)] 
man: add bhyve description for ConditionVirtualization=
The description in man is missing in #3840.

6 years agovirt: detect QNX hypervisor
Shuang Liu [Thu, 22 Feb 2018 13:35:47 +0000 (14:35 +0100)] 
virt: detect QNX hypervisor
Detect QNX hypervisor based on the CPUID.

Fixes: #7239
6 years agosystemctl: use VARIABLE as the placeholder for a variable name 8252/head
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 13:39:06 +0000 (14:39 +0100)] 
systemctl: use VARIABLE as the placeholder for a variable name

The man page was already using VARIABLE=VALUE, so no change there.

6 years agosystemctl,man: use PROPERTY as the placeholder for a property name
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 13:37:02 +0000 (14:37 +0100)] 
systemctl,man: use PROPERTY as the placeholder for a property name

6 years agosystemctl,man: use UNIT as the placeholder for a unit name
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 11:58:53 +0000 (12:58 +0100)] 
systemctl,man: use UNIT as the placeholder for a unit name

NAME is kind of meaningless, because everything has a name. "Unit"
makes it more obvious that a name of a unit is necessary. I was always
momentarily baffled by "set-property NAME ASSIGNMENT...", where there
are two objects (the unit and the property), and it's not clear which of
the two "NAME" is supposed to signify.

6 years agoman: IPAccounting for slices in now allowed
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 11:53:15 +0000 (12:53 +0100)] 
man: IPAccounting for slices in now allowed

Also split that description into paragraphs by subject.

6 years agoMerge pull request #8205 from poettering/bpf-multi
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 13:52:48 +0000 (14:52 +0100)] 
Merge pull request #8205 from poettering/bpf-multi

bpf/cgroup improvements

6 years agoUpdate Russian translation (#8248)
Sergey Ptashnick [Thu, 22 Feb 2018 13:25:11 +0000 (16:25 +0300)] 
Update Russian translation (#8248)

Used "in"-form here (i.e. "зарегистрировать службу *в* DNS-SD") because
simply "служба DNS-SD" may be confused with resolved itself (at least in
Russian).

6 years agonologin: extend the /run/nologin descriptions a bit (#8244)
Lennart Poettering [Thu, 22 Feb 2018 13:21:30 +0000 (14:21 +0100)] 
nologin: extend the /run/nologin descriptions a bit (#8244)

This is an attempt to improve #8228 a bit, by extending the /run/nologin
a bit, but still keeping it somewhat brief.

On purpose I used the vague wording "unprivileged user" rather than
"non-root user" so that pam_nologin can be updated to disable its
behaviour for members of the "wheel" group one day, and our messages
would still make sense.

See #8228.

6 years agoMerge pull request #8243 from poettering/statx-syscall-unfuck
Lennart Poettering [Thu, 22 Feb 2018 12:15:41 +0000 (13:15 +0100)] 
Merge pull request #8243 from poettering/statx-syscall-unfuck

statx() syscall macro fix + reboot() handling improvements

6 years agoMerge pull request #8218 from keszybz/zanata
Lennart Poettering [Thu, 22 Feb 2018 10:56:24 +0000 (11:56 +0100)] 
Merge pull request #8218 from keszybz/zanata

po: add basic fedora.zanata.org configuration

6 years agopid1: when creating service directories, don't chown existing files (#8181)
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 10:30:59 +0000 (11:30 +0100)] 
pid1: when creating service directories, don't chown existing files (#8181)

This partially reverts 3536f49e8fa281539798a7bc5004d73302f39673 and
3536f49e8fa281539798a7bc5004d73302f39673.

When the user is dynamic, and we are setting up state, cache, or logs dirs,
behaviour is unchanged, we always do a recursive chown. This is necessary
because the user number might change between invocations.

But when setting up a directory for non-dynamic user, or a runtime directory
for a dynamic user, do any ownership or mode changes only when the directory
is initially created. Nothing says that the files under those directories have
to be all recursively owned by our user. This restores behaviour before
3536f49e8fa281539798a7bc5004d73302f39673, so modifications to the state of
the runtime directory persist between ExecStartPre's and ExecStart's, and even
longer in case the directory is persistent.

I think it _would_ be a nice property if setting a user would automatically
propagate to ownership of any Runtime/Logs/Cache directories. But this is
incompatible with another nice property, namely preserving changes to those
directories made by an admin, and with allowing change of ownership of files
in those directories by the service (e.g. to allow other users to access them).
Of the two, I think the second property is more important. Also, it's backwards
compatible.

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

There is no need to chmod a directory we just created, so move that step
up into a branch. After that, 'effective' is only used once, so get rid of
it too.

6 years agoshutdown: let's not use exit() needlessly 8243/head
Lennart Poettering [Wed, 21 Feb 2018 17:50:34 +0000 (18:50 +0100)] 
shutdown: let's not use exit() needlessly

Generally we prefer 'return' from main() over exit() so that automatic
cleanups and such work correct. Let's do that in shutdown.c too, becuase
there's not really any reason not to.

With this we are pretty good in consistently using return from main()
rather than exit() all across the codebase. Yay!

6 years agoreboot-util: unify reboot with parameter in a single implementation
Lennart Poettering [Wed, 21 Feb 2018 17:48:49 +0000 (18:48 +0100)] 
reboot-util: unify reboot with parameter in a single implementation

So far, we had two implementations of reboot-with-parameter doing pretty
much the same. Let's unify that in a generic implementation used by
both.

This is particulary nice as it unifies all /run/systemd/reboot-param
handling in a single .c file.

6 years agobasic: split out update_reboot_parameter_and_warn() into its own .c/.h files
Lennart Poettering [Wed, 21 Feb 2018 16:54:35 +0000 (17:54 +0100)] 
basic: split out update_reboot_parameter_and_warn() into its own .c/.h files

This is primarily preparation for a follow-up commit that adds a common
implementation of the other side of the reboot parameter file, i.e. the
code that reads the file and issues reboot() for it.

6 years agotree-wide: voidify reboot() invocations
Lennart Poettering [Wed, 21 Feb 2018 16:46:55 +0000 (17:46 +0100)] 
tree-wide: voidify reboot() invocations

We use (void) in most cases for reboot() already, let's add it to the
others as well.

6 years agobasic: add a common syscall wrapper around reboot()
Lennart Poettering [Wed, 21 Feb 2018 16:42:59 +0000 (17:42 +0100)] 
basic: add a common syscall wrapper around reboot()

This mimics the raw_clone() call we have in place already and
establishes a new syscall wrapper raw_reboot() that wraps the kernel's
reboot() system call in a bit more low-level fashion that glibc's
reboot() wrapper. The main difference is that the extra "arg" argument
is supported.

Ultimately this just replaces the syscall wrapper implementation we
currently have at three places in our codebase by a single one.

With this change this means that all our syscall() invocations are
neatly separated out in static inline system call wrappers in our header
functions.

6 years agomissing: always use __NR_ as prefix for syscall numbers
Lennart Poettering [Wed, 21 Feb 2018 16:27:34 +0000 (17:27 +0100)] 
missing: always use __NR_ as prefix for syscall numbers

Apparently, both __NR_ and SYS_ are useful, but we mostly use __NR_
hence use it for these two cases too, so that we settle on __NR_
exclusively.

6 years agomissing: Fix statx syscall ifdeffery
Lennart Poettering [Wed, 21 Feb 2018 16:25:01 +0000 (17:25 +0100)] 
missing: Fix statx syscall ifdeffery

Fix a copy/paste mistake.

Fixes: #8238
6 years agoMerge pull request #8246 from poettering/wait-for-terminate-eproto
Zbigniew Jędrzejewski-Szmek [Thu, 22 Feb 2018 07:27:44 +0000 (08:27 +0100)] 
Merge pull request #8246 from poettering/wait-for-terminate-eproto

some shutdown logging fixes

6 years agotree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS children 8246/head
Lennart Poettering [Wed, 21 Feb 2018 23:35:00 +0000 (00:35 +0100)] 
tree-wide: reopen log when we need to log in FORK_CLOSE_ALL_FDS children

In a number of occasions we use FORK_CLOSE_ALL_FDS when forking off a
child, since we don't want to pass fds to the processes spawned (either
because we later want to execve() some other process there, or because
our child might hang around for longer than expected, in which case it
shouldn't keep our fd pinned). This also closes any logging fds, and
thus means logging is turned off in the child. If we want to do proper
logging, explicitly reopen the logs hence in the child at the right
time.

This is particularly crucial in the umount/remount children we fork off
the shutdown binary, as otherwise the children can't log, which is
why #8155 is harder to debug than necessary: the log messages we
generate about failing mount() system calls aren't actually visible on
screen, as they done in the child processes where the log fds are
closed.

6 years agoshutdown: explicitly set a log target in shutdown.c
Lennart Poettering [Wed, 21 Feb 2018 23:33:12 +0000 (00:33 +0100)] 
shutdown: explicitly set a log target in shutdown.c

We used to set this, but this was dropped when shutdown got taught to
get the target passed in from the regular PID 1. Let's readd this to
make things more explanatory, and cover all grounds, since after all the
target passed is in theory an optional part of the protocol between the
regular PID 1 and the shutdown PID 1.

6 years agoshutdown: always pass errno to logging functions
Lennart Poettering [Wed, 21 Feb 2018 23:32:31 +0000 (00:32 +0100)] 
shutdown: always pass errno to logging functions

We have them, let's propagate them.

6 years agolog: only open kmsg on fallback if we actually want to use it
Lennart Poettering [Wed, 21 Feb 2018 23:31:36 +0000 (00:31 +0100)] 
log: only open kmsg on fallback if we actually want to use it

Previously, we'd try to open kmsg on failure of the journal/syslog even
if no automatic fallback to kmsg was requested — and we wouldn't even
use the open connection afterwards...

6 years agoumount: beef up logging when umount/remount child processes fail
Lennart Poettering [Wed, 21 Feb 2018 22:57:21 +0000 (23:57 +0100)] 
umount: beef up logging when umount/remount child processes fail

Let's extend what we log if umount/remount doesn't work correctly as we
expect.

See #8155

6 years agouser-sessions: let's simplify our code paths a bit
Lennart Poettering [Wed, 21 Feb 2018 22:42:58 +0000 (23:42 +0100)] 
user-sessions: let's simplify our code paths a bit

Let's always go through mac_selinux_finish(), by making our
success/failure codepaths more alike.

This also saves a few lines of code. Yay!

6 years agohwdb: drop bad definition for Cordless Wave Pro keyboard (#8230)
Zbigniew Jędrzejewski-Szmek [Wed, 21 Feb 2018 22:21:28 +0000 (23:21 +0100)] 
hwdb: drop bad definition for Cordless Wave Pro keyboard (#8230)

[I'm just submitting the solution originally suggested by @barzog.
Nevertheless, this looks pretty straightforward, we don't want to define
any keys on a universal receiver.

Note that this definition was added back in
aedc2eddd16e48d468e6ad0aea2caf00c7d37365, when we didn't yet have
support for figuring out what hardware is connected behind a logitech
receiver.]

In 60-keyboard.hwdb there is a definition of # Cordless Wave Pro
evdev:input:b0003v046DpC52[9B]*

which in fact not a cordless keyboard but an USB receiver to which different
types of keyboard can be connected. The solution is to completely clean
definition evdev:input:b0003v046DpC52B* from there.

I: Bus=0003 Vendor=046d Product=c52b Version=0111
N: Name="Logitech USB Receiver"
P: Phys=usb-0000:00:1d.0-1.8/input1
S: Sysfs=/devices/pci0000:00/0000:00:1d.0/usb4/4-1/4-1.8/4-1.8:1.1/0003:046D:C52B.0005/input/input20
U: Uniq=
H: Handlers=kbd mouse0 event8
B: PROP=0
B: EV=1f
B: KEY=3007f 0 0 83ffff17aff32d bf54444600000000 ffff0001 130f978b17c000 6773fad941dfed 9ed68000004400 10000002
B: REL=1c3
B: ABS=100000000
B: MSC=10

Fixed #8095.

6 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.

6 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.

6 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.

6 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.

6 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=.

6 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.

6 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.

6 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.)

6 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.

6 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.

6 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

6 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

6 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.

6 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

6 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.)

6 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=

6 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.

6 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

6 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=

6 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`.

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

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

6 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=.

6 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.

6 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

6 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()

6 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()

6 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.

6 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=

6 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=

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

6 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.

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

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

6 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()

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

6 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

6 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

6 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.

6 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.

6 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

6 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.

6 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.

6 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.

6 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

6 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

6 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.

6 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.

6 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.

6 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
6 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)

6 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

6 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...

6 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
6 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

6 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

6 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

6 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

6 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>
6 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.

6 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

6 years agopo: add a test translation of one string through zanata 8218/head
Zbigniew Jędrzejewski-Szmek [Mon, 19 Feb 2018 15:51:08 +0000 (16:51 +0100)] 
po: add a test translation of one string through zanata

I use the web translation interface to translate one simple string,
then I clicked on the .po link. The file I get is called "systemd.po",
but I saved it over pt_BR.po. Then I had to do
    sed -i -r 's/\s+$//' po/pt_BR.po
    truncate --size=-1 po/pt_BR.po
(i.e. fix whitespace issues) and commit. So it seems zanata does not mess up
existing copyright marks and allows for proper attribution.

6 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()

6 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.

6 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