Commit Graph

1120 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
Lennart Poettering 1b630835df sd-bus: add API for connecting to a specific user's user bus of a specific container
This is unfortunately harder to implement than it sounds. The user's bus
is bound a to the user's lifecycle after all (i.e. only exists as long
as the user has at least one PAM session), and the path dynamically (at
least theoretically, in practice it's going to be the same always)
generated via $XDG_RUNTIME_DIR in /run/.

To fix this properly, we'll thus go through PAM before connecting to a
user bus. Which is hard since we cannot just link against libpam in the
container, since the container might have been compiled entirely
differently. So our way out is to use systemd-run from outside, which
invokes a transient unit that does PAM from outside, doing so via D-Bus.
Inside the transient unit we then invoke systemd-stdio-bridge which
forwards D-Bus from the user bus to us. The systemd-stdio-bridge makes
up the PAM session and thus we can sure tht the bus exists at least as
long as the bus connection is kept.

Or so say this differently: if you use "systemctl -M lennart@foobar"
now, the bus connection works like this:

        1. sd-bus on the host forks off:

                systemd-run -M foobar -PGq --wait -pUser=lennart -pPAMName=login systemd-stdio-bridge

        2. systemd-run gets a connection to the "foobar" container's
           system bus, and invokes the "systemd-stdio-bridge" binary as
           transient service inside a PAM session for the user "lennart"

        3. The systemd-stdio-bridge then proxies our D-Bus traffic to
           the user bus.

sd-bus (on host) → systemd-run (on host) → systemd-stdio-bridge (in container)

Complicated? Well, to some point yes, but otoh it's actually nice in
various other ways, primarily as it makes the -H and -M codepaths more
alike. In the -H case (i.e. connect to remote host via SSH) a very
similar three steps are used. The only difference is that instead of
"systemd-run" the "ssh" binary is used to invoke the stdio bridge in a
PAM session of some other system. Thus we get similar implementation and
isolation for similar operations.

Fixes: #14580
2020-12-15 18:00:15 +01:00
Yu Watanabe db9ecf0501 license: LGPL-2.1+ -> LGPL-2.1-or-later 2020-11-09 13:23:58 +09:00
Lennart Poettering daf71ef61c systemctl: split up humungous systemctl.c file
This is just some refactoring: shifting around of code, not change in
codeflow.

This splits up the way too huge systemctl.c in multiple more easily
digestable files. It roughly follows the rule that each family of verbs
gets its own .c/.h file pair, and so do all the compat executable names
we support. Plus three extra files for sysv compat (which existed before
already, but I renamed slightly, to get the systemctl- prefix lik
everything else), a -util file with generic stuff everything uses, and a
-logind file with everything that talks directly to logind instead of
PID1.

systemctl is still a bit too complex for my taste, but I think this way
itc omes in a more digestable bits at least.

No change of behaviour, just reshuffling of some code.
2020-10-07 23:12:15 +02:00
Lennart Poettering 4dcc0653b5 systemctl: move compare_unit_info() to bus-unit-util.[ch]
It's an auxiliary function to the UnitInfo structures, and very generic.
Let's hence move it over to the other code operating with UnitInfo, even
if it's not used by code outside of systemctl (yet).
2020-10-07 22:19:37 +02:00
Lennart Poettering b8aaceb9b5 systemctl: drop unsused variable original_stdout_is_tty
Unused since de9a8fe18e.
2020-10-07 14:13:19 +02:00
Topi Miettinen 9df2cdd8ec exec: SystemCallLog= directive
With new directive SystemCallLog= it's possible to list system calls to be
logged. This can be used for auditing or temporarily when constructing system
call filters.

---
v5: drop intermediary, update HASHMAP_FOREACH_KEY() use
v4: skip useless debug messages, actually parse directive
v3: don't declare unused variables with old libseccomp
v2: fix build without seccomp or old libseccomp
2020-09-15 12:54:17 +03:00
Zbigniew Jędrzejewski-Szmek e6e691aebf systemctl: give a nice hint about org.freedesktop.LogControl1 when applicable 2020-09-14 22:12:14 +02:00
Zbigniew Jędrzejewski-Szmek d94bab0805 systemctl: immediately reject invalid log levels
Symbolic names and number in the appropriate range are allowed
(log_level_from_string() DTRT already).

The target names are more messy, so we leave the verification to the service.
2020-09-12 10:22:51 +02:00
Zbigniew Jędrzejewski-Szmek 77db9433a7 systemctl: merge log_target(), log_level(), service_log_setting() 2020-09-12 10:22:51 +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 f3f4abad29
Merge pull request #16979 from keszybz/return-log-debug
Fix 'return log_error()' and 'return log_warning()' patterns
2020-09-08 19:54:38 +02:00
Zbigniew Jędrzejewski-Szmek c413bb28df tree-wide: correct cases where return log_{error,warning} is used without value
In various cases, we would say 'return log_warning()' or 'return log_error()'. Those
functions return 0 if no error is passed in. For log_warning or log_error this doesn't
make sense, and we generally want to propagate the error. In the few cases where
the error should be ignored, I think it's better to split it in two, and call 'return 0'
on a separate line.
2020-09-08 17:40:46 +02:00
Zbigniew Jędrzejewski-Szmek 90e74a66e6 tree-wide: define iterator inside of the macro 2020-09-08 12:14:05 +02:00
Christian Göttsche 346543d6f9 selinux/systemctl: create unit file with default context on edit 2020-09-02 09:07:59 +02:00
fangxiuning 6d95e7d9b2
tree-wide: drop pointless zero initialization (#16900) 2020-08-30 06:21:20 +09:00
Zbigniew Jędrzejewski-Szmek 955a632971 tree-wide: use sd_bus_error_has_names() in more places 2020-08-24 19:48:26 +02:00
Luca Boccassi 427353f668 core: add mount options support for MountImages
Follow the same model established for RootImage and RootImageOptions,
and allow to either append a single list of options or tuples of
partition_number:options.
2020-08-20 14:45:40 +01: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
Matt Fenwick c1c28fe2f7 fix typo in systemctl help 2020-08-07 16:57:28 +02:00
Luca Boccassi b3d133148e core: new feature MountImages
Follows the same pattern and features as RootImage, but allows an
arbitrary mount point under / to be specified by the user, and
multiple values - like BindPaths.

Original implementation by @topimiettinen at:
https://github.com/systemd/systemd/pull/14451
Reworked to use dissect's logic instead of bare libmount() calls
and other review comments.
Thanks Topi for the initial work to come up with and implement
this useful feature.
2020-08-05 21:34:55 +01:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
Lennart Poettering 9176326ba2 shared: split out code for printing properties
No code changes, just some refactoring.
2020-06-30 15:09:56 +02:00
Lennart Poettering 807542bece shared: split out code that maps properties to local structs
Just some refactoring, no code changes.
2020-06-30 15:09:35 +02:00
Lennart Poettering 9b71e4ab90 shared: actually move all BusLocator related calls to bus-locator.c 2020-06-30 15:09:19 +02:00
Luca Boccassi d4d55b0d13 core: add RootHashSignature service parameter
Allow to explicitly pass root hash signature as a unit option. Takes precedence
over implicit checks.
2020-06-25 08:45:21 +01:00
Lennart Poettering 6b000af4f2 tree-wide: avoid some loaded terms
https://tools.ietf.org/html/draft-knodel-terminology-02
https://lwn.net/Articles/823224/

This gets rid of most but not occasions of these loaded terms:

1. scsi_id and friends are something that is supposed to be removed from
   our tree (see #7594)

2. The test suite defines an API used by the ubuntu CI. We can remove
   this too later, but this needs to be done in sync with the ubuntu CI.

3. In some cases the terms are part of APIs we call or where we expose
   concepts the kernel names the way it names them. (In particular all
   remaining uses of the word "slave" in our codebase are like this,
   it's used by the POSIX PTY layer, by the network subsystem, the mount
   API and the block device subsystem). Getting rid of the term in these
   contexts would mean doing some major fixes of the kernel ABI first.

Regarding the replacements: when whitelist/blacklist is used as noun we
replace with with allow list/deny list, and when used as verb with
allow-list/deny-list.
2020-06-25 09:00:19 +02:00
Filipe Brandenburger 41d1f469cf log: introduce log_parse_environment_cli() and log_setup_cli()
Presently, CLI utilities such as systemctl will check whether they have a tty
attached or not to decide whether to parse /proc/cmdline or EFI variable
SystemdOptions looking for systemd.log_* entries.

But this check will be misleading if these tools are being launched by a
daemon, such as a monitoring daemon or automation service that runs in
background.

Make log handling of CLI tools uniform by never checking /proc/cmdline or EFI
variables to determine the logging level.

Furthermore, introduce a new log_setup_cli() shortcut to set up common options
used by most command-line utilities.
2020-06-24 16:49:26 +02:00
Tomáš Pospíšek 6df8a6c753
Improve message for scheduled shutdown or reboot
Depending on if the system has been scheduled for shutdown or for reboot pring the corresponding message (and not only "Shutdown"). Prtinting the "wrong" message when rebooting will mislead and panic people. I get these messages via cron from remote servers and it would be bad if those systems actually *did* shut down, as the email from cron is telling me. Those messages cause an adrenalin spike in our team, which wouldn't happen, if the message was "correct"

Fixes #16129.
2020-06-14 10:43:06 +02:00
Lennart Poettering 24bd74ae03
Merge pull request #15940 from keszybz/names-set-optimization
Try to optimize away Unit.names set
2020-06-10 18:52:08 +02:00
Zbigniew Jędrzejewski-Szmek 4562c35527 core: store unit aliases in a separate set
We allocated the names set for each unit, but in the majority of cases, we'd
put only one name in the set:

$ systemctl show --value -p Names '*'|grep .|grep -v ' '|wc -l
564
$ systemctl show --value -p Names '*'|grep .|grep ' '|wc -l
16

So let's add a separate .id field, and only store aliases in the set, and only
create the set if there's at least one alias. This requires a bit of gymnastics
in the code, but I think this optimization is worth the trouble, because we
save one object for many loaded units.

In particular set_complete_move() wasn't very useful because the target
unit would always have at least one name defined, i.e. the optimization to
move the whole set over would never fire.
2020-06-10 09:36:58 +02:00
Zbigniew Jędrzejewski-Szmek c9d243cdef resolvectl,systemctl: reduce scope of variables 2020-06-03 15:31:28 +02:00
Zbigniew Jędrzejewski-Szmek 6cf3011c6c Introduce strcasecmp_ptr() and use it in a few places 2020-06-03 15:31:28 +02:00
laydervus dae710bef1 #15773 add --reboot-argument to systemctl reboot 2020-05-29 21:22:29 +01:00
Michal Koutný 38fee61952 systemctl: Fix frozen state coloring
When unit is in an unhighlighted state, freezer coloring won't be turned off
(active_off is empty) until the end of the TTY output.
2020-05-19 19:35:36 +02:00
Benjamin Robin fbb0b66577 systemctl: Check clean_or_freeze_unit(): Add assert if unknown method 2020-05-13 22:56:42 +02:00
Lennart Poettering 266dd55505 systemctl: fix indentation of 'Active:' field in status output
Somehow two spaces got lost in d9e45bc3ab here, which made the status
output all unaligned. Let's put them back in.
2020-05-13 08:32:40 +02:00
Vito Caputo 8010c205dd systemctl: switch to BusLocator-oriented helpers
Mechanical substitution reducing some verbosity
2020-05-07 08:46:44 -07:00
Lennart Poettering 1fab579743 systemctl: underline whole rows, gapless
Just some tweaking of the output.
2020-05-06 15:40:15 +02:00
Lennart Poettering 45d82c3f1c systemctl: ensure underline for "list-unit-files" empty cells 2020-05-06 15:40:15 +02:00
Lennart Poettering 50098d87fb systemctl: let's tweak how we synthesize a cell for activating unit
Let's create a string cell for the unit if possible (since there can
only be one unit right now, and the JSON alternative output then
generates a string instead of an array for us), an empty cell if empty.
2020-05-06 15:40:15 +02:00
Lennart Poettering bc04bb0d29 systemctl: change column name in "list-sockets" out from "units" to "unit"
All our other tables call the field in singular, hence let's do so here,
too.
2020-05-06 15:40:15 +02:00
Lennart Poettering 0773357ad1 systemctl: show empty cells as '-'
This is mostly relevant for "systemct list-sockets" which can have empty
cells for the activating unit.
2020-05-06 15:40:15 +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 31b8895af7 systemctl: do not show preset state for "static"/"alias"/"generated"/"transient" units
This modifies list-unit-files and status.

The output of list-unit-files would contain various lines with "static
disabled", which is just misleading, because systemctl preset will not touch
those files, so the preset configuration is not relevant. Similarly, for
"generated" and "transient" units, preset state is irrelevant. For "alias"
lines, the preset for the alias target would be used. In all cases let's just
skip preset status in those cases.

Diff for a a Fedora rawhide container:

--- $ systemctl --root=/tmp/root2 list-unit-files
+++ $ build/systemctl --root=/tmp/root2 list-unit-files
@@ -1,125 +1,125 @@
 UNIT FILE                                  STATE    VENDOR PRESET
-proc-sys-fs-binfmt_misc.automount          static   disabled
-dev-hugepages.mount                        static   disabled
-dev-mqueue.mount                           static   disabled
-proc-fs-nfsd.mount                         static   disabled
+proc-sys-fs-binfmt_misc.automount          static
+dev-hugepages.mount                        static
+dev-mqueue.mount                           static
+proc-fs-nfsd.mount                         static
 proc-sys-fs-binfmt_misc.mount              disabled disabled
-sys-fs-fuse-connections.mount              static   disabled
-sys-kernel-config.mount                    static   disabled
-sys-kernel-debug.mount                     static   disabled
-sys-kernel-tracing.mount                   static   disabled
-tmp.mount                                  static   disabled
-var-lib-nfs-rpc_pipefs.mount               static   disabled
+sys-fs-fuse-connections.mount              static
+sys-kernel-config.mount                    static
+sys-kernel-debug.mount                     static
+sys-kernel-tracing.mount                   static
+tmp.mount                                  static
+var-lib-nfs-rpc_pipefs.mount               static
 ostree-finalize-staged.path                disabled enabled
-systemd-ask-password-console.path          static   disabled
-systemd-ask-password-plymouth.path         static   disabled
-systemd-ask-password-wall.path             static   disabled
+systemd-ask-password-console.path          static
+systemd-ask-password-plymouth.path         static
+systemd-ask-password-wall.path             static
 abrt-journal-core.service                  enabled  enabled
 abrt-oops.service                          enabled  enabled
 abrt-pstoreoops.service                    disabled disabled
 abrt-vmcore.service                        enabled  enabled
 abrt-xorg.service                          enabled  enabled
 abrtd.service                              enabled  enabled
-anaconda-direct.service                    static   disabled
-anaconda-nm-config.service                 static   disabled
-anaconda-noshell.service                   static   disabled
-anaconda-pre.service                       static   disabled
-anaconda-shell@.service                    static   disabled
-anaconda-sshd.service                      static   disabled
-anaconda-tmux@.service                     static   disabled
-anaconda.service                           static   disabled
+anaconda-direct.service                    static
+anaconda-nm-config.service                 static
+anaconda-noshell.service                   static
+anaconda-pre.service                       static
+anaconda-shell@.service                    static
+anaconda-sshd.service                      static
+anaconda-tmux@.service                     static
+anaconda.service                           static
 arp-ethers.service                         disabled disabled
 atd.service                                enabled  enabled
 auditd.service                             enabled  enabled
-auth-rpcgss-module.service                 static   disabled
+auth-rpcgss-module.service                 static
 autofs.service                             disabled disabled
-autovt@.service                            enabled  disabled
-blivet.service                             static   disabled
+autovt@.service                            alias
+blivet.service                             static
 blk-availability.service                   disabled disabled
 bluetooth.service                          enabled  enabled
-btattach-bcm@.service                      static   disabled
+btattach-bcm@.service                      static
 certmonger.service                         disabled disabled
-chrony-dnssrv@.service                     static   disabled
+chrony-dnssrv@.service                     static
 chrony-wait.service                        disabled disabled
 chronyd.service                            enabled  enabled
-clean-mount-point@.service                 static   disabled
-cockpit-motd.service                       static   disabled
-cockpit-wsinstance-http-redirect.service   static   disabled
-cockpit-wsinstance-http.service            static   disabled
-cockpit-wsinstance-https-factory@.service  static   disabled
-cockpit-wsinstance-https@.service          static   disabled
-cockpit.service                            static   disabled
+clean-mount-point@.service                 static
+cockpit-motd.service                       static
+cockpit-wsinstance-http-redirect.service   static
+cockpit-wsinstance-http.service            static
+cockpit-wsinstance-https-factory@.service  static
+cockpit-wsinstance-https@.service          static
+cockpit.service                            static
 console-getty.service                      disabled disabled
-container-getty@.service                   static   disabled
+container-getty@.service                   static
 dbus-broker.service                        enabled  enabled
 dbus-daemon.service                        disabled disabled
-dbus-org.bluez.service                     enabled  disabled
-dbus-org.fedoraproject.FirewallD1.service  enabled  disabled
-dbus-org.freedesktop.home1.service         static   disabled
-dbus-org.freedesktop.hostname1.service     static   disabled
-dbus-org.freedesktop.locale1.service       static   disabled
-dbus-org.freedesktop.login1.service        static   disabled
-dbus-org.freedesktop.ModemManager1.service enabled  disabled
-dbus-org.freedesktop.nm-dispatcher.service enabled  disabled
-dbus-org.freedesktop.portable1.service     static   disabled
-dbus-org.freedesktop.timedate1.service     static   disabled
-dbus.service                               enabled  disabled
+dbus-org.bluez.service                     alias
+dbus-org.fedoraproject.FirewallD1.service  alias
+dbus-org.freedesktop.home1.service         alias
+dbus-org.freedesktop.hostname1.service     alias
+dbus-org.freedesktop.locale1.service       alias
+dbus-org.freedesktop.login1.service        alias
+dbus-org.freedesktop.ModemManager1.service alias
+dbus-org.freedesktop.nm-dispatcher.service alias
+dbus-org.freedesktop.portable1.service     alias
+dbus-org.freedesktop.timedate1.service     alias
+dbus.service                               alias
 dbxtool.service                            enabled  enabled
 debug-shell.service                        disabled disabled
-dm-event.service                           static   enabled
+dm-event.service                           static
 dmraid-activation.service                  enabled  enabled
-dnf-makecache.service                      static   disabled
+dnf-makecache.service                      static
 dnsmasq.service                            disabled disabled
-dracut-cmdline.service                     static   disabled
-dracut-initqueue.service                   static   disabled
-dracut-mount.service                       static   disabled
-dracut-pre-mount.service                   static   disabled
-dracut-pre-pivot.service                   static   disabled
-dracut-pre-trigger.service                 static   disabled
-dracut-pre-udev.service                    static   disabled
-dracut-shutdown.service                    static   disabled
+dracut-cmdline.service                     static
+dracut-initqueue.service                   static
+dracut-mount.service                       static
+dracut-pre-mount.service                   static
+dracut-pre-pivot.service                   static
+dracut-pre-trigger.service                 static
+dracut-pre-udev.service                    static
+dracut-shutdown.service                    static
 ead.service                                disabled disabled
-emergency.service                          static   disabled
+emergency.service                          static
 fancontrol.service                         disabled disabled
 firewalld.service                          enabled  enabled
-fprintd.service                            static   disabled
-fstrim.service                             static   disabled
+fprintd.service                            static
+fstrim.service                             static
 getty@.service                             enabled  enabled
-grub-boot-indeterminate.service            static   disabled
+grub-boot-indeterminate.service            static
 gssproxy.service                           disabled disabled
 import-state.service                       enabled  enabled
 initial-setup-reconfiguration.service      disabled disabled
 initial-setup.service                      enabled  disabled
-initrd-cleanup.service                     static   disabled
-initrd-parse-etc.service                   static   disabled
-initrd-switch-root.service                 static   disabled
-initrd-udevadm-cleanup-db.service          static   disabled
-instperf.service                           static   disabled
+initrd-cleanup.service                     static
+initrd-parse-etc.service                   static
+initrd-switch-root.service                 static
+initrd-udevadm-cleanup-db.service          static
+instperf.service                           static
 io.podman.service                          disabled disabled
 irqbalance.service                         enabled  enabled
-iscsi-shutdown.service                     static   disabled
+iscsi-shutdown.service                     static
 iscsi.service                              enabled  disabled
 iscsid.service                             disabled disabled
 iscsiuio.service                           disabled disabled
 iwd.service                                disabled disabled
 kdump.service                              disabled disabled
-kmod-static-nodes.service                  static   disabled
-ldconfig.service                           static   disabled
+kmod-static-nodes.service                  static
+ldconfig.service                           static
 lm_sensors.service                         enabled  enabled
 loadmodules.service                        disabled disabled
-logrotate.service                          static   disabled
-lvm2-lvmpolld.service                      static   enabled
+logrotate.service                          static
+lvm2-lvmpolld.service                      static
 lvm2-monitor.service                       enabled  enabled
-lvm2-pvscan@.service                       static   disabled
-man-db-cache-update.service                static   disabled
+lvm2-pvscan@.service                       static
+man-db-cache-update.service                static
 man-db-restart-cache-update.service        disabled disabled
-mdadm-grow-continue@.service               static   disabled
-mdadm-last-resort@.service                 static   disabled
-mdmon@.service                             static   disabled
+mdadm-grow-continue@.service               static
+mdadm-last-resort@.service                 static
+mdmon@.service                             static
 mdmonitor.service                          enabled  enabled
-mlocate-updatedb.service                   static   disabled
+mlocate-updatedb.service                   static
 ModemManager.service                       enabled  enabled
-modprobe@.service                          static   disabled
+modprobe@.service                          static
 multipathd.service                         enabled  enabled
 ndctl-monitor.service                      disabled disabled
 NetworkManager-dispatcher.service          enabled  enabled
@@ -127,53 +127,53 @@
 NetworkManager.service                     enabled  enabled
 nfs-blkmap.service                         disabled disabled
 nfs-convert.service                        enabled  disabled
-nfs-idmapd.service                         static   disabled
-nfs-mountd.service                         static   disabled
+nfs-idmapd.service                         static
+nfs-mountd.service                         static
 nfs-server.service                         disabled disabled
-nfs-utils.service                          static   disabled
-nfsdcld.service                            static   disabled
+nfs-utils.service                          static
+nfsdcld.service                            static
 nftables.service                           disabled disabled
 nis-domainname.service                     disabled disabled
 oddjobd.service                            disabled disabled
 openhpid.service                           disabled disabled
-ostree-finalize-staged.service             static   disabled
-ostree-prepare-root.service                static   disabled
+ostree-finalize-staged.service             static
+ostree-prepare-root.service                static
 ostree-remount.service                     enabled  enabled
-packagekit-offline-update.service          static   disabled
-packagekit.service                         static   disabled
+packagekit-offline-update.service          static
+packagekit.service                         static
 pcscd.service                              indirect disabled
-plymouth-halt.service                      static   disabled
-plymouth-kexec.service                     static   disabled
-plymouth-poweroff.service                  static   disabled
-plymouth-quit-wait.service                 static   disabled
-plymouth-quit.service                      static   disabled
-plymouth-read-write.service                static   disabled
-plymouth-reboot.service                    static   disabled
-plymouth-start.service                     static   disabled
-plymouth-switch-root.service               static   disabled
+plymouth-halt.service                      static
+plymouth-kexec.service                     static
+plymouth-poweroff.service                  static
+plymouth-quit-wait.service                 static
+plymouth-quit.service                      static
+plymouth-read-write.service                static
+plymouth-reboot.service                    static
+plymouth-start.service                     static
+plymouth-switch-root.service               static
 podman.service                             disabled disabled
-polkit.service                             static   enabled
+polkit.service                             static
 psacct.service                             disabled disabled
 qemu-guest-agent.service                   enabled  enabled
-quotaon.service                            static   disabled
+quotaon.service                            static
 raid-check.service                         disabled disabled
-rc-local.service                           static   disabled
+rc-local.service                           static
 rdisc.service                              disabled disabled
-realmd.service                             static   disabled
-rescue.service                             static   disabled
+realmd.service                             static
+rescue.service                             static
 rngd.service                               enabled  enabled
-rpc-gssd.service                           static   disabled
-rpc-statd-notify.service                   static   disabled
-rpc-statd.service                          static   disabled
+rpc-gssd.service                           static
+rpc-statd-notify.service                   static
+rpc-statd.service                          static
 rpcbind.service                            disabled disabled
 rsyslog.service                            enabled  enabled
 selinux-autorelabel-mark.service           enabled  enabled
-selinux-autorelabel.service                static   disabled
+selinux-autorelabel.service                static
 serial-getty@.service                      disabled disabled
 smartd.service                             enabled  enabled
 sshd-keygen@.service                       disabled disabled
 sshd.service                               enabled  enabled
-sshd@.service                              static   disabled
+sshd@.service                              static
 sssd-autofs.service                        indirect disabled
 sssd-kcm.service                           indirect disabled
 sssd-nss.service                           indirect disabled
@@ -182,84 +182,84 @@
 sssd-ssh.service                           indirect disabled
 sssd-sudo.service                          indirect disabled
 sssd.service                               enabled  enabled
-system-update-cleanup.service              static   disabled
-systemd-ask-password-console.service       static   disabled
-systemd-ask-password-plymouth.service      static   disabled
-systemd-ask-password-wall.service          static   disabled
-systemd-backlight@.service                 static   disabled
-systemd-binfmt.service                     static   disabled
-systemd-bless-boot.service                 static   disabled
+system-update-cleanup.service              static
+systemd-ask-password-console.service       static
+systemd-ask-password-plymouth.service      static
+systemd-ask-password-wall.service          static
+systemd-backlight@.service                 static
+systemd-binfmt.service                     static
+systemd-bless-boot.service                 static
 systemd-boot-check-no-failures.service     disabled disabled
-systemd-boot-system-token.service          static   disabled
-systemd-coredump@.service                  static   disabled
-systemd-exit.service                       static   disabled
-systemd-firstboot.service                  static   disabled
-systemd-fsck-root.service                  static   disabled
-systemd-fsck@.service                      static   disabled
-systemd-halt.service                       static   disabled
-systemd-hibernate-resume@.service          static   disabled
-systemd-hibernate.service                  static   disabled
-systemd-homed.service                      static   disabled
-systemd-hostnamed.service                  static   disabled
-systemd-hwdb-update.service                static   disabled
-systemd-hybrid-sleep.service               static   disabled
-systemd-initctl.service                    static   disabled
-systemd-journal-catalog-update.service     static   disabled
-systemd-journal-flush.service              static   disabled
-systemd-journald.service                   static   disabled
-systemd-journald@.service                  static   disabled
-systemd-kexec.service                      static   disabled
-systemd-localed.service                    static   disabled
-systemd-logind.service                     static   disabled
-systemd-machine-id-commit.service          static   disabled
-systemd-modules-load.service               static   disabled
+systemd-boot-system-token.service          static
+systemd-coredump@.service                  static
+systemd-exit.service                       static
+systemd-firstboot.service                  static
+systemd-fsck-root.service                  static
+systemd-fsck@.service                      static
+systemd-halt.service                       static
+systemd-hibernate-resume@.service          static
+systemd-hibernate.service                  static
+systemd-homed.service                      static
+systemd-hostnamed.service                  static
+systemd-hwdb-update.service                static
+systemd-hybrid-sleep.service               static
+systemd-initctl.service                    static
+systemd-journal-catalog-update.service     static
+systemd-journal-flush.service              static
+systemd-journald.service                   static
+systemd-journald@.service                  static
+systemd-kexec.service                      static
+systemd-localed.service                    static
+systemd-logind.service                     static
+systemd-machine-id-commit.service          static
+systemd-modules-load.service               static
 systemd-network-generator.service          disabled disabled
 systemd-networkd-wait-online.service       disabled disabled
 systemd-networkd.service                   disabled disabled
-systemd-portabled.service                  static   disabled
-systemd-poweroff.service                   static   disabled
+systemd-portabled.service                  static
+systemd-poweroff.service                   static
 systemd-pstore.service                     disabled enabled
-systemd-quotacheck.service                 static   disabled
-systemd-random-seed.service                static   disabled
-systemd-reboot.service                     static   disabled
-systemd-remount-fs.service                 static   disabled
-systemd-repart.service                     static   disabled
+systemd-quotacheck.service                 static
+systemd-random-seed.service                static
+systemd-reboot.service                     static
+systemd-remount-fs.service                 static
+systemd-repart.service                     static
 systemd-resolved.service                   disabled disabled
-systemd-rfkill.service                     static   disabled
-systemd-suspend-then-hibernate.service     static   disabled
-systemd-suspend.service                    static   disabled
-systemd-sysctl.service                     static   disabled
-systemd-sysusers.service                   static   disabled
+systemd-rfkill.service                     static
+systemd-suspend-then-hibernate.service     static
+systemd-suspend.service                    static
+systemd-sysctl.service                     static
+systemd-sysusers.service                   static
 systemd-time-wait-sync.service             disabled disabled
-systemd-timedated.service                  static   disabled
+systemd-timedated.service                  static
 systemd-timesyncd.service                  disabled disabled
-systemd-tmpfiles-clean.service             static   disabled
-systemd-tmpfiles-setup-dev.service         static   disabled
-systemd-tmpfiles-setup.service             static   disabled
-systemd-udev-settle.service                static   disabled
-systemd-udev-trigger.service               static   disabled
-systemd-udevd.service                      static   disabled
-systemd-update-done.service                static   disabled
-systemd-update-utmp-runlevel.service       static   disabled
-systemd-update-utmp.service                static   disabled
-systemd-user-sessions.service              static   disabled
-systemd-userdbd.service                    static   disabled
-systemd-vconsole-setup.service             static   disabled
-systemd-volatile-root.service              static   disabled
-teamd@.service                             static   disabled
+systemd-tmpfiles-clean.service             static
+systemd-tmpfiles-setup-dev.service         static
+systemd-tmpfiles-setup.service             static
+systemd-udev-settle.service                static
+systemd-udev-trigger.service               static
+systemd-udevd.service                      static
+systemd-update-done.service                static
+systemd-update-utmp-runlevel.service       static
+systemd-update-utmp.service                static
+systemd-user-sessions.service              static
+systemd-userdbd.service                    static
+systemd-vconsole-setup.service             static
+systemd-volatile-root.service              static
+teamd@.service                             static
 udisks2.service                            enabled  enabled
-user-runtime-dir@.service                  static   disabled
-user@.service                              static   disabled
+user-runtime-dir@.service                  static
+user@.service                              static
 winbind.service                            disabled disabled
 zram-swap.service                          enabled  disabled
-zram.service                               static   disabled
-system-cockpithttps.slice                  static   disabled
-system-systemd\x2dcryptsetup.slice         static   disabled
-user.slice                                 static   disabled
-cockpit-wsinstance-http-redirect.socket    static   disabled
-cockpit-wsinstance-http.socket             static   disabled
-cockpit-wsinstance-https-factory.socket    static   disabled
-cockpit-wsinstance-https@.socket           static   disabled
+zram.service                               static
+system-cockpithttps.slice                  static
+system-systemd\x2dcryptsetup.slice         static
+user.slice                                 static
+cockpit-wsinstance-http-redirect.socket    static
+cockpit-wsinstance-http.socket             static
+cockpit-wsinstance-https-factory.socket    static
+cockpit-wsinstance-https@.socket           static
 cockpit.socket                             enabled  enabled
 dbus.socket                                enabled  enabled
 dm-event.socket                            enabled  enabled
@@ -280,95 +280,95 @@
 sssd-pam.socket                            disabled disabled
 sssd-ssh.socket                            disabled disabled
 sssd-sudo.socket                           disabled disabled
-syslog.socket                              static   disabled
-systemd-coredump.socket                    static   disabled
-systemd-initctl.socket                     static   disabled
-systemd-journald-audit.socket              static   disabled
-systemd-journald-dev-log.socket            static   disabled
-systemd-journald-varlink@.socket           static   disabled
-systemd-journald.socket                    static   disabled
-systemd-journald@.socket                   static   disabled
+syslog.socket                              static
+systemd-coredump.socket                    static
+systemd-initctl.socket                     static
+systemd-journald-audit.socket              static
+systemd-journald-dev-log.socket            static
+systemd-journald-varlink@.socket           static
+systemd-journald.socket                    static
+systemd-journald@.socket                   static
 systemd-networkd.socket                    disabled disabled
-systemd-rfkill.socket                      static   disabled
-systemd-udevd-control.socket               static   disabled
-systemd-udevd-kernel.socket                static   disabled
-systemd-userdbd.socket                     static   disabled
-anaconda.target                            static   disabled
-basic.target                               static   disabled
-blockdev@.target                           static   disabled
-bluetooth.target                           static   enabled
-boot-complete.target                       static   disabled
-cryptsetup-pre.target                      static   disabled
-cryptsetup.target                          static   disabled
-ctrl-alt-del.target                        enabled  disabled
-default.target                             indirect disabled
-emergency.target                           static   disabled
+systemd-rfkill.socket                      static
+systemd-udevd-control.socket               static
+systemd-udevd-kernel.socket                static
+systemd-userdbd.socket                     static
+anaconda.target                            static
+basic.target                               static
+blockdev@.target                           static
+bluetooth.target                           static
+boot-complete.target                       static
+cryptsetup-pre.target                      static
+cryptsetup.target                          static
+ctrl-alt-del.target                        alias
+default.target                             alias
+emergency.target                           static
 exit.target                                disabled disabled
-final.target                               static   disabled
-getty-pre.target                           static   disabled
-getty.target                               static   disabled
-graphical.target                           static   disabled
+final.target                               static
+getty-pre.target                           static
+getty.target                               static
+graphical.target                           static
 halt.target                                disabled disabled
-hibernate.target                           static   disabled
-hybrid-sleep.target                        static   disabled
-initrd-fs.target                           static   disabled
-initrd-root-device.target                  static   disabled
-initrd-root-fs.target                      static   disabled
-initrd-switch-root.target                  static   disabled
-initrd.target                              static   disabled
+hibernate.target                           static
+hybrid-sleep.target                        static
+initrd-fs.target                           static
+initrd-root-device.target                  static
+initrd-root-fs.target                      static
+initrd-switch-root.target                  static
+initrd.target                              static
 kexec.target                               disabled disabled
-local-fs-pre.target                        static   disabled
-local-fs.target                            static   disabled
+local-fs-pre.target                        static
+local-fs.target                            static
 multi-user.target                          indirect disabled
-network-online.target                      static   disabled
-network-pre.target                         static   disabled
-network.target                             static   disabled
+network-online.target                      static
+network-pre.target                         static
+network.target                             static
 nfs-client.target                          enabled  disabled
-nss-lookup.target                          static   disabled
-nss-user-lookup.target                     static   disabled
-paths.target                               static   disabled
+nss-lookup.target                          static
+nss-user-lookup.target                     static
+paths.target                               static
 poweroff.target                            disabled disabled
-printer.target                             static   disabled
+printer.target                             static
 reboot.target                              enabled  enabled
 remote-cryptsetup.target                   disabled enabled
-remote-fs-pre.target                       static   disabled
+remote-fs-pre.target                       static
 remote-fs.target                           enabled  enabled
-rescue.target                              static   disabled
-rpc_pipefs.target                          static   disabled
-rpcbind.target                             static   disabled
-runlevel0.target                           disabled disabled
-runlevel1.target                           static   disabled
-runlevel2.target                           indirect disabled
-runlevel3.target                           indirect disabled
-runlevel4.target                           indirect disabled
-runlevel5.target                           static   disabled
-runlevel6.target                           enabled  disabled
-selinux-autorelabel.target                 static   disabled
-shutdown.target                            static   disabled
-sigpwr.target                              static   disabled
-sleep.target                               static   disabled
-slices.target                              static   disabled
-smartcard.target                           static   disabled
-sockets.target                             static   disabled
-sound.target                               static   disabled
-sshd-keygen.target                         static   disabled
-suspend-then-hibernate.target              static   disabled
-suspend.target                             static   disabled
-swap.target                                static   disabled
-sysinit.target                             static   disabled
-system-update-pre.target                   static   disabled
-system-update.target                       static   disabled
-time-set.target                            static   disabled
-time-sync.target                           static   disabled
-timers.target                              static   disabled
-umount.target                              static   disabled
+rescue.target                              static
+rpc_pipefs.target                          static
+rpcbind.target                             static
+runlevel0.target                           alias
+runlevel1.target                           alias
+runlevel2.target                           alias
+runlevel3.target                           alias
+runlevel4.target                           alias
+runlevel5.target                           alias
+runlevel6.target                           alias
+selinux-autorelabel.target                 static
+shutdown.target                            static
+sigpwr.target                              static
+sleep.target                               static
+slices.target                              static
+smartcard.target                           static
+sockets.target                             static
+sound.target                               static
+sshd-keygen.target                         static
+suspend-then-hibernate.target              static
+suspend.target                             static
+swap.target                                static
+sysinit.target                             static
+system-update-pre.target                   static
+system-update.target                       static
+time-set.target                            static
+time-sync.target                           static
+timers.target                              static
+umount.target                              static
 chrony-dnssrv@.timer                       disabled disabled
 dnf-makecache.timer                        enabled  enabled
 fstrim.timer                               enabled  enabled
 logrotate.timer                            enabled  enabled
-mdadm-last-resort@.timer                   static   disabled
+mdadm-last-resort@.timer                   static
 mlocate-updatedb.timer                     enabled  enabled
 raid-check.timer                           disabled disabled
-systemd-tmpfiles-clean.timer               static   disabled
+systemd-tmpfiles-clean.timer               static

 371 unit files listed.

In particular, this allows a meaningful comparison to be made:

$ ~/src/systemd/build/systemctl --root=/tmp/root2 list-unit-files|rg 'enabled.*disabled|disabled.*enabled'
ostree-finalize-staged.path                disabled enabled
initial-setup.service                      enabled  disabled
iscsi.service                              enabled  disabled
nfs-convert.service                        enabled  disabled
systemd-pstore.service                     disabled enabled
zram-swap.service                          enabled  disabled
iscsid.socket                              enabled  disabled
iscsiuio.socket                            enabled  disabled
multipathd.socket                          enabled  disabled
nfs-client.target                          enabled  disabled
remote-cryptsetup.target                   disabled enabled

(It turns out that most of the services on this list that are enabled without a
corresponding preset are against rpm packaging and do direct 'systemctl enable'
calls in %post, instead of going through presets as they are supposed to.)

systemctl: also skip preset status in status verb
2020-05-05 22:03:53 +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
Zbigniew Jędrzejewski-Szmek 8f7b256665 shared/install: optionally cache the preset list
When doing list-unit-files with --root, we would re-read the preset
list for every unit. This uses a cache to only do it once. The time
for list-unit-files goes down by about ~30%.

unit_file_query_preset() is also called from src/core/. This patch does not
touch that path, since the saving there are smaller, since preset status is
only read on demand over dbus, and caching would be more complicated.
2020-05-05 21:50:31 +02:00
Zbigniew Jędrzejewski-Szmek c39b7821f6 systemctl: fix --root support in querying presets
We would always look on the host, ignoring --root.
2020-05-05 18:05:32 +02:00