Commit Graph
3645 Commits
Author SHA1 Message Date
Yu Watanabe 1eede15851 sd-journal: refuse to write entry without boot ID
To make journal entries always contain valid boot ID.
2023-09-26 13:26:22 +09:00
Yu Watanabe b761ae0fca sd-journal: boot_id is always non-NULL
The two callers of journal_file_append_entry_internal() always pass
non-NULL boot ID.
2023-09-26 13:26:22 +09:00
Yu Watanabe 6ea51363c8 sd-journal: also verify tail_entry_boot_id and friends in journal_file_verify_header()
Then, we can drop the redundant check in journal_file_read_tail_timestamp().
2023-09-26 13:26:22 +09:00
Zbigniew Jędrzejewski-Szmek 660087dc9c tree-wide: add path_simplify_alloc() and use it
path_simplify_full()/path_simplify() are changed to allow a NULL path, for
which a NULL is returned. Generally, callers have already asserted before that
the argument is nonnull. This way path_simplify_full()/path_simplify() and
path_simplify_alloc() behave consistently.

In sd-device.c, logging in device_set_syspath() is intentionally dropped: other
branches don't log.

In mount-tool.c, logging in parse_argv() is changed to log the user-specified
value, not the simplified string. In an error message, we should show the
actual argument we got, not some transformed version.
2023-09-22 08:13:34 +02:00
Yu Watanabe c650d4cdef sd-journal: refuse entry objects with an empty boot ID
Otherwise, e.g. sd_journal_get_monotonic_usec() return an empty boot ID
when called for such a broken entry object.

Such a broken object may be stored when the system was not cleanly shutdown.

Fixes #29167.
2023-09-22 08:05:53 +02:00
Yu Watanabe afb81a0c05 sd-event: drop unnecessary call of sd_event_now() when requested relative time is zero 2023-09-21 11:03:37 +02:00
Yu Watanabe d08ff4506c sd-device: include missing alloc-util.h
unref_and_replace_full() is defined in alloc-util.h.
2023-09-21 14:28:55 +08:00
Luca Boccassi 2cb170376a Merge pull request #29235 from yuwata/sd-journal-reset-saved-direction-on-seek
sd-journal: reset saved direction on seek
2023-09-20 22:06:01 +01:00
Yu Watanabe 4aa33df845 sd-journal: also clear saved direction on seek
Otherwise, sd_journal_previous() -> real_journal_next(DIRECTION_UP) ->
next_beyond_location() wrongly handles that previously we hit EOF of
the file, and returns 0 without finding a matching entry.

Fixes #29216.
2023-09-21 01:59:21 +09:00
Mike Yuan 79de6eb1a7 tree-wide: explicitly compare return value of fd_is_fs_type with 0
According to our coding style.
2023-09-19 21:45:27 +08:00
Joerg Behrmann 7227dd816f treewide: fix typos
- mostly: usecase -> use case
- continously -> continuously
- single typos in docs/FILE_DESCRIPTOR_STORE.md
2023-09-19 10:05:38 +02:00
Mike Yuan e22c60a9d5 io-util: introduce loop_write_full that takes a timeout
Also drop do_poll as the use case is covered
by timeout.
2023-09-07 20:30:44 +08:00
Luca Boccassi 626a9eba09 Merge pull request #28988 from keszybz/sd128-arbitrary-values
Add sd-id128 and systemd-id128 functionality to do "app specific" with any "base"
2023-09-03 14:05:32 +01:00
Zbigniew Jędrzejewski-Szmek a53dc9b130 Merge pull request #29017 from msizanoen1/fix-onboot-rotate
journal: Relax boot ID and monotonic clock consistency checks
2023-09-02 14:26:44 +03:00
Zbigniew Jędrzejewski-Szmek fa96afb4c4 sd-id128: do not allow null 'app_id' param
If it is null, we get the 'base' param unchanged:
$ build/systemd-id128 show 00000000000000000000000000000001 \
  --app-specific=00000000000000000000000000000000
00000000000000000000000000000001

This is not good, because it breaks our promise that the base (usually either
machine-id or boot-id) cannot be derived from the result. Some application
using the library could use a null app id, inadvertently exposing the machine
or boot id. (This could happen because of forgotten initialization, or maybe
because the app id is configurable, and the user configures it wrongly.)

Note: the other way the secret is not exposed:
$ build/systemd-id128 show 00000000000000000000000000000000 \
  --app-specific=00000000000000000000000000000002
4f63080959264900b0d88d999dae2d3a

Normally systemd would not allow a null machine-id or boot-id, but we can let
the user do the calculation that if they want to.
2023-09-02 14:17:29 +03:00
Yu Watanabe 1d4c874d3c Merge pull request #24570 from topimiettinen/nft-sets-v2
network: firewall integration with NFT sets
2023-09-01 20:13:39 +09:00
msizanoen addcecf6f4 journal: Relax boot ID and monotonic clock consistency checks
The monotonic clock value consistency should only be checked if the boot
ID is the same as the last journal entry, and requiring that the current
boot ID be the same as the boot ID of the last entry is not necessary
for ensuring deterministic bisection as we already enforce strict
ordering of the real time clock value in a single journal file.

This fixes an issue where a new journal file is unnecessarily created
every boot, potentially wasting storage space.
2023-08-30 20:17:18 +07:00
msizanoen 2f766aca1e journal: Don't write to journal files without the new boot ID update behavior guarantee
With the old boot ID update behavior there's no way to compare the boot
ID of a new entry to be written with the boot ID of the last entry in
the journal in a performant manner, and therefore no way to determine if
monotonic clock value consistency checking is needed. Refuse to open
journal files without the new boot ID update behavior guarantee to
simplify consistency checking.
2023-08-30 20:16:45 +07:00
Zbigniew Jędrzejewski-Szmek 7c9de5d85d id128-util: add id128_from_string_not_null() 2023-08-29 17:06:47 +03:00
Zbigniew Jędrzejewski-Szmek 62b4bee9bc sd-id128: export sd_id128_get_app_specific()
We exported sd_id128_get_machine_app_specific() and
sd_id128_get_boot_app_specific(). But those operate on the current machine,
and sometimes the user might want to do the same calculation for a different
machine, or an earlier boot, etc. We expose the underlying implementation
to make this easy.
2023-08-29 17:06:47 +03:00
Zbigniew Jędrzejewski-Szmek 0f7735d7a9 sd-id128: avoid one memcpy
By aligning the output buffer, we can just use the result directly, no need to
copy stuff around.
2023-08-29 17:06:47 +03:00
Topi Miettinen 940965803e shared/firewall-util: parametrize table and set names
Parametrize table and set names for fw_nftables_add_masquerade_internal, rename
to nft_set_element_op_iprange to reflect more general usage. Export and use
nfproto_is_valid().

Remove also unused and obsolete NFPROTO_DECNET.
2023-08-23 19:53:13 +03:00
Zbigniew Jędrzejewski-Szmek c5ed77b220 libsystemd: use _NEG_ macros, adjust some comments
No functional change.
2023-08-16 12:52:56 +02:00
Zbigniew Jędrzejewski-Szmek d66ad6ff85 sd-id128: introduce ERRNO_IS_NEG_MACHINE_ID_UNSET 2023-08-16 12:52:56 +02:00
Zbigniew Jędrzejewski-Szmek 13d84288bc tree-wide: use cocinnelle to apply _NEG_ macros 2023-08-16 12:52:56 +02:00
Lennart Poettering d1e8e8b5ae tree-wide: drop _pure_ + _const_ from local, static functions
This is supposed to be a help for compilers to apply optimizations on
functions where they can't determine whether they are const/pure on
their own. For static, local functions the compiler can do this on its
own easily however, hence the decoration with pure/const is just noise.
Let's drop it, and let the compiler to its thing better.

(Use it for exported functions, since compilers can't 'reach-over' into
other modules to determine if they are pure, except if LTO is used)
2023-08-10 00:01:04 +08:00
Yu Watanabe 130c87b16a meson: merge declarations of normal and test executables 2023-08-03 20:37:16 +09:00
Luca Boccassi b0d3095fd6 Drop split-usr and unmerged-usr support
As previously announced, execute order 66:

https://lists.freedesktop.org/archives/systemd-devel/2022-September/048352.html

The meson options split-usr, rootlibdir and rootprefix become no-ops
that print a warning if they are set to anything other than the
default values. We can remove them in a future release.
2023-07-28 19:34:03 +01:00
Daan De Meyer 7ccb171c4c Merge pull request #28359 from keszybz/ret-gather
Add RET_GATHER macro to make continue-but-remember-first-error functions easier
2023-07-28 14:28:35 +02:00
Luca Boccassi de06b9a1b9 Merge pull request #28430 from keszybz/cleanups
Various small cleanups
2023-07-28 09:56:28 +01:00
Luca Boccassi 46021aaaa6 Merge pull request #28417 from bluca/coverity
Some coverity fixes
2023-07-28 09:56:08 +01:00
Zbigniew Jędrzejewski-Szmek 9194c1e697 sd-device, basic: align backslashes and drop unnecessary parens
Follow-up for a1af83728f
and 2507731374.
2023-07-17 20:57:42 +02:00
Dmitry V. Levin bb228f0ebc sd-bus: fix use of ERRNO_IS_DISCONNECT()
Given that ERRNO_IS_DISCONNECT() also matches positive values,
make sure this macro is not called with arguments that do not have
errno semantics.

In this case the argument passed to ERRNO_IS_DISCONNECT() is the value
returned by bus_socket_process_watch_bind(), bus_socket_process_opening(),
and bus_socket_process_authenticating() which can legitimately return
positive values without errno semantics, so fix this by moving the
ERRNO_IS_DISCONNECT() invocation to the branch where the return value
is known to be negative.
2023-07-16 10:53:30 +00:00
Luca Boccassi d80cc39558 bus: add some minimal bounds check on signatures
CID#1491292
CID#1491291
CID#1491290
CID#1491289
CID#1491284
CID#1491281
CID#1491280
CID#1491278
2023-07-16 11:32:54 +01:00
Yu Watanabe 4cbabc195c sd-journal: fix 'the the' 2023-07-14 16:53:41 +09:00
Frantisek Sumsal 9e94023236 journal: clean up the FSS handling code a bit 2023-07-13 15:32:20 +02:00
Zbigniew Jędrzejewski-Szmek 9ef648cca1 various: use RET_GATHER
No functional change indentended.
2023-07-13 11:12:00 +02:00
Zbigniew Jędrzejewski-Szmek 09ace4c76d sd-device: simplify code flow
This function was written as if it wanted to do some cleanup after exiting from
the loop, but that never happened.
2023-07-13 11:12:00 +02:00
Daan De Meyer a1af83728f device-util: Declare iterator variables inline 2023-07-12 20:05:18 +02:00
Luca Boccassi 79be4b7da8 Merge pull request #28255 from yuwata/sd-device-fix-clone
sd-device: fix device_clone_with_db()
2023-07-05 21:38:52 +01:00
Yu Watanabe 4a45a2e0e3 sd-journal: introduce SD_JOURNAL_TAKE_DIRECTORY_FD flag for sd_journal_open_directory_fd()
If it is called with the flag, then the provided file descriptor will be
owned by the sd_journal object, and will be closed in sd_journal_close().
2023-07-06 00:06:20 +09:00
Yu Watanabe 35e49f2856 sd-device: do not read uevent file in device_clone_with_db()
Follow-up for 381f6d4ba5.

When the function is called, the device may be already removed, and
another device has the same syspath. Such situation can occur when a
partition removed and another is created. In that case, the sysfs paths
of the removed and newly created partitions can be same, but their
devnums are different, and thus the database files corresponding to the
devices are also different.

Fixes #27981.
2023-07-05 23:45:57 +09:00
Yu Watanabe 86c2a76e09 Merge pull request #28132 from rpigott/dhcp-captive-portal
Implement RFC8910: captive portal dhcp options
2023-07-03 14:51:56 +09:00
Luca Boccassi b9d29a2028 Merge pull request #28226 from mrc0mmand/coverity-fixes
A couple of Coverity-related fixes
2023-07-02 15:54:56 +01:00
Frantisek Sumsal 5000cea8d2 tree-wide: explicitly ignore return value in a couple more places
Resolves:
  - CID#1490777
  - CID#1498366
  - CID#1508639
  - CID#1509084
  - CID#1509086
  - CID#1509087
2023-07-02 12:22:45 +02:00
Zbigniew Jędrzejewski-Szmek da89046643 tree-wide: "<n>bit" → "<n>-bit"
In some places, "<n> bits" is used when more appropriate.
2023-07-02 11:10:12 +01:00
Ronan Pigott edb88a7201 network: Introduce UseCaptivePortal DHCPv4 option
Accepts a boolean. When enabled, UseCaptivePortal will request and
retain the captive portal configuration from the DHCP server.
2023-07-02 01:13:43 -07:00
Lennart Poettering 9a653235d1 sd-path: add support for XDG_STATE_HOME 2023-06-28 21:55:33 +02:00
Lennart Poettering 1db8c86196 Merge pull request #28179 from poettering/sysvgendeprecated
make systemd-sysv-generator even more deprecated
2023-06-28 09:37:42 +02:00
Yu Watanabe 16e1e4b3e7 meson: drop doubled empty line 2023-06-27 22:34:25 -06:00