Commit Graph

348 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek 32854f7044 systemctl: deprecate blanket import-environment
Importing the full environment is convenient, but it doesn't work too well in
practice, because we get a metric ton of shell-specific crap that should never
end up in the global environment block:

$ systemctl --user show-environment
...
SHELL=/bin/zsh
AUTOJUMP_ERROR_PATH=/home/zbyszek/.local/share/autojump/errors.log
AUTOJUMP_SOURCED=1
CONDA_SHLVL=0
CVS_RSH=ssh
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
DESKTOP_SESSION=gnome
DISPLAY=:0
FPATH=/usr/share/Modules/init/zsh-functions:/usr/local/share/zsh/site-functions:/usr/share/zsh/site-functions:/usr/share/zsh/5.8/functions
GDMSESSION=gnome
GDM_LANG=en_US.UTF-8
GNOME_SETUP_DISPLAY=:1
GUESTFISH_INIT=$'\\e[1;34m'
GUESTFISH_OUTPUT=$'\\e[0m'
GUESTFISH_PS1=$'\\[\\e[1;32m\\]><fs>\\[\\e[0;31m\\] '
GUESTFISH_RESTORE=$'\\e[0m'
HISTCONTROL=ignoredups
HISTSIZE=1000
LOADEDMODULES=
OLDPWD=/home/zbyszek
PWD=/home/zbyszek
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
QTLIB=/usr/lib64/qt-3.3/lib
QT_IM_MODULE=ibus
SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS=0
SESSION_MANAGER=local/unix:@/tmp/.ICE-unix/2612,unix/unix:/tmp/.ICE-unix/2612
SHLVL=0
STEAM_FRAME_FORCE_CLOSE=1
TERM=xterm-256color
USERNAME=zbyszek
WISECONFIGDIR=/usr/share/wise2/
...

Plenty of shell-specific and terminal-specific stuff that have no global
significance.

Let's start warning when this is used to push people towards importing only
specific variables.

Putative NEWS entry:
  * systemctl import-environment will now emit a warning when called without
    any arguments (i.e. to import the full environment block of the called
    program). This command will usually be invoked from a shell, which means
    that it'll inherit a bunch of variables which are specific to that shell,
    and usually to the tty the shell is connected to, and don't have any
    meaning in the global context of the system or user service manager.
    Instead, only specific variables should be imported into the manager
    environment block.

    Similarly, programs which update the manager environment block by directly
    calling the D-Bus API of the manager, should also push specific variables,
    and not the full inherited environment.
2021-01-08 20:01:40 +01:00
Zbigniew Jędrzejewski-Szmek 82651d5b6b man: improve description of environment block creation
This adds a general description of "philosphy" of keeping the environemnt
block small and hints about systemd-run -P env.

The list of generated variables is split out to a subsection. Viewing
the patch with ignoring whitespace changes is recommended.

We don't ignore invalid assignments (except in import-environment to some
extent), previous description was wrong.

For https://bugzilla.redhat.com/show_bug.cgi?id=1912046#c17.
2021-01-08 20:01:40 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Zbigniew Jędrzejewski-Szmek 0dc9fd56a5 man: document what variables are allowed 2020-10-23 15:49:03 +02:00
Lennart Poettering 84fc961082
Merge pull request #17270 from keszybz/less-secure-mode
Use less in "secure" mode when under sudo
2020-10-14 18:33:10 +02:00
Lennart Poettering 612ebf6c91 pager: set $LESSSECURE whenver we invoke a pager
Some extra safety when invoked via "sudo". With this we address a
genuine design flaw of sudo, and we shouldn't need to deal with this.
But it's still a good idea to disable this surface given how exotic it
is.

Prompted by #5666
2020-10-07 09:23:07 +02:00
Zbigniew Jędrzejewski-Szmek 3b1211574b man: use trailing slash on directories in more places 2020-10-05 18:44:05 +02:00
Zbigniew Jędrzejewski-Szmek 6824c132e9 systemctl: add service-log-{level,target} verbs
Heavily inspired by #15622. This adds:
  systemctl service-log-level systemd-resolved
  systemctl service-log-level systemd-resolved info
  systemctl service-log-target systemd-resolved
  systemctl service-log-target systemd-resolved console

We already have systemctl verbs log-level, log-target, and service-watchdogs.
Those two new verbs tie nicely into this scheme.
2020-09-12 10:22:51 +02:00
Zbigniew Jędrzejewski-Szmek 172338d51b systemctl: list unit introspection verbs first, modification second
The list was rather ad hoc, with "reset-failed" sandwiched between
"help" and "list-dependencies". Since a person will usually either want
to introspect state in various ways or modify state in a certain way, let's
put all the introspection commands together and all the ones that actually
have an effect second.
2020-09-09 16:59:18 +02:00
Lennart Poettering 3c719357dc man: extend on the usec/sec discrepancy
Let's document the discrepancy between the Sec and USec suffixing of
unit files and D-Bus properties at three places: in "systemctl show"
(where it already was briefly mentioned), in the D-Bus interface
description (at one place at least, i.e. the most prominent of
properties that encapsulate time values, there are many more) and in the
general man page explaining time values.

By documenting this at all three places I think we now do as much as we
can do about this highlighting the discrepancy of the naming and the
reasons behind it.

Fixes: #2047
2020-08-28 18:01:17 +02:00
Luca Boccassi 46ad9c5378 systemctl: add --timestamp to change timestamp print format
Timestamps for unit start/stop are recorded with microsecond granularity,
but status and show truncate to second granularity by default.
Add a --timestamp=pretty|us|utc option to allow including the microseconds
or to use the UTC TZ to all timestamps printed by systemctl.
2020-08-19 15:30:13 +01:00
Zbigniew Jędrzejewski-Szmek 5cf821acf8 man: do not say that isolate is like switching runlevels
We need to do better here, but for now let's at least not trick
users into nuking their graphical environment. Inspired by #16548.
2020-07-23 15:30:35 +02:00
Zbigniew Jędrzejewski-Szmek bdac560801 tree-wide: drop quotes from around [section]
For users, the square brackets already serve as markup and clearly delineate
the section name from surrounding text. Putting additional markup around that
only adds clutter. Also, we were very inconsistent in using the quotes. Let's
just drop them altogether.
2020-07-06 11:29:05 +02:00
Zbigniew Jędrzejewski-Szmek e9dd698407 tree-wide: fixes for assorted grammar and spelling issues
Fixes #16363. Also includes some changes where I generalized the pattern.
2020-07-06 11:29:05 +02:00
laydervus dae710bef1 #15773 add --reboot-argument to systemctl reboot 2020-05-29 21:22:29 +01:00
Zbigniew Jędrzejewski-Szmek 201632e314 tree-wide: s/time-out/timeout/g
See 3f9a0a522f for justification.
2020-05-26 10:28:59 +02:00
Lennart Poettering c92391f52f
Merge pull request #15692 from keszybz/preset-cleanup
Make systemctl list-unit-files output more useful
2020-05-06 08:19:37 +02:00
Zbigniew Jędrzejewski-Szmek 15d7ab87c4 systemctl: add new enablement state "alias"
For units which are aliases of other units, reporting preset status as
"enabled" is rather misleading. For example, dbus.service is an alias of
dbus-broker.service. In list-unit-files we'd show both as "enabled".  In
particular, systemctl preset ignores aliases, so showing any preset status at
all is always going to be misleading. Let's introduce a new state "alias" and
use that for all aliases.

I was trying to avoid adding a new state, to keep compatibility with previous
behaviour, but for alias unit files it simply doesn't seem very useful to show
any of the existing states. It seems that the clearly showing that those are
aliases for other units will be easiest to understand for users.
2020-05-05 21:50:38 +02:00
Michal Sekletár d9e45bc3ab core: introduce support for cgroup freezer
With cgroup v2 the cgroup freezer is implemented as a cgroup
attribute called cgroup.freeze. cgroup can be frozen by writing "1"
to the file and kernel will send us a notification through
"cgroup.events" after the operation is finished and processes in the
cgroup entered quiescent state, i.e. they are not scheduled to
run. Writing "0" to the attribute file does the inverse and process
execution is resumed.

This commit exposes above low-level functionality through systemd's DBus
API. Each unit type must provide specialized implementation for these
methods, otherwise, we return an error. So far only service, scope, and
slice unit types provide the support. It is possible to check if a
given unit has the support using CanFreeze() DBus property.

Note that DBus API has a synchronous behavior and we dispatch the reply
to freeze/thaw requests only after the kernel has notified us that
requested operation was completed.
2020-04-30 19:02:51 +02:00
Zbigniew Jędrzejewski-Szmek df9578498f resolve: allow setting the log level dynamically as in pid1
This is useful to raise the log level for a single transaction or a few,
without affecting other state of the resolved as a restart would.
The log level can only be set, I didn't bother with having the ability
to restore the original as in pid1.
2020-04-20 15:33:18 +02:00
Zbigniew Jędrzejewski-Szmek 5292c24047 systemctl: add -P as short for --value --property= 2020-04-03 18:24:20 +02:00
Zbigniew Jędrzejewski-Szmek 94c3a838da systemctl: make list-dependencies take multiple arguments
Other similar commands do, no reason not to do this here too.
2020-03-05 08:27:58 +01:00
Lennart Poettering 0b9da3d9e8
Merge pull request #14293 from keur/systemctl_with_dependencies
systemctl: Add --with-dependencies switch
2020-01-13 17:42:55 +01:00
Kevin Kuehler a602a0b44b man: Document systemctl --with-dependencies switch 2020-01-09 22:58:00 -08:00
Felipe Sateler 11fcfc5398 Fix several typos in documentation
Found by lintian
2019-12-24 14:45:40 +01:00
Zbigniew Jędrzejewski-Szmek 3d58bfc01c man: document all pager variables for systemctl and systemd
In those two pages, we need to include individual entries with xi:include to
merge the list less-variables.xml with the other entries, which is obviously
error prone. All variables are supported in both tools so add them.
2019-11-24 13:59:32 +01:00
Zbigniew Jędrzejewski-Szmek 6ab863190d systemctl: add service-watchdogs command
The rationale is the same as for log-level/log-target: this controls the behaviour
of the manager, and belongs in systemctl.
2019-11-18 16:28:38 +01:00
Zbigniew Jędrzejewski-Szmek 38fcb7f766 systemctl: add log-level and log-target commands
This copies the commands log-level and log-target (to query and set the current
settings) from systemd-analyze to systemctl, essentially reverting
a65615ca5d. Controllling the log level settings
of the manager is basic functionality, that should be available even if
systemd-analyze (which is more of an analysis tool) is not installed. This is
like dmesg and journalctl, which should be available even if a debugger and
more advanced tools to analyze the kernel are not available. (Note that dmesg
is used to control the log level too, not just to browse the kernel logs.)

I chose to copy&paste the methods from analyze.c to the new location. There
isn't enough code to share, because acquire_bus() in both places has a
different signature despite the same name, so the only part that is common
is the invocation of sd_bus_set_property().
2019-11-18 16:26:17 +01:00
Kevin Kuehler 132e0b532c man: Document --job-mode=triggering switch 2019-11-05 11:17:56 -08:00
Zbigniew Jędrzejewski-Szmek 1d56bc094c systemctl: emit warning if start is used with globs
Fixes #6379.
2019-10-16 17:33:40 +02:00
Zbigniew Jędrzejewski-Szmek e1fac8a68a Move the Commands section above Options section
For executables which take a verb, we should list the verbs first, and
then options which modify those verbs second. The general layout of
the man page is from general description to specific details, usually
Overview, Commands, Options, Return Value, Examples, References.
2019-10-08 18:21:26 +02:00
Carlo Teubner f06530d86b man/systemctl.xml: fix missing "not" 2019-09-05 07:43:00 +09:00
Zbigniew Jędrzejewski-Szmek 4f0acdb366 man: add note about systemctl stop return value
Fixes #13104.

(I know a lot more could be added to that  man page. This patch only addresses that
once specific complaint.)
2019-07-18 16:20:38 +02:00
Lennart Poettering 5b792edb68 man: add example for setting multiple properties at once
Fixes: #4908
2019-07-12 16:00:23 +02:00
Lennart Poettering 84f8e250ff man: CPUShares= is so 2015
Let's update our example to the brave new cgroupsv2 world, and use
CPUWeight= in our example.
2019-07-12 16:00:13 +02:00
Lennart Poettering 8c8208cb80 man: document new "systemctl clean…" operation 2019-07-11 12:18:51 +02:00
Philip Withnall f627573031 man: Add missing <literal> tags in various man pages
A minor formatting improvement brought to you by the wonders of `git
grep`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-12 10:39:50 +01:00
Lennart Poettering df4a7cb732 man: document the new systemctl --show-transaction option 2019-03-27 12:37:37 +01:00
Zbigniew Jędrzejewski-Szmek 3a54a15760 man: use same header for all files
The "include" files had type "book" for some raeason. I don't think this
is meaningful. Let's just use the same everywhere.

$ perl -i -0pe 's^..DOCTYPE (book|refentry) PUBLIC "-//OASIS//DTD DocBook XML V4.[25]//EN"\s+"http^<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"\n  "http^gms' man/*.xml
2019-03-14 14:42:05 +01:00
Zbigniew Jędrzejewski-Szmek 0307f79171 man: standarize on one-line license header
No need to waste space, and uniformity is good.

$ perl -i -0pe 's|\n+<!--\s*SPDX-License-Identifier: LGPL-2.1..\s*-->|\n<!-- SPDX-License-Identifier: LGPL-2.1+ -->|gms' man/*.xml
2019-03-14 14:29:37 +01:00
Lennart Poettering 97af80c5a7 systemctl: add support for booting into boot menu/entry
(This also removes support for booting into the EFI firmware setup
without logind. That's because otherwise the non-EFI fallback logind
implements can't work.)

Fixes: #9896
2019-03-05 16:52:46 +01:00
Lucas Werkmeister 4fa226ff3b man: systemctl: document effect of --all on journal output
Based on the journalctl documentation of this option added in 23ad99b519
(#10527), but with the first reference to “fields” replaced by “journal
messages”, since I think it’s less common to show other fields with
`systemctl status` (though it’s possible with the `-o` option).
2019-01-06 14:03:16 +01:00
Michael Biebl 1830ac51a4 Revert "systemctl: when removing enablement or mask symlinks, cover both /run and /etc"
Having systemctl disable/unmask remove all symlinks in /etc and /run is
unintuitive and breaks existing use cases.
systemctl should behave symmetrically.
A "systemctl --runtime unmask" should undo a "systemctl --runtime mask"
action.
Say you have a service, which was masked by the admin in /etc.
If you temporarily want to mask the execution of the service (say in a
script), you'd create a runtime mask via "systemctl --runtime mask".
It is is now no longer possible to undo this temporary mask without
nuking the admin changes, unless you start rm'ing files manually.

While it is useful to be able to remove all enablement/mask symlinks in
one go, this should be done via a separate command line switch, like
"systemctl --all unmask".

This reverts commit 4910b35078.

Fixes: #9393
2018-11-27 15:15:52 +01:00
Lennart Poettering ff5bd14bb4 man: document that "list-dependencies --reverse" is pretty incomplete
Fixes: #9681
2018-10-30 15:30:18 +01:00
Lennart Poettering 860cc6df6d man: document that "systemctl reset-failed" also reset the start limit counters
Fixes: #10529
2018-10-30 15:30:18 +01:00
Lucas Werkmeister d5bf4f9b8f man: systemctl: clarify that --lines=0 is allowed (#10375)
The term “positive” is often read to exclude 0 (though “strictly
positive” is sometimes used to clarify this), so let’s explicitly state
that --lines=0 is legal and completely disables journal output.

Motivated by an answer on StackExchange [1].

[1]: https://unix.stackexchange.com/a/475068/44049
2018-10-13 17:31:40 +09:00
Jonas DOREL 6cc2b88275 man: add systemctl suspend-then-hibernate (#10194)
This commit tries to document the systemctl suspend-then-hibernate documentation in the systemctl(1) manpage.

Fixes #10192.
2018-09-28 15:56:48 +02:00
Zbigniew Jędrzejewski-Szmek 23a9ffb093 man: add a description of systemctl return codes
Fixes #10056.
2018-09-14 16:02:48 +02:00
Liberasys 8b247b43c8 man: fix a typo in the documentation (#10003) 2018-09-04 00:35:44 +09:00
Filipe Brandenburger adb6cd9be2 systemctl: add support for --wait to is-system-running
This makes it possible to wait until boot is finished without having to poll
for this command repeatedly, instead using the syntax:

  $ systemctl is-system-running --wait

Waiting is implemented by waiting for the StartupFinished signal to be posted
on the bus.

Register the matcher before checking for the property to avoid race conditions.

Tested by artificially delaying startup with a oneshot service and calling this
command, checked that it emitted `running` and exited with a 0 return code as
soon as the delay service completed startup.

Also tested that booting to degraded state unblocks the command.

Inserted a delay between getting the property and waiting for the signal and
confirmed this seems to work free of race conditions.

Updated the --help text (under --wait) and the man page to document the new
feature.
2018-08-07 09:33:25 +02:00