Commit Graph

78 Commits

Author SHA1 Message Date
Filipe Brandenburger b4c14404b3 execute: Add new PassEnvironment= directive
This directive allows passing environment variables from the system
manager to spawned services. Variables in the system manager can be set
inside a container by passing `--set-env=...` options to systemd-spawn.

Tested with an on-disk test.service unit. Tested using multiple variable
names on a single line, with an empty setting to clear the current list
of variables, with non-existing variables.

Tested using `systemd-run -p PassEnvironment=VARNAME` to confirm it
works with transient units.

Confirmed that `systemctl show` will display the PassEnvironment
settings.

Checked that man pages are generated correctly.

No regressions in `make check`.
2015-11-11 07:55:23 -08:00
Lennart Poettering 5732a7dbb0 Merge pull request #1690 from evverx/run-runtime-directory
systemd-run can launch units with RuntimeDirectory
2015-11-02 20:16:18 +01:00
Lennart Poettering 7b3e062cb6 process-util: move a couple of process-related calls over 2015-10-27 14:24:58 +01:00
Lennart Poettering b5efdb8af4 util-lib: split out allocation calls into alloc-util.[ch] 2015-10-27 13:45:53 +01:00
Lennart Poettering 7ccbd1ae84 util-lib: split out syslog-related calls into syslog-util.[ch] 2015-10-27 13:25:57 +01:00
Lennart Poettering 430f0182b7 src/basic: rename audit.[ch] → audit-util.[ch] and capability.[ch] → capability-util.[ch]
The files are named too generically, so that they might conflict with
the upstream project headers. Hence, let's add a "-util" suffix, to
clarify that this are just our utility headers and not any official
upstream headers.
2015-10-27 13:25:57 +01:00
Lennart Poettering 78f22b973f util-lib: split out resource limits related calls into rlimit-util.[ch] 2015-10-27 13:25:56 +01:00
Lennart Poettering e4e73a6325 util-lib: split out hex/dec/oct encoding/decoding into its own file 2015-10-27 13:25:55 +01:00
Lennart Poettering 6bedfcbb29 util-lib: split string parsing related calls from util.[ch] into parse-util.[ch] 2015-10-27 13:25:55 +01:00
Evgeny Vereshchagin fa21b5e3d7 run: can launch units with RuntimeDirectory 2015-10-27 05:18:06 +03:00
Evgeny Vereshchagin eff580744c run: can launch units with ProtectHome 2015-10-26 00:20:49 +00:00
Tom Gundersen 7c8871d315 Merge pull request #1654 from poettering/util-lib
Various changes to src/basic/
2015-10-25 14:22:43 +01:00
Lennart Poettering 3ffd4af220 util-lib: split out fd-related operations into fd-util.[ch]
There are more than enough to deserve their own .c file, hence move them
over.
2015-10-25 13:19:18 +01:00
Evgeny Vereshchagin 5664e6cf46 run: can launch units with ProtectSystem 2015-10-24 22:48:33 +00:00
Lennart Poettering b0830e21f4 core: check parsed bus msg in full before applying it 2015-10-22 02:02:17 +02:00
Lennart Poettering 5e4cecfb67 Merge pull request #1623 from evverx/run-rw-ro-ia-dirs
systemd-run can launch units with ReadWriteDirectories, ReadOnlyDirectories, InaccessibleDirectories
2015-10-21 12:08:44 +02:00
Evgeny Vereshchagin 08596068d7 run: can launch units with ReadWriteDirectories, ReadOnlyDirectories, InaccessibleDirectories 2015-10-20 22:03:43 +00:00
Thomas Hindoe Paaboel Andersen 9ecc70db1e dbus-execute: remove unused variable
from ceb728cf
2015-10-20 19:39:31 +02:00
Lennart Poettering f73e8b9caf Merge pull request #1616 from evverx/run-fix-environment-parsing
run: fix Environment parsing
2015-10-20 15:26:19 +02:00
Evgeny Vereshchagin e9876fc9c5 run: fix Environment parsing
* `Environment=` resets previous assignments
* `Environment='a=1 b=2'` sets `a` to `1` and `b` to `2`
* `Environment='"a=1 2" b=2"'` sets `a` to `1 2` and `b` to `2`
2015-10-20 12:55:07 +00:00
Lennart Poettering 2229f65667 dbus-execute: some cleanups when parsing EnvironmentFiles= for transient units 2015-10-19 23:43:19 +02:00
Nicolas Cornu ceb728cf0f Hook more properties for transient units
systemd-run can now launch units with EnvironmentFile set.
2015-10-19 21:58:01 +02:00
Evgeny Vereshchagin 6b862936c7 run: can launch units with OOMScoreAdjust 2015-10-17 20:03:40 +00:00
Evgeny Vereshchagin f1db332756 run: can launch units with TimerSlackNSec 2015-10-15 09:57:28 +00:00
Evgeny Vereshchagin e0d6e0fa55 core: execute: validate syslog level and facility 2015-10-14 16:35:30 +00:00
Evgeny Vereshchagin 460ed929cf systemd-run: can launch units with SyslogFacility 2015-10-14 15:05:04 +00:00
Evgeny Vereshchagin a8a1357560 systemd-run: can launch units with SyslogLevel 2015-10-14 14:48:45 +00:00
Lennart Poettering ade37eb98c Merge pull request #1529 from evverx/dbus-props-syslog-fac-pri
core: expose `SyslogFacility` and `SyslogLevel` as properties on dbus
2015-10-14 12:05:24 +02:00
Evgeny Vereshchagin 06f2ccf949 core: expose SyslogLevel and SyslogFacility as properties on dbus 2015-10-14 09:52:58 +00:00
Evgeny Vereshchagin c9d031c353 bus-util: add bus_property_get_rlimit (move from core/dbus_execute) 2015-10-12 05:16:05 +00:00
Evgeny Vereshchagin de53c41748 systemd-run can now launch units with SyslogIdentifier 2015-10-09 12:37:50 +00:00
Evgeny Vereshchagin 047d99337f systemd-run can now launch units with SyslogLevelPrefix 2015-10-09 12:17:41 +00:00
Lennart Poettering 5f5d8eab1f core: allow setting WorkingDirectory= to the special value ~
If set to ~ the working directory is set to the home directory of the
user configured in User=.

This change also exposes the existing switch for the working directory
that allowed making missing working directories non-fatal.

This also changes "machinectl shell" to make use of this to ensure that
the invoked shell is by default in the user's home directory.

Fixes #1268.
2015-09-29 21:55:51 +02:00
Nicolas Cornu 602b83559a Hook more properties for transient units
systemd-run can now launch units with WorkingDirectory, RootDirectory set.
2015-09-23 09:45:50 +02:00
Gabriel de Perthuis b9c50073fc Hook more properties for transient units
systemd-run can now launch units with PrivateTmp, PrivateDevices,
PrivateNetwork, NoNewPrivileges set.
2015-09-11 18:25:41 +02:00
Lennart Poettering a1e58e8ee1 tree-wide: use coccinelle to patch a lot of code to use mfree()
This replaces this:

        free(p);
        p = NULL;

by this:

        p = mfree(p);

Change generated using coccinelle. Semantic patch is added to the
sources.
2015-09-09 08:19:27 +02:00
Lennart Poettering 7e9cc4361d core: drop spurious new line 2015-08-25 18:37:31 +02:00
Lennart Poettering 506711fddd core: open up more executable properties via the bus
This is preparation for a later commit that makes use of these
properties for spawning an interactive shell in a container.
2015-08-24 22:46:45 +02:00
Lennart Poettering 023a4f6701 core: optionally create LOGIN_PROCESS or USER_PROCESS utmp entries
When generating utmp/wtmp entries, optionally add both LOGIN_PROCESS and
INIT_PROCESS entries or even all three of LOGIN_PROCESS, INIT_PROCESS
and USER_PROCESS entries, instead of just a single INIT_PROCESS entry.

With this change systemd may be used to not only invoke a getty directly
in a SysV-compliant way but alternatively also a login(1) implementation
or even forego getty and login entirely, and invoke arbitrary shells in
a way that they appear in who(1) or w(1).

This is preparation for a later commit that adds a "machinectl shell"
operation to invoke a shell in a container, in a way that is compatible
with who(1) and w(1).
2015-08-24 22:46:45 +02:00
Lennart Poettering 9b15b7846d run: add a new "-t" mode for invoking a binary on an allocated TTY 2014-12-23 03:26:24 +01:00
WaLyong Cho 2ca620c4ed smack: introduce new SmackProcessLabel option
In service file, if the file has some of special SMACK label in
ExecStart= and systemd has no permission for the special SMACK label
then permission error will occurred. To resolve this, systemd should
be able to set its SMACK label to something accessible of ExecStart=.
So introduce new SmackProcessLabel. If label is specified with
SmackProcessLabel= then the child systemd will set its label to
that. To successfully execute the ExecStart=, accessible label should
be specified with SmackProcessLabel=.
Additionally, by SMACK policy, if the file in ExecStart= has no
SMACK64EXEC then the executed process will have given label by
SmackProcessLabel=. But if the file has SMACK64EXEC then the
SMACK64EXEC label will be overridden.

[zj: reword man page]
2014-11-24 10:20:53 -05:00
Kay Sievers 3a43da2832 time-util: add and use USEC/NSEC_INFINIY 2014-07-29 13:20:20 +02:00
Hristo Venev cdd7b7dfd4 core: make sure Environment fields passed in for transient units are properly written to unit files
https://bugs.freedesktop.org/show_bug.cgi?id=76744
2014-06-23 18:53:56 +02:00
Lennart Poettering 1b8689f949 core: rename ReadOnlySystem= to ProtectSystem= and add a third value for also mounting /etc read-only
Also, rename ProtectedHome= to ProtectHome=, to simplify things a bit.

With this in place we now have two neat options ProtectSystem= and
ProtectHome= for protecting the OS itself (and optionally its
configuration), and for protecting the user's data.
2014-06-04 18:12:55 +02:00
Lennart Poettering 417116f234 core: add new ReadOnlySystem= and ProtectedHome= settings for service units
ReadOnlySystem= uses fs namespaces to mount /usr and /boot read-only for
a service.

ProtectedHome= uses fs namespaces to mount /home and /run/user
inaccessible or read-only for a service.

This patch also enables these settings for all our long-running services.

Together they should be good building block for a minimal service
sandbox, removing the ability for services to modify the operating
system or access the user's private data.
2014-06-03 23:57:51 +02:00
Lennart Poettering 7f8aa67131 core: remove tcpwrap support
tcpwrap is legacy code, that is barely maintained upstream. It's APIs
are awful, and the feature set it exposes (such as DNS and IDENT
access control) questionnable. We should not support this natively in
systemd.

Hence, let's remove the code. If people want to continue making use of
this, they can do so by plugging in "tcpd" for the processes they start.
With that scheme things are as well or badly supported as they were from
traditional inetd, hence no functionality is really lost.
2014-03-24 20:07:42 +01:00
Lennart Poettering d584f63894 core: make the LimitXYZ= properties settable for transient service units 2014-03-05 04:08:04 +01:00
Lennart Poettering a049d1a972 core: when passing resource limit values to client, map RLIM_INFINITY into portable value (uint64_t) -1 2014-03-05 02:31:09 +01:00
Zbigniew Jędrzejewski-Szmek 6e18964d3a Introduce strv_consume which takes ownership
This mirrors set_consume and makes the common use a bit nicer.
2014-03-04 10:04:50 -05:00
Lennart Poettering e66cf1a3f9 core: introduce new RuntimeDirectory= and RuntimeDirectoryMode= unit settings
As discussed on the ML these are useful to manage runtime directories
below /run for services.
2014-03-03 17:55:32 +01:00