summaryrefslogtreecommitdiffstats
path: root/src/systemctl/systemctl-util.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Rename spawn-polkit-agent.c to just polkit-agent.cZbigniew Jędrzejewski-Szmek2024-06-261-1/+1
| | | | | The functions in the file were *not* using the spawn prefix, and the prefix seems completely unnecessary.
* libsystemd: turn json.[ch] into a public APILennart Poettering2024-06-121-1/+1
| | | | | | | | | | | | | | | This is preparation for making our Varlink API a public API. Since our Varlink API is built on top of our JSON API we need to make that public first (it's a nice API, but JSON APIs there are already enough, this is purely about the Varlink angle). I made most of the json.h APIs public, and just placed them in sd-json.h. Sometimes I wasn't so sure however, since the underlying data structures would have to be made public too. If in doubt I didn#t risk it, and moved the relevant API to src/libsystemd/sd-json/json-util.h instead (without any sd_* symbol prefixes). This is mostly a giant search/replace patch.
* systemctl: use FOREACH_ARRAY and FOREACH_ELEMENT moreMike Yuan2024-04-191-2/+2
|
* systemctl: allow connecting to capsule instances with --capsule=/-CLennart Poettering2024-03-141-1/+1
|
* systemctl: generalize GetUnitByPIDFD handlingMike Yuan2024-02-241-0/+148
|
* systemctl-util: use strv_free_and_replace at one more placeMike Yuan2024-02-241-3/+1
|
* systemctl: don't warn unit needs reload if --no-warnMike Yuan2024-02-141-0/+3
|
* systemctl-util: some modernizationsMike Yuan2024-02-091-31/+21
|
* systemctl: swap cached_id_map and cached_name_map at one more placeYu Watanabe2023-12-231-1/+1
| | | | | | | | Follow-up for 2962a508508564ec35f231bd4246846d6d057115. Fortunately, this does not change any behavior. Replaces #30601. Fixes CID#1532831.
* systemctl: clean up check_triggering_unitsMike Yuan2023-09-271-19/+52
| | | | Preparation for #311
* systemctl: make unit_is_masked always query managerMike Yuan2023-09-271-11/+17
|
* tree-wide: remove (void) cast around sync()Lennart Poettering2023-05-191-1/+1
| | | | | | | The call is void anyway, it doesn't return an failure indication. Hence, no need to cast void to (void)... (We got this right in most cases, but forgot some)
* chase-symlinks: Rename chase_symlinks() to chase()Daan De Meyer2023-03-241-2/+2
| | | | | | | | | Chasing symlinks is a core function that's used in a lot of places so it deservers a less verbose names so let's rename it to chase() and chaseat(). We also slightly change the pattern used for the chaseat() helpers so we get chase_and_openat() and similar.
* systemctl: refuse to acquire dbus connection with --globalYu Watanabe2023-03-131-0/+3
| | | | | | | | | Maybe, better to check the runtime scope each verb for better log message, but this is a good start point to not trigger assertion. Fixes oss-fuzz#56915 (https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=56915). Fixes #26402 and #26754.
* basic: add RuntimeScope enumLennart Poettering2023-03-101-10/+6
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* systemctl: list-dependencies: support --type= and --state=Mike Yuan2023-01-161-0/+29
| | | | Closes #25975
* systemctl: include upheld units in dependenciesDavid Tardon2022-07-171-1/+3
| | | | Fixes: #22706
* systemctl: drop color settings in log messageYu Watanabe2022-07-071-3/+1
| | | | `log_warning()` colorize the message gracefully.
* systemctl: simplify code a bitZbigniew Jędrzejewski-Szmek2022-06-091-4/+5
| | | | | gcc insists that bus may be used unitialized here, but I don't see any possibility of that.
* Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-291-5/+5
| | | | | | | | | As suggested in https://github.com/systemd/systemd/pull/22649/commits/8b3ad3983f5440eef812b34e5ed862ca59fdf7f7#r837345892 The define is generalized and moved to path-lookup.h, where it seems to fit better. This allows a recursive include to be removed and in general makes things simpler.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-191-6/+1
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* systemctl: fix operations on relative pathsZbigniew Jędrzejewski-Szmek2022-03-181-9/+6
| | | | | | | | | | | | | We should treat ./some.service and $PWD/some.service as equivalent. But we'd try to send the relative paths over dbus, which can't work well: $ sudo systemctl enable ./test2.service Failed to look up unit file state: Invalid argument $ sudo systemctl enable $PWD/test2.service Created symlink /etc/systemd/system/multi-user.target.wants/test2.service → /home/zbyszek/src/systemd/test2.service. Created symlink /etc/systemd/system/test2.service → /home/zbyszek/src/systemd/test2.service. Now both are equivalent.
* tree-wide: use strv_contains() in more placesZbigniew Jędrzejewski-Szmek2022-03-181-1/+1
|
* tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
| | | | | | | | (Or when -H is used, since -H and -M are incompatible.) Note that the slightly unusual form with separate boolean variables (hint_vars, hint_addr) instead of e.g. a const char* variable to hold the message, because this way we don't trigger the warning about non-literal format.
* basic: spit out chase_symlinks() from fs-util.[ch] → chase-symlinks.[ch]Lennart Poettering2021-10-051-0/+1
|
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-1/+1
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* alloc-util: simplify GREEDY_REALLOC() logic by relying on malloc_usable_size()Lennart Poettering2021-05-191-5/+3
| | | | | | | | | | | | | | | | | | | | | | | | We recently started making more use of malloc_usable_size() and rely on it (see the string_erase() story). Given that we don't really support sytems where malloc_usable_size() cannot be trusted beyond statistics anyway, let's go fully in and rework GREEDY_REALLOC() on top of it: instead of passing around and maintaining the currenly allocated size everywhere, let's just derive it automatically from malloc_usable_size(). I am mostly after this for the simplicity this brings. It also brings minor efficiency improvements I guess, but things become so much nicer to look at if we can avoid these allocation size variables everywhere. Note that the malloc_usable_size() man page says relying on it wasn't "good programming practice", but I think it does this for reasons that don't apply here: the greedy realloc logic specifically doesn't rely on the returned extra size, beyond the fact that it is equal or larger than what was requested. (This commit was supposed to be a quick patch btw, but apparently we use the greedy realloc stuff quite a bit across the codebase, so this ends up touching *a*lot* of code.)
* systemctl: reduce scope of iterator variablesZbigniew Jędrzejewski-Szmek2021-02-151-5/+3
|
* tree-wide: propagate error code from _from_string() functionsZbigniew Jędrzejewski-Szmek2021-02-101-1/+1
| | | | Now that we know we have something useful, no need to make an answer up.
* systemctl: unit_file_find_fragment() doesn't log about errors, hence do it ↵Lennart Poettering2021-01-141-1/+1
| | | | in the caller
* systemctl: explicitly comment two cases where we don't log on error cases, ↵Lennart Poettering2021-01-141-3/+6
| | | | on purpose
* systemctl: properly initialize return params in all success casesLennart Poettering2021-01-141-2/+2
|
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* sd-bus: add custom return code when $XDG_RUNTIME_DIR is not setZbigniew Jędrzejewski-Szmek2020-10-141-1/+1
| | | | | | | We would return ENOENT, which is extremely confusing. Strace is not helpful because no *file* is actually missing. So let's add some logs at debug level and also use a custom return code. Let all user-facing utilities print a custom error message in that case.
* systemctl: split up humungous systemctl.c fileLennart Poettering2020-10-071-0/+936
This is just some refactoring: shifting around of code, not change in codeflow. This splits up the way too huge systemctl.c in multiple more easily digestable files. It roughly follows the rule that each family of verbs gets its own .c/.h file pair, and so do all the compat executable names we support. Plus three extra files for sysv compat (which existed before already, but I renamed slightly, to get the systemctl- prefix lik everything else), a -util file with generic stuff everything uses, and a -logind file with everything that talks directly to logind instead of PID1. systemctl is still a bit too complex for my taste, but I think this way itc omes in a more digestable bits at least. No change of behaviour, just reshuffling of some code.