1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-10 05:18:17 +03:00
Commit Graph

63407 Commits

Author SHA1 Message Date
Frantisek Sumsal
d31706384d userdb: fix a memory leak
[   49.275617] testsuite-46.sh[1862]: =================================================================
[   49.275870] testsuite-46.sh[1862]: ==1862==ERROR: LeakSanitizer: detected memory leaks
[   49.276039] testsuite-46.sh[1862]: Direct leak of 103 byte(s) in 14 object(s) allocated from:
[   49.276515] testsuite-46.sh[1862]:     #0 0x7f4dbc07243b in strdup (/lib64/libasan.so.8+0x7243b)
[   49.276707] testsuite-46.sh[1862]:     #1 0x7f4dbb3900d5 in free_and_strdup ../src/basic/string-util.c:952
[   49.276931] testsuite-46.sh[1862]:     #2 0x7f4dbb15c67d in json_dispatch_user_group_name ../src/shared/json.c:4699
[   49.277134] testsuite-46.sh[1862]:     #3 0x7f4dbb16da9b in json_dispatch ../src/shared/json.c:4395
[   49.277352] testsuite-46.sh[1862]:     #4 0x7f4dbb25b28e in userdb_on_query_reply ../src/shared/userdb.c:305
[   49.277603] testsuite-46.sh[1862]:     #5 0x7f4dbb2748b9 in varlink_dispatch_reply ../src/shared/varlink.c:760
[   49.277766] testsuite-46.sh[1862]:     #6 0x7f4dbb2748b9 in varlink_process ../src/shared/varlink.c:951
[   49.277975] testsuite-46.sh[1862]:     #7 0x7f4dbb27a001 in defer_callback ../src/shared/varlink.c:1897
[   49.278197] testsuite-46.sh[1862]:     #8 0x7f4dbb5d57dd in source_dispatch ../src/libsystemd/sd-event/sd-event.c:4191
[   49.278421] testsuite-46.sh[1862]:     #9 0x7f4dbb5d685d in sd_event_dispatch ../src/libsystemd/sd-event/sd-event.c:4780
[   49.278675] testsuite-46.sh[1862]:     #10 0x7f4dbb5d70bf in sd_event_run ../src/libsystemd/sd-event/sd-event.c:4841
[   49.278873] testsuite-46.sh[1862]:     #11 0x7f4dbb257e7c in userdb_process ../src/shared/userdb.c:591
[   49.279048] testsuite-46.sh[1862]:     #12 0x7f4dbb25f78f in membershipdb_iterator_get ../src/shared/userdb.c:1411
[   49.279280] testsuite-46.sh[1862]:     #13 0x7f4dbb23a98c in user_record_show ../src/shared/user-record-show.c:187
[   49.279504] testsuite-46.sh[1862]:     #14 0x404ae3 in show_user ../src/userdb/userdbctl.c:93
[   49.279710] testsuite-46.sh[1862]:     #15 0x40b4f5 in display_user ../src/userdb/userdbctl.c:418
[   49.279961] testsuite-46.sh[1862]:     #16 0x7f4dbb2804d2 in dispatch_verb ../src/shared/verbs.c:110
[   49.280233] testsuite-46.sh[1862]:     #17 0x40dcf3 in run ../src/userdb/userdbctl.c:1327
[   49.280434] testsuite-46.sh[1862]:     #18 0x40dcf3 in main ../src/userdb/userdbctl.c:1330
[   49.280657] testsuite-46.sh[1862]:     #19 0x7f4db9e4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
[   49.280907] testsuite-46.sh[1862]: SUMMARY: AddressSanitizer: 103 byte(s) leaked in 14 allocation(s).
2023-03-27 13:29:49 +02:00
Frantisek Sumsal
98fa6c7210 test: explicitly pull in systemd-userdbd.socket
Since we don't run preset-all on the test image, the
systemd-userdbd.socket remains disabled. Let's pull it in explicitly
to give systemd-userdbd some coverage as well.
2023-03-27 13:29:12 +02:00
Yu Watanabe
cccc14c5a8
Merge pull request #26973 from mrc0mmand/userdbctl-tests
test: add a couple of tests for userdbctl
2023-03-26 09:49:27 +09:00
Zbigniew Jędrzejewski-Szmek
14ecfc1cd2 core/main: restore the correct assert about array position
'pos' is incremented after each assignment. If we use the maximum number
of arguments, we end up with pos==9 after all the assignments, and it
points to where the next value would be assigned. This position must remain
NULL.

The assert I "fixed" was intentionally introduced in
26abdc73a2 as a bugfix. So my "fix" repeated
the same error that was fixed back then.
2023-03-26 09:48:14 +09:00
Yu Watanabe
6fc0d6b5ac
Merge pull request #26983 from mrc0mmand/coredump-test-followup
test: don't expand the subshell expression prematurely
2023-03-26 09:47:49 +09:00
Frantisek Sumsal
237d81fdb3 test: filter the merged coverage report instead
So we don't have to do this twice - once for the base report and then
for each "real" one.

Follow-up to 7fdd6e157a.
2023-03-25 17:55:41 +01:00
Frantisek Sumsal
93fe228bb1 test: add a couple of tests for userdbctl 2023-03-25 14:13:00 +01:00
Frantisek Sumsal
7fdd6e157a test: do an initial coverage capture
I noticed that our coverage reports miss some files completely - this
happens when the test doesn't touch the code in them at all, so the
generated coverage data (and resulting reports) have no information
about them. Let's fix this by doing an initial zero coverage capture
that contains a zeroed counter for every instrumented line in every
file, so when we later merge it with a capture from the test, it shows up
with a missing coverage instead of not showing at all.
2023-03-25 12:29:40 +00:00
Frantisek Sumsal
91c031f169 test: drop unnecessary return
Return code of the EXIT trap handler is ignored in bash.
2023-03-25 12:17:11 +01:00
Frantisek Sumsal
370fa624f5 test: don't touch the /failed marker in the subtest scripts
As it is already handled by the "main" script (testsuite-74.sh).
2023-03-25 12:15:33 +01:00
Frantisek Sumsal
0b189ac84c test: don't expand the subshell expression prematurely
We need to expand the subshell expression during the `bash -c`
invocation, not before, to take the desired effect, as now it expands to:

timeout 30 bash -c 'while [[ 0 -eq 0 ]]; do sleep 1; done'

instead of the expected:

timeout 30 bash -c 'while [[ $(coredumpctl list -q --no-legend 770 | wc -l) -eq 0 ]]; do sleep 1; done'

Follow-up to aadbd81f7f.
2023-03-25 12:10:58 +01:00
taniishkaaa
ff155c8162
hwdb: Fix incorrect touchpad dimensions on Thinkpad L14 Gen1 (#26937)
Closes #22793.
2023-03-25 11:41:07 +01:00
Yu Watanabe
363ed18730
Merge pull request #26960 from poettering/syscall-catchup
syscall filter group updates
2023-03-25 13:39:27 +09:00
Zbigniew Jędrzejewski-Szmek
b5a70eeecd xdg-autostart-generator: do not warn about unknown fields
My user manager says:
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:256: Unknown key name 'Actions' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:258: Unknown section 'Desktop Action new-window'. Ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.gnome.Terminal.desktop:343: Unknown section 'Desktop Action preferences'. Ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:12: Unknown key name 'Actions' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:13: Unknown key name 'SingleMainWindow' in section 'Desktop Entry', ignoring.
systemd-xdg-autostart-generator[2933]: /home/zbyszek/.config/autostart/org.telegram.desktop.desktop:19: Unknown section 'Desktop Action Quit'. Ignoring.

This is not useful. Those are externally-provided files, and they are likely to
have entries which we know nothing about.
2023-03-25 13:38:39 +09:00
Yu Watanabe
01c357b0ac
Merge pull request #26977 from poettering/find-line-startswith
add new find_line_startswith() helper
2023-03-25 13:38:24 +09:00
Yu Watanabe
87dc8b0851 bootctl: enable colored logging 2023-03-25 12:38:11 +09:00
Zbigniew Jędrzejewski-Szmek
4688b08984 core/main: fix setting of arguments for shutdown
Fixup for d2ebd50d7f
and 6920049fad:
- add a comment that the last arg must be NULL and adjust the assert.
- move initialization around so that fields are declared,
  initialized, and consumed in the same order.
- move declaration of pos adjacent do declaration of command_line.
  This makes it easy to see that it was not initialized correctly.
- initialize buffers before writing the pointer into the args array.
  This makes no difference for the compiler, but it just feels "wrong"
  to do it in opposite order.

Because pos was off, we would ignore args after the timeout, and also
overwrite the buffer if enough args were used.

I think this is case shows clearly that declaring all variables at the
top of the function, with some initialized and other not, is very
error-prone. The compiler has no issue with declaring variables whereever,
and we should take advantage of this to make it keep declaration,
initialization, and use close. (Within reason of course.)
2023-03-24 19:08:20 +00:00
Zbigniew Jędrzejewski-Szmek
85a336f81d tools: add dump-auxv.py
This is a little helper I used when preparing the tests for auxv
parsing. Just looking at hexdump output is pretty hard. We could
enhance it to display some specific data types better.
2023-03-24 18:49:34 +00:00
Zbigniew Jędrzejewski-Szmek
61b69bec8e hwdb: drop boilerplate about match patterns in two more cases
Follow-up for adbe000e3d.
Somehow I missed those two files.
2023-03-25 03:11:23 +09:00
Lennart Poettering
90f5f3552c import: use truncate_nl() where appropriate 2023-03-24 18:33:59 +01:00
Lennart Poettering
50ed5cbf5f tree-wide: port various places to find_line_startswith() 2023-03-24 18:30:20 +01:00
Lennart Poettering
7b82d95f8d string-util: add new helper for finding line starting with specific string in a text buffer
We have implemented this manually a couple of times, and always wrong.
Hence let's implement this correctly for once and use everywhere.
2023-03-24 18:30:20 +01:00
Frantisek Sumsal
5b09499cac userdbctl: flush stdout before running the chain command
Otherwise it's quite difficult to capture the entire output:

$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA//dxI2xLg4MgxIKKZv1nqwTEIlE/fdakii2Fb75pG+ foo@bar.tld
ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMlaqG2rTMje5CQnfjXJKmoSpEVJ2gWtx4jBvsQbmee2XbU/Qdq5+SRisssR9zVuxgg5NA5fv08MgjwJQMm+csc= hello@world.tld
hello
$ userdbctl ssh-authorized-keys dropinuser --chain /bin/echo hello | tee
hello
2023-03-24 17:17:31 +01:00
Zbigniew Jędrzejewski-Szmek
32e07cff96
Merge pull request #26920 from medhefgo/ukify
ukify: Use pefile to add sections to EFI stub
2023-03-24 17:00:31 +01:00
Frantisek Sumsal
13bf321610 docs: s/authorized_key/authorized_keys/ 2023-03-24 16:16:50 +01:00
Frantisek Sumsal
8f572d0d82 man: s/io.systemd.Dropin/io.systemd.DropIn/ 2023-03-24 15:43:04 +01:00
Frantisek Sumsal
eedd1da9f9 userdbctl: don't show legend when dumping JSON with services 2023-03-24 15:19:21 +01:00
Lennart Poettering
f452e0461f man: update syscal filter group list 2023-03-24 14:52:34 +01:00
Daan De Meyer
f461a28da7 chase-symlinks: Rename chase_symlinks() to chase()
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.
2023-03-24 13:43:51 +01:00
Zbigniew Jędrzejewski-Szmek
0da2780c8a
Merge pull request #26785 from keszybz/udev-distcheck
Implement --help/--version in all udev builtins
2023-03-24 13:38:54 +01:00
Jan Janssen
52abd56915 ukify: Add riscv32 and loongarch support 2023-03-24 13:01:53 +01:00
Jan Janssen
3fc5eed470 ukify: Use pefile to add sections to EFI stub 2023-03-24 13:01:45 +01:00
Lennart Poettering
950c0ed389 analyze: don't claim "@known" was an unlisted syscall
It's a sycall group of our own definition, and the output is erroneous
to claim otherwise. Let's hide it.

This adds syscall_set_add() which is nicely symmetric to the existing
syscall_set_remove().

Follow-up for: 6d6a08547c
2023-03-24 12:29:30 +01:00
Lennart Poettering
50524bd887 seccomp-util: enforce group ordering
So far we asked via a comment that @default should stay the first group
and @known the last group in the list. Let's enforce that statically, in
code, too.
2023-03-24 12:28:46 +01:00
Lennart Poettering
76e86b8dd8 seccomp-util: add some newer syscalls to existing groups
These three new syscalls are mostly just new flavours or extensions of
existing syscalls, hence add them to the same groups.
2023-03-24 12:28:03 +01:00
Lennart Poettering
d12632a861 seccomp-util: add new @sandbox syscall group with landlock/seccomp
Let's group these 4 syscalls, as they offer similar things and I guess
might be used in conjunction quite often, as they offer unprivileged
sandboxing.

Fixes: #26913
2023-03-24 12:27:23 +01:00
Frantisek Sumsal
aadbd81f7f test: add a couple of tests for systemd-coredump 2023-03-24 11:56:33 +01:00
Daan De Meyer
12962485e4
Merge pull request #26958 from yuwata/nulstr-optionally-drop-trailing-nulstr
nulstr: make strv_parse_nulstr() optionally drop trailing NULs
2023-03-24 11:33:58 +01:00
Daan De Meyer
d258aacdfb
Merge pull request #26957 from yuwata/proc-cmdline-cleanups
proc-cmdline: several cleanups
2023-03-24 11:29:54 +01:00
Daan De Meyer
53c3342253
Merge pull request #26948 from yuwata/vconsole-fix-memleak
vconsole: introduce Context and its helper functions
2023-03-24 11:28:00 +01:00
Daan De Meyer
0405e7c5e1
Merge pull request #26956 from yuwata/core-main-arguments-followed-by-equal
core/main: make arguments followed by '='
2023-03-24 11:27:45 +01:00
Yu Watanabe
4669be626d process-util: drop trailing NUls before parsing the nulstr
No functional changes, just refactoring.
2023-03-24 15:21:59 +09:00
Yu Watanabe
55479c208d test: add tests from strv_parse_nulstr_full() 2023-03-24 15:21:59 +09:00
Yu Watanabe
a4f66f90ad nulstr-util: introduce strv_parse_nulstr_full() that optionally drop trailing empty strings 2023-03-24 15:21:59 +09:00
Yu Watanabe
a3cb11f841 test-proc-cmdline: test proc_cmdline_get_key() actually parses EFI options
Follow-up for 53aa0d02ad.
2023-03-24 15:20:05 +09:00
Yu Watanabe
2a6911bb1f proc-cmdline: make proc_cmdline_parse_given() static
It is used only in proc-cmdline.c and its test. And the test can be
covered by proc_cmdline_parse().
2023-03-24 15:20:05 +09:00
Yu Watanabe
1479799c4d proc-cmdline: use proc_cmdline_key_string() when we search for key 2023-03-24 15:20:05 +09:00
Yu Watanabe
b3e9a267ce proc-cmdline: rename variable 2023-03-24 15:20:05 +09:00
Yu Watanabe
a175b98171 proc-cmdline: insert an empty line between variable declaration and assertion 2023-03-24 15:20:05 +09:00
Yu Watanabe
d2ebd50d7f core/main: make positional arguments followed by '=', then by value
To make ConditionKernelCommandLine= or friend not confused when we are
running in a container.

Addresses https://github.com/systemd/systemd/pull/26887#discussion_r1143358884.
2023-03-24 15:16:21 +09:00