summaryrefslogtreecommitdiffstats
path: root/src/run (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* cgroup: add support for memory.swap.peakFlorian Schmaus2023-11-111-0/+6
|
* run: include peak memory in outputFlorian Schmaus2023-11-061-0/+6
| | | | | | Fixes #28542. Signed-off-by: Florian Schmaus <flo@geekplace.eu>
* run: pin the unit we invoke continously while we are runningLennart Poettering2023-10-161-6/+13
| | | | | | We read properties of the unit, hence it shouldn't be GC'ed as long as we run. Hence, let's just set AddRef unconditionally for the units we create.
* run: output invocation ID when starting service and scope unitsLennart Poettering2023-10-161-41/+68
|
* run: support --scope on old service managers that lack native PIDFD supportLennart Poettering2023-10-141-36/+56
| | | | | | Before this we'd fail with a complaint that PIDFDs is not supported by the service manager. Add some compat support by falling back to classic numeric PIDs in that case.
* tree-wide: prefer sending pifds over pids when creating scope unitsLennart Poettering2023-10-051-1/+6
|
* meson: move declarations of busctl, stdio-bridge, and runYu Watanabe2023-08-011-0/+9
|
* run: disable --expand-environment by default for --scopeLuca Boccassi2023-07-201-7/+25
| | | | | | | | | | | | | | | | | | | | | | The intention was to have this option enabled by default everywhere, but unfortunately at least one case was found where it breaks compatibility of a program using systemd-run --scopes and expecting variables not to be expanded: https://sources.debian.org/src/pbuilder/0.231/pbuilder-checkparams/#L400 Example run: systemd-run --quiet --scope --description=pbuilder_build_xfce4-notes-plugin_1.10.0-1.dsc '--slice=system-pbuilder-build-xfce4\x2dnotes\x2dplugin_1.10.0\x2d1-449932.slice' chroot /var/cache/pbuilder/build/449932 dpkg-query -W '--showformat=${Version}' apt Restore backward compatibility and make the option disabled by default when --scope is used, and enabled by default for other types. In case --expand-environment is not specified and a '$' character is detected, print a warning to nudge users toward specifying the parameter as needed. In the future we can then flip the default. Follow-up for 2ed7a221fafb25eea937c4e86fb88ee501dba51e
* env-file: when resolving env vars in command lines, collect list of ↵Lennart Poettering2023-06-271-5/+18
| | | | | | | | | | | unset/invalid ones When resolving environment variables we currently silently resolve unset and invalid environment variables to empty strings. Let's do this slightly less silently: log about unset and invalid env vars, but still resolve them to an empty string. Fixes: #27036
* various: fix error message for bus_wait_for_jobs_new()Zbigniew Jędrzejewski-Szmek2023-05-261-2/+2
| | | | | As pointed out by Mike Yuan in review of grandparent commit, bus_wait_for_jobs_new() can also fail for non-oom reasons.
* run: change sd_bus_call_method to bus_call_method (#27518)Arthur Shau2023-05-041-8/+6
| | | Migrates the sd_bus_call_method code in run.c to use bus-locator.h api
* Merge pull request #27113 from keszybz/variable-expansion-reworkZbigniew Jędrzejewski-Szmek2023-04-241-164/+250
|\ | | | | Rework serialization of command lines in pid1 and make run not expand variables
| * run: expand variables also with --scopeZbigniew Jędrzejewski-Szmek2023-04-241-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes syntax be the same for commands which are started by the manager and those which are spawned directly (when --scope is used). Before: $ systemd-run -q -t echo '$TERM' xterm-256color $ systemd-run -q --scope echo '$TERM' $TERM Now: $ systemd-run -q --scope echo '$TERM' xterm-256color Previous behaviour can be restored via --expand-environment=no: $ systemd-run -q --scope --expand-environment=no echo '$TERM' $TERM Fixes #22948. At some level, this is a compat break. Fortunately --scope is not very widely used, so I think we can get away with this. Having different syntax depending on whether --scope was used or not was bad UX. A NEWS entry will be required.
| * run: add --expand-environment=no to disable server-side envvar expansionZbigniew Jędrzejewski-Szmek2023-04-241-51/+98
| | | | | | | | | | | | | | | | | | | | This uses StartExecEx to get the equivalent of ExecStart=:. StartExecEx was added in b3d593673c5b8b0b7d781fd26ab2062ca6e7dbdb, so this will not work with older systemds. A hint is emitted if we get an error indicating lack of support. PID1 returns SD_BUS_ERROR_PROPERTY_READ_ONLY, but I'm checking for SD_BUS_ERROR_UNKNOWN_PROPERTY too for safety.
| * run: split out creation of unit creation messagesZbigniew Jędrzejewski-Szmek2023-04-241-86/+132
| | | | | | | | | | | | | | | | | | | | Just refactoring, in preparation for future changes. (Though I think it'd be reasonable to do anyway, those functions were awfully long.) 'git diff' displays this badly. The middle part of start_transient_service() is moved to make_transient_service_unit(), and the middle part of start_transient_trigger() is moved to make_transient_trigger_unit().
| * run: simplify returning of statusZbigniew Jędrzejewski-Szmek2023-04-241-32/+19
| | | | | | | | | | | | start_transient_service() would return two ints: one normally and one via *retval. We can just return one int and propagate it directly, because we use DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE().
* | tree-wide: reset optind to 0 when GNU extensions in optstring are usedYu Watanabe2023-03-291-0/+3
|/ | | | | | | | | | Otherwise, if getopt() and friends are used before parse_argv(), then the GNU extensions may be ignored. This should not change any behavior at least now, as we usually use getopt_long() only once per invocation. But in the next commit, getopt_long() will be used for other arrays, hence this change will become necessary.
* basic: add RuntimeScope enumLennart Poettering2023-03-101-13/+23
| | | | | | | | | | | | In various tools and services we have a per-system and per-user concept. So far we sometimes used a boolean indicating whether we are in system mode, or a reversed boolean indicating whether we are in user mode, or the LookupScope enum used by the lookup path logic. Let's address that, in introduce a common enum for this, we can use all across the board. This is mostly just search/replace, no actual code changes.
* tree-wide: use -EBADF moreYu Watanabe2022-12-201-1/+1
|
* basic: move version() to build.h+cZbigniew Jędrzejewski-Szmek2022-11-081-0/+1
|
* run: make --working-directory= work for --scope tooLennart Poettering2022-09-221-0/+3
| | | | This sounds like a more user-friendly alternative to #24780
* Revert "systemd-run: refuse --working-directory option with --scope"Lennart Poettering2022-09-221-4/+0
| | | | This reverts commit 780c8055378589e5a7d419789761c35d05295291.
* systemd-run: refuse --working-directory option with --scopeJoost Heitbrink2022-09-221-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | systemd-run's man page says the following about the working directory of the process: "If a command is run as transient scope unit, it will be executed by systemd-run itself as parent process and will thus inherit the execution environment of the caller." This means working directory assignment does not work, as evidenced by the following invocation: ```bash $ systemd-run --scope --property=WorkingDirectory=/tmp/ bash -c 'echo $(pwd)' Unknown assignment: WorkingDirectory=/tmp/ ``` However, using the shorthand switch --working-directory silently ignores this instead of giving a similar error. ```bash systemd-run --scope --user --working-directory=/tmp/ bash -c 'echo $(pwd)' Running scope as unit: run-r19cc32e744e64285814dbf2204637a2b.scope /home/test/projects/systemd ``` This commit fixes this by explicitly generating an error instead of silently ignoring the switch: ```bash $ systemd-run --scope --working-directory=/tmp/ bash -c 'echo $(pwd)' --working-directory is not supported in --scope mode. ```
* tree-wide: use ASSERT_PTR moreDavid Tardon2022-09-131-2/+1
|
* tree-wide: Use correct format specifiersJan Janssen2022-08-301-1/+1
| | | | gcc will complain about all these with -Wformat-signedness.
* run: simplificationZbigniew Jędrzejewski-Szmek2022-08-171-5/+1
|
* strv: declare iterator of FOREACH_STRING() in the loopZbigniew Jędrzejewski-Szmek2022-03-231-2/+0
| | | | | | | | | | | Same idea as 03677889f0ef42cdc534bf3b31265a054b20a354. No functional change intended. The type of the iterator is generally changed to be 'const char*' instead of 'char*'. Despite the type commonly used, modifying the string was not allowed. I adjusted the naming of some short variables for clarity and reduced the scope of some variable declarations in code that was being touched anyway.
* tree-wide: don't use strjoina() on getenv() valuesAnita Zhang2022-01-271-2/+5
| | | | Avoid doing stack allocations on environment variables.
* systemd-run: ensure error logs suggest to use '--user' when appropriateLuca Boccassi2021-12-301-3/+3
| | | | | | | | | | | | | | | | Before: $ systemd-run --service-type=notify --user false Job for run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service failed because the control process exited with error code. See "systemctl status run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service" and "journalctl -xeu run-rc3fe52ee6ddd4a6eaaf1a20e0a949cdf.service" for details. After: $ systemd-run --service-type=notify --user false Job for run-r7791e380a7b6400ea01d6a0e5a458b23.service failed because the control process exited with error code. See "systemctl --user status run-r7791e380a7b6400ea01d6a0e5a458b23.service" and "journalctl --user -xeu run-r7791e380a7b6400ea01d6a0e5a458b23.service" for details. Fixes https://github.com/systemd/systemd/issues/21933
* dbus-wait-for-jobs: add extra_args to bus_wait_for_jobs_one()Luca Boccassi2021-12-301-3/+3
| | | | And pass it through to bus_wait_for_jobs()
* 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-271-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.