summaryrefslogtreecommitdiffstats
path: root/src/libsystemd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* pidref: fix typoYu Watanabe2024-10-161-1/+1
| | | | Follow-up for de34ec188c4d4f682a337445aa7753259cd7f821.
* json-util: initialize "remote" flag for PidRef when parsing JSON pidref ↵Lennart Poettering2024-10-151-31/+39
| | | | | | | serializations Now that we have a way to recognize "remoteness" of a PidRef, let's make sure when we decode a JSON pidref we initialize things that way.
* Merge pull request #34778 from poettering/userdb-error-tweakLennart Poettering2024-10-152-0/+21
|\ | | | | userdb: handle userbd replies indicating invalid user/group names like record not found
| * sd-varlink: add new sd_varlink_error_is_invalid_parameter() helperLennart Poettering2024-10-152-0/+21
| |
* | Merge pull request #34747 from yuwata/busctl-json-fdLennart Poettering2024-10-153-0/+159
|\ \ | |/ |/| busctl: dump passed fd info
| * sd-json: introduce json_variant_new_fd_info()Yu Watanabe2024-10-152-0/+81
| | | | | | | | Currently this is not used, but will be used later.
| * sd-json: introduce json_variant_new_devnum() and friendsYu Watanabe2024-10-153-0/+78
| |
* | network: add AF_TO_ADDRESS_FAMILY() helperLennart Poettering2024-10-151-0/+12
|/ | | | Make some code a bit shorter.
* sd-json: drop sd_json_dispatch_pid() again, as we prefer ↵Lennart Poettering2024-10-142-39/+0
| | | | | | | | json_dispatch_pidref() now The calls are now unused, and we generally prefer if people send a PID triplet rather than a single PID, hence stop supporting a high-level dispacher for pid_t.
* pidref: hookup PID_AUTOMATIC special pid_t value with PidRefLennart Poettering2024-10-141-1/+14
| | | | | | The PID_AUTOMATIC value is now properly recognized by the PidRef logic too. This needed some massaging of header includes, to ensure pidref.h can access process-util.h's definitions and vice versa.
* Merge pull request #34520 from vcaputo/mmap-cache-unused-minYu Watanabe2024-10-132-7/+14
|\ | | | | mmap-cache: enforce an unused windows minimum
| * mmap-cache: add some stats about files/windows/unusedVito Caputo2024-09-222-5/+7
| | | | | | | | | | Let's give some visibility into the ratio of files:windows:unused by the time we're done using the cache.
| * mmap-cache: enforce an unused windows minimumVito Caputo2024-09-221-2/+7
| | | | | | | | | | | | | | | | | | | | | | | | With many fds the global windows count generally exceeds the minimum. This results in always reusing the unused entry if there is one, which becomes a sort of degenerate case where we're just constantly unmapping->mapping. Instead let's try always have at least several unused windows on the unused list before we resort to churning through it. Fixes #34516
* | Merge pull request #34703 from poettering/pidref-varlinkLennart Poettering2024-10-113-0/+202
|\ \ | | | | | | Serialize "PidRef" in a reasonable way in Varlink interfaces
| * | json: add builder/dispatcher for PidRef → JSON and backLennart Poettering2024-10-113-0/+202
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far, at the one place we sent a PID over Varlink we did so as a simple numeric pid_t value. That's of course is racy, since classic PIDs are recycled too eagerly. Let's address that, by passing around JSON objects distantly resembling our PidRef structure. Note that this JSON object does *not* contain the pidfd, however, but just the pidfd inode number if known. I originally planned to include the pidfd in some direct form, but I figured that's not really the best idea, since we always need a side-channel of some form for that (i.e. AF_UNIX/SCM_RIGHTS), but we should be able to report about PIDs even without that. Moreover, while sending the pid number and pidfd id around should always be OK to do, it's a lot more problematic to always send a pidfd around, since that implies that fd passing is on and it is OK to install fds remotely in some IPC peers fd table. For example, when doing a wild dump of service manager service state we really shouldn't end up with a bunch of fds installed in our client's fd table. Hence, all in all I think it is cleaner to define a structure carrying pid number and pidfd inode id, wich is passed directly as JSON. And then optionally, in a separate field also pass around a pidfd where it makes sense. Note that sending around pidfds is not that beneficial anymore if we have the pidfd inode id, because we can always securely and reliably get a pidfd back from a pair of pid + inode id: first we do pidfd_open() on the pid, and then we check if it is really the right one by comparing .st_ino after fstat(). This logic is implemented gracefully: if for some reason pidfd/pidfd inode nrs are not available (too old kernel), we'll fall back to plain PID numbers. The dispatching logic knows two distinct levels of validation of the provided PID data: if SD_JSON_STRICT is specified we'll acquire a pidfd for the PID, thus verifying it currently exists and failing if it doesn't. If the flag is not set, well just store the provided info as-is, will try to acquire a pidfd for it, but not fail if we cannot. Both modes are important in different contexts. Also note that in addition to the pidfd inode nr we always store the current boot ID of the system in the JSON object, since only the combination of pidfd inode nr and boot ID of the system really is a world-wide unique reference to a process. When dispatching a JSON pid field we operate somewhat gracefully: we either support the triplet structure of pid, pid inode nr, boot id, or we accept a simple classic UNIX pid.
* | | Merge pull request #34681 from ↵Lennart Poettering2024-10-112-0/+65
|\ \ \ | |/ / |/| | | | | | | | ikruglov/ikruglov/io-systemd-Machine-post-merge-review machine: address post-merge review #34623
| * | sd-json: add sd_json_dispatch_pid()Ivan Kruglov2024-10-102-0/+40
| | |
| * | sd-json: add sd_json_dispatch_signal()Ivan Kruglov2024-10-102-0/+25
| | |
* | | sd-netlink: introduce two more _get_family()Yu Watanabe2024-10-101-44/+14
| | | | | | | | | | | | Then, use them in sd_rtnl_message_get_family().
* | | sd-netlink,network: rename functions and RoutingPolicyRule.typeYu Watanabe2024-10-101-6/+6
| | | | | | | | | | | | | | | To make them consistent to the netlink message header. No functional change, just refactoring.
* | | sd-netlink: introduce macros to define sd_rtnl_message setters and gettersYu Watanabe2024-10-101-807/+139
| | |
* | | sd-netlink: make size verifier in sd_netlink_message_read_xyz() stricterYu Watanabe2024-10-102-142/+90
| | | | | | | | | | | | Also, fill remaining output buffer with zero, for safety.
* | | sd-netlink: shorten sd_netlink_message_read_string_strdup() a bitYu Watanabe2024-10-101-17/+3
| | |
* | | sd-netlink: various cleanupsYu Watanabe2024-10-104-201/+213
|/ / | | | | | | | | | | | | - use uint8_t, uint16_t, and so on, rather than unsigned char, unsigned short, and so on, respectively, - rename output parameters to ret or ret_xyz, - add several missing assertions.
* | sd-event: rename output parameters to retYu Watanabe2024-10-101-37/+37
| |
* | Merge pull request #34675 from poettering/dupfd-queryLuca Boccassi2024-10-081-1/+4
|\ \ | | | | | | fd-util: use F_DUPFD_QUERY for same_fd()
| * | fd-util: introduce fd_validate() helperLennart Poettering2024-10-081-1/+4
| | | | | | | | | | | | | | | It just uses F_GETFD to validate an fd. it's a bit easier to read though, and handles the < 0 case internally.
* | | tree-wide: replace reallocarray() with GREEDY_REALLOC()Yu Watanabe2024-10-083-30/+17
| | |
* | | sd-bus: introduce bus_process_cmsg()Yu Watanabe2024-10-081-46/+52
|/ / | | | | | | | | - Close all fds on failure. - Close pidfd on success.
* | sd-json: use sd_json_dispatch_const_string() in sd_json_dispatch_string()Yu Watanabe2024-10-072-22/+8
| | | | | | | | Also, do similar for json_dispatch_user_group_name().
* | tree-wide: drop doubled empty linesYu Watanabe2024-10-073-5/+0
| |
* | path-lookup: move xdg_user_dirs() to xdg-autostart-generatorMike Yuan2024-10-062-37/+0
| | | | | | | | | | | | This is the only place where xdg_user_dir() is needed and makes sense. All other invocations have been replaced with user_search_dirs() - see previous commits for details.
* | path-lookup: refactor lookup_paths_init() search paths handlingMike Yuan2024-10-061-129/+119
| | | | | | | | | | | | | | * Rename user_dirs() -> user_unit_search_dirs() and port to user_search_dirs() * Use STRV_IFNOTNULL to guard paths that could be NULL, assert otherwise
* | path-lookup: introduce user_search_dirs() (shall replace xdg_user_dirs())Mike Yuan2024-10-062-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | xdg_user_dirs() doesn't seem well-organized currently. In all other xdg_user_*() funcs we assume /etc/xdg/systemd to be a symlink to /etc/systemd/, hence it is the odd one out. Also, when the relevant envvar is unset, it only returns the global search dirs. sd_path_lookup() actually covers this nicely with SD_PATH_SEARCH_*, where the combined search paths (from user home and system) are used. Therefore, let's introduce a wrapper for that, and deprecate xdg_user_dirs() (would be removed in later commits).
* | path-lookup: assert that LOOKUP_PATHS_{EXCLUDE,TEMPORARY}_GENERATED are not ↵Mike Yuan2024-10-061-0/+1
| | | | | | | | used in conjunction
* | path-lookup: unify *_generator_binary_paths()Mike Yuan2024-10-063-90/+66
| |
* | path-lookup: modernize get_paths_from_environ()Mike Yuan2024-10-061-27/+19
| | | | | | | | | | Use retval rather than additional param to indicate whether the normal paths shall be appended.
* | path-lookup: shortcut patch_root_prefix() if no root_dirMike Yuan2024-10-061-0/+3
| |
* | path-lookup: unify acquire_{config,control,attached}_dir()Mike Yuan2024-10-061-116/+69
| | | | | | | | | | | | Note that -ENXIO reported by xdg_user_config_dir() is now properly propagated rather than ignored, as unlike XDG_RUNTIME_DIR, XDG_CONFIG_HOME has a default value hence ENXIO is not really expected.
* | path-lookup: use path_strv_contains() rather than strv_contains()Mike Yuan2024-10-061-2/+2
| |
* | path-lookup: clean up acquire_{generator,transient}_dirs() a bitMike Yuan2024-10-061-35/+26
| |
* | path-lookup: modernize runtime_directory() tooMike Yuan2024-10-062-7/+7
| |
* | path-lookup: deduplicate xdg_user_*() with sd_path_lookup()Mike Yuan2024-10-062-87/+25
| | | | | | | | While at it, place ret param at last.
* | path-lookup: move from basic/ to libsystemd/Mike Yuan2024-10-063-26/+1027
| | | | | | | | | | So that sd_path_lookup() can be utilized to replace duplicate functions.
* | path-lookup: move NETWORK_DIRS to network-util.hMike Yuan2024-10-062-0/+5
| |
* | fs-util: rename laccess to access_nofollowMike Yuan2024-10-051-1/+1
| | | | | | | | In order to distinguish it from libc function naming.
* | various: correct laccess() error checkMike Yuan2024-10-041-7/+8
| | | | | | | | laccess is our own macro that uses RET_NERRNO.
* | sd-varlink: mark functions that can take 'more' flag in IDL structures with ↵Lennart Poettering2024-10-023-31/+67
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | an explicit flag Let's mark functions that accept the 'more' flag explicitly for that, and validate for this explicitly. This is preparation for https://github.com/varlink/varlink.github.io/issues/26, if we get that one day. Let's make sure that from day #1 we have this info available even if we don't generate this in the IDL for now. Also enables the two flags for all interfaces we export that use the logic.
* | json: add json_dispatch_const_user_group_name()Lennart Poettering2024-10-012-1/+21
|/ | | | | | | | | | | | | | | | | | This is the same as json_dispatch_user_group_name() but fills in the string as "const char*" to the JSON field. Or in other words, it's what sd_json_dispatch_const_string() is to sd_json_dispatch_string(). Note this drops the SD_JSON_STRICT flags from various dispatch tables for these fields, and replaces this by SD_JSON_RELAX, i.e. the opposite behaviour. As #34558 correctly suggests we should validate user names in lookup functions using the lax rules, rather than the strict ones, since clients not knowing the rules might ask us for arbitrary resolution. (SD_JSON_RELAX internally translates to valid_user_group_name() with the VALID_USER_RELAX flag). See: #34558
* tree-wide: use strv_extend_strv_consume() where appropriateMike Yuan2024-09-211-1/+1
|