summaryrefslogtreecommitdiff
path: root/src/systemctl/systemctl-util.c
Commit message (Collapse)AuthorAgeFilesLines
* 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.