]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
5 years agotest-fileio: test safe_fgetc directly 11182/head
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 12:27:59 +0000 (13:27 +0100)] 
test-fileio: test safe_fgetc directly

Non-ascii chars are used so that we get both "positive" and "negative"
characters (on the arches where char is signed).

5 years agoupdate TODO
Lennart Poettering [Mon, 17 Dec 2018 10:53:21 +0000 (11:53 +0100)] 
update TODO

5 years agoprocess-util: rework getenv_for_pid() to use read_nul_string()
Lennart Poettering [Mon, 17 Dec 2018 11:17:36 +0000 (12:17 +0100)] 
process-util: rework getenv_for_pid() to use read_nul_string()

5 years agotest: add test case for read_nul_string()
Lennart Poettering [Mon, 17 Dec 2018 10:52:51 +0000 (11:52 +0100)] 
test: add test case for read_nul_string()

5 years agofileio: let's minimize 'count' inc/dec calls
Lennart Poettering [Mon, 17 Dec 2018 10:52:05 +0000 (11:52 +0100)] 
fileio: let's minimize 'count' inc/dec calls

instead of increasing it and immediately after decreasing it again,
let's just increase it a bit later.

5 years agofileio: replace read_nul_string() by read_line() with a special flag
Lennart Poettering [Mon, 17 Dec 2018 10:50:33 +0000 (11:50 +0100)] 
fileio: replace read_nul_string() by read_line() with a special flag

read_line() is a lot more careful and optimized than read_nul_string()
but does mostly the same thing. let's replace the latter by the former,
just with a special flag that toggles between the slightly different EOL
rules if both.

5 years agoprocess-util: make get_process_environ() safer
Lennart Poettering [Mon, 17 Dec 2018 10:23:15 +0000 (11:23 +0100)] 
process-util: make get_process_environ() safer

Let's add a size limit, and let's use safe_fgetc().

5 years agotree-wide: port some code over to safe_fgetc()
Lennart Poettering [Mon, 17 Dec 2018 10:22:38 +0000 (11:22 +0100)] 
tree-wide: port some code over to safe_fgetc()

5 years agofileio: add new safe_fgetc() helper call
Lennart Poettering [Mon, 17 Dec 2018 10:21:12 +0000 (11:21 +0100)] 
fileio: add new safe_fgetc() helper call

We have very similar code whenever we call fgetc() in place, let's
replae it by a common implementation.

5 years agoMerge pull request #10221 from lucaswerkmeister/bash-completion
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 13:47:12 +0000 (14:47 +0100)] 
Merge pull request #10221 from lucaswerkmeister/bash-completion

Merged locally to resolve a conflict. The redirection of error is required to
suppress "# Not showing unlisted system calls, ...".

5 years agoMerge pull request #11197 from keszybz/various-fixups
Lennart Poettering [Tue, 18 Dec 2018 13:35:00 +0000 (14:35 +0100)] 
Merge pull request #11197 from keszybz/various-fixups

Various fixups

5 years agoMerge pull request #11191 from poettering/hashmap-clear
Lennart Poettering [Tue, 18 Dec 2018 13:34:39 +0000 (14:34 +0100)] 
Merge pull request #11191 from poettering/hashmap-clear

rework hashmap_clear()

5 years agoMerge pull request #11200 from poettering/mailmap-updates-240
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 13:00:59 +0000 (14:00 +0100)] 
Merge pull request #11200 from poettering/mailmap-updates-240

updates for .mailmap and NEWS

5 years agoMerge pull request #11194 from poettering/resolved-soa-parent
Lennart Poettering [Tue, 18 Dec 2018 12:07:24 +0000 (13:07 +0100)] 
Merge pull request #11194 from poettering/resolved-soa-parent

be more conservative with set of RRs to authenticate

5 years agoNEWS: add one more item 11200/head
Lennart Poettering [Tue, 18 Dec 2018 12:04:43 +0000 (13:04 +0100)] 
NEWS: add one more item

5 years agoNEWS: update contributors list, taking new .mailmap into account
Lennart Poettering [Tue, 18 Dec 2018 11:56:56 +0000 (12:56 +0100)] 
NEWS: update contributors list, taking new .mailmap into account

5 years agosort .mailmap alphabetically
Lennart Poettering [Tue, 18 Dec 2018 11:55:00 +0000 (12:55 +0100)] 
sort .mailmap alphabetically

5 years agoupdate .mailmap a bit from v240 contributions
Lennart Poettering [Tue, 18 Dec 2018 11:53:58 +0000 (12:53 +0100)] 
update .mailmap a bit from v240 contributions

5 years agotest-mountpoint-util: more debug info 11197/head
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 07:53:48 +0000 (08:53 +0100)] 
test-mountpoint-util: more debug info

5 years agomeson: print EFI CC configuration nicely
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 23:02:11 +0000 (00:02 +0100)] 
meson: print EFI CC configuration nicely

In 595343fb4c99c2679d347ef7c19debfbfed6342e it was converted to an array.
This doesn't look good in the output. Let's convert it back to a string.

5 years agomeson: rename two more variables from _c to _sources
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 22:39:17 +0000 (23:39 +0100)] 
meson: rename two more variables from _c to _sources

_c is misleading because .h files should be included in those lists too
(this tells meson that the build outputs should be rebuilt if the header
files change).

Follow-up for 1437822638ff9468fa78c7cfe56f8f55f955a61d.

5 years agosystemctl: add comment why whitespace in message is needed
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 22:19:06 +0000 (23:19 +0100)] 
systemctl: add comment why whitespace in message is needed

5 years agotest-hashmap: add test to compare hashmap_free performance 11191/head
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 10:35:48 +0000 (11:35 +0100)] 
test-hashmap: add test to compare hashmap_free performance

The point here is to compare speed of hashmap_destroy with free and a different
freeing function, to the implementation details of hashmap_clear can be
evaluated.

Results:
current code:

/* test_hashmap_free (slow, 1048576 entries) */
string_hash_ops test took 2.494499s
custom_free_hash_ops test took 2.640449s

string_hash_ops test took 2.287734s
custom_free_hash_ops test took 2.557632s

string_hash_ops test took 2.299791s
custom_free_hash_ops test took 2.586975s

string_hash_ops test took 2.314099s
custom_free_hash_ops test took 2.589327s

string_hash_ops test took 2.319137s
custom_free_hash_ops test took 2.584038s

code with a patch which restores the "fast path" using:
    for (idx = skip_free_buckets(h, 0); idx != IDX_NIL; idx = skip_free_buckets(h, idx + 1))
in the case where both free_key and free_value are either free or NULL:

/* test_hashmap_free (slow, 1048576 entries) */
string_hash_ops test took 2.347013s
custom_free_hash_ops test took 2.585104s

string_hash_ops test took 2.311583s
custom_free_hash_ops test took 2.578388s

string_hash_ops test took 2.283658s
custom_free_hash_ops test took 2.621675s

string_hash_ops test took 2.334675s
custom_free_hash_ops test took 2.601568s

So the test is noisy, but there clearly is no significant difference with the
"fast path" restored. I'm surprised by this, but it shows that the current
"safe" implementation does not cause a performance loss.

When the code is compiled with optimization, those times are significantly
lower (e.g. 1.1s and 1.4s), but again, there is no difference with the "fast
path" restored.

The difference between string_hash_ops and custom_free_hash_ops is the
additional cost of global modification and the extra function call.

5 years agotest-hashmap: use the usual function headers and print timing stats
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 10:33:52 +0000 (11:33 +0100)] 
test-hashmap: use the usual function headers and print timing stats

This makes it slightly easier to watch for performance changes.

5 years agohashmap: use ternary op to shorten code
Zbigniew Jędrzejewski-Szmek [Tue, 18 Dec 2018 08:50:01 +0000 (09:50 +0100)] 
hashmap: use ternary op to shorten code

5 years agolldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors
Filipe Brandenburger [Thu, 6 Dec 2018 07:58:58 +0000 (23:58 -0800)] 
lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors

In particular, check that the order of the results is consistent.

This test coverage will be useful in order to refactor the compare_func
used while sorting the results.

When introduced, this test also uncovered a memory leak in sd_lldp_stop(),
which was then fixed by a separate commit using a specialized function
as destructor of the LLDP Hashmap.

Tested:
  $ ninja -C build/ test
  $ valgrind --leak-check=full build/test-lldp

5 years agosd-lldp: accept if a neighbor is already removed from the hashtable
Lennart Poettering [Mon, 17 Dec 2018 17:43:11 +0000 (18:43 +0100)] 
sd-lldp: accept if a neighbor is already removed from the hashtable

5 years agohashmap: rework hashmap_clear() to be more defensive
Lennart Poettering [Mon, 17 Dec 2018 17:42:09 +0000 (18:42 +0100)] 
hashmap: rework hashmap_clear() to be more defensive

Let's first remove an item from the hashmap and only then destroy it.
This makes sure that destructor functions can mdoify the hashtables in
their own codee and we won't be confused by that.

5 years agoresolved: mention which RRs we query when requesting them to authenticate some other RR 11194/head
Lennart Poettering [Mon, 17 Dec 2018 20:16:48 +0000 (21:16 +0100)] 
resolved: mention which RRs we query when requesting them to authenticate some other RR

5 years agoresolved: only attempt non-answer SOA RRs if they are parents of our query
Lennart Poettering [Mon, 17 Dec 2018 20:14:17 +0000 (21:14 +0100)] 
resolved: only attempt non-answer SOA RRs if they are parents of our query

There's no value in authenticating SOA RRs that are neither answer to
our question nor parent of our question (the latter being relevant so
that we have a TTL from the SOA field for negative caching of the actual
query).

By being to eager here, and trying to authenticate too much we run the
risk of creating cyclic deps between our transactions which then causes
the over-all authentication to fail.

Fixes: #9771
5 years agotimesync: fix serialization of IP address
Lennart Poettering [Mon, 17 Dec 2018 14:30:23 +0000 (15:30 +0100)] 
timesync: fix serialization of IP address

Fixes: #11169
5 years agoNEWS: document the usern/mknod borkage in 4.18 a bit
Lennart Poettering [Mon, 17 Dec 2018 15:46:36 +0000 (16:46 +0100)] 
NEWS: document the usern/mknod borkage in 4.18 a bit

5 years agoNEWS: add missing 'not'
Lennart Poettering [Thu, 13 Dec 2018 15:53:40 +0000 (16:53 +0100)] 
NEWS: add missing 'not'

5 years agodocs: add missing section to ENVIRONMENT.md
Lennart Poettering [Mon, 17 Dec 2018 15:37:18 +0000 (16:37 +0100)] 
docs: add missing section to ENVIRONMENT.md

No, this is not an env var understood by logind. Let's fix the
confusoin.

5 years agoMerge pull request #11144 from keszybz/dissect-image-fix
Lennart Poettering [Mon, 17 Dec 2018 18:36:36 +0000 (19:36 +0100)] 
Merge pull request #11144 from keszybz/dissect-image-fix

Fix for dissect-image use in nspawn

5 years agocore: do cgroup migration first and only then connect to journald
Michal Sekletar [Mon, 17 Dec 2018 14:57:42 +0000 (15:57 +0100)] 
core: do cgroup migration first and only then connect to journald

Fixes #11162

5 years agoMerge pull request #11167 from yuwata/sd-resolve-typesafe
Lennart Poettering [Mon, 17 Dec 2018 18:22:07 +0000 (19:22 +0100)] 
Merge pull request #11167 from yuwata/sd-resolve-typesafe

sd-resolve: introduce typesafe macros

5 years agocore: fix KeyringMode for user services
Alexey Bogdanenko [Sun, 16 Dec 2018 16:04:28 +0000 (19:04 +0300)] 
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.

5 years agoMerge pull request #11159 from keszybz/udev-typedef
Lennart Poettering [Mon, 17 Dec 2018 15:19:10 +0000 (16:19 +0100)] 
Merge pull request #11159 from keszybz/udev-typedef

Udev typedef and normal error reporting

5 years agojournald: correctly attribute log messages also with cgroupsv1
Michal Sekletar [Fri, 14 Dec 2018 14:17:27 +0000 (15:17 +0100)] 
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: https://github.com/torvalds/linux/commit/2e91fa7f6d451e3ea9fec999065d2fd199691f9d

5 years agoMerge pull request #11184 from poettering/resolved-search-domains-max
Lennart Poettering [Mon, 17 Dec 2018 14:15:45 +0000 (15:15 +0100)] 
Merge pull request #11184 from poettering/resolved-search-domains-max

resolve: bump max of dns servers/search domains

5 years agoresolve: enable EDNS0 towards the 127.0.0.53 stub resolver
Tore Anderson [Mon, 17 Dec 2018 08:15:59 +0000 (09:15 +0100)] 
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.

5 years agodissect-image: wait for the main device and all partitions to be known by udev 11144/head
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 15:39:05 +0000 (16:39 +0100)] 
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

5 years agodissect-image: wait for the root to appear
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 13:35:15 +0000 (14:35 +0100)] 
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.

5 years agodissect-image: split out a chunk of dissect_image() out
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 12:28:58 +0000 (13:28 +0100)] 
dissect-image: split out a chunk of dissect_image() out

No functional change, just moving code around.

5 years agorfkill: move wait_for_initialized() to shared/
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 11:32:33 +0000 (12:32 +0100)] 
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.

5 years agoresolve: bump max of dns servers/search domains 11184/head
Lennart Poettering [Mon, 17 Dec 2018 12:34:50 +0000 (13:34 +0100)] 
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
5 years agosd-device: remove holes in struct sd_device
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 11:29:28 +0000 (12:29 +0100)] 
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 */

5 years agoMerge pull request #11077 from yuwata/udev-issue-better-fix
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 11:13:35 +0000 (12:13 +0100)] 
Merge pull request #11077 from yuwata/udev-issue-better-fix

sd-device: do not change buffer size if the socket is already bound

5 years agoMerge pull request #11180 from yuwata/update-bash-completion
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 11:11:00 +0000 (12:11 +0100)] 
Merge pull request #11180 from yuwata/update-bash-completion

several updates of bash completion for udevadm, resolvectl, and nspawn

5 years agoMerge pull request #11086 from poettering/nscd-cache-flush
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 10:29:58 +0000 (11:29 +0100)] 
Merge pull request #11086 from poettering/nscd-cache-flush

flush nscd's caches when we register user/groups/hostnames

5 years agohwdb: add accelerometer orientation quirk for the Teclast F5 (#11005)
lbernstone [Mon, 17 Dec 2018 08:33:35 +0000 (01:33 -0700)] 
hwdb: add accelerometer orientation quirk for the Teclast F5 (#11005)

5 years agoudev: use typedef for struct udev_event 11159/head
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 09:27:24 +0000 (10:27 +0100)] 
udev: use typedef for struct udev_event

5 years agoudev: use typedef for struct udev_rules
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 09:24:40 +0000 (10:24 +0100)] 
udev: use typedef for struct udev_rules

5 years agoMerge pull request #11179 from kraj/kraj/pu
Zbigniew Jędrzejewski-Szmek [Mon, 17 Dec 2018 08:17:35 +0000 (09:17 +0100)] 
Merge pull request #11179 from kraj/kraj/pu

Fix issues found with gcc trunk

5 years agofileio: when reading a full file into memory, refuse inner NUL bytes
Lennart Poettering [Sat, 15 Dec 2018 11:25:32 +0000 (12:25 +0100)] 
fileio: when reading a full file into memory, refuse inner NUL bytes

Just some extra care to avoid any ambiguities in what we read.

5 years agoNEWS: mention DynamicTransmitLoadBalancing=
Yu Watanabe [Mon, 17 Dec 2018 01:12:08 +0000 (10:12 +0900)] 
NEWS: mention DynamicTransmitLoadBalancing=

Which was added by #11142.

5 years agocore: Fix use after free case in load_from_path() 11179/head
Khem Raj [Mon, 17 Dec 2018 04:58:35 +0000 (20:58 -0800)] 
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>
5 years agobash-completion: also suggests device units 11180/head
Yu Watanabe [Mon, 17 Dec 2018 05:44:38 +0000 (14:44 +0900)] 
bash-completion: also suggests device units

Follow-up for b6854081ffb26c32a8d1440346f9ee5b9d2f1e57.

5 years agobash-completion: udevadm: suggest argument for several options
Yu Watanabe [Mon, 17 Dec 2018 03:17:12 +0000 (12:17 +0900)] 
bash-completion: udevadm: suggest argument for several options

5 years agosysctl: Don't pass null directive argument to '%s'
Khem Raj [Mon, 17 Dec 2018 04:53:38 +0000 (20:53 -0800)] 
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>
5 years agobash-completion: fix __get_interfaces()
Yu Watanabe [Mon, 17 Dec 2018 02:13:15 +0000 (11:13 +0900)] 
bash-completion: fix __get_interfaces()

5 years agoMerge pull request #11142 from ssahani/bond-dynamic-tlb
Yu Watanabe [Mon, 17 Dec 2018 01:06:05 +0000 (02:06 +0100)] 
Merge pull request #11142 from ssahani/bond-dynamic-tlb

netdev bond: add support to configure tlb_dynamic_lb

5 years agotimesync: use typesafe resolve_getaddrinfo() 11167/head
Yu Watanabe [Mon, 17 Dec 2018 01:01:43 +0000 (10:01 +0900)] 
timesync: use typesafe resolve_getaddrinfo()

5 years agosocket-proxyd: use typesafe resolve_getaddrinfo()
Yu Watanabe [Sat, 15 Dec 2018 12:01:06 +0000 (21:01 +0900)] 
socket-proxyd: use typesafe resolve_getaddrinfo()

5 years agonetdev: use typesafe resolve_getaddrinfo() in wireguard.c
Yu Watanabe [Sat, 15 Dec 2018 11:57:50 +0000 (20:57 +0900)] 
netdev: use typesafe resolve_getaddrinfo() in wireguard.c

5 years agonetdev: sort headers
Yu Watanabe [Sat, 15 Dec 2018 11:57:20 +0000 (20:57 +0900)] 
netdev: sort headers

5 years agosd-resolve: add sd_resolve_get{addr,info}_with_destroy_callback() and typesafe macros
Yu Watanabe [Mon, 10 Dec 2018 06:45:48 +0000 (15:45 +0900)] 
sd-resolve: add sd_resolve_get{addr,info}_with_destroy_callback() and typesafe macros

5 years agosd-device: pass timestamp internally as usec_t not char*
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 10:33:17 +0000 (11:33 +0100)] 
sd-device: pass timestamp internally as usec_t not char*

5 years agosd-device: reduce the number of implementations of device_read_db() we keep around
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 14:49:49 +0000 (15:49 +0100)] 
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 7141e4f62c3f220872df3114c42d9e4b9525e43e (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.

5 years agosd-device: attempt to read db again if it wasn't found
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 14:41:09 +0000 (15:41 +0100)] 
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", 7141e4f62c3f220872df3114c42d9e4b9525e43e. 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.

5 years agoFixed small typo in 70-mouse.hwdb
Claudius Ellsel [Sun, 16 Dec 2018 14:34:47 +0000 (15:34 +0100)] 
Fixed small typo in 70-mouse.hwdb

5 years agocore/mount: minimize impact on mount storm.
NeilBrown [Thu, 4 Oct 2018 05:49:22 +0000 (15:49 +1000)] 
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.

5 years agoMerge pull request #11143 from keszybz/enable-symlink
Lennart Poettering [Sun, 16 Dec 2018 11:37:07 +0000 (12:37 +0100)] 
Merge pull request #11143 from keszybz/enable-symlink

Runtime mask symlink confusion fix

5 years agoRevert "lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors"
Filipe Brandenburger [Sat, 15 Dec 2018 17:43:18 +0000 (09:43 -0800)] 
Revert "lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors"

This reverts commit dd102e4d0c6551e9d39c3bdb6715eceea57c8761.

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.

5 years agoMerge pull request #11137 from poettering/bogus-id128
Filipe Brandenburger [Sat, 15 Dec 2018 17:27:14 +0000 (09:27 -0800)] 
Merge pull request #11137 from poettering/bogus-id128

hostnamed: let's filter out some obviously bogus product UUIDs

5 years agonetworkd: Bond - AllSlavesActive fix parser 11142/head
Susant Sahani [Sat, 15 Dec 2018 12:47:02 +0000 (18:17 +0530)] 
networkd: Bond - AllSlavesActive fix parser

Bond.AllSlavesActive use parser type bool

5 years agonetdev bond: add support to configure tlb_dynamic_lb
Susant Sahani [Thu, 13 Dec 2018 09:23:07 +0000 (14:53 +0530)] 
netdev bond: add support to configure tlb_dynamic_lb

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

Add test for bond : tlb_dynamic_lb

5 years agoMerge pull request #11140 from filbranden/lldpcmp1
Lennart Poettering [Sat, 15 Dec 2018 11:12:06 +0000 (12:12 +0100)] 
Merge pull request #11140 from filbranden/lldpcmp1

Use ?: to chain comparison functions (for now, in lldp only)

5 years agocore: flush nscd's caches whenever we allocate/release a dynamic user 11086/head
Lennart Poettering [Fri, 7 Dec 2018 16:03:32 +0000 (17:03 +0100)] 
core: flush nscd's caches whenever we allocate/release a dynamic user

This should make dynamic users and nscd work together better.

Fixes: #10740
5 years agohostnamed: always flush nscd cache when changing hostname
Lennart Poettering [Fri, 7 Dec 2018 15:51:39 +0000 (16:51 +0100)] 
hostnamed: always flush nscd cache when changing hostname

This way we know that nss-myhostname always serves the correct answer.

5 years agomachined: flush nscd caches whenever a machine comes/goes
Lennart Poettering [Fri, 7 Dec 2018 15:49:52 +0000 (16:49 +0100)] 
machined: flush nscd caches whenever a machine comes/goes

This way, nss-mymachines should always serve authoritative data.

5 years agomachined: fix memory corruption
Lennart Poettering [Fri, 7 Dec 2018 15:47:20 +0000 (16:47 +0100)] 
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.

5 years agoshared: add helper for flushing nscd caches
Lennart Poettering [Fri, 7 Dec 2018 15:24:55 +0000 (16:24 +0100)] 
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.

5 years agohostnamed: filter out all-zero and all-0xFF DMI ProductUUIDs 11137/head
Lennart Poettering [Wed, 12 Dec 2018 19:40:12 +0000 (20:40 +0100)] 
hostnamed: filter out all-zero and all-0xFF DMI ProductUUIDs

These UUIDs are considered as wildcard value for "unset" UUIDs
typically, and this even makes sense. Let's suppress them hence.

5 years agosd-id128: add helpers to check fo all-0xFF ids
Lennart Poettering [Fri, 14 Dec 2018 10:46:07 +0000 (11:46 +0100)] 
sd-id128: add helpers to check fo all-0xFF ids

5 years agosd-id128: slightly reorder function prototypes
Lennart Poettering [Fri, 14 Dec 2018 10:45:21 +0000 (11:45 +0100)] 
sd-id128: slightly reorder function prototypes

Let's place the three calls for acquiring the IDs together, and the
calls for getting the app-specific ones separate from them.

5 years agosd-128: base SD_ID128_MAKE() macro on existing SD_ID128_ARRAY() macro
Lennart Poettering [Fri, 14 Dec 2018 10:44:43 +0000 (11:44 +0100)] 
sd-128: base SD_ID128_MAKE() macro on existing SD_ID128_ARRAY() macro

5 years agofstab-generator: remove spurious newline
Lennart Poettering [Wed, 12 Dec 2018 19:38:43 +0000 (20:38 +0100)] 
fstab-generator: remove spurious newline

5 years agomkosi: update libqrencode in Debian config
Alexey Bogdanenko [Sat, 15 Dec 2018 05:38:14 +0000 (08:38 +0300)] 
mkosi: update libqrencode in Debian config

In Debian unstable package libqrencode-dev is version 4.0.2-1, and the
corresponding runtime library is provided by package libqrencode4.

This change fixes the following error when running journalctl:

    root@image:~# journalctl
    journalctl: error while loading shared libraries: libqrencode.so.4: cannot
    open shared object file: No such file or directory

This change also fixes the following boot failures in
systemd-journal-flush.service and systemd-journal-catalog-update.service:

    [FAILED] Failed to start Flush Journal to Persistent Storage.
    [FAILED] Failed to start Rebuild Journal Catalog.

See also #4949

5 years agolldp: simplify compare_func, using ?: to chain comparisons 11140/head
Filipe Brandenburger [Thu, 6 Dec 2018 08:02:51 +0000 (00:02 -0800)] 
lldp: simplify compare_func, using ?: to chain comparisons

The ?: operator is very useful for chaining comparison functions
(strcmp, memcmp, CMP), since its behavior is to return the result
of the comparison function call if non-zero, or continue evaluating
the chain of comparison functions.

This simplifies the code in that using a temporary `r` variable
to store the function results is no longer necessary and the checks
for non-zero to return are no longer needed either, resulting in a
typical three-fold reduction to the number of lines in the code.

Introduce a new memcmp_nn() to compare two memory buffers in
lexicographic order, taking length in consideration.

Tested: $ ninja -C build/ test

All test cases pass. In particular, test_multiple_neighbors_sorted()
in test-lldp would catch regressions introduced by this commit.

5 years agolldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors
Filipe Brandenburger [Thu, 6 Dec 2018 07:58:58 +0000 (23:58 -0800)] 
lldp: add test coverage for sd_lldp_get_neighbors() with multiple neighbors

In particular, check that the order of the results is consistent.

This test coverage will be useful in order to refactor the compare_func
used while sorting the results.

Tested: ninja -C build/ test

5 years agoMerge pull request #11160 from poettering/read-line-more-tests
Chris Down [Fri, 14 Dec 2018 13:00:28 +0000 (13:00 +0000)] 
Merge pull request #11160 from poettering/read-line-more-tests

some tests for read_line() EOL markers that coincide with EOF

5 years agotests: add a test that checks read_line() properly handles line endings at EOF 11160/head
Lennart Poettering [Fri, 14 Dec 2018 11:57:32 +0000 (12:57 +0100)] 
tests: add a test that checks read_line() properly handles line endings at EOF

As requested here: https://github.com/systemd/systemd/pull/11129#discussion_r241588835

5 years agofileio: fail early if we can't return the number of bytes we read anymore in an int
Lennart Poettering [Fri, 14 Dec 2018 11:56:12 +0000 (12:56 +0100)] 
fileio: fail early if we can't return the number of bytes we read anymore in an int

This is mostly paranoia, but let's better be safer than sorry. This of
course means there's always an implicit limit to how much we can read at
a time of 2G. But that should be ample.

5 years agopid1: fix free of uninitialized pointer in unit_fail_if_noncanonical()
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 07:16:31 +0000 (08:16 +0100)] 
pid1: fix free of uninitialized pointer in unit_fail_if_noncanonical()

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

5 years agoman: add note about systemd-vconsole-setup.service and tty as input/output
Zbigniew Jędrzejewski-Szmek [Thu, 13 Dec 2018 18:43:55 +0000 (19:43 +0100)] 
man: add note about systemd-vconsole-setup.service and tty as input/output

Closes #10019.

5 years agotree-wide: s/time-out/timeout/g
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 07:26:46 +0000 (08:26 +0100)] 
tree-wide: s/time-out/timeout/g

From WordNet (r) 3.0 (2006) [wn]:

  time-out
      n 1: a brief suspension of play; "each team has two time-outs left"

From The Free On-line Dictionary of Computing (18 March 2015) [foldoc]:

  timeout

     A period of time after which an error condition is raised if
     some event has not occured.  A common example is sending a
     message.  If the receiver does not acknowledge the message
     within some preset timeout period, a transmission error is
     assumed to have occured.

5 years agoin-addr-util: fix undefined result for in4_addr_netmask_to_prefixlen(<0.0.0.0>)
Thomas Haller [Thu, 13 Dec 2018 18:59:46 +0000 (19:59 +0100)] 
in-addr-util: fix undefined result for in4_addr_netmask_to_prefixlen(<0.0.0.0>)

u32ctz() was undefined for zero due to __builtin_ctz() [1].
Explicitly check for zero to make the behavior defined.

Note that this issue only affected in4_addr_netmask_to_prefixlen()
which is the only caller.

It may seem slightly odd, to return 32 (bits) for utz(0). But that
is what in4_addr_netmask_to_prefixlen() needs, and it probably makes
the most sense here.

[1] https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

Fixes: ba91431154ad7bac82ddf0a540ec1b40db62d782
5 years agoudev: make udev_rules_new() return a proper error code
Zbigniew Jędrzejewski-Szmek [Fri, 14 Dec 2018 09:20:43 +0000 (10:20 +0100)] 
udev: make udev_rules_new() return a proper error code