summaryrefslogtreecommitdiff
path: root/src
Commit message (Collapse)AuthorAge
* basic: add minimalistic table formatterLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have plenty of code in our codebase that outputs tables to the console, and all is homegrown and awful. Let's replace it with a generic implementation that can do automatically what the old implementations did manually. Features: 1. Ellipsation (for fields overly long) and alignment (for fields overly short) 2. Sorting of rows 3. automatically copies formatting from the same cell in the row above 4. Heavy use of varargs to make putting together tables easy 5. can expand and compress tables, with weights 6. Has a minimal understanding of unicode wide characters in order to match unicode strings to character cell terminals. 7. Columns can be reordered and individually turned off. 8. pretty printing for various data types And more.
* pager: move pager.[ch] src/shared/ → src/basic/Lennart Poettering2018-08-24
| | | | | | | | | pager.[ch] doesn't use any APIs from src/libsystemd/ or src/shared/ hence there's no reason for it to be in src/shared/, let's move it to src/basic/ instead. This enables us to use pager.[ch] APIs from other code in src/basic/, for example pager_have() and suchlike.
* string-util: tweak ellipsation a bitLennart Poettering2018-08-24
| | | | | | | | | | | | | | | | | | | This primarily changes to things: 1. Ellipsation to 0, 1 or 2 characters is now supported. Previously we'd hit an assert if the new lengths was < 3, this is now permitted. The result strings won't show too much info still of course, but the code becomes a bit more generic and robust to use. 2. If a UTF-8 mode is disabled and the input string is pure ASCII, then "..." is used for ellipsation, otherwise (as before) "…". This means on a pure-ASCII system we should remain pure-ASCII, matching behaviour otherwise exposed with special_glyph() and friends. Note that we'll use "…" for ellipsiation as soon as either the locale settings indicate an UTF-8 mode or the input string already contains non-ASCII unicode characters. Testing for these special cases is improved.
* util: add qsort_r_safe(), similar to qsort_safe()Lennart Poettering2018-08-24
|
* utf8: add helper call for counting display width of stringsLennart Poettering2018-08-24
|
* locale: add ellipsis as special glyphLennart Poettering2018-08-24
|
* path-lookup: properly chase paths when reducing with root dir (#8750)Lennart Poettering2018-08-24
| | | | Let's make this correct.
* util-lib: introduce new empty_or_root() helper (#8746)Lennart Poettering2018-08-24
| | | | | | | | We check the same condition at various places. Let's add a trivial, common helper for this, and use it everywhere. It's not going to make things much faster or much shorter, but I think a lot more readable
* polkit: normalize exit values of polkit_agent_open_if_enabled()Lennart Poettering2018-08-24
| | | | | It's strange eating up the errors here, hence don't. Let's leave this to the caller.
* path-util: Finish DEFAULT_PATH_NULSTR with an extra NUL (#8745)Filipe Brandenburger2018-08-24
| | | | | | | | | | | The NULSTR_FOREACH iterator needs to see an empty string at the end, so we need to insert an extra NUL explicitly. Also update PATH0_BIN_SBIN(x) to include an extra NUL terminator, rename it to PATH_BIN_SBIN_NULSTR(x), which is more consistent with the similar CONF_PATHS_NULSTR(x) macro. Fixes: 5008da1ec1cf2cf8c15b702c4052e3a49583095d
* bus-util: introduce bus_open_system_watch_bind_with_description()Yu Watanabe2018-08-24
| | | | | | Similar to 56fbd7187a5af44a90c258fbeb1f17114f226bb3, this adds bus_open_system_watch_bind_with_description() to set description for busses.
* basic/copy: fix awkward sentenceZbigniew Jędrzejewski-Szmek2018-08-24
|
* basic/unit-name: remove duplicate checkZbigniew Jędrzejewski-Szmek2018-08-24
| | | | The check that was right below already covers this case.
* logind: enable limiting of user session scopes using pam context objects (#8397)Jan Synacek2018-08-24
|
* test-execute: make find invocation a bit more efficent, increase timeoutZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | We go through the whole file system, so this test can take arbitrary time. But this test is still quite useful, so let's at least try to make it more efficent by not descending at all into the directories we would filter out later on anyway. Also increase the timeout, in case the previous step doesn't help enough.
* systemd: do not require absolute paths in ExecStartZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | Absolute paths make everything simple and quick, but sometimes this requirement can be annoying. A good example is calling 'test', which will be located in /usr/bin/ or /bin depending on the distro. The need the provide the full path makes it harder a portable unit file in such cases. This patch uses a fixed search path (DEFAULT_PATH which was already used as the default value of $PATH), and if a non-absolute file name is found, it is immediately resolved to a full path using this search path when the unit is loaded. After that, everything behaves as if an absolute path was specified. In particular, the executable must exist when the unit is loaded.
* unit-name: add new unit_name_build_from_type() helperLennart Poettering2018-08-24
| | | | | The new helper is much like unit_name_build() but expects a UnitType value instead of a suffix.
* copy: rearrange flags field definitionLennart Poettering2018-08-24
| | | | Let's use the usual 1U << 0,1,2,3,4 spelling for definiting flags enums.
* copy: reduce number of checksLennart Poettering2018-08-24
| | | | | We check max_bytes twice here, let's simplify that, and reduce one level of indentation.
* copy: drop _unlikely_() that isn't obviously the caseLennart Poettering2018-08-24
| | | | | | | | If a tool only invokes copy_bytes() a single time the _unlikely_() will always be wrong, and is hence not useful. Let's drop it and let the compiler figure our what to do, instead of misleading it. Also, some coding style imprvoements.
* copy: hide in copy_bytes() the strange way splice() handles O_NONBLOCKLennart Poettering2018-08-24
| | | | | | splice() ignores O_NONBLOCK on pipes but not on other fds. Let's handle that properly, and query O_ONBLOCK manually in that case, ensuring systematic behaviour in either case.
* copy: extend copy_bytes() a bitLennart Poettering2018-08-24
| | | | | | | Optionally, when we copy between fds with simple read/write, let's return any remaining data we already read into the buffer if write fails. This is useful to allow callers to use the read data otherwise, perhaps implementing a different fallback for copying.
* copy: tweak reflink logic in copy_bytes() a bitLennart Poettering2018-08-24
| | | | | Let's use btrfs_clone_range() if partial copies are desired. And use btrfs_reflink() only for full-file reflinks.
* copy: add brief comment to copy_bytes() explaining its return valuesLennart Poettering2018-08-24
|
* macro: don't rely on C's downgrade-to-bool feature for numeric comparisonsLennart Poettering2018-08-24
|
* path-util: document a few other special cases for last_path_component()Lennart Poettering2018-08-24
|
* process-util: add TAKE_PID(), similar to TAKE_PTR/TAKE_FD, but for child ↵Lennart Poettering2018-08-24
| | | | process PIDs
* util: introduce typesafe_qsort(), a typesafe version of qsort()/qsort_safe()Lennart Poettering2018-08-24
| | | | | | | | | | | | It does two things: 1. It derives the element size from the array argument type 2. It derives the right type for the function from the array argument type Using this macro call should make the invocations of qsort() quite a bit safer.
* shared/sleep-config: rename misnamed functionZbigniew Jędrzejewski-Szmek2018-08-24
|
* shared/sleep-config: return a custom message when not enough swap for ↵Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | hibernation $ sudo swapoff -av swapoff /dev/vda4 $ sudo systemctl hibernate Failed to hibernate system via logind: Not enough swap space for hibernation Fixes #6729.
* logind: refuse operations if the target unit is masked or unavailableZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | | | | If hibernate.target is masked, and systemctl hibernate is invoked, havoc ensues. logind starts the hibernation operation, but then doesn't go through with it; gnome-shell segfaults. Let's be nice to the user and refuse doing anything in that case. $ sudo systemctl mask hibernate.target $ busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager CanHibernate s "no" $ sudo systemctl hibernate Failed to hibernate system via logind: Access denied Failed to start hibernate.target: Unit hibernate.target is masked. https://bugzilla.redhat.com/show_bug.cgi?id=1468003#c4
* shared/sleep-fix: fix check if s-then-h is possibleZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | can_sleep() returns 0 if the operation is impossible, but the code assumed that negative is returned in that case, in effect reporting s2h was possible even if hibernation or suspend were not possible.
* shared/sleep-config: get rid of explicit allocation size calculationZbigniew Jędrzejewski-Szmek2018-08-24
|
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tmpfiles: add a new return code for "operational failure" when processingZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | Things can fail, and we have no control over it: - file system issues (immutable bits, file system errors, MAC refusals, etc) - kernel refusing certain arguments when writing to /proc/sys or /sys Let's add a new code for the case where we parsed configuration but failed to execute it because of external errors.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* fs-util: add shortcut for chase_symlinks() when it is called like open(O_PATH)Lennart Poettering2018-08-24
| | | | | Let's optimize things, and let the kernel chase the paths if none of the features chase_symlinks() offers are actually used.
* fs-util: add calls that combine chase_symlinks() and open()/opendir() in oneLennart Poettering2018-08-24
| | | | | This is useful when opening files within disk images, as we'll then take the relative root directory properly into account.
* fd-util: introduce fd_reopen() helper for reopening an fdLennart Poettering2018-08-24
| | | | | | We have the same code for this in place at various locations, let's unify that. Also, let's repurpose test-fs-util.c as a test for this new helper cal..
* sd-bus: allow description to be set for system/user busses (#8594)Zbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | | | | | | sd_bus_open/sd_bus_open_system/sd_bus_open_user are convenient, but don't allow the description to be set. After they return, the bus is is already started, and sd_bus_set_description() fails with -EBUSY. It would be possible to allow sd_bus_set_description() to update the description "live", but messages are already emitted from sd_bus_open functions, so it's better to allow the description to be set in sd_bus_open/sd_bus_open_system/sd_bus_open_user. Fixes message like: Bus n/a: changing state UNSET → OPENING
* sleep: Move the error level debugging for write_mode and write_stateMario Limonciello2018-08-24
| | | | | | This makes it more consistent with other code used in the file. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* sleep: Add support for setting a disk offset when hibernatingMario Limonciello2018-08-24
| | | | | | | | | | | The Linux kernel is adding support for configuring the offset into a disk. This allows swapfiles to be more usable as users will no longer need to set the offset on their kernel command line. Use this API in systemd when hibernating as well. Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
* sd-event: use _cleanup_ to manage temporary referencesZbigniew Jędrzejewski-Szmek2018-08-24
|
* tmpfiles: add a new return code for "operational failure" when processingZbigniew Jędrzejewski-Szmek2018-08-24
| | | | | | | | Things can fail, and we have no control over it: - file system issues (immutable bits, file system errors, MAC refusals, etc) - kernel refusing certain arguments when writing to /proc/sys or /sys Let's add a new code for the case where we parsed configuration but failed to execute it because of external errors.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-08-24
|
* bus-util: fix a meaningless assertionYu Watanabe2018-08-24
|
* fs-util: add shortcut for chase_symlinks() when it is called like open(O_PATH)Lennart Poettering2018-08-24
| | | | | Let's optimize things, and let the kernel chase the paths if none of the features chase_symlinks() offers are actually used.
* fs-util: add calls that combine chase_symlinks() and open()/opendir() in oneLennart Poettering2018-08-24
| | | | | This is useful when opening files within disk images, as we'll then take the relative root directory properly into account.
* fd-util: introduce fd_reopen() helper for reopening an fdLennart Poettering2018-08-24
| | | | | | We have the same code for this in place at various locations, let's unify that. Also, let's repurpose test-fs-util.c as a test for this new helper cal..
* core: skip the removal of cgroups in the TEST_RUN_MINIMAL mode (#8622)Evgeny Vereshchagin2018-08-24
| | | | | | | When `systemd` is run in the TEST_RUN_MINIMAL mode, it doesn't really set up cgroups, so it shouldn't try to remove anything. Closes https://github.com/systemd/systemd/issues/8474.