Commit Graph

46 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
Franck Bui ea1a971646 Teach bus_append_unit_property_assignment() about 'Delegate' property 2015-11-02 12:37:45 +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 15a5e95075 util-lib: split out printf() helpers to stdio-util.h 2015-10-27 13:25:57 +01:00
Lennart Poettering ee104e11e3 user-util: move UID/GID related macros from macro.h to user-util.h 2015-10-27 13:25:57 +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 4e731273ed util-lib: move /proc/cmdline parsing code to proc-cmdline.[ch] 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 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 07630cea1f util-lib: split our string related calls from util.[ch] into its own file string-util.[ch]
There are more than enough calls doing string manipulations to deserve
its own files, hence do something about it.

This patch also sorts the #include blocks of all files that needed to be
updated, according to the sorting suggestions from CODING_STYLE. Since
pretty much every file needs our string manipulation functions this
effectively means that most files have sorted #include blocks now.

Also touches a few unrelated include files.
2015-10-24 23:05:02 +02:00
Lennart Poettering 4f5dd3943b util: split out escaping code into escape.[ch]
This really deserves its own file, given how much code this is now.
2015-10-24 23:04:42 +02:00
Evgeny Vereshchagin 08596068d7 run: can launch units with ReadWriteDirectories, ReadOnlyDirectories, InaccessibleDirectories 2015-10-20 22:03:43 +00: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
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 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
Evgeny Vereshchagin f6bcaf4cf6 bus-util: change `Default`-chopping to `Limit`-searching
See https://github.com/systemd/systemd/pull/1534#commitcomment-13744013

Actually, thinking about this, maybe it would be nicer to actually look
for "Limit" in the string rather than chopping off a "Default"....
Sounds more generic...
2015-10-13 18:45:11 +00:00
Evgeny Vereshchagin 97eb423157 core: manager: expose DefaultLimit* as properties on dbus 2015-10-12 06:39:00 +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 266f3e269d bus-util: rename bus_open_transport() to bus_connect_transport()
In sd-bus, the sd_bus_open_xyz() family of calls allocates a new bus,
while sd_bus_default_xyz() family tries to reuse the thread's default
bus. bus_open_transport() sometimes internally uses the former,
sometimes the latter family, but suggests it only calls the former via
its name. Hence, let's avoid this confusion, and generically rename the
call to bus_connect_transport().

Similar for all related calls.

And while we are at it, also change cgls + cgtop to do direct systemd
connections where possible, since all they do is talk to systemd itself.
2015-09-29 21:55:52 +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
Lennart Poettering d801577473 Merge pull request #1250 from g2p/master
Hook more properties for transient units
2015-09-14 23:19:03 +02:00
Lennart Poettering d53d94743c core: refactor cpu shares/blockio weight cgroup logic
Let's stop using the "unsigned long" type for weights/shares, and let's
just use uint64_t for this, as that's what we expose on the bus.

Unify parsers, and always validate the range for these fields.

Correct the default blockio weight to 500, since that's what the kernel
actually uses.

When parsing the weight/shares settings from unit files accept the empty
string as a way to reset the weight/shares value. When getting it via
the bus, uniformly map (uint64_t) -1 to unset.

Open up StartupCPUShares= and StartupBlockIOWeight= to transient units.
2015-09-11 18:31:49 +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
Daniel Mack a18f3caa56 Merge pull request #1239 from poettering/cgroup-pids
core: add support for the "pids" cgroup controller
2015-09-10 19:11:29 +02:00
Lennart Poettering 03a7b521e3 core: add support for the "pids" cgroup controller
This adds support for the new "pids" cgroup controller of 4.3 kernels.
It allows accounting the number of tasks in a cgroup and enforcing
limits on it.

This adds two new setting TasksAccounting= and TasksMax= to each unit,
as well as a gloabl option DefaultTasksAccounting=.

This also updated "cgtop" to optionally make use of the new
kernel-provided accounting.

systemctl has been updated to show the number of tasks for each service
if it is available.

This patch also adds correct support for undoing memory limits for units
using a MemoryLimit=infinity syntax. We do the same for TasksMax= now
and hence keep things in sync here.
2015-09-10 18:41:06 +02:00
Lennart Poettering 59f448cf15 tree-wide: never use the off_t unless glibc makes us use it
off_t is a really weird type as it is usually 64bit these days (at least
in sane programs), but could theoretically be 32bit. We don't support
off_t as 32bit builds though, but still constantly deal with safely
converting from off_t to other types and back for no point.

Hence, never use the type anymore. Always use uint64_t instead. This has
various benefits, including that we can expose these values directly as
D-Bus properties, and also that the values parse the same in all cases.
2015-09-10 18:16:18 +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
Michael Chapman 403ed0e5c9 bus-util: support details in CheckAuthorization calls
Extra details for an action can be supplied when calling polkit's
CheckAuthorization method. Details are a list of key/value string pairs.
Custom policy can use these details when making authorization decisions.
2015-09-06 00:07:16 +10:00
David Herrmann 057171efc1 Revert "sd-bus: do not connect to dbus-1 socket when kdbus is available"
This reverts commit d4d00020d6. The idea of
the commit is broken and needs to be reworked. We really cannot reduce
the bus-addresses to a single address. We always will have systemd with
native clients and legacy clients at the same time, so we also need both
addresses at the same time.
2015-08-27 16:32:22 +02:00
Lennart Poettering 8bed4cbcc0 bus-util: make more properties settable in --property=
Add a couple of new properties to the supported set we can pass in
systemd-run's and systemd-nspawn's --property= switch.
2015-08-25 18:39:50 +02:00
Kay Sievers d4d00020d6 sd-bus: do not connect to dbus-1 socket when kdbus is available
We should not fall back to dbus-1 and connect to the proxy when kdbus
returns an error that indicates that kdbus is running but just does not
accept new connections because of quota limits or something similar.

Using is_kdbus_available() in libsystemd/ requires it to move from
shared/ to libsystemd/.

Based on a patch from David Herrmann:
  https://github.com/systemd/systemd/pull/886
2015-08-11 20:49:36 +02:00
Thomas Hindoe Paaboel Andersen 7d6884b65e tree-wide: fix indentation 2015-08-06 00:44:19 +02:00
Kay Sievers 1b09f548c7 turn kdbus support into a runtime option
./configure --enable/disable-kdbus can be used to set the default
behavior regarding kdbus.

If no kdbus kernel support is available, dbus-dameon will be used.

With --enable-kdbus, the kernel command line option "kdbus=0" can
be used to disable kdbus.

With --disable-kdbus, the kernel command line option "kdbus=1" is
required to enable kdbus support.
2015-06-17 18:01:49 +02:00
Kay Sievers a095315b3c build-sys: split internal basic/ library from shared/
basic/      can be used by everything
            cannot use anything outside of basic/

libsystemd/ can use basic/
            cannot use shared/

shared/     can use libsystemd/
2015-06-11 10:52:46 +02:00
Renamed from src/libsystemd/sd-bus/bus-util.c (Browse further)