Commit Graph

1402 Commits

Author SHA1 Message Date
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
Luca Boccassi
e0e7bc8223 core: add GetUnitByPIDFD method and use it in systemctl
A pid can be recycled, but a pidfd is pinned. Add a new method that is safer
as it takes a pidfd as input.
Return not only the D-Bus object path, but also the unit id and the last
recorded invocation id, as they are both useful (especially the id, as
converting from a path object to a unit id from a script requires another
round-trip via D-Bus).

Note that the manager still tracks processes by pid, so theorethically this
is not fully error-proof, but on the other hand the method response is
synchronous and the manager is single-threaded, so once a call is being
processed the unit database will not change anyway. Once the manager
switches to use pidfds everywhere, this can be further hardened.
2023-01-18 10:58:46 +01:00
Mike Yuan
3729976944 systemctl: list-dependencies: support --type= and --state=
Closes #25975
2023-01-16 19:46:52 +08:00
Mike Yuan
8e481bd292 systemctl: list-dependencies: pass bool where appropriate 2023-01-13 16:15:32 +08:00
Yu Watanabe
91dfb74ef5 systemctl: suppress warning about missing /proc/ when --no-warn
Follow-up for 0f958c8d4f.

systemctl is called many times by dnf or so, and missing /proc/ is not
a user's fault, but package manager's issue.
With this commit, we can suppress the warning by updating rpm macros if
necessary.
2023-01-12 11:50:41 +09:00
Richard Phibel
cd48e23f6a core: add OpenFile setting 2023-01-10 15:16:26 +01:00
Daan De Meyer
cc232fa094 basic: Use statement expressions more in list.h
Let's use statement expressions to return values instead of passing
in return arguments to the LIST macros.
2023-01-08 16:31:15 +01:00
Mike Yuan
44db9fbb39 systemctl: edit: rephrase edit markers to avoid misunderstanding
Closes #25856
2023-01-05 01:58:05 +01:00
Lennart Poettering
4f06325ce9 fundamental: rework IN_SET() to require at least three arguments
If less than three parameters are passed a simple comparison is the
better choice.

Lo and behold this found two pretty bad typos.
2023-01-02 17:16:50 +01:00
Lennart Poettering
457bbbce7b systemctl: rework how we detect if init is systemd 2022-12-23 18:29:35 +01:00
Antonio Alvarez Feijoo
09ed55c26d systemctl: fix typo 2022-12-21 19:34:25 +09:00
Mike Yuan
f206809b97 systemctl: new option --drop-in for specifying drop-in filename
Previously 'systemctl edit' would only operate on
'override.conf', but users may need more than that.
Thus the new option '--drop-in' is added to allow
users to specify the drop-in file name.

Closes #25767
2022-12-20 15:59:11 +01:00
Zbigniew Jędrzejewski-Szmek
254d1313ae tree-wide: use -EBADF for fd initialization
-1 was used everywhere, but -EBADF or -EBADFD started being used in various
places. Let's make things consistent in the new style.

Note that there are two candidates:
EBADF 9 Bad file descriptor
EBADFD 77 File descriptor in bad state

Since we're initializating the fd, we're just assigning a value that means
"no fd yet", so it's just a bad file descriptor, and the first errno fits
better. If instead we had a valid file descriptor that became invalid because
of some operation or state change, the other errno would fit better.

In some places, initialization is dropped if unnecessary.
2022-12-19 15:00:57 +01:00
Lennart Poettering
557bde331b systemctl: don't unlink non-existing temporary files 2022-12-15 17:54:27 +01:00
Lennart Poettering
1ae886fe28 systemctl: if we edit a single file only, jump to the right line 2022-12-15 17:53:49 +01:00
Lennart Poettering
d88e1e484a systemctl: stop using basename() at one more place 2022-12-15 17:53:07 +01:00
Lennart Poettering
0ce6f0a35a systemctl: line break string where the newlines are 2022-12-15 17:52:26 +01:00
Lennart Poettering
2865507008 systemctl: minor modernizations/simplifications 2022-12-15 17:51:45 +01:00
Lennart Poettering
8eda5560b0 systemctl: simplify trim_edit_markers()
This is not performance sensitive, don#t try to be smart with realloc()

Follow-up for: #25305
Fixes: #25303
2022-12-15 17:51:11 +01:00
Quentin Deslandes
c00b95d5e9 systemctl: add support for LogFilterPatterns for show command
Parse DBus structure send by LogFilterPatterns to print it in systemctl
show.
2022-12-15 09:57:39 +00:00
Mike Yuan
43e48a4738 systemctl: is-*: return correct code when no unit is found
According to systemctl(1), we should use LSB return code 4
(EXIT_PROGRAM_OR_SERVICES_STATUS_UNKNOWN) when the state
is "no such unit" for is-{active,failed,enabled} verbs.

Fixes #25680
2022-12-14 01:43:25 +08:00
Yu Watanabe
9644fbd584 fuzz-systemctl: adjust size limit
Follow-up for 719b7d4dc2.

The size of the current reproducer is 250KB. Hence, 16KB should be
enough, but still we can test most arguments within the size.

Hopefully fixes oss-fuzz#53552.
2022-12-07 09:56:50 +01:00