summaryrefslogtreecommitdiff
path: root/src/run/run.c
Commit message (Collapse)AuthorAgeFilesLines
* tree-wide: do not print hint about -M if -M is already usedZbigniew Jędrzejewski-Szmek2021-11-041-1/+1
| | | | | | | | (Or when -H is used, since -H and -M are incompatible.) Note that the slightly unusual form with separate boolean variables (hint_vars, hint_addr) instead of e.g. a const char* variable to hold the message, because this way we don't trigger the warning about non-literal format.
* run: do not validate exe early if MountImages/ExtensionImages are usedLuca Boccassi2021-10-281-5/+16
| | | | | Same as with RootImage&friends, the executable might be in the image, so it's not visible in the host before the unit is set up.
* core: Add ExecSearchPath parameter to specify the directory relative to ↵alexlzhu2021-09-281-0/+1
| | | | | | | | | | | | | which binaries executed by Exec*= should be found Currently there does not exist a way to specify a path relative to which all binaries executed by Exec should be found. The only way is to specify the absolute path. This change implements the functionality to specify a path relative to which binaries executed by Exec*= can be found. Closes #6308
* run/mount/systemctl: don't fork off PolicyKit/ask-pw agent when in --user modeLennart Poettering2021-08-301-0/+4
| | | | | | | | When we are in --user mode there's no point in doing PolicyKit/ask-pw because both of these systems are only used by system-level services. Let's disable the two agents for that automaticlly hence. Prompted by: #20576
* run: allow --setenv=FOOZbigniew Jędrzejewski-Szmek2021-08-111-3/+4
|
* Add implicit sentinel to strv_env_merge()Zbigniew Jędrzejewski-Szmek2021-08-111-1/+1
| | | | Just to make it a tiny bit nicer to use.
* Drop the text argument from assert_not_reached()Zbigniew Jędrzejewski-Szmek2021-08-031-3/+3
| | | | | | | | | | | | | | | | | In general we almost never hit those asserts in production code, so users see them very rarely, if ever. But either way, we just need something that users can pass to the developers. We have quite a few of those asserts, and some have fairly nice messages, but many are like "WTF?" or "???" or "unexpected something". The error that is printed includes the file location, and function name. In almost all functions there's at most one assert, so the function name alone is enough to identify the failure for a developer. So we don't get much extra from the message, and we might just as well drop them. Dropping them makes our code a tiny bit smaller, and most importantly, improves development experience by making it easy to insert such an assert in the code without thinking how to phrase the argument.
* tree-wide: add FORMAT_BYTES()Zbigniew Jędrzejewski-Szmek2021-07-091-16/+11
|
* tree-wide: add FORMAT_TIMESPAN()Zbigniew Jędrzejewski-Szmek2021-07-091-8/+4
|
* run: use strextend_with_separator()Yu Watanabe2021-05-201-9/+2
|
* run: update checks to allow running with a user's busAnita Zhang2021-05-131-5/+5
| | | | | | systemd-run is documented to as being able to connect and run on a specific user bus with "--user --machine=lennart@.host" arguments. This PR updates some logic that prevented this from working.
* run: tweak algorithm for generating unit name from dbus unique nameLennart Poettering2021-03-041-3/+5
| | | | | | | | | | | | | This reverts behaviour of systemd-run's unit name generation to the status quo ante of #18871: we chop off the ":1." prefix if we can. However, to address the issue that the unique name can overrun we then do what #18871 did as fallback: only chop off the ":" prefix. This way we should have pretty names that look like they always looked in the common case, but in the case of a unique name overrun we still will have names that work. Follow-up for #18871
* run: update dbus unique names checkAnita Zhang2021-03-041-1/+1
| | | | | | | | Some code in systemd-run checks that a bus's unique name must start with `:1.`. However the dbus specification on unique connection names only specifies that it must begin with a colon. And the freedesktop/dbus implementation allows allows unique names to go up to `:INT_MAX.INT_MAX`. So update the current check to only look for a colon at the beginning.
* Move and rename parse_path_argument() functionZbigniew Jędrzejewski-Szmek2021-02-151-1/+2
| | | | | This fits better in shared/, and the new parse-argument.c file is a good home for it.
* tree-wide: Drop custom formatting for print() help messagesDaan De Meyer2021-01-311-5/+5
| | | | | | | | | | | | I think this formatting was originally used because it simplified adding new options to the help messages. However, these days, most tools their help message end with "\nSee the %s for details.\n" so the final line almost never has to be edited which eliminates the benefit of the custom formatting used for printf() help messages. Let's make things more consistent and use the same formatting for printf() help messages that we use everywhere else. Prompted by https://github.com/systemd/systemd/pull/18355#discussion_r567241580
* license: LGPL-2.1+ -> LGPL-2.1-or-laterYu Watanabe2020-11-091-1/+1
|
* tree-wide: drop if braces around single line expressions as wellFrantisek Sumsal2020-10-091-2/+1
|
* tree-wide: assorted coccinelle fixesFrantisek Sumsal2020-10-091-1/+1
|
* run: let systemd resolve the path with RootDirectory=/RootImage=Zbigniew Jędrzejewski-Szmek2020-09-231-4/+8
| | | | Fixes #13338.
* Rename find_binary to find_executableZbigniew Jędrzejewski-Szmek2020-09-181-1/+1
| | | | "executable" is more correct than "binary", since scripts are OK too.
* tree-wide: don't needlessly negate error number passed to bus_error_message()Lennart Poettering2020-09-141-3/+3
| | | | | | Like it's customary in our codebase bus_error_message() internally takes abs() of the passed error anyway, hence no need to explicitly negate it. We mostly got this right, but in too many cases we didn't. Fix that.
* bus: use bus_log_connect_error to print error messagefangxiuning2020-07-211-1/+1
|
* shared: split out code that maps properties to local structsLennart Poettering2020-06-301-0/+1
| | | | Just some refactoring, no code changes.
* shared: actually move all BusLocator related calls to bus-locator.cLennart Poettering2020-06-301-1/+1
|
* run: when waiting for unit, also check if no job is pending anymoreLennart Poettering2020-05-271-13/+31
| | | | | | | This is a fix-up for a7c71d214c37797d82de2f66cfe0a0a79c3a5c92: since we now don't wait for the job to finish anymore right after enqueuing it, we should not exit our ptyfwd logic before the unit is back to inactive *and* no job pending anymore.
* run: switch to BusLocator-oriented helpersVito Caputo2020-05-071-21/+3
| | | | Mechanical substitution reducing some verbosity
* run: don't wait for start job to complete when running interactively anywayLennart Poettering2020-04-231-1/+5
| | | | | | | | Otherwise we'd not read the services input while waiting for the job to wait, and there's no point in waiting for the job anyway if we wait for the unit to stop ultimately. Fixes: #15395
* systemd-run: add --slice-inheritMarc-André Lureau2020-04-091-9/+44
| | | | Add a new option to easily place a slice within the systemd-run slice.
* tree-wide: clean up --help texts a bitLennart Poettering2019-11-181-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This cleans up and unifies the outut of --help texts a bit: 1. Highlight the human friendly description string, not the command line via ANSI sequences. Previously both this description string and the brief command line summary was marked with the same ANSI highlight sequence, but given we auto-page to less and less does not honour multi-line highlights only the command line summary was affectively highlighted. Rationale: for highlighting the description instead of the command line: the command line summary is relatively boring, and mostly the same for out tools, the description on the other hand is pregnant, important and captions the whole thing and hence deserves highlighting. 2. Always suffix "Options" with ":" in the help text 3. Rename "Flags" → "Options" in one case 4. Move commands to the top in a few cases 5. add coloring to many more help pages 6. Unify on COMMAND instead of {COMMAND} in the command line summary. Some tools did it one way, others the other way. I am not sure what precisely {} is supposed to mean, that uppercasing doesn't, hence let's simplify and stick to the {}-less syntax And minor other tweaks.
* run: propagate return code/status from the childZbigniew Jędrzejewski-Szmek2019-11-051-2/+8
| | | | | | | | | | | | | | | Fixes #13756. We were returning things that didn't make much sense: we would always use the exit_code value as the exit code. But it sometimes contains a exit code from the process, and sometimes the number of a signal that was used to kill the process. We would also ignore SuccessExitStatus= and in general whether systemd thinks the service exited successfully (hence the issue in #13756, where systemd would return success/SIGTERM, but we'd just look at the SIGTERM part.) If we are doing --wait, let's always propagate the exit code/status from the child. While at it, make the documentation useful.
* nspawn: wrap some long linesZbigniew Jędrzejewski-Szmek2019-10-291-9/+13
|
* various tools: be more explicit when a glob is passed when not supportedZbigniew Jędrzejewski-Szmek2019-10-251-5/+15
| | | | | | | | | | | | See https://bugzilla.redhat.com/show_bug.cgi?id=1763488: when we say that 'foo@*.service' is not a valid unit name, this is not clear enough. Let's include the name of the operation that does not support globbing in the error message: $ build/systemctl enable 'foo@*.service' Glob pattern passed to enable, but globs are not supported for this. Invalid unit name "foo@*.service" escaped as "foo@\x2a.service". ...
* run: add -u as a synonym for --unitDavid Tardon2019-10-231-5/+4
| | | | | Other tools that do have --unit= option (journalctl and systemd-cgls) already do this, so let's be consistent.
* run: move comment to appropriate placeZbigniew Jędrzejewski-Szmek2019-07-161-1/+1
|
* basic/time-util: add helper function to check if timestamp is setZbigniew Jędrzejewski-Szmek2019-07-041-2/+2
| | | | No functional change.
* Enable log colors for most of tools in /usr/binZbigniew Jędrzejewski-Szmek2019-05-081-0/+1
| | | | | | | | | | When emitting the calendarspec warning we want to see some color. Follow-up for 04220fda5c. Exceptions: - systemctl, because it has a lot hand-crafted coloring - tmpfiles, sysusers, stdio-bridge, etc, because they are also used in services and I'm not sure if this wouldn't mess up something.
* run: reword a commentZbigniew Jędrzejewski-Szmek2019-04-261-5/+4
| | | | | Use unicode m-dash and remove the part about discoverability, since it's just a warning on the terminal.
* 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".