Commit Graph
1523 Commits
Author SHA1 Message Date
David Tardon c6b9baaa5b systemctl: drop stray empty line 2023-03-17 10:47:44 +01:00
David Tardon bb7c4a93ea systemctl: always print circular deps. at the end
Before:
a.target
○ └─b.target
    ├─...
●   └─paths.target

After:
a.target
○ └─b.target
●   ├─paths.target
    └─...
2023-03-17 10:47:04 +01:00
David Tardon 5a4711e489 systemctl: fix formatting of circular dep.
Before:
a.target
○ └─b.target
    └─...
●   └─paths.target

After:
a.target
○ └─b.target
    ├─...
●   └─paths.target
2023-03-17 10:09:07 +01:00
David Tardon a9f2f486f3 systemctl: fix indentation of circular deps
We're still at level `level` here.

Before:
b.target
○ ├─a.target
  │   └─...
● └─paths.target

After:
b.target
○ ├─a.target
  │ └─...
● └─paths.target

Fixes #26052.
2023-03-17 10:05:47 +01:00
Daan De Meyer f5abe8f957 Merge pull request #26784 from DaanDeMeyer/chase-fix
Allow creating files and directories with chase_symlinks_open() and further improvements
2023-03-15 15:51:47 +01:00
Daan De Meyer 06344330a1 chase-symlinks: Remove unused ret_fd arguments 2023-03-14 13:46:58 +01:00
Mike Yuan 1433e1f998 systemctl: add option --when for scheduled shutdown
Pass an empty string or "cancel" will cancel the action.
Pass "show" will show the scheduled actions.

Replaces #17258
2023-03-14 19:21:11 +08:00
Mike Yuan 92b00e8678 systemctl: logind: make logind_schedule_shutdown accept action as param 2023-03-14 19:21:11 +08:00
Mike Yuan 9071eea01b systemctl: logind: add missing asserts 2023-03-14 19:21:06 +08:00
Yu Watanabe d77d42ed3a systemctl: refuse to acquire dbus connection with --global
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.
2023-03-13 12:27:34 +01:00
Yu Watanabe 321291d82b systemctl-edit: invert one error check 2023-03-11 22:19:22 +09:00
Yu Watanabe 7a2a7f2c00 systemctl-edit: shorten code a bit 2023-03-11 22:19:22 +09:00
Mike Yuan 90c462bdd1 systemctl: edit: several cleanups 2023-03-11 02:02:44 +08:00
Mike Yuan 9a11b4f953 edit-util: introduce EditFileContext
This is a rather large change which moves
the add and install logic into edit-util.

We store an EditFile array and the number of
elements, along with the edit markers used in
temporary files and whether to remove the parent
directories of the target files if they're empty
in an EditFileContext object.

Call edit_files_add() to add an file to edit,
and do_edit_files_and_install() to do the actual
editing (through create_edit_temp_file(),
run_editor() and trim_edit_markers()).
After that, edit_file_context_done() can be used
to destroy the object.
2023-03-11 02:01:00 +08:00
Mike Yuan a01c4bc9af shared: extract edit-util from systemctl-edit 2023-03-11 01:38:52 +08:00
Lennart Poettering 40d73340fa runtime-scope: add helper that turns RuntimeScope enum into --system/--user string 2023-03-10 09:47:58 +01:00
Lennart Poettering 4870133bfa basic: add RuntimeScope enum
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.
2023-03-10 09:47:39 +01:00
Yu Watanabe 9ecacf1eae systemctl: port FOREACH_ARRAY() to systemctl-list-units.c 2023-03-07 13:27:18 +09:00
Frantisek Sumsal c63bfd0884 systemctl: explicitly cast the constants to uint64_t
Otherwise under certain conditions `va_arg()` might get garbage instead
of the expected value, i.e.:

$ sudo build-o0/systemctl disable asdfasfaf
sd_bus_message_appendv: Got uint64_t: 0
Failed to disable unit: Unit file asdfasfaf.service does not exist.

$ sudo build-o1/systemctl disable asdfasfaf
sd_bus_message_appendv: Got uint64_t: 7954875719681572864
Failed to disable unit: Invalid argument

(reproduced on an armv7hl machine)

Resolves: #26568
Follow-up to: bf1bea43f1
Related issue: https://github.com/systemd/systemd/pull/14470#discussion_r362893735
2023-03-03 15:57:34 +00:00
David Tardon 7c78a19322 systemctl: print better message if default target is masked
If the default target is masked, `systemctl get-default` prints

  Failed to get default target: Operation not possible due to RF-kill

That's a bit too cryptic, so let's make it clear what's actually
happening.

Fixes #26589.
2023-02-28 06:45:15 +09:00
Yu Watanabe 43823dfefd systemctl: use bus_message_hash_ops 2023-02-23 19:10:00 +00:00
Yu Watanabe 500ecfd513 Merge pull request #26535 from yuwata/systemctl-list-cleanups
systemctl-list: several cleanups
2023-02-23 21:38:13 +09:00
Zbigniew Jędrzejewski-Szmek a34180a22f Merge pull request #26556 from keszybz/list-timers-optimize-left
Do not say " left" on every timer in LEFT column
2023-02-23 11:37:48 +01:00
Yu Watanabe 1b7b956a9b systemctl: cleanups for list-paths
- Rename struct path_info -> PathInfo,
- Drop struct path_infos,
- Use CLEANUP_ARRAY(),

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 032b3f518c systemctl: cleanups for list-automounts
- Rename struct automount_info -> AutomountInfo,
- use CLEANUP_ARRAY(), and etc.

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 0e351e9a27 systemctl: cleanups for list-timers
- Rename struct timer_info -> TimerInfo,
- use CLEANUP_ARRAY().

No functional change, just refactoring.
2023-02-23 18:00:38 +09:00
Yu Watanabe 1b87606639 systemctl: cleanups for list-sockets
- Rename struct socket_info -> SocketInfo.
- Drop own_triggered field, and always copy the triggered field.
- Use CLEANUP_ARRAY().

No functional changes, just refactoring.
2023-02-23 18:00:24 +09:00
Yu Watanabe f2ccc0d3e1 systemctl-list-units: drop unused return value 2023-02-23 15:13:05 +09:00
Yu Watanabe eef96911e1 systemctl-list-units: fix memleak on error 2023-02-23 15:13:05 +09:00
Zbigniew Jędrzejewski-Szmek de2c4707c1 systemctl: make list-timers not say "left" in "LEFT" column
We would print:
NEXT                        LEFT          LAST                        PASSED        UNIT                           >
Wed 2023-02-22 23:55:00 CET 20min left    Wed 2023-02-22 23:25:00 CET 9min ago      pmlogger_check.timer           >
Wed 2023-02-22 23:55:10 CET 21min left    Wed 2023-02-22 23:25:16 CET 8min ago      pmlogger_farm_check.timer      >
Wed 2023-02-22 23:58:00 CET 23min left    Wed 2023-02-22 23:28:02 CET 6min ago      pmie_check.timer               >
Wed 2023-02-22 23:58:10 CET 24min left    Wed 2023-02-22 23:28:11 CET 5min ago      pmie_farm_check.timer          >
Thu 2023-02-23 00:00:00 CET 25min left    Wed 2023-02-22 00:00:10 CET 23h ago       logrotate.timer                >
Thu 2023-02-23 00:00:00 CET 25min left    Wed 2023-02-22 00:00:10 CET 23h ago       unbound-anchor.timer           >
Thu 2023-02-23 00:08:00 CET 33min left    Wed 2023-02-22 00:08:05 CET 23h ago       pmie_daily.timer               >
Thu 2023-02-23 00:10:00 CET 35min left    Wed 2023-02-22 00:10:03 CET 23h ago       pmlogger_daily.timer           >
Thu 2023-02-23 00:14:14 CET 40min left    Wed 2023-02-22 22:35:09 CET 58min ago     dnf-makecache.timer            >
Thu 2023-02-23 05:05:04 CET 5h 30min left Wed 2023-02-22 03:29:00 CET 20h ago       plocate-updatedb.timer         >
Thu 2023-02-23 11:34:34 CET 12h left      Wed 2023-02-22 11:34:33 CET 11h ago       systemd-tmpfiles-clean.timer   >
Sun 2023-02-26 01:00:00 CET 3 days left   Mon 2023-02-20 07:51:59 CET 2 days ago    raid-check.timer               >
Mon 2023-02-27 00:19:48 CET 4 days left   Mon 2023-02-20 07:51:59 CET 2 days ago    fstrim.timer                   >
Mon 2023-02-27 12:34:36 CET 4 days left   Tue 2023-02-21 08:22:14 CET 1 day 15h ago archlinux-keyring-wkd-sync.time>

The "left" part uses precious screen estate and is pretty much implied
by the column name. Drop it.
2023-02-22 23:43:33 +01:00
Lennart Poettering 976baf26d3 systemctl: read 64bit integers into uint64_t
usec_t is also a uint64_t internally, hence this doesn't actually change
anything. However, on the conceptual level, sd-bus expects a uint64_t
hence give it one.
2023-02-22 19:00:42 +01:00
Lennart Poettering 21ae8c17d4 systemctl: suppress timeout display if unset in list-automounts
If the timeout is zero it's not set, let's suppress the output then.
2023-02-22 19:00:42 +01:00
Lennart Poettering f168919da8 systemctl: right-align left/passed columns in list-timers
Timespans are probably best right-aligned, in particular if they
systematically end in either " ago" or " left" because they are used as
"relative timestamps".
2023-02-22 18:59:15 +01:00
Mike Yuan e774d3c9f1 systemctl: warn if units disabled in user scope are still enabled globally
Fixes #18271
2023-02-22 23:05:41 +09:00
Yu Watanabe b59052be26 systemctl: show "Until:" field only for service and scope units
Only service and scope units have RuntimeMaxUSec bus property.
To suppress the "Until:" field for other unit types, the entry must be
initialized with USEC_INFINITY.

Fixes #26473.
2023-02-22 23:04:43 +09:00
Yu Watanabe 4788f635e3 Merge pull request #26203 from medhefgo/meson
meson: Use dicts for test/fuzzer definitions
2023-02-22 10:27:16 +09:00
Yu Watanabe 086234e39b Merge pull request #26491 from dtardon/list-paths
Add systemctl list-paths
2023-02-22 09:29:54 +09:00
David Tardon 5fb5f49bec systemctl: add list-paths verb
Fixes #6054.
2023-02-21 19:03:24 +01:00
David Tardon f748b2d01a systemctl: prepend machine ID to unit ID in list-sockets
We do it that way in all other list-* functions, so let's be consistent.
2023-02-21 17:15:12 +01:00
David Tardon ac1405960a systemctl: extract common code to a function 2023-02-21 17:15:12 +01:00
David Tardon f4384e199d systemctl: use table_add_triggered 2023-02-21 17:15:12 +01:00
David Tardon 531a45f35a systemctl: extract code to a helper function
It will be used more in subsequent commits.
2023-02-21 17:15:12 +01:00
Jan Janssen 2ed35b2f3e meson: Use dicts for fuzzer definitions 2023-02-21 15:10:26 +01:00
Ronan Pigott fe5cb7a7ae systemctl: edit: fix double free of instanced name
There is a double free of unit_name when an instance is used, causing
systemctl --user edit service@instance to abort.
2023-02-19 07:07:15 +09:00
Daan De Meyer a133d2c366 dissect-image: Return mount point fd if requested 2023-02-17 14:58:55 +01:00
Lennart Poettering d06e61996d systemctl: add --kill-value= argument to systemctl
This allows accompanying a signal with a value (as supported for Linux
Realtime signals). This is particularly useful as it allows us to do
stuff like this:

   systemctl kill --kill-whom=main --kill-value=0x300 systemd-journald

In order to ask journald to flush its allocation caches and compact
memory.
2023-02-17 09:55:35 +01:00
Luca Boccassi 53fda560dc core: add support for Startup memory limits
We support separate Startup configurations for CPU and I/O, so
add it for memory too. Only cover cgroupsv2 settings.
2023-02-15 20:01:16 +00:00
Jan Janssen 4a7ee0a521 meson: Do not include headers in source lists
Meson+ninja+compiler do this for us and are better at it.

https://mesonbuild.com/FAQ.html#do-i-need-to-add-my-headers-to-the-sources-list-like-in-autotools
2023-01-24 22:04:03 +01:00
Yu Watanabe 1dcfbc514c systemctl,test: -EBADF instead of -EBADFD
Follow-up for da20baaecc.
2023-01-21 10:47:54 +01:00
Luca Boccassi 71c6f0ac52 Merge pull request #23309 from DaanDeMeyer/log-context
basic: Add log context
2023-01-20 15:01:03 +00:00