summaryrefslogtreecommitdiff
path: root/src/systemctl
Commit message (Collapse)AuthorAgeFilesLines
* fuzz-systemctl-parse-argv: refuse commandlines above 1k entriesZbigniew Jędrzejewski-Szmek2022-05-081-0/+6
| | | | | | | | | | | | | | | oss-fuzz reports timeouts which are created by appending to a very long strv. The code is indeed not very efficient, but it's designed for normal command-line use, where we don't expect more than a dozen of entries. The fact that it is slow with ~100k entries is not particularly interesting. In the future we could rework the code to have better algorithmic complexity. But let's at least stop oss-fuzz from wasting more time on such examples. (My first approach was to set max_len in .options, but apparently this doesn't work for hongfuzz and and AFL.) oss-fuzz-34527: https://oss-fuzz.com/issue/5722283944574976
* systemctl: colorize "enabled" in 'systemctl status ...'amarjargal2022-04-171-3/+20
| | | | | | | | | "enabled" state is highlighted in green and "disabled" state is highlighted in yellow because I felt that white and grey colors were not so distinguishable. Other states are not highlighted. Any other coloring suggestions are welcome! Closes #16932.
* systemctl: show tainted stateLennart Poettering2022-03-313-7/+22
|
* Merge pull request #22649 from ↵Zbigniew Jędrzejewski-Szmek2022-03-2910-29/+29
|\ | | | | | | | | keszybz/symlink-enablement-yet-again-punish-me-harder Fixups to the unit enablement logic
| * Rename UnitFileScope to LookupScopeZbigniew Jędrzejewski-Szmek2022-03-299-23/+23
| | | | | | | | | | | | | | | | | | 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.
| * systemctl: fix silent failure when --root is not foundZbigniew Jędrzejewski-Szmek2022-03-293-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some calls to lookup_path_init() were not followed by any log emission. E.g.: $ SYSTEMD_LOG_LEVEL=debug systemctl --root=/missing enable unit; echo $? 1 Let's add a helper function and use it in various places. $ SYSTEMD_LOG_LEVEL=debug build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory 1 $ SYSTEMCTL_SKIP_SYSV=1 build/systemctl --root=/missing enable unit; echo $? Failed to initialize unit search paths for root directory /missing: No such file or directory Failed to enable: No such file or directory. 1 The repeated error in the second case is not very nice, but this is a niche case and I don't think it's worth the trouble to trying to avoid it.
* | bootspec: normalize function names/parameter listsLennart Poettering2022-03-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | This normalizes naming of functions operating on BootConfig objects. Let's always call them boot_config_xyz(), like our usual way to name stuff. moreover, move the BootConfig parameter to the beginning, as it's not a return value (which we typically move to the end of the parameter list), but simply an object, that even happens to be initialized already. With these changes the functions are more like our usual way to call things, and less surprises are good.
* | bootspec: assess default/selected entries *after* we augmented entry list ↵Lennart Poettering2022-03-281-1/+5
|/ | | | | | with entries from loader Fixes: #22580
* systemctl: use the right name in error messageZbigniew Jędrzejewski-Szmek2022-03-231-1/+1
|
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-232-17/+16
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* strv: make iterator in STRV_FOREACH() declaread in the loopYu Watanabe2022-03-1917-42/+5
| | | | This also avoids multiple evaluations in STRV_FOREACH_BACKWARDS()
* list: declare iterator of LIST_FOREACH() in the loopYu Watanabe2022-03-191-2/+0
|
* 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.
* systemctl: remove unused parameterZbigniew Jędrzejewski-Szmek2022-03-181-3/+3
|
* systemctl: drop left-over parensZbigniew Jędrzejewski-Szmek2022-03-181-2/+2
|
* tree-wide: use strv_contains() in more placesZbigniew Jędrzejewski-Szmek2022-03-182-3/+3
|
* systemctl: use action_table for scheduling shutdownLudwig Nussel2022-02-281-18/+3
| | | | | | The fall-through to reboot doesn't seem to make sense. It won't happen in the current code. Filtering the actions on client side is not needed either as the server will refuse unsupported operations anyway.
* systemctl: Show how long a service ran for after it exited in status outputDaan De Meyer2022-02-231-0/+12
|
* tree-wide: use timestamp_is_set() moreLennart Poettering2022-02-221-2/+2
|
* systemctl: rework daemon_reload() functionsLennart Poettering2022-02-229-32/+67
| | | | | | | | | | Let's split out the inner parts of verb_daemon_reload() as a function daemon_reload() and then stop using the former outside of the verbs logic, and instead call the latter whenever we need to reload the daemon as auxiliary opeation. This should make our logic more systematic as we don't have to provide fake or misleading argc/argv to verb_daemon_reload() anymore.
* systemctl: systematically rename verb entrypoints verb_xyz()Lennart Poettering2022-02-2258-167/+167
| | | | | | | | | Let's clean up our function naming a bit, and always name the verb_xyz(), where the xyz maps to the command line verb as closely as possible. No actual code changes, just an attempt to make the systemctl sources a bit more systematic, and less surprising.
* systemctl: improve error messages related to halt failuresLudwig Nussel2022-02-222-4/+7
|
* systemctl,man: update docs for `--timestamp=`Frantisek Sumsal2022-02-211-5/+2
|
* systemctl: make `--timestamp=` affect the `show` verb as wellFrantisek Sumsal2022-02-191-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently the `--timestamp=` option has no effect on timestamps shown by `systemctl show`, let's fix that. Spotted in #22567. Before: ``` $ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp= ExecMainStartTimestamp=Sat 2021-12-11 15:25:57 CET StateChangeTimestamp=Sat 2021-12-11 15:25:57 CET InactiveExitTimestamp=Sat 2021-12-11 15:25:57 CET ActiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET ActiveExitTimestamp=Sat 2021-12-11 15:25:57 CET InactiveEnterTimestamp=Sat 2021-12-11 15:25:57 CET ConditionTimestamp=Sat 2021-12-11 15:25:57 CET AssertTimestamp=Sat 2021-12-11 15:25:57 CET ``` After: ``` $ systemctl show --timestamp=us+utc systemd-journald | grep Timestamp= ExecMainStartTimestamp=Sat 2021-12-11 14:25:57.177848 UTC StateChangeTimestamp=Sat 2021-12-11 14:25:57.196714 UTC InactiveExitTimestamp=Sat 2021-12-11 14:25:57.177871 UTC ActiveEnterTimestamp=Sat 2021-12-11 14:25:57.196714 UTC ActiveExitTimestamp=Sat 2021-12-11 14:25:57.144677 UTC InactiveEnterTimestamp=Sat 2021-12-11 14:25:57.176331 UTC ConditionTimestamp=Sat 2021-12-11 14:25:57.176980 UTC AssertTimestamp=Sat 2021-12-11 14:25:57.176980 UTC ```
* systemctl: expand error messageZbigniew Jędrzejewski-Szmek2022-02-151-1/+1
|
* systemctl: fix halt -fLudwig Nussel2022-02-141-21/+24
| | | | | Commit adefc8789b always asks logind for shutdown first. So I broke halt -f which is supposed to issue a direct syscall in that case.
* systemctl: use STR_IN_SET() where appropriateLennart Poettering2022-02-031-1/+3
| | | | Follow-up for: 8e98568165ee3db049160045d94ce030dc7fbb79
* systemctl: strings returned by sd_bus_message_read_basic() are immutableLennart Poettering2022-02-021-13/+12
| | | | | | | | | | It's totally not OK to write to the strings returned by it, the data is shared by all code that references the message. While we are at it, simplify the code via json_variant_set_field_string(). Follow-up for: 5ef599b324efbcb7af317c102b59c662df068500
* systemctl: shutdown don't fallback on auth failLudwig Nussel2022-01-253-5/+5
| | | | | | For shutdowns don't fall back to starting the target directly if talking to logind failed with auth failure. That would just lead to another polkit auth attempt.
* systemctl: simplify halt_main()Ludwig Nussel2022-01-251-28/+19
| | | | | | | | | | | The code at this point is not able to tell whether it was called as halt/poweroff/reboot or shutdown with time "now". The code also takes a shortcut to skip logind if called as root. That however means asking shutdown for immediate action won't trigger a wall message. As per https://github.com/systemd/systemd/issues/8424#issuecomment-374677315 all commands should trigger a wall message. That simplifies the code as we can try logind first always.
* meson: Use files() for fuzzersJan Janssen2022-01-111-3/+4
| | | | | | Not having to provide the full path in the source tree is much nicer and the produced lists can also be used anywhere in the source tree.
* systemctl: consistent output for scheduled shutdownsLudwig Nussel2022-01-101-9/+9
| | | | Use same terms when scheduling and showing sheduled shutdowns.
* systemctl: Fix --show timestampLudwig Nussel2022-01-051-1/+1
|
* systemctl: add shutdown --show optionLudwig Nussel2021-12-095-1/+49
| | | | Shows the scheduled shutdown action and time if there's one.
* systemctl: support JSON output for "show-environment"Joris Hartog2021-12-061-4/+49
| | | | | | | | This commit adds a function which converts a bus message containing the environment variables to a JSON object and uses this function to support JSON formatted output for the "systemctl show-environment" command. Fixes #21348
* systemctl: display how long a systemd service will run (#21494)Amir Omidi2021-11-301-2/+13
|
* shared: clean up mkdir.h/label.h situationLennart Poettering2021-11-161-1/+1
| | | | | | | | | | Previously the mkdir_label() family of calls was implemented in src/shared/mkdir-label.c but its functions partly declared ins src/shared/label.h and partly in src/basic/mkdir.h (!!). That's weird (and wrong). Let's clean this up, and add a proper mkdir-label.h matching the .c file.
* Merge pull request #20138 from keszybz/coding-style-variable-declsLuca Boccassi2021-11-059-13/+13
|\ | | | | A coding style tweak and checking of sd_notify() calls and voidification of pager_open()
| * Make pager_open() return voidZbigniew Jędrzejewski-Szmek2021-11-039-13/+13
| |
* | 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.
* Merge pull request #21172 from poettering/fix-systemctl-cgroup-treeLennart Poettering2021-10-291-19/+13
|\ | | | | fix "sytemctl status" cgroup tree output
| * systemctl: make sure "systemctl -M status" shows cgroup tree of container ↵Lennart Poettering2021-10-281-7/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | not host This shows the cgroup tree of the root slice of the container now, by querying the cgroup pid tree via the bus instead of going directly to the cgroupfs. A fallback is kept for really old systemd versions where querying the PID tree was not available. Fixes: #20958
| * systemctl: only fall back to local cgroup display if we talk to local systemdLennart Poettering2021-10-281-1/+1
| | | | | | | | | | | | Otherwise we likely show rubbish because even in local containers we nowadays have cgroup namespacing, hence we likely can't access the cgroup tree from the host at the same place as inside the container.
| * systemctl: use LESS_BY where appropriateLennart Poettering2021-10-281-10/+2
| |
| * systemctl: use empty_to_root() where appropriateLennart Poettering2021-10-281-1/+1
| |
| * systemctl: suppress second argument of ternary op where we canLennart Poettering2021-10-281-1/+1
| |
* | core: add [State|Runtime|Cache|Logs]Directory symlink as second parameterLuca Boccassi2021-10-281-0/+18
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When combined with a tmpfs on /run or /var/lib, allows to create arbitrary and ephemeral symlinks for StateDirectory or RuntimeDirectory. This is especially useful when sharing these directories between different services, to make the same state/runtime directory 'backend' appear as different names to each service, so that they can be added/removed to a sharing agreement transparently, without code changes. An example (simplified, but real) use case: foo.service: StateDirectory=foo bar.service: StateDirectory=bar foo.service.d/shared.conf: StateDirectory= StateDirectory=shared:foo bar.service.d/shared.conf: StateDirectory= StateDirectory=shared:bar foo and bar use respectively /var/lib/foo and /var/lib/bar. Then the orchestration layer decides to stop this sharing, the drop-in can be removed. The services won't need any update and will keep working and being able to store state, transparently. To keep backward compatibility, new DBUS messages are added.
* systemctl: drop redundant "else"Yu Watanabe2021-10-281-4/+4
|
* systemctl: small fixes for MountImages pretty printingLuca Boccassi2021-10-271-10/+10
|
* systemctl: pretty-print ExtensionImages propertyLuca Boccassi2021-10-271-0/+56
| | | | Complex type, so without explicit support 'systemctl show' just prints [unprintable]