1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00
Commit Graph

37714 Commits

Author SHA1 Message Date
Lennart Poettering
4f9cf94c4a
Merge pull request #11144 from keszybz/dissect-image-fix
Fix for dissect-image use in nspawn
2018-12-17 19:36:36 +01:00
Michal Sekletar
4c70a4a748 core: do cgroup migration first and only then connect to journald
Fixes #11162
2018-12-17 19:22:30 +01:00
Lennart Poettering
500c65ad69
Merge pull request #11167 from yuwata/sd-resolve-typesafe
sd-resolve: introduce typesafe macros
2018-12-17 19:22:07 +01:00
Alexey Bogdanenko
8f9f3cb724 core: fix KeyringMode for user services
KeyringMode option is useful for user services. Also, documentation for the
option suggests that the option applies to user services. However, setting the
option to any of its allowed values has no effect.

This commit fixes that and removes EXEC_NEW_KEYRING flag. The flag is no longer
necessary: instead of checking if the flag is set we can check if keyring_mode
is not equal to EXEC_KEYRING_INHERIT.
2018-12-17 16:56:36 +01:00
Lennart Poettering
95cde1ed24
Merge pull request #11159 from keszybz/udev-typedef
Udev typedef and normal error reporting
2018-12-17 16:19:10 +01:00
Michal Sekletar
672773b63a journald: correctly attribute log messages also with cgroupsv1
With cgroupsv1 a zombie process is migrated to root cgroup in all
hierarchies. This was changed for unified hierarchy and /proc/PID/cgroup
reports cgroup to which process belonged before it exited.

Be more suspicious about cgroup path reported by the kernel and use
unit_id provided by the log client if the kernel reports that process is
running in the root cgroup.

Users tend to care the most about 'log->unit_id' mapping so systemctl
status can correctly report last log lines. Also we wouldn't be able to
infer anything useful from "/" path anyway.

See: 2e91fa7f6d
2018-12-17 15:16:11 +01:00
Lennart Poettering
a9238f6a33
Merge pull request #11184 from poettering/resolved-search-domains-max
resolve: bump max of dns servers/search domains
2018-12-17 15:15:45 +01:00
Tore Anderson
93158c77bc resolve: enable EDNS0 towards the 127.0.0.53 stub resolver
This appears to be necessary for client software to ensure the reponse data
is validated with DNSSEC. For example, `ssh -v -o VerifyHostKeyDNS=yes -o
StrictHostKeyChecking=yes redpilllinpro01.ring.nlnog.net` fails if EDNS0 is
not enabled. The debugging output reveals that the `SSHFP` records were
found in DNS, but were considered insecure.

Note that the patch intentionally does *not* enable EDNS0 in the
`/run/systemd/resolve/resolv.conf` file (the one that contains `nameserver`
entries for the upstream DNS servers), as it is impossible to know for
certain that all the upstream DNS servers handles EDNS0 correctly.
2018-12-17 15:15:18 +01:00
Zbigniew Jędrzejewski-Szmek
a8040b6d0a dissect-image: wait for the main device and all partitions to be known by udev
Fixes #10526.

Even if we waited for the root device to appear, the mount could still fail if
we didn't wait for udev to initalize the device. In particular, the
/dev/block/n:m path used to mount the device is created by udev, and nspawn
would sometimes win the race and the mount would fail with -ENOENT.

The same wait is done for partitions, since if we try to mount them, the same
considerations apply.

Note: I first implemented a version which just does a loop (with a short wait).
In that approach, udev takes on average ~800 µs to initialize the loopback
device. The approach where we set up a monitor and avoid the loop is a bit
nicer. There doesn't seem to be a significant difference in speed.
With 1000 invocations of 'systemd-nspawn -i image.squashfs echo':

loop (previous approach):
real	4m52.625s
user	0m37.094s
sys	2m14.705s

monitor (this patch):
real	4m50.791s
user	0m36.619s
sys	2m14.039s
2018-12-17 13:50:57 +01:00
Zbigniew Jędrzejewski-Szmek
b887c8b8a8 dissect-image: wait for the root to appear
dissect-image would wait for the root device and paritions to appear. But if we
had an image with no partitions, we'd not wait at all. If the kernel or udev
were slow in creating device nodes or symlinks, subsequent mount attempt might
fail if nspawn won the race.

Calling wait_for_partitions_to_appear() in case of no partitions means that we
verify that the kernel agrees that there are no partitions. We verify that the
kernel sees the same number of partitions as blkid, so let's that also in this
case.

This makes the failure in #10526 much less likely, but doesn't eliminate it
completely. Stay tuned.
2018-12-17 13:50:57 +01:00
Zbigniew Jędrzejewski-Szmek
ea887be00b dissect-image: split out a chunk of dissect_image() out
No functional change, just moving code around.
2018-12-17 13:50:57 +01:00
Zbigniew Jędrzejewski-Szmek
ed435031a5 rfkill: move wait_for_initialized() to shared/
The function interface is the same, except that the output pointer may be NULL.

The implementation is slightly simplified by taking advantage of changes in
ancestor commit 'sd-device: attempt to read db again if it wasn't found', by
not creating a new sd_device object before re-checking the is_initialized
status.

v2:
- In v1, the old object was always used and the device received back from the
  sd_device_monitor_start callback was ignored. I *think* the result will be
  equivalent in both cases, because by the time we the callback gets called,
  the db entry in the filesystem will also exist, and any subsequent access to
  properties of the object would trigger a read of the database from disk. But
  I'm not certain, and anyway, using the device object received in the callback
  seems cleaner.
2018-12-17 13:50:51 +01:00
Lennart Poettering
b950ee06e6 resolve: bump max of dns servers/search domains
Apparently people want more of these (as #11175 shows). Since this is
merely a safety limit for us, let's just bump all values substantially.

Fixes: #11175
2018-12-17 13:34:50 +01:00
Zbigniew Jędrzejewski-Szmek
11c49e6df5 sd-device: remove holes in struct sd_device
Normally, we don't care too much about what pahole reports. But this structure
could potentially be allocated for every device on the system, i.e. in a large
number of copies. 5 vs 7 cache lines is nice.

/* size: 400, cachelines: 7, members: 53 */
/* sum members: 330, holes: 12, sum holes: 70 */
/* last cacheline: 16 bytes */

/* size: 320, cachelines: 5, members: 53 */
/* bit holes: 1, sum bit holes: 6 bits */
/* bit_padding: 5 bits */
2018-12-17 12:29:28 +01:00
Zbigniew Jędrzejewski-Szmek
bce48452b8
Merge pull request #11077 from yuwata/udev-issue-better-fix
sd-device: do not change buffer size if the socket is already bound
2018-12-17 12:13:35 +01:00
Zbigniew Jędrzejewski-Szmek
c9cd236f92
Merge pull request #11180 from yuwata/update-bash-completion
several updates of bash completion for udevadm, resolvectl, and nspawn
2018-12-17 12:11:00 +01:00
Zbigniew Jędrzejewski-Szmek
582de70f2f
Merge pull request #11086 from poettering/nscd-cache-flush
flush nscd's caches when we register user/groups/hostnames
2018-12-17 11:29:58 +01:00
lbernstone
cb84bb25d5 hwdb: add accelerometer orientation quirk for the Teclast F5 (#11005) 2018-12-17 09:33:35 +01:00
Zbigniew Jędrzejewski-Szmek
2e08871534 udev: use typedef for struct udev_event 2018-12-17 09:27:24 +01:00
Zbigniew Jędrzejewski-Szmek
9a07157dd5 udev: use typedef for struct udev_rules 2018-12-17 09:27:21 +01:00
Zbigniew Jędrzejewski-Szmek
96fd7bc536
Merge pull request #11179 from kraj/kraj/pu
Fix issues found with gcc trunk
2018-12-17 09:17:35 +01:00
Lennart Poettering
2d78717b09 fileio: when reading a full file into memory, refuse inner NUL bytes
Just some extra care to avoid any ambiguities in what we read.
2018-12-17 09:14:23 +01:00
Yu Watanabe
d6131be94d NEWS: mention DynamicTransmitLoadBalancing=
Which was added by #11142.
2018-12-17 07:25:48 +01:00
Khem Raj
baa162cecd core: Fix use after free case in load_from_path()
ensure that mfree() on filename is called after the logging function
which uses the string pointed by filename

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-12-16 22:02:00 -08:00
Yu Watanabe
1f7951241f bash-completion: also suggests device units
Follow-up for b6854081ff.
2018-12-17 14:44:58 +09:00
Yu Watanabe
19582502c0 bash-completion: udevadm: suggest argument for several options 2018-12-17 14:44:00 +09:00
Khem Raj
bfc4183ea9 sysctl: Don't pass null directive argument to '%s'
value pointer here is always NULL but  subsequent use of that pointer
with a %s format will always be NULL, printing p instead would be a
valid string

Signed-off-by: Khem Raj <raj.khem@gmail.com>
2018-12-16 21:01:39 -08:00
Yu Watanabe
d5acf7da91 bash-completion: fix __get_interfaces() 2018-12-17 11:13:15 +09:00
Yu Watanabe
45cb8247d9
Merge pull request #11142 from ssahani/bond-dynamic-tlb
netdev bond: add support to configure tlb_dynamic_lb
2018-12-17 02:06:05 +01:00
Yu Watanabe
7082bb05ad timesync: use typesafe resolve_getaddrinfo() 2018-12-17 10:02:36 +09:00
Yu Watanabe
f2935c77c6 socket-proxyd: use typesafe resolve_getaddrinfo() 2018-12-17 10:02:36 +09:00
Yu Watanabe
1061dab129 netdev: use typesafe resolve_getaddrinfo() in wireguard.c 2018-12-17 10:02:36 +09:00
Yu Watanabe
a4c9ae400f netdev: sort headers 2018-12-17 10:02:36 +09:00
Yu Watanabe
ceb26cdbc2 sd-resolve: add sd_resolve_get{addr,info}_with_destroy_callback() and typesafe macros 2018-12-17 10:02:36 +09:00
Zbigniew Jędrzejewski-Szmek
dc5042c0a3 sd-device: pass timestamp internally as usec_t not char* 2018-12-16 20:58:45 +01:00
Zbigniew Jędrzejewski-Szmek
ebcc52fad6 sd-device: reduce the number of implementations of device_read_db() we keep around
We had two very similar functions: device_read_db_aux and device_read_db,
and a number of wrappers for them:

device_read_db_aux
  ← device_read_db (in sd-device.c)
    ← all functions in sd-device.c, including sd_device_is_initialized

  ← device_read_db_force
     ← event_execute_rules_on_remove (in udev-event.c)

device_read_db (in device-private.c)
  ← functions in device_private.c (but not device_read_db_force):
    device_get_devnode_{mode,uid,gid}
    device_get_devlink_priority
    device_get_watch_handle
    device_clone_with_db
    ← called from udevadm, udev-{node,event,watch}.c

Before 7141e4f62c (sd-device: don't retry loading
uevent/db files more than once), the two implementations were the same. In that
commit, device_read_db_aux was changed. Those changes were reverted in the parent
commit, so the two implementations are now again the same except for superficial
differences. This commit removes device_read_db (in sd-device.c), and renames
device_read_db_aux to device_read_db_internal and makes everyone use this one
implementation. There should be no functional change.
2018-12-16 20:17:39 +01:00
Zbigniew Jędrzejewski-Szmek
cd53c8f97d sd-device: attempt to read db again if it wasn't found
This mostly reverts "sd-device: don't retry loading uevent/db files more than
once", 7141e4f62c. We will retry if we couldn't
access the file, but not if parsing failed.

Not re-reading the database at all just doesn't seem like a good idea. We have
two implementations of device_read_db, and one does that, and the other retries
to read the db. Re-reading seems more useful, since we can create the object
and then access properties as some later time when we know that the device has
been initialized and we can get useful results. Otherwise, we force the user to
destroy this object and create a new one.

This changes device_read_uevent_file() and device_read_db_aux(). See next
commit for description of where those functions are used.
2018-12-16 19:52:58 +01:00
Claudius Ellsel
bd1c8360a4 Fixed small typo in 70-mouse.hwdb 2018-12-16 19:37:22 +01:00
NeilBrown
89f9752ea0 core/mount: minimize impact on mount storm.
If we create 2000 mounts (on a 1-CPU qemu VM) with
  mkdir -p /MNT/{1..2000}
  time for i in {1..2000}; do mount --bind /etc /MNT/$i ; done

it takes around 20 seconds to complete.  Much of this time is taken up
by systemd repeatedly processing /proc/self/mountinfo.
If I disable the processing, the time drops to about 4 seconds.

I have reports that on a larger system with multiple active user sessions, each
with it's own systemd, the impact can be higher.

One particular use-case where a large number of mounts can be expected in quick
succession is when the "clearcase" SCM starts up.

This patch modifies the handling up events from /proc/self/mountinfo so
that systemd backs off when a storm is detected.  Specifically the time to process
mountinfo is measured, and the process will not be repeated until 10 times
that duration has passed.  This ensures systemd won't use more than 10% of
real time processing mountinfo.

With this patch, my test above takes about 5 seconds.
2018-12-16 12:38:40 +01:00
Lennart Poettering
2d41e9b7a0
Merge pull request #11143 from keszybz/enable-symlink
Runtime mask symlink confusion fix
2018-12-16 12:37:07 +01:00
Filipe Brandenburger
fc833520e4 Revert "lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors"
This reverts commit dd102e4d0c.

That test case exposed a memory leak and breaks CI, so let's revert it until
the original issue is fixed, to prevent disruption of automated testing.
2018-12-15 20:58:39 +03:00
Filipe Brandenburger
2e14ea7d78
Merge pull request #11137 from poettering/bogus-id128
hostnamed: let's filter out some obviously bogus product UUIDs
2018-12-15 09:27:14 -08:00
Susant Sahani
6d4efac2d9 networkd: Bond - AllSlavesActive fix parser
Bond.AllSlavesActive use parser type bool
2018-12-15 18:17:02 +05:30
Susant Sahani
fde60a424e netdev bond: add support to configure tlb_dynamic_lb
Closes https://github.com/systemd/systemd/issues/11135

Add test for bond : tlb_dynamic_lb
2018-12-15 18:15:16 +05:30
Lennart Poettering
ffd79164aa
Merge pull request #11140 from filbranden/lldpcmp1
Use ?: to chain comparison functions (for now, in lldp only)
2018-12-15 12:12:06 +01:00
Lennart Poettering
460ec54908 core: flush nscd's caches whenever we allocate/release a dynamic user
This should make dynamic users and nscd work together better.

Fixes: #10740
2018-12-15 12:10:19 +01:00
Lennart Poettering
7782e0a0ea hostnamed: always flush nscd cache when changing hostname
This way we know that nss-myhostname always serves the correct answer.
2018-12-15 12:10:19 +01:00
Lennart Poettering
9fdcbae5e2 machined: flush nscd caches whenever a machine comes/goes
This way, nss-mymachines should always serve authoritative data.
2018-12-15 12:10:19 +01:00
Lennart Poettering
5be61bead5 machined: fix memory corruption
Let's make sure the first hashmap we destroy also frees all machines,
because otherwise when freeing the other hashmaps we'll try to
deregister the contained machines from the hashmaps already destroyed.
2018-12-15 12:10:19 +01:00
Lennart Poettering
f079c3727c shared: add helper for flushing nscd caches
Apparently, people do use nscd, hence play somewhat nice with it, and
let's explicitly flush nscd caches whenever we register a new
user/group.

This patch only adds the actual refresh request invocation. Later
commits then issue this call at appropriate moments.

Note that the nscd protocol is not officially documented though very
simple. This code is written very defensively so that incompatibilities
don't affect us much.

Given that glibc really has a duty to maintain compat between
differently compiled programs and their system nscd they can't break API
and thus it should be safe for us to implement an alternative,
minimalistic client.

Ideally this kind of explicit, global cache flushing would not be necessary.
However nscd currently has no cache coherency protocol, hence we can't
really implement this better. The only concept it knows is a TTL for
positive hosts lookups. Hoewver for negative lookups or any of the other
tables nothing is available.
2018-12-15 12:10:19 +01:00