Commit graph

86 commits

Author SHA1 Message Date
Lennart Poettering 479050b363 core: drop Capabilities= setting
The setting is hardly useful (since its effect is generally reduced to zero due
to file system caps), and with the advent of ambient caps an actually useful
replacement exists, hence let's get rid of this.

I am pretty sure this was unused and our man page already recommended against
its use, hence this should be a safe thing to remove.
2016-02-13 11:59:34 +01:00
Daniel Mack b26fa1a2fb tree-wide: remove Emacs lines from all files
This should be handled fine now by .dir-locals.el, so need to carry that
stuff in every file.
2016-02-10 13:41:57 +01:00
Lennart Poettering cab2aca3e7 core: fix support for transient resource limit properties
Make sure we can properly process resource limit properties. Specifically, allow transient configuration of both the
soft and hard limit, the same way from the unit files. Previously, only the the hard rlimits could be configured but
they'd implicitly spill into the soft hard rlimits.

This also updates the client-side code to be able to parse hard/soft resource limit specifications. Since we need to
serialize two properties in bus_append_unit_property_assignment() now, the marshalling of the container around it is
now moved into the function itself. This has the benefit of shortening the calling code.

As a side effect this now beefs up the rlimit parser of "systemctl set-property" to understand time and disk sizes
where that's appropriate.
2016-02-01 22:18:16 +01:00
Zbigniew Jędrzejewski-Szmek cb51e6b734 core/dbus-execute: do not needlessly compare strings again
gcc complains that dirs might be unitialized. It cannot, but
we just checked that name has one of three values above, so
no need to check again.
2016-01-18 15:09:36 -05:00
Zbigniew Jędrzejewski-Szmek b326715278 tree-wide: check if errno is greater than zero (2)
Compare errno with zero in a way that tells gcc that
(if the condition is true) errno is positive.
2016-01-13 15:10:17 -05:00
Ismo Puustinen 755d4b67a4 capabilities: added support for ambient capabilities.
This patch adds support for ambient capabilities in service files. The
idea with ambient capabilities is that the execed processes can run with
non-root user and get some inherited capabilities, without having any
need to add the capabilities to the executable file.

You need at least Linux 4.3 to use ambient capabilities. SecureBit
keep-caps is automatically added when you use ambient capabilities and
wish to change the user.

An example system service file might look like this:

[Unit]
Description=Service for testing caps

[Service]
ExecStart=/usr/bin/sleep 10000
User=nobody
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_RAW

After starting the service it has these capabilities:

CapInh: 0000000000003000
CapPrm: 0000000000003000
CapEff: 0000000000003000
CapBnd: 0000003fffffffff
CapAmb: 0000000000003000
2016-01-12 12:14:50 +02:00
Ismo Puustinen a103496ca5 capabilities: keep bounding set in non-inverted format.
Change the capability bounding set parser and logic so that the bounding
set is kept as a positive set internally. This means that the set
reflects those capabilities that we want to keep instead of drop.
2016-01-12 12:14:50 +02:00
Evgeny Vereshchagin 147f6858ab core: expose soft limits on the bus
This is a follow-up for https://github.com/systemd/systemd/pull/1994

See https://github.com/systemd/systemd/pull/1994#issuecomment-160087219
2015-11-30 21:28:16 +00:00
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