summaryrefslogtreecommitdiff
path: root/src/libsystemd
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #27655 from ↵Yu Watanabe2023-05-173-23/+77
|\ | | | | | | | | yuwata/udev-net-assign-alternative-names-only-on-add-event udev/net: assign alternative names only on add event
| * sd-netlink: make rtnl_set_link_name() optionally append alternative namesYu Watanabe2023-05-163-23/+77
| |
* | test: add testcase for the new sockaddr metainfo logicLennart Poettering2023-05-162-0/+131
| |
* | sd-bus: use the new information in the client's sockaddr in the creds structureLennart Poettering2023-05-163-2/+89
| | | | | | | | | | | | | | Now that clients might convey comm/description strings via the sockaddr, let's actually use them on the other side, read the data via getpeername() parse it, and include it in the "owner" creds (which is how we call the peer's creds).
* | sd-bus: bind outgoing AF_UNIX sockets to abstract addresses conveying client ↵Lennart Poettering2023-05-161-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | comm + bus description string Let's pass some additional meta information along bus connections without actually altering the communication protocol. Pass the client comm and client description string of the bus via including it in the abstract namespace client socket address we connect to. This is purely informational (and entirely user controlled), but has the benefit that servers can make use of the information if they want, but really don't have to. It works entirely transparently. This takes inspiration from how we convey similar information via credential socket connections.
* | test-bus-server: minor modernizationsLennart Poettering2023-05-161-6/+1
| |
* | test-bus-chat: modernize a few thingsLennart Poettering2023-05-161-102/+54
|/
* sd-bus: bus_message_type_from_string is not pureXi Ruoyao2023-05-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC document [1] says: The pure attribute prohibits a function from modifying the state of the program that is observable by means other than inspecting the function’s return value. And there is an example: `int hash (char *) __attribute__ ((pure));` ... Even though hash takes a non-const pointer argument it must not modify the array it points to, ... But we are modifying the object pointed to by the pointer u, which is clearly a violation of the semantic of pure. With -ftrivial-auto-var-init (enabled by -Dmode=release), on some targets (GCC 12.2 on AArch64 and GCC 13.1 on x86_64) performs an optimization: as the variable "u" in bus_match_parse has been zero-initialized (by the -ftrivial-auto-var-init option) and never modified (because a "pure" bus_message_type_from_string is not allowed to modify it), "u" will be always 0. Then 0 is used to initialize .value_u8 field of struct bus_match_component. This then causes a infinite event loop, so "systemctl restart" never stops, and pam_systemd timeouts communicating with logind, etc. So we should remove the "pure" attribute here. Fixes #26395. [1]:https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
* sd-journal: split out generic_array_bisect_one() from generic_array_bisect()Yu Watanabe2023-05-071-82/+72
| | | | | | | This also makes journal corruption always handled gracefully, and drop potentially unsatisfied assertion on corrupted journal. Fixes #27533.
* sd-journal: re-read entry array objectYu Watanabe2023-05-071-1/+9
| | | | | `test_object()` may call `journal_file_move_to_object()` and thus the `array` object may be invalidated.
* sd-journal: drop unnecessary initializationYu Watanabe2023-05-071-1/+1
|
* sd-journal: rebreak commentsYu Watanabe2023-05-071-9/+5
|
* sd-journal: fix commentYu Watanabe2023-05-071-1/+1
|
* sd-daemon: add sd_pid_notify_barrier() call and use it in systemd-notifyLennart Poettering2023-05-032-2/+7
| | | | | Previously we'd honour --pid= from the main notification we send, but not from the barrier. This is confusing at best. Let's fix that.
* Revert "sd-journal: introduce simple loop detection for entry array objects"Yu Watanabe2023-05-031-19/+7
| | | | | | | This reverts commit a8fbcc0e3c033a43e511550052cace6b0dcf3df7. The commit is not necessary, as the invalid entry array object is filtered earlier by the previous commit.
* sd-journal: check .next_entry_array_offset earlierYu Watanabe2023-05-031-5/+6
| | | | | | | Then, if it is invalid, refuse to use the entry array object. Follow-up for a8fbcc0e3c033a43e511550052cace6b0dcf3df7. Fixes #27489.
* tree-wide: Handle EADDRNOTAVAIL as journal corruptionDaan De Meyer2023-05-021-2/+2
| | | | | Journal corruption is not only indicated by EBADMSG but also by EADDRNOTAVAIL so treat that as corruption in a few more cases.
* Merge pull request #27455 from yuwata/test-lib-symYu Watanabe2023-05-025-27/+29
|\ | | | | test: check all public functions are listed in .sym file
| * test: also test all _public_ functions are listed in .sym filesYu Watanabe2023-05-011-1/+3
| | | | | | | | Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
| * libsystemd: add missing _public_ attributesYu Watanabe2023-04-292-2/+2
| |
| * libsystemd: drop _public_ attribute for non-exported functionsYu Watanabe2023-04-292-24/+24
| |
* | sd-journal: introduce simple loop detection for entry array objectsYu Watanabe2023-05-011-7/+19
| | | | | | | | | | | | | | | | | | If .next_entry_array_offset points to one of the previous entry or the self entry, then the loop for entry array objects may run infinitely. Let's assume that the offsets of each entry array object are in increasing order, and check that in loop. Fixes #27470.
* | sd-journal: tighten variable scopeYu Watanabe2023-05-011-1/+3
| |
* | sd-journal: read entry array object againYu Watanabe2023-05-011-1/+6
| | | | | | | | | | Otherwise, the object may be invalidated by the previous call of journal_file_move_to_object().
* | sd-journal: check validity of object type more strictlyYu Watanabe2023-05-011-3/+3
| | | | | | | | | | Otherwise, the object with invalid type may pass check_object_header() when the requested type is OBJECT_UNUSED.
* | sd-journal: add _OBJECT_TYPE_INVALID as usualYu Watanabe2023-05-011-1/+2
| |
* | sd-journal: align tableYu Watanabe2023-05-011-7/+7
| |
* | sd-journal: check that the journal file is not stored in .newest_by_boot_id ↵Yu Watanabe2023-05-011-0/+2
| | | | | | | | on free
* | sd-journal: unset prioq index on failureYu Watanabe2023-05-011-1/+3
| | | | | | | | | | Otherwise, potentially, the assertion in journal_file_unlink_newest_by_bood_id() will be triggered.
* | sd-journal: fix use-after-freeYu Watanabe2023-05-011-1/+1
|/ | | | | | | As commented in the code, we need to replace the pointer to the key, hence, hashmap_replace() must be used, instead of hashmap_update(). Fixes #27459.
* libsystemd: Add missing memory pressure functions to public symbolsDaan De Meyer2023-04-281-0/+4
|
* sd-journal: make journal_file_copy_entry() return earlierYu Watanabe2023-04-261-0/+2
|
* sd-journal: copy boot IDYu Watanabe2023-04-261-3/+3
| | | | | The pointer to boot ID may be invalidate by journal_file_move_to_object() calls in the later loop.
* sd-journal: tighten variable scopeYu Watanabe2023-04-261-2/+2
|
* journal: Don't try to write garbage if journal entry is corruptedDaan De Meyer2023-04-261-3/+6
| | | | | | | | | | | If journal_file_data_payload() returns -EBADMSG or -EADDRNOTAVAIL, we skip the entry and go to the next entry, but we never modify the number of items that we pass to journal_file_append_entry_internal() if that happens, which means we could try to append garbage to the journal file. Let's keep track of the number of fields we've appended to avoid this problem.
* Merge pull request #27347 from bluca/sd_bus_nonceLennart Poettering2023-04-2511-217/+340
|\ | | | | sd: avoid closing sd-bus in a fork, store module-global id for sd-bus/sd-session/sd-journal
| * sd-event: store and compare per-module static origin idLuca Boccassi2023-04-252-67/+129
| | | | | | | | | | | | | | | | | | sd-event objects use hashmaps, which use module-global state, so it is not safe to pass a sd-event object created by a module instance to another module instance (e.g.: when two libraries static linking sd-event are pulled in a single process). Initialize a random per-module origin id and store it in the object, and compare it when entering a public API, and error out if they don't match, together with the PID.
| * sd-journal: store and compare per-module static origin idLuca Boccassi2023-04-253-48/+61
| | | | | | | | | | | | | | | | | | sd-journal objects use hashmaps, which use module-global state, so it is not safe to pass a sd-journal object created by a module instance to another module instance (e.g.: when two libraries static linking sd-journal are pulled in a single process). Initialize a random per-module origin id and store it in the object, and compare it when entering a public API, and error out if they don't match, together with the PID.
| * sd-bus: store and compare per-module static origin idLuca Boccassi2023-04-256-105/+126
| | | | | | | | | | | | | | | | | | sd-bus objects use hashmaps, which use module-global state, so it is not safe to pass a sd-bus object created by a module instance to another module instance (e.g.: when two libraries static linking sd-bus are pulled in a single process). Initialize a random per-module origin id and store it in the object, and compare it when entering a public API, and error out if they don't match, together with the PID.
| * sd-bus: check for pid change before closingLuca Boccassi2023-04-251-1/+28
| | | | | | | | | | | | | | If we try to close after a fork, the FDs will have been cloned too and we'll assert. This can happen for example in PAM modules. Avoid the macro and define ref/unref by hand to do the same check.
* | sd-daemon: add sd_pid_notifyf_with_fds()Lennart Poettering2023-04-252-0/+31
|/ | | | | | | | | | | | I guess it was only a question of time until we need to add the final frontier of notification functions: one that combines the features of all the others: 1. specifiying a source PID 2. taking a list of fds to send along 3. accepting a format string for the status string Hence, let's add it.
* tree-wide: convert more cases do DEVNUM_FORMAT_STR()/DEVNUM_FORMAT_VAL()Lennart Poettering2023-04-211-3/+3
| | | | | | Let's use our nice macros a bit more. (Not comprehensive)
* Merge pull request #27253 from yuwata/cmsg-find-and-copy-dataYu Watanabe2023-04-161-1/+1
|\ | | | | socket-util: introduce CMSG_FIND_AND_COPY_DATA()
| * tree-wide: also use CMSG_TYPED_DATA() on writing message headerYu Watanabe2023-04-161-1/+1
| |
* | string-util: add strstrafter()Lennart Poettering2023-04-141-2/+1
|/ | | | | | | | | strstrafter() is like strstr() but returns a pointer to the first character *after* the found substring, not on the substring itself. Quite often this is what we actually want. Inspired by #27267 I think it makes sense to add a helper for this, to avoid the potentially fragile manual pointer increment afterwards.
* udev,sd-device: use CMSG_FIND_DATA() moreLennart Poettering2023-04-131-4/+2
|
* tree-wide: port more code over to CMSG_TYPED_DATA()Lennart Poettering2023-04-131-4/+4
|
* Merge pull request #27220 from yuwata/sd-device-follow-ups-for-devlinkDaan De Meyer2023-04-121-27/+37
|\ | | | | sd-device: several follow-ups about devlink creation
| * sd-device: absolute devlink must start with /dev/Yu Watanabe2023-04-121-27/+37
| | | | | | | | | | | | | | | | This also makes device node path is handled with the same logic. Addresses https://github.com/systemd/systemd/pull/27169#discussion_r1162739511. Follow-up for 2c5f119c3cc78bd7da0c7c56b57eca43bac464c1.
* | Merge pull request #27033 from dtardon/array-cleanupYu Watanabe2023-04-121-19/+13
|\ \ | |/ |/| Use CLEANUP_ARRAY more