summaryrefslogtreecommitdiff
path: root/src/basic
Commit message (Collapse)AuthorAgeFilesLines
* Merge pull request #26506 from keszybz/tiny-cleanupsYu Watanabe2023-02-211-0/+3
|\ | | | | Various trivial cleanups and follow-ups
| * sleep: use shared constant for freeze timeoutZbigniew Jędrzejewski-Szmek2023-02-201-0/+3
| | | | | | | | Let's keep all the timeout definitions in one place.
* | capability-util: use UINT32_MAX as shortcut where appropriateaLennart Poettering2023-02-201-2/+2
| |
* | capability-util: add macro for largest cap we're willing to acceptLennart Poettering2023-02-203-10/+16
| | | | | | | | Let's hide the hard to grasp 62 behind a name.
* | capability-util: add CAP_MASK_ALL + CAP_MASK_UNSET macrosLennart Poettering2023-02-202-15/+19
| | | | | | | | | | | | | | | | | | We should be more careful with distinguishing the cases "all bits set in caps mask" from "cap mask invalid". We so far mostly used UINT64_MAX for both, which is not correct though (as it would mean AmbientCapabilities=~0 followed by AmbientCapabilities=0) would result in capability 63 to be set (which we don't really allow, since that means unset).
* | cap-list: make sure never to accidentally return more than 63 capsLennart Poettering2023-02-201-5/+7
| | | | | | | | | | | | | | | | | | The rest of our codebase stores caps masks in a uint64_t, and also assumes UINT64_MAX was a suitable value for "unset mask". Hence refuse any caps outside of 0…62. (right now the kernel knows 40 caps, hence 22 more to go before we have to reconsider our life's choices.)
* | cap-list: rework capability_set_to_string()Lennart Poettering2023-02-201-22/+15
| | | | | | | | Let's use strextend_with_separator() and CAPABILITY_TO_STRING().
* | cap-list: add CAPABILITY_TO_STRING() macro using compound initialization to ↵Lennart Poettering2023-02-202-1/+24
| | | | | | | | | | | | | | allocate fallback buffer Let's add a helper that can return a numeric string in case we don't recognize a name for a capability.
* | cap-list: refuse parsing numeric capability 63Lennart Poettering2023-02-202-7/+7
| | | | | | | | | | | | | | | | We refuse it otherwise currently, simply because we cannot store it in a uint64_t caps mask value anymore while retaining the ability to use UINT64_MAX as "unset" marker. The check actually was in place already, just one off.
* | cap-list: modernize capability_set_from_string() a bitLennart Poettering2023-02-202-13/+14
| | | | | | | | | | Make return parameter optional. And return whether there were any caps we didn't recognize via 0/1 return value.
* | cap-list: rename capability_set_to_string_alloc() → capability_set_to_string()Lennart Poettering2023-02-202-5/+4
| | | | | | | | | | We typically don't use the _alloc() suffix anymore for anything, hence drop it here too.
* | Merge pull request #26465 from DaanDeMeyer/openat-helpersDaan De Meyer2023-02-202-5/+10
|\ \ | |/ |/| Add more openat() helpers of utility functions
| * env-file: Add write_env_file_at()Daan De Meyer2023-02-202-5/+10
| |
* | process-util: show requested process name in the logYu Watanabe2023-02-191-1/+1
| | | | | | | | This is useful for debugging issues like #26474.
* | shared: move psi-util.[ch] to basic/ so that we can use it in sd-eventLennart Poettering2023-02-173-0/+154
| |
* | util: move mallinfo compat glue from selinux code into generic codeLennart Poettering2023-02-171-0/+24
| |
* | hashmap: fix build with valgrindYu Watanabe2023-02-171-1/+1
| | | | | | | | Follow-up for a2b052b29f8bc141e94a4af95d1653a38a57eaeb.
* | mempool: rework mempool_cleanup() to only release freed tilesLennart Poettering2023-02-174-12/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This substantially reworks mempool_cleanup() so that it releases pools with all freed tiles only, but keeps all pools with still-allocated tiles around. This is more correct, as the previous implementation just released all pools regardless if anything was still used or not. This would make valgrind shut up but would just hide memory leaks altogether. Moreover if called during regular runtime of a program would result in bad memory accesses all over. Hence, let's add a proper implementation and only trim pools we really know are empty. This way we can safely call these functions later, when under memory pressure, at any time.
* | mempool: make mempool_free_tile() return NULLLennart Poettering2023-02-172-3/+10
| | | | | | | | | | | | | | To match how we usually do this current allocation code. (Also, make it accept a NULL pointer, also in order to match behaviour in the rest of our codebase)
* | mempool: introduce new helper pool_ptr()Lennart Poettering2023-02-171-1/+5
| | | | | | | | | | | | | | This new helper returns the beginning of the usable area of the pool object. For now this is only used once, a later commit will use it more.
* | mempool: rename local variable to match current coding styleLennart Poettering2023-02-171-4/+5
| |
* | mempool: use size_t for all memory object sizes and countsLennart Poettering2023-02-171-1/+1
| |
* | hashmap: expose helper for releasing memory pools independently of valgrindLennart Poettering2023-02-174-18/+20
|/ | | | | Let's clean this up and export this always, so that we can later call when we are under memory pressure.
* process-util: add helper get_process_threads()Lennart Poettering2023-02-173-3/+28
| | | | | Let's add a proper helper for querying the number of threads in a process.
* sync-util: port fsync_directory_of_file() to fd_is_opath()Lennart Poettering2023-02-171-10/+6
| | | | | | As suggested here: https://github.com/systemd/systemd/pull/26450#pullrequestreview-1302922404
* Merge pull request #26438 from poettering/event-source-shortenLennart Poettering2023-02-171-0/+1
|\ | | | | sd-event: reduce memory use of sd_event_source objects
| * macro: add macro for determining size of struct with trailing unionLennart Poettering2023-02-171-0/+1
| |
* | Merge pull request #26341 from DaanDeMeyer/chase-fixesLuca Boccassi2023-02-171-29/+36
|\ \ | | | | | | chase-symlinks fixes
| * | chase-symlinks: Always open a dirfd to the root directoryDaan De Meyer2023-02-071-18/+14
| | | | | | | | | | | | | | | Instead of special casing "/", let's just always open a dirfd to the root directory.
| * | chase-symlinks: chase_symlinks_at() AT_FDCWD fixesDaan De Meyer2023-02-071-12/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Whether we should return an absolute path or not is irrelevant to whether CHASE_AT_RESOLVE_IN_ROOT is set. We should only return an absolute path if we are provided one and the directory file descriptor is AT_FDCWD - When the directory file descriptor is AT_FDCWD, we should always resolve symlinks against "/". Currently, if the directory file descriptor is AT_FDCWD and CHASE_AT_RESOLVE_IN_ROOT is set, we resolve symlinks against the current working directory which is almost always not going to be what the caller wants. - Currently, if we provide an absolute path with a positive directory file descriptor without CHASE_AT_RESOLVE_IN_ROOT SET, we interpret the path relative to "/" instead of the given directory file descriptor. Let's make sure that when we're given a positive directory file descriptor, we always resolve the given path relative to it.
* | | Merge pull request #26447 from poettering/sigqueueLennart Poettering2023-02-172-3/+12
|\ \ \ | | | | | | | | pid1/systemctl: add ability to enqueue POSIX RT sigs with associated value to service processes
| * | | strv: add strv_copy_n() helper for copying part of a n strvLennart Poettering2023-02-172-3/+12
| | |/ | |/|
* | | socket-util: make connect_unix_path() work with a NULL pathLennart Poettering2023-02-171-28/+36
| | |
* | | xattr-util: check if fd has O_PATH and do not try setxattr() twiceYu Watanabe2023-02-171-21/+16
| | | | | | | | | | | | Follow-up for a4d2461c46f40c9ae5002a2aea35b35ccb60ef9c.
* | | fd-util: introduce a simple helper to check a file descriptor has O_PATHYu Watanabe2023-02-172-0/+13
|/ /
* | log: add common helper log_set_target_and_open()Lennart Poettering2023-02-162-0/+6
| | | | | | | | | | quite often we want to set a log target and immediately open it. Add a common helper for that.
* | Merge pull request #26410 from DaanDeMeyer/xattr-symlinkLuca Boccassi2023-02-152-0/+76
|\ \ | | | | | | Copy symlink xattrs
| * | xattr-util: Add xsetxattr()Daan De Meyer2023-02-142-0/+76
| | | | | | | | | | | | Like getxattr_malloc() but for setxattr() and friends.
* | | treewide: fix a few typos in NEWS, docs and commentsDmitry V. Levin2023-02-152-2/+2
| | |
* | | tree-wide: fix typo and comment style updateYu Watanabe2023-02-154-4/+4
|/ /
* | various: boldify version outputZbigniew Jędrzejewski-Szmek2023-02-091-1/+2
| | | | | | | | | | | | Follow-up for 4453ebe4db0511d25bed1040930ea6430c1bed91. With the feature list all dandified, the most important part of the output, i.e. the project name and version, are less visible.
* | process-util: add missing error checkLennart Poettering2023-02-081-0/+2
| |
* | core: add cg_path_get_unit_path()Quentin Deslandes2023-02-082-0/+23
|/ | | | | | | | | | From a given cgroup path, cg_path_get_unit() allows to retrieve the unit's name. Although, this removes the path to the unit's cgroup, preventing the result to be used to fetch xattrs. Introduce cg_path_get_unit_path() which provides the path to the unit's cgroup. This function behave similarly to cg_path_get_unit() (checking the validity and escaping the unit's name).
* argv-util: also update program_invocation_short_nameYu Watanabe2023-02-061-0/+4
| | | | | | Our logging uses program_invocation_short_name. Without this patch, logs from forked client may become broken; spuriously truncated or the short invocation name is not completely shown in the log.
* Merge pull request #26269 from keszybz/sysusers-empty-etc-and-improved-messagesLuca Boccassi2023-02-012-29/+21
|\ | | | | sysusers: improve messages and autocreate /etc
| * basic/user-util: create /etc from take_etc_passwd_lockZbigniew Jędrzejewski-Szmek2023-02-011-0/+3
| | | | | | | | | | | | | | | | This allows sysusers to operate with --root that is an empty directory. It may be useful to, for example, populate the user database before installing anything else. firstboot was already doing this, so drop the duplicated call there.
| * basic/user-util: convert prefix_roota→path_join and use _cleanup_ moreZbigniew Jędrzejewski-Szmek2023-02-011-14/+6
| |
| * basic: reword some commentsZbigniew Jędrzejewski-Szmek2023-02-012-14/+11
| | | | | | | | Without commas, the sentences can be hard to parse.
* | core: split system/user job timeouts and make them configurableZbigniew Jędrzejewski-Szmek2023-02-011-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Config options are -Ddefault-timeout-sec= and -Ddefault-user-timeout-sec=. Existing -Dupdate-helper-user-timeout= is renamed to -Dupdate-helper-user-timeout-sec= for consistency. All three options take an integer value in seconds. The renaming and type-change of the option is a small compat break, but it's just at compile time and result in a clear error message. I also doubt that anyone was actually using the option. This commit separates the user manager timeouts, but keeps them unchanged at 90 s. The timeout for the user manager is set to 4/3*user-timeout, which means that it is still 120 s. Fedora wants to experiment with lower timeouts, but doing this via a patch would be annoying and more work than necessary. Let's make this easy to configure.
* | glibc: Conditionally #include <linux/fs.h> to resolve ↵Rudi Heitbaum2023-02-013-0/+4
|/ | | | | | fsconfig_command/mount_attr conflict with glibc 2.36 Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>