summaryrefslogtreecommitdiff
path: root/src/run
Commit message (Collapse)AuthorAgeFilesLines
* run: when we determine a timer cannot elapse anymore, really just warn, ↵Lennart Poettering2019-04-251-11/+12
| | | | | | | | | | | | | | nothing else When we determine that a calendar expression cannot elapse anymore, print a warning but proceed regardless like we normally would. Quite possibly a remote system has a different understanding of time (timezone, system clock) than we have, hence we really shouldn't change behaviour here client side, but log at best, and then leave the decision what to do to the server side. Follow-up for #12299
* Merge pull request #12074 from poettering/io-acctZbigniew Jędrzejewski-Szmek2019-04-251-0/+14
|\ | | | | expose IO stats on the bus and in "systemctl status" and "systemd-run --wait"
| * run: show IO stats in --wait resource outputLennart Poettering2019-04-121-0/+14
| |
* | run: check if the specified calendar event is not in the pastFrantisek Sumsal2019-04-251-1/+19
|/ | | | | Check if calendar event specification passed by --on-calendar runs in some time in the future. If not, execute the given command immediately
* core: optionally, trigger .timer units on timezone and clock changesLennart Poettering2019-04-021-0/+22
| | | | Fixes: #6228
* run: rename with_timer → arg_with_timerLennart Poettering2019-04-021-12/+12
| | | | | The value is directly initialized from cmdline args, hence let's name it so, following our usual naming style.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-271-0/+3
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* shared: split out code to wait for jobs to complet into its own source fileLennart Poettering2019-03-131-0/+1
| | | | | | | It's complex enough and quite a few functions. Let's hence split this out. No code change, just some rearranging of source files.
* tree-wide: port various places over to STARTSWITH_SET()Lennart Poettering2018-11-261-6/+7
|
* run: set $INVOCATION_ID for scope unitsLennart Poettering2018-11-231-9/+49
| | | | | | | | Services invoked by PID1 have $INVOCATION_ID initialized, hence let's do that for scope units (where the payload process is invoked by us on the client side) too, to minimize needless differences. Fixes: #8082
* run: port to static destructorsLennart Poettering2018-11-231-24/+19
|
* run: port to DEFINE_MAIN_FUNCTION()Lennart Poettering2018-11-231-2/+5
|
* run: add new --shell switch for spawning a shell as serviceLennart Poettering2018-11-231-33/+90
| | | | | | | | | I keep running "systemd-run -t /bin/bash" to quickly get a shell running in service context. I suspect I am not the only one, hence let's add a shortcut for it. While we are at it, let's make it smarter, and automatically inherit the $SHELL of the invoking user as well as the working directory, and let's imply --pty. --shell (or -S) is hence equivalent to "-t -d $SHELL".
* run: add a switch for specifiying the working directory of a serviceLennart Poettering2018-11-231-36/+70
| | | | | | | | | | | | I find myself testing service management quite often with "systemd-run -t /bin/bash". For that it is handy if the invoked shell would use the working directory I am currently in. Hence introduce a shorthand for that: $ systemd-run -dt /bin/bash This will automatically insert a WorkingDirectory= property into the transient service, pointing to the working directory of the caller.
* coccinelle: make use of SYNTHETIC_ERRNOZbigniew Jędrzejewski-Szmek2018-11-221-56/+43
| | | | | | | | | | | Ideally, coccinelle would strip unnecessary braces too. But I do not see any option in coccinelle for this, so instead, I edited the patch text using search&replace to remove the braces. Unfortunately this is not fully automatic, in particular it didn't deal well with if-else-if-else blocks and ifdefs, so there is an increased likelikehood be some bugs in such spots. I also removed part of the patch that coccinelle generated for udev, where we returns -1 for failure. This should be fixed independently.
* Split out pretty-print.c and move pager.c and main-func.h to shared/Zbigniew Jędrzejewski-Szmek2018-11-201-0/+1
| | | | | This is high-level functionality, and fits better in shared/ (which is for our executables), than in basic/ (which is also for libraries).
* Merge pull request #9783 from poettering/get-user-creds-flagsZbigniew Jędrzejewski-Szmek2018-08-211-2/+2
|\ | | | | beef up get_user_creds() a bit and other improvements
| * Rename USER_CREDS_SYNTHESIZE_FALLBACK to …_PREFER_NSSZbigniew Jędrzejewski-Szmek2018-08-201-1/+1
| |
| * user-util: rework get_user_creds()Lennart Poettering2018-08-201-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Let's fold get_user_creds_clean() into get_user_creds(), and introduce a flags argument for it to select "clean" behaviour. This flags parameter also learns to other new flags: - USER_CREDS_SYNTHESIZE_FALLBACK: in this mode the user records for root/nobody are only synthesized as fallback. Normally, the synthesized records take precedence over what is in the user database. With this flag set this is reversed, and the user database takes precedence, and the synthesized records are only used if they are missing there. This flag should be set in cases where doing NSS is deemed safe, and where there's interest in knowing the correct shell, for example if the admin changed root's shell to zsh or suchlike. - USER_CREDS_ALLOW_MISSING: if set, and a UID/GID is specified by numeric value, and there's no user/group record for it accept it anyway. This allows us to fix #9767 This then also ports all users to set the most appropriate flags. Fixes: #9767 [zj: remove one isempty() call]
* | tree-wide: add clickable man page link to all --help textsLennart Poettering2018-08-201-4/+15
| | | | | | | | | | | | | | | | | | | | This is a bit like the info link in most of GNU's --help texts, but we don't do info but man pages, and we make them properly clickable on terminal supporting that, because awesome. I think it's generally advisable to link up our (brief) --help texts and our (more comprehensive) man pages a bit, so this should be an easy and straight-forward way to do it.
* | tree-wide: shorten error logging a bitYu Watanabe2018-08-071-12/+6
|/ | | | Continuation of 4027f96aa08c73f109aa46b89842ca0e25c9c0e9.
* tree-wide: remove Lennart's copyright linesLennart Poettering2018-06-141-3/+0
| | | | | | | | | | | These lines are generally out-of-date, incomplete and unnecessary. With SPDX and git repository much more accurate and fine grained information about licensing and authorship is available, hence let's drop the per-file copyright notice. Of course, removing copyright lines of others is problematic, hence this commit only removes my own lines and leaves all others untouched. It might be nicer if sooner or later those could go away too, making git the only and accurate source of authorship information.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-141-2/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: some O_NDELAY → O_NONBLOCK fixesLennart Poettering2018-05-311-1/+1
| | | | Somehow the coccinelle script misses these, hence fix them manually.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-061-13/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* bus-util: add flags for bus_map_all_properties() (#8546)Yu Watanabe2018-03-281-0/+1
| | | | | | | | | This adds flags BUS_MAP_STRDUP and BUS_MAP_BOOLEAN_AS_BOOL. If BUS_MAP_STRDUP is set, then each "s" message is duplicated. If BUS_MAP_BOOLEAN_AS_BOOL is set, then each "b" message is written to a bool pointer. Follow-up for #8488. See https://github.com/systemd/systemd/pull/8488#discussion_r175816270.
* When mangling names, optionally emit a warning (#8400)Zbigniew Jędrzejewski-Szmek2018-03-211-5/+5
| | | | | | | | | | | | | | | | | | The warning is not emitted for absolute paths like /dev/sda or /home, which are converted to .device and .mount unit names without any fuss. Most of the time it's unlikely that users use invalid unit names on purpose, so let's warn them. Warnings are silenced when --quiet is used. $ build/systemctl show -p Id hello@foo-bar/baz Invalid unit name "hello@foo-bar/baz" was escaped as "hello@foo-bar-baz" (maybe you should use systemd-escape?) Id=hello@foo-bar-baz.service $ build/systemd-run --user --slice foo-bar/baz --unit foo-bar/foo true Invalid unit name "foo-bar/foo" was escaped as "foo-bar-foo" (maybe you should use systemd-escape?) Invalid unit name "foo-bar/baz" was escaped as "foo-bar-baz" (maybe you should use systemd-escape?) Running as unit: foo-bar-foo.service Fixes #8302.
* bus-util: make bus_map_all_properties() not copy stringYu Watanabe2018-03-201-0/+1
|
* tree-wide: install matches asynchronouslyLennart Poettering2018-01-051-9/+10
| | | | | | | | | Let's remove a number of synchronization points from our service startups: let's drop synchronous match installation, and let's opt for asynchronous instead. Also, let's use sd_bus_match_signal() instead of sd_bus_add_match() where we can.
* run: double freeZbigniew Jędrzejewski-Szmek2018-01-041-3/+1
| | | | Introduced in f2b9f2c83e5b4035b22eb2f610531fce275bf55f. CID #1384218.
* run: add support to create transient path and socket unitYu Watanabe2017-12-231-20/+66
|
* bus-unit-util: add socket unit related optionsYu Watanabe2017-12-231-5/+6
| | | | Also, split bus_append_unit_property_assignment().
* run: allow to specify multiple timer optionsYu Watanabe2017-12-111-85/+49
|
* run: run pty forwarder at higher event priority than the busLennart Poettering2017-12-051-1/+4
| | | | | We want any tty I/O to happen before we look at service messages, hence let's set priorities on them, and give tty I/O a higher priority.
* run: rearrange error handling when adding unit propertiesLennart Poettering2017-11-291-48/+53
| | | | | | | | Let's always leave logging to the call that actually added the fields to the bus message. This way we don't get duplicate logging whenver bus_append_unit_property_assignment() ends up being called, which does all its logging on its own (and probably should do, as it can output much more precise errors).
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-191-0/+1
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* run: add "-G" as shortcut for "--property=CollectMode=inactive-or-failed"Lennart Poettering2017-11-161-2/+15
| | | | | | | | | This option is likely to be very useful for systemd-run invocations, hence let's add a shortcut for it. With this new concepts it's now very easy to put together systemd-run invocations that leave zero artifacts in the system, including when they fail.
* treewide: unify identical definitions of polkit_agent_open_if_enabled() (#7187)Zbigniew Jędrzejewski-Szmek2017-10-301-15/+3
| | | Follows the same pattern as pager_open() now.
* run: also show IP traffic accounting data on "systemd-run --wait"Lennart Poettering2017-09-261-2/+21
| | | | If we collect we should show it.
* run: add new --pipe option for including "systemd-run" commands in shell ↵Lennart Poettering2017-09-121-18/+62
| | | | | | | | | | | | | | pipelines In this mode, we'll directly connect stdin/stdout/stderr of the invoked service with whatever systemd-run itself is invoked on. This allows inclusion of "systemd-run" commands in shell pipelines, as unlike "--pty" this means EOF of stdin/stdout/stderr are propagated independently. If --pty and --pipe are combined systemd-run will automatically pick the right choice for the context it is invoked in, i.e. --pty when invoked on a TTY, and --pipe otherwise.
* tree-wide: make use of getpid_cached() wherever we canLennart Poettering2017-07-201-1/+1
| | | | | | | This moves pretty much all uses of getpid() over to getpid_raw(). I didn't specifically check whether the optimization is worth it for each replacement, but in order to keep things simple and systematic I switched over everything at once.
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* run: also pin unit when we we are in --pty modeLennart Poettering2017-02-281-2/+1
| | | | | | | | | | | | | | | | | | | | Since 95f1d6bfecde60b245fae1ab0313b550201e7880 we'll subscribe to unit signals to figure out when to disconnect the pty. But that can only work correctly if we actually subscribe to the unit's signals. Hence, explicitly pin (and thus subscribe to) the unit we just created not only in --wait mode but also in --pty mode. Or to say this differently: we need to pin the unit in the same cases as we install the signal match. 95f1d6bfecde60b245fae1ab0313b550201e7880 forgot to do that. This is relevant to make sure systemd-run works correctly in --user mode, and correctly exits when the spawned service dies. To test: systemd-run --user -t /bin/bash And then press ^D. This will hang before this change, but exit cleanly after it.
* tree-wide: make bus_map_all_properties return a proper sd_bus_errorLennart Poettering2017-02-091-1/+3
| | | | | | | | 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.
* run: exit early in --pty if service failedLennart Poettering2017-02-031-27/+27
| | | | | | | | | | | | | | | | | | | | This reworks systemd-run so that in --pty mode we watch the unit state the way we do it in --wait mode. Whenever we notice that the service is in failed or inactive state finish right-away, but first write all unwritten characters we can read from the master TTY device. This makes sure that when the TTY service fails before it opens the slave PTY device we properly notice that and exit early, so that borked start parameters result in immediate systemd-run failure. Previously, we'd not notice this at all, as a PTY slave that never was opened won't result in POLLHUP events, and we'd hence simply keep reading from it forever. In essence, --pty now enables the same unit watching logic that --wait enables. However, unless --wait is specified we won#t show the final summary, hence the effective difference should be pretty minimal. Fixes: #3915
* run: explicitly close pty forwarder before printing summaryLennart Poettering2017-02-031-0/+6
| | | | | | If the PTY forwarder is still around our TTY will have borked settings, regarding newlines, hence explicitly close it before showing the summary, so that it looks pretty.
* run: complain when --pty is used together with --no-block, which makes no senseLennart Poettering2017-02-031-0/+5
|
* run: fix race for "systemd-run --wait"Lennart Poettering2017-02-021-3/+15
| | | | | | | | | | | | D-Bus is inherently racy when a function returns an object path for a newly allocated object the client shall watch: as the object already exists before the client can subscribe to it, it might lose messages from it. Let's fix this, by explicitly querying unit properties right after subscribing to its property changes. Fixes: #4920
* Rename formats-util.h to format-util.hZbigniew Jędrzejewski-Szmek2016-11-071-1/+1
| | | | | | 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.
* tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek2016-10-231-1/+1
| | | | | | | | | | | | | 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.