Commit Graph
1390 Commits
Author SHA1 Message Date
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
Zbigniew Jędrzejewski-Szmek cc420ae52a Merge pull request #25616 from poettering/chase-symlinks-opendir
chase-symlinks/systemctl: let's handle cases without /proc/ better
2022-12-06 17:10:54 +01:00
Zbigniew Jędrzejewski-Szmek 8608fef36c Merge pull request #25437 from YHNdnzj/systemctl-disable-warn-statically-enabled-services
systemctl: warn if trying to disable a unit with no install info
2022-12-05 10:27:24 +01:00
Mike Yuan 108d35ac7d systemctl: allow suppress the warning of no install info using --no-warn
In cases like packaging scripts, it might be desired to use
enable/disable on units without install info. So, adding an
option '--no-warn' to suppress the warning.
2022-12-03 20:26:19 +08:00
Mike Yuan bf1bea43f1 systemctl: warn if trying to disable a unit with no install info
Trying to disable a unit with no install info is mostly useless, so
adding a warning like we do for enable (with the new dbus method
'DisableUnitFilesWithFlagsAndInstallInfo()'). Note that it would
still find and remove symlinks to the unit in /etc, regardless of
whether it has install info or not, just like before. And if there are
actually files to remove, we suppress the warning.

Fixes #17689
2022-12-03 20:26:14 +08:00
Lennart Poettering 0f958c8d4f systemctl: print a clear warning if people invoke systemctl without /proc/ 2022-12-02 23:56:20 +01:00
Yu Watanabe 719b7d4dc2 fuzz-systemctl: limit the size of input
Fixes [oss-fuzz#53552](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53552).
Fixes #25445.
2022-12-02 14:22:25 +01:00
Mike Yuan 3185360980 systemctl: deprecate passing positional argument to reboot completely
(follow-up of #15958)

In #15958 we deprecated passing positional argument to reboot by
generate a warning. It's been two years now and I believe it can
be dropped completely, as per requested in #15773.
2022-11-27 11:18:32 +01:00
наб 848517ddd4 systemctl: edit: write override files as text files
Instead of stripping the newline off the final would-be line;
continue to reduce an empty-line-only file to an empty file, though

Closes #25303
2022-11-22 01:45:50 +01:00
Pasha Vorobyev d7fe0a6723 MemoryZSwapMax directive to configure new memory.zswap.max cgroup file 2022-11-15 21:15:37 +01:00
Yu Watanabe 0b51a1c8c4 systemctl: do not show unit properties with --all
Fixes a bug introduced by a6e334649d.

Fixes #25343.
2022-11-14 10:00:02 +01:00
Lennart Poettering 08af3cc5a5 strv: move nulstr utilities to nulstr-util.[ch]
Let's move them out of the generic, already very long strv.[ch] module
into the more specific nulst-util.[ch]

No code changes.
2022-11-13 17:39:08 +09:00
Zbigniew Jędrzejewski-Szmek ee617a4e5c basic: move a bunch of cmdline-related funcs to new argv-util.c+h
I wanted to move saved_arg[cv] to process-util.c+h, but this causes problems:
process-util.h includes format-util.h which includes net/if.h, which conflicts
with linux/if.h. So we can't include process-util.h in some files.

But process-util.c is very long anyway, so it seems nice to create a new file.
rename_process(), invoked_as(), invoked_by_systemd(), and argv_looks_like_help()
which lived in process-util.c refer to saved_argc and saved_argv, so it seems
reasonable to move them to the new file too.

util.c is now empty, so it is removed. util.h remains.
2022-11-08 18:21:10 +01:00