summaryrefslogtreecommitdiff
path: root/src/systemctl
AgeCommit message (Collapse)Author
2017-02-21systemctl: suffix cmdline options that take arguments with =Lennart Poettering
Just to clarify, that these options expect arguments, following our usual style.
2017-02-20tree-wide: add man: to manpage references (#5402)Lucas Werkmeister
Found with: git grep '"[^"]*[a-z0-9]([0-9]\+p\?)' src/ | grep -vF man:
2017-02-20systemctl: Fix condition in start_special() (#5399)Benjamin Robin
2017-02-20Merge pull request #5392 from keszybz/systemctl-editLennart Poettering
systemctl edit & reboot fixlets
2017-02-19systemctl: give a hint about --force --force when communication with manager ↵Zbigniew Jędrzejewski-Szmek
fails The hint is not too explicit, and just refers to the man page, because this option is slightly dangereous. This was we don't have to discuss the limitation in the hint itself. Fixes #4002.
2017-02-19systemctl: fix hint with edit --global/--userZbigniew Jędrzejewski-Szmek
2017-02-19systemctl: fix editing of units with no fragmentZbigniew Jędrzejewski-Szmek
"systemctl --user edit --force --full tmp.mount" would crash, when we'd do basename(NULL). Fix this by creating a new unit or a new override even if not path is found. Tested with: systemctl --user edit --force --full tmp.mount systemctl --user edit --force tmp.mount systemctl --user edit foo@.service systemctl --user edit foo@bar.service systemctl --user edit --full foo@.service systemctl --user edit --full foo@bar.service
2017-02-19systemctl: when told to edit an instance, do not edit the templateZbigniew Jędrzejewski-Szmek
Fixes #5383.
2017-02-19systemctl: fix error messages (#5389)Lucas Werkmeister
2017-02-17copy: change the various copy_xyz() calls to take a unified flags parameterLennart Poettering
This adds a unified "copy_flags" parameter to all copy_xyz() function calls, replacing the various boolean flags so far used. This should make many invocations more readable as it is clear what behaviour is precisely requested. This also prepares ground for adding support for more modes later on.
2017-02-09tree-wide: make bus_map_all_properties return a proper sd_bus_errorLennart Poettering
And then show it, to make things a bit friendlier to the user if we fail acquiring some props. In fact, this fixes a number of actual bugs, where we used an error structure for output that we actually never got an error in.
2017-02-08systemctl: make sure that --now is carried out (#5209)Jan Synacek
When services are already enabled/disabled/masked, make sure that --now still enforces start/stop.
2017-02-07core: when loading .wants and .requires, follow the same logic as .d conf ↵Zbigniew Jędrzejewski-Szmek
dropins Essentially, instead of sequentially adding deps based on all symlinks encountered in .wants and .requires dirs for each name and each unit file load path, iteratate over the load paths and unit names gathering symlinks, then order them based on priority, and then iterate over the final list, adding dependencies. This patch doesn't change the logic too much, except that the order in which dependencies are applied might be different. It wasn't defined before, so that not really a change. Adding filtering on the symlinks is left for later patches.
2017-02-03Merge pull request #5213 from keszybz/systemctl-root-catLennart Poettering
Two fixes to path lookup when --root is used
2017-02-02systemctl: 'show' don't exit with a failure status if the requested property ↵Franck Bui
does not exist (#5201) "systemctl show -pUnknown <service>" used to exit with '0' even if the property passed by '-p' doesn't exist. But since commit 3dced37b7c2c9a5c733817 (v231+), it exits with a failure status. "systemctl show" is supposed to be scriptable and therefore its behavior is supposed to be stable. This patch restores the old behavior on which a couple of scripts already rely now. Also when the requested property doesn't exist, it always logs it at the debug level since this part of the code is only used by the show command. Fixes: #5118
2017-02-02systemctl: also use chase_symlinks for dropinsZbigniew Jędrzejewski-Szmek
The general rule is: - code in shared/ should take an "original_root" argument (possibly NULL) and pass it along down to chase_symlinks - code in core/ should always use specify original_root==NULL, since we don't support running the manager from non-root directory - code in systemctl and other tools should pass arg_root. For any code that is called from tools which support --root, chase_symlinks must be used to look up paths.
2017-02-02systemctl: do not prepend arg_root twice when catting unitsZbigniew Jędrzejewski-Szmek
The paths in lookup_paths already contain the arg_root prefix. Fixes #5190.
2017-02-02systemctl: restore --failed (#5198)Zbigniew Jędrzejewski-Szmek
'systemctl --failed' is an extremely common operation and it's nice to have a shortcut for it. Revert "man: don't document systemctl --failed" and add the option back to systemctl's help and shell completion scripts. This reverts commit 036359ba8d0aba7db7eac75d10073a849a033fd1.
2017-01-31systemctl: ignore SIGTERM after switch rootZbigniew Jędrzejewski-Szmek
https://bugzilla.redhat.com/show_bug.cgi?id=1414904#c14 and #c15.
2017-01-31systemctl: always avoid being killed when doing switch-rootZbigniew Jędrzejewski-Szmek
The same logic as described in acc28e2e3037d689d6481e applies to any time we are switching root, to just set the flag unconditionally.
2017-01-15systemctl: fix alignment with units in not-found stateZbigniew Jędrzejewski-Szmek
A fixed value (6 and later 5) was added back in 4deb3b93911, and not updated when load_len was added later on. Also the other 5 with 1 + 1 + 1 + 1 + 1 to make it easier to see that this is about the column separators.
2017-01-15systemctl: uninitalized variableZbigniew Jędrzejewski-Szmek
CID #1368270. Easily reproduced with COLUMNS=50 ./systemctl --no-pager.
2017-01-11systemctl: remove duplicate entries showed by list-dependencies (#5049)Franck Bui
When a unit is part of several dependency constraints of another unit, list-dependencies repeats the name of the dependency for each dep constraint the unit is encountered. For example: $ systemctl cat test-main.target # /etc/systemd/system/test-main.target [Unit] Description=Main Target $ systemctl cat test.target [Unit] Description=Sub target PartOf=test-main.target [Install] WantedBy=test-main.target $ systemctl enable test.target Created symlink from /etc/systemd/system/test-main.target.wants/test.target to /etc/systemd/system/test.target. $ systemctl show test-main.target | grep test.target Wants=test.target ConsistsOf=test.target [...] $ systemctl list-dependencies test-main.target test-main.target ● ├─test.target ● └─test.target With this patch applied, dependencies are shown only once.
2016-12-20systemctl: do not segfault when we cannot find template unit (#4915)Zbigniew Jędrzejewski-Szmek
Core was generated by `systemctl cat test@.target test@.service'. Program terminated with signal SIGSEGV, Segmentation fault. 32 movdqu (%rdi), %xmm0 (gdb) bt -0 strrchr () at ../sysdeps/x86_64/strrchr.S:32 -1 0x00007f57fdf837fe in __GI___basename (filename=0x0) at basename.c:24 -2 0x000055b8a77d0d91 in unit_find_paths (bus=0x55b8a9242f90, unit_name=0x55b8a92428f0 "test@.service", lp=0x7ffdc9070400, fragment_path=0x7ffdc90703e0, dropin_paths=0x7ffdc90703e8) at src/systemctl/systemctl.c:2584 -3 0x000055b8a77dbae5 in cat (argc=3, argv=0x7ffdc9070678, userdata=0x0) at src/systemctl/systemctl.c:5324 -4 0x00007f57fe55fc6b in dispatch_verb (argc=5, argv=0x7ffdc9070668, verbs=0x55b8a77f1c60 <verbs>, userdata=0x0) at src/basic/verbs.c:92 -5 0x000055b8a77e477f in systemctl_main (argc=5, argv=0x7ffdc9070668) at src/systemctl/systemctl.c:8141 -6 0x000055b8a77e5572 in main (argc=5, argv=0x7ffdc9070668) at src/systemctl/systemctl.c:8412 The right behaviour is not easy in this case. Implement some "sensible" logic. Fixes #4912.
2016-12-01fs-util: add flags parameter to chase_symlinks()Lennart Poettering
Let's remove chase_symlinks_prefix() and instead introduce a flags parameter to chase_symlinks(), with a flag CHASE_PREFIX_ROOT that exposes the behaviour of chase_symlinks_prefix().
2016-11-30systemctl: fix 'is-enabled' exit status on failure when executed in chroot ↵Franck Bui
(#4773)
2016-11-24core: make sure initrd-switch-root command survives PID1's killing spree (#4730)Franck Bui
This is a different way to implement the fix proposed by commit a4021390fef27f4136497328f suggested by Lennart Poettering. In this patch we instruct PID1 to not kill "systemctl switch-root" command started by initrd-switch-root service using the "argv[0][0]='@'" trick. See: https://www.freedesktop.org/wiki/Software/systemd/RootStorageDaemons/ for more details. We had to backup argv[0] because argv is modified by dispatch_verb().
2016-11-16core/dbus-job, systemctl: shorten some codeZbigniew Jędrzejewski-Szmek
2016-11-16systemctl: shorter list-jobs --before/--after output a bitZbigniew Jędrzejewski-Szmek
(before)$ systemctl list-jobs --before --after JOB UNIT TYPE STATE 8769 foobar.device start running A job waits for this job: 8669 (run-rb6da596d0cfa4e36b7c594cd973e795a.service/start) 8669 run-rb6da596d0cfa4e36b7c594cd973e795a.service start waiting This job waits for a job: 8769 (foobar.device/start) 2 jobs listed. (after)$ systemctl list-jobs --before --after JOB UNIT TYPE STATE 8769 foobar.device start running waiting for job 8669 (run-rb6da596d0cfa4e36b7c594cd973e795a.service/start) 8669 run-rb6da596d0cfa4e36b7c594cd973e795a.service start waiting blocking job 8769 (foobar.device/start) 2 jobs listed.
2016-11-16systemctl: show waiting jobs when "systemctl list-jobs --after/--before" is ↵Lennart Poettering
called Let's expose the new bus functions we added in the previous commit in systemctl.
2016-11-16systemctl: add env var to force connection to system manager via the busLennart Poettering
Sometimes it is useful for debugging purposes to force systemctl to connect to PID 1 via the bus instead of direct connection, even if the direct connection is possible.
2016-11-11systemctl: resolve symlinks when finding unit paths (#4545)Felipe Sateler
Otherwise we think the alias is the real unit, and may edit/cat the wrong unit. Before this patch: $ systemctl edit autovt@ # creates dropin in /etc/systemd/system/autovt@.service.d $ systemctl cat autovt@ | grep @.service # /lib/systemd/system/autovt@.service # that serial gettys are covered by serial-getty@.service, not this # /etc/systemd/system/autovt@.service.d/override.conf $ systemctl cat getty@ | grep @.service # /lib/systemd/system/getty@.service # that serial gettys are covered by serial-getty@.service, not this After this patch $ systemctl edit autovt@ # creates dropin in /etc/systemd/system/getty@.service.d $ systemctl cat autovt@ | grep @.service # /usr/lib/systemd/system/getty@.service # that serial gettys are covered by serial-getty@.service, not this # /etc/systemd/system/getty@.service.d/override.conf systemctl cat getty@ | grep @.service # /usr/lib/systemd/system/getty@.service # that serial gettys are covered by serial-getty@.service, not this # /etc/systemd/system/getty@.service.d/override.conf
2016-11-11tree-wide: make invocations of extract_first_word more uniform (#4627)Zbigniew Jędrzejewski-Szmek
extract_first_words deals fine with the string being NULL, so drop the upfront check for that.
2016-11-07Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek
We don't have plural in the name of any other -util files and this inconsistency trips me up every time I try to type this file name from memory. "formats-util" is even hard to pronounce.
2016-11-03Merge pull request #4510 from keszybz/tree-wide-cleanupsLennart Poettering
Tree wide cleanups
2016-11-02Merge pull request #4481 from poettering/perpetualZbigniew Jędrzejewski-Szmek
Add "perpetual" unit concept, sysctl fixes, networkd fixes, systemctl color fixes, nspawn discard.
2016-11-02systemctl: fix incorrect "need reload" on cat (#4535)Lucas Werkmeister
Reported by @evverx in #4493.
2016-11-02systemctl: tweak the "systemctl list-units" output a bitLennart Poettering
Make the underlining between the header and the body and between the units of different types span the whole width of the table. Let's never make the table wider than necessary (which is relevant due the above). When space is limited and we can't show the full ID or description string prefer showing the full ID over the full description. The ID is after all something people might want to copy/paste, while the description is mostly just helpful decoration.
2016-11-02systemctl: properly turn off color after active columnLennart Poettering
If we turn on red color for the active column and it is not combined with underlining, then we need to turn it off explicitly afterwards. Do that.
2016-10-27systemctl: warn when cat shows changed unit files (#4493)Lucas Werkmeister
Suggested by @keszybz in #4488.
2016-10-25systemctl: fix two minor memory leaks in --wait handlingLennart Poettering
(Also, let's not use the binary |= operator on "bool" variables). Fix-up for 93a0884126146361ca078ec627da2cf766205a1c.
2016-10-24shared, systemctl: teach is-enabled to show installation targetsJan Synacek
It may be desired by users to know what targets a particular service is installed into. Improve user friendliness by teaching the is-enabled command to show such information when used with --full. This patch makes use of the newly added UnitFileFlags and adds UNIT_FILE_DRY_RUN flag into it. Since the API had already been modified, it's now easy to add the new dry-run feature for other commands as well. As a next step, --dry-run could be added to systemctl, which in turn might pave the way for a long requested dry-run feature when running systemctl start.
2016-10-24install: introduce UnitFileFlagsJan Synacek
Introduce a new enum to get rid of some boolean arguments of unit_file_* functions. It unifies the code, makes it a bit cleaner and extensible.
2016-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
2016-10-17systemctl: ditto for list-unit-filesZbigniew Jędrzejewski-Szmek
2016-10-17systemctl: use underlines to seperate unit types in listingZbigniew Jędrzejewski-Szmek
(printf("%.*s", -1, "…") is the same as not specifying the precision at all.) v2: also underline highlighted (failing) units Fixes #4137.
2016-10-11man: avoid using the term "loaded" for units currently in memory, since we ↵Lennart Poettering
also have a unit state of that name Fixes: #3971
2016-10-10core: when determining whether a process exit status is clean, consider ↵Lennart Poettering
whether it is a command or a daemon SIGTERM should be considered a clean exit code for daemons (i.e. long-running processes, as a daemon without SIGTERM handler may be shut down without issues via SIGTERM still) while it should not be considered a clean exit code for commands (i.e. short-running processes). Let's add two different clean checking modes for this, and use the right one at the appropriate places. Fixes: #4275
2016-10-10exit-status: kill is_clean_exit_lsb(), move logic to sysv-generatorLennart Poettering
Let's get rid of is_clean_exit_lsb(), let's move the logic for the special handling of the two LSB exit codes into the sysv-generator by writing out appropriate SuccessExitStatus= lines if the LSB header exists. This is not only semantically more correct, bug also fixes a bug as the code in service.c that chose between is_clean_exit_lsb() and is_clean_exit() based this check on whether a native unit files was available for the unit. However, that check was bogus since a long time, since the SysV generator was introduced and native SysV script support was removed from PID 1, as in that case a unit file always existed.
2016-10-01systemctl: Add --wait option to wait until started units terminate againMartin Pitt
Fixes #3830