Commit Graph

47948 Commits

Author SHA1 Message Date
Lennart Poettering eaa269484b resolved: fix non-initialized memory access
Fix for bug introduced in 1ed314087f.
2020-11-06 13:58:20 -08:00
Lennart Poettering 2386d1c1d3
Merge pull request #17534 from poettering/resolved-more-tweaks
seven smaller resolved tweaks
2020-11-06 22:39:09 +01:00
Lennart Poettering 76f772298e resolved: slightly extend debug log output about outgoing messages 2020-11-06 14:43:05 +01:00
Lennart Poettering 088648d081 resolved: don't resolve "local." via LLMNR
It's the mDNS top-level domain, hence don't consider it for LLMNR, ever.

Fixes: #16233
2020-11-06 14:43:01 +01:00
Lennart Poettering dc194dce80 resolved: add comments for various query flags 2020-11-06 14:42:56 +01:00
Lennart Poettering 5cdcac6cf6 resolved: show all answer flags when dumping answer 2020-11-06 14:42:53 +01:00
Lennart Poettering 032b398224 resolved: add minor optimization path to dns_answer_merge() 2020-11-06 14:42:49 +01:00
Lennart Poettering 02c205359b resolved: suppress misleading debug message about ignored resolv.conf line 2020-11-06 14:42:45 +01:00
Lennart Poettering 8d50c14252 errno: ETIMEDOUT is also a connection error 2020-11-06 14:42:18 +01:00
Michal Sekletár 30f6dce62c udev: make algorithm that selects highest priority devlink less susceptible to race conditions
Previously it was very likely, when multiple contenders for the symlink
appear in parallel, that algorithm would select wrong symlink (i.e. one
with lower-priority).

Now the algorithm is much more defensive and when we detect change in
set of contenders for the symlink we reevaluate the selection. Same
happens when new symlink replaces already existing symlink that points
to different device node.
2020-11-06 13:35:05 +01:00
Michal Sekletár a59b0a9f76 basic/stat-util: make mtime check stricter and use entire timestamp
Note that st_mtime member of struct stat is defined as follows,

 #define st_mtime st_mtim.tv_sec

Hence we omitted checking nanosecond part of the timestamp (struct
timespec) and possibly would miss modifications that happened within the
same second.
2020-11-06 12:28:40 +01:00
Ronan Pigott ea394d48cc journalctl: show boot id in the reboot context separator 2020-11-06 12:17:03 +01:00
Jian-Hong Pan f25e30dec4 hwdb: Fix Pinebook Pro's brightness up/down and sleep keys
Pinebook Pro's display brightness up & down keys do not work until the
keys are mapped to the corresponding codes.

Also, the sleep key is mapped to KEY_POWER code originally. This quirk
maps the sleep key to the KEY_SLEEP code.

This idea comes from the pinebookpro-post-install package [1] of Manjaro
ARM, which is the preloaded OS on Pinebook Pro.

[1]: 7ab1a134ea
2020-11-06 10:50:40 +01:00
Lennart Poettering ce8f6d478e seccomp: allow turning off of seccomp filtering via env var
Fixes: #17504

(While we are it, also move $SYSTEMD_SECCOMP_LOG= env var description
into the right document section)

Also suggested in: https://github.com/systemd/systemd/issues/17245#issuecomment-704773603
2020-11-05 20:22:19 +01:00
Kristijan Gjoshev acf24a1a84 timer: add new feature FixedRandomDelay=
FixedRandomDelay=yes will use
`siphash24(sd_id128_get_machine() || MANAGER_IS_SYSTEM(m) || getuid() || u->id)`,
where || is concatenation, instead of a random number to choose a value between
0 and RandomizedDelaySec= as the timer delay.
This essentially sets up a fixed, but seemingly random, offset for each timer
iteration rather than having a random offset recalculated each time it fires.

Closes #10355

Co-author: Anita Zhang <the.anitazha@gmail.com>
2020-11-05 10:59:33 -08:00
Lennart Poettering d72ff2df1c update TODO 2020-11-04 18:00:56 +01:00
Zbigniew Jędrzejewski-Szmek 961b341e85 selinux: also try the netlink-based fallback and continue on permission error
Fedora Rawhide still has the old policy, so selinux prevents our selinux code
from checking if selinux is enabled. But it seems smart to fall back to the old
API anyway.

Follow-up for fd5e402fa9.

Both the reference policy [1] and Fedora selinux policy [2] needed to be
updated, so it's likely that this will impact other distros too.

[1] https://github.com/SELinuxProject/refpolicy/pull/308
[2] https://github.com/fedora-selinux/selinux-policy/pull/464
2020-11-04 09:49:53 +01:00
Topi Miettinen ae5e9bf46f shared/seccomp-util: move stime() to @obsolete
Quoting the manual page of stime(2): "Starting with glibc 2.31, this function
is no longer available to newly linked applications and is no longer declared
in <time.h>."
2020-11-04 09:48:33 +01:00
Zbigniew Jędrzejewski-Szmek 04bd604fb9 sd-login: fix parsing in sd_uid_is_on_seat
Bug introduced in 81823e6c12771721e9a729f6280a9de26fd70bad:
logind uses spaces not commas to separate items.
2020-11-04 09:46:59 +01:00
Zbigniew Jędrzejewski-Szmek 585d7a893e
Merge pull request #17521 from poettering/resolved-more-fixes
six fixes to resolved
2020-11-04 09:38:09 +01:00
Zbigniew Jędrzejewski-Szmek ac5e2729c6
Merge pull request #17517 from keszybz/revert-hwdb-trailing-colon
Revert hwdb trailing colon
2020-11-04 09:26:31 +01:00
Zbigniew Jędrzejewski-Szmek 24309e6683
Merge pull request #17493 from Villemoes/va-arg-simplifications
Some vararg simplifications
2020-11-04 09:22:15 +01:00
Anita Zhang 5cecbae158 man: add <option> around default booleans in systemd.timer 2020-11-03 20:25:53 -08:00
Lennart Poettering 2f4c2db20a resolved: handle RRs where we don't have a signer
If we encounter an RR that has no matching signature, then we don't know
whether it was expanded from a wildcard or not. We need to accept that
and not make the NSEC test fail, just skip over the RR.
2020-11-03 20:36:02 +01:00
Lennart Poettering de4a0138e7 resolved: drop unused family argument from manager_routable() 2020-11-03 20:35:09 +01:00
Lennart Poettering 014e8cc131 resolved: fix dumping of DnsAnswer objects 2020-11-03 20:35:09 +01:00
Lennart Poettering 398c611833 resolved: put size limit in DnsAnswer size to UINT16_MAX
The three answer sections can only carry up to UINT16_MAX entries, hence
put a hard upper limit on how far DnsAnswer can grow. The three count
fields in the DNS packet header are 16 bit only, hence the limit.

If code actually tries to add more than 64K RRs it will get ENOSPC with
this new checking.

And similar to DnsQuestion.
2020-11-03 20:35:04 +01:00
Lennart Poettering a63a1252b5 resolved: check return value of memdup() correctly for OOM 2020-11-03 20:05:46 +01:00
Lennart Poettering 8b2e362651 man: remove misplaced comma 2020-11-03 20:05:46 +01:00
Zbigniew Jędrzejewski-Szmek 9887369972 Partially revert "hwdb: reindent commments and say that "*" should always be trailing"
This partially reverts commit 62ad1c6495.

I kept the reindents and other cosmetic changes, but removed the statements
about trailing ":*".
2020-11-03 15:02:52 +01:00
Zbigniew Jędrzejewski-Szmek a21ac934a1 Revert "parse_hwdb: enforce the ":*" suffix"
This reverts commit ad2d8e61ee.
2020-11-03 14:26:51 +01:00
Rasmus Villemoes 3d2b1fa473 strv.c: simplify strv_new_ap
Instead of duplicating the code for x and the varargs, handle them all the same
way by using for loops.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes bd8e699c27 signal-util: make sigaction_many_ap a little more concise
There's no reason to duplicate the stop condition sig < 0, nor the sigaction()
call.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes 6ced0770c7 string-util: improve overflow checking
The current overflow checking is broken in the corner case of the strings'
combined length being exactly SIZE_MAX: After the loop, l would be SIZE_MAX,
but we're not testing whether the l+1 expression overflows.

Fix it by simply pre-accounting for the final '\0': initialize l to 1 instead
of 0.
2020-11-03 14:26:08 +01:00
Rasmus Villemoes 020003f235 string-util: simplify logic in strjoin_real()
The loops over (x, then all varargs, until a NULL is found) can be written much
simpler with an ordinary for loop. Just initialize the loop variable to x, test
that, and in the increment part, fetch the next va_arg(). That removes a level
of indentation, and avoids doing a separate strlen()/stpcpy() call for x.

While touching this code anyway, change (size_t)-1 to the more readable
SIZE_MAX.
2020-11-03 14:25:28 +01:00
Zbigniew Jędrzejewski-Szmek 3a7771c9c4 Partially revert "hwdb: add trailing ":*" everywhere"
This reverts commit c0443b97b7.

I got various cases wrong:
"usb:v04F3p2B7Cd5912dc00dsc00dp00ic03isc00ip00in00"
"usb:v0627p0001:QEMU USB Tablet"
"input:b0003v0627p0001e0001-e0,1,2,4,k110,111,112,r0,1,8,B,am4,lsfw"

OTOH:
-evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV:*
+evdev:name:ETPS/2 Elantech Touchpad:dmi:*svnASUSTeKComputerInc.:pnN53SV*
is OK. Other parts follow after 'pn'.

-mouse:*:name:*Trackball*:*
-mouse:*:name:*trackball*:*
-mouse:*:name:*TrackBall*:*
+mouse:*:name:*Trackball*:
+mouse:*:name:*trackball*:
+mouse:*:name:*TrackBall*:
... and anything else with :name should be OK too, because our imports always
include ":" at the end:
IMPORT{builtin}="hwdb 'joystick:$env{ID_BUS}:v$attr{id/vendor}p$attr{id/product}:name:$attr{name}:'"
Including '*' at the end makes the pattern work even if we decide to add
something to the match string later.

Fixes #17499.
2020-11-03 14:17:53 +01:00
Lennart Poettering d3dcf4e3b9 fileio: beef up READ_FULL_FILE_CONNECT_SOCKET to allow setting sender socket name
This beefs up the READ_FULL_FILE_CONNECT_SOCKET logic of
read_full_file_full() a bit: when used a sender socket name may be
specified. If specified as NULL behaviour is as before: the client
socket name is picked by the kernel. But if specified as non-NULL the
client can pick a socket name to use when connecting. This is useful to
communicate a minimal amount of metainformation from client to server,
outside of the transport payload.

Specifically, these beefs up the service credential logic to pass an
abstract AF_UNIX socket name as client socket name when connecting via
READ_FULL_FILE_CONNECT_SOCKET, that includes the requesting unit name
and the eventual credential name. This allows servers implementing the
trivial credential socket logic to distinguish clients: via a simple
getpeername() it can be determined which unit is requesting a
credential, and which credential specifically.

Example: with this patch in place, in a unit file "waldo.service" a
configuration line like the following:

    LoadCredential=foo:/run/quux/creds.sock

will result in a connection to the AF_UNIX socket /run/quux/creds.sock,
originating from an abstract namespace AF_UNIX socket:

    @$RANDOM/unit/waldo.service/foo

(The $RANDOM is replaced by some randomized string. This is included in
the socket name order to avoid namespace squatting issues: the abstract
socket namespace is open to unprivileged users after all, and care needs
to be taken not to use guessable names)

The services listening on the /run/quux/creds.sock socket may thus
easily retrieve the name of the unit the credential is requested for
plus the credential name, via a simpler getpeername(), discarding the
random preifx and the /unit/ string.

This logic uses "/" as separator between the fields, since both unit
names and credential names appear in the file system, and thus are
designed to use "/" as outer separators. Given that it's a good safe
choice to use as separators here, too avoid any conflicts.

This is a minimal patch only: the new logic is used only for the unit
file credential logic. For other places where we use
READ_FULL_FILE_CONNECT_SOCKET it is probably a good idea to use this
scheme too, but this should be done carefully in later patches, since
the socket names become API that way, and we should determine the right
amount of info to pass over.
2020-11-03 09:48:04 +01:00
Lennart Poettering ff640bd2e1 update TODO 2020-11-02 15:30:16 +01:00
Muhammet Kara cf45341d11 po: Update Turkish translation 2020-11-02 12:41:39 +01:00
Martin Wilck dec8e6cfb4 test/sys-script.py: add missing DEVNAME entries to uevents 2020-11-02 11:43:15 +01:00
Martin Wilck cbeb23d863 test/udev_test.pl: add "expected good" count
Since 'test/udev-test.pl: count "good" results', we know how many
checks succeeded. Add an "expected good" count to make that number
more meaningful.
2020-11-02 11:43:15 +01:00
Martin Wilck f1cb086054 test/udev-test.pl: suppress umount error message at startup
umount emits an error message "no mount point specified" if the
tmpfs isn't mounted yet, which is the normal case.
Suppress that by redirecting stderr.
2020-11-02 11:43:15 +01:00
Martin Wilck 0ed1b64469 test/sd-script.py: new helper script for udev testing
Script for generating LOTS of SCSI disk and partition devices in
the fake sysfs we use for udev testing.

This script is supposed to be run after sys-script.py. It uses
code from sys-script.py as template to generate additional SCSI disk data
structures. Together with the "generator" code in udev-test.pl
added in the previous patch, it allows to run udev tests with almost
arbitrarily many devices, and thus to do performance scaling tests.
2020-11-02 11:43:15 +01:00
Martin Wilck eb44d715eb test/udev-test.pl: generator for large list of block devices
Manually listing all devices in the test definition becomes cumbersome with
lots of devices. Add a function that scans on all block devices in
the test sysfs and generates a list of devices to test.
2020-11-02 11:43:15 +01:00
Martin Wilck 2ab0a8d00b test/udev-test.pl: add repeat count
for easier reproduction of sporadic test failures.
2020-11-02 11:43:15 +01:00
Martin Wilck 4a0ec82daf tests/udev-test.pl: add multiple device test
Add 4 new tests using multiple devices. Number 2-4 use many
devices claiming the same symlink, where only one device has
a higher priority thatn the others. They fail sporadically with
the current code, if a race condition causes the symlink to point
to the wrong device. Test 4 is like test 2 with sleeps in between,
it's much less likely to fail.
2020-11-02 11:43:15 +01:00
Martin Wilck b95c43982a test/udev-test.pl: count "good" results
This is helpful to catch possible regressions in the test.
Also, don't count wait() errors, they are likely not udev errors.
2020-11-02 11:43:15 +01:00
Martin Wilck a96cd21d31 test/udev-test.pl: merge import parent tests into one
As we can test multiple devices and multiple links per device
in one test now, these two tests can be merged into one.
2020-11-02 11:43:15 +01:00
Martin Wilck 2084fe0d32 test/udev-test.pl: merge "space and var with space" tests
As we can check multiple links in a single test now, these 3
tests can be merged into one.
2020-11-02 11:43:15 +01:00
Martin Wilck 86634df43b test/udev-test.pl: remove bogus rules from magic subsys test
These rules have survived from an ancient version of the code
and save no purpose any more.
2020-11-02 11:43:14 +01:00