Commit Graph

65 Commits

Author SHA1 Message Date
Lennart Poettering ebcf1f97de bus: rework message handlers to always take an error argument
Message handler callbacks can be simplified drastically if the
dispatcher automatically replies to method calls if errors are returned.

Thus: add an sd_bus_error argument to all message handlers. When we
dispatch a message handler and it returns negative or a set sd_bus_error
we send this as message error back to the client. This means errors
returned by handlers by default are given back to clients instead of
rippling all the way up to the event loop, which is desirable to make
things robust.

As a side-effect we can now easily turn the SELinux checks into normal
function calls, since the method call dispatcher will generate the right
error replies automatically now.

Also, make sure we always pass the error structure to all property and
method handlers as last argument to follow the usual style of passing
variables for return values as last argument.
2013-11-21 21:12:36 +01:00
Lennart Poettering df2d202e6e bus: let's simplify things by getting rid of unnecessary bus parameters 2013-11-21 02:07:35 +01:00
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00
Thomas Hindoe Paaboel Andersen c2e0d600ed analyze: plot the time spent setting up security modules 2013-11-10 23:21:15 +01:00
Kay Sievers 98e6c5e62f detect_virtualization() returns NULL; pass empty string to dbus 2013-11-02 00:02:56 +01:00
Kay Sievers ca2871d9b0 bus: remove static introspection file export 2013-10-21 00:41:26 +02:00
Lennart Poettering a316932f5a manager: when verifying whether clients may change environment using selinux check for "reload" rather "reboot"
This appears to be a copy/paste error.
2013-10-04 17:05:15 +02:00
Lennart Poettering 7ac807320a core: drop some out-of-date references to cgroup settings 2013-09-26 22:57:43 +02:00
Ronny Chevalier 68eda4bd16 dbus: use _cleanup_free_ instead of freeing ourself 2013-08-08 00:21:33 -04:00
Zbigniew Jędrzejewski-Szmek 459da00fe6 core: correct dbus parameter direction 2013-07-20 16:12:20 -04:00
Lennart Poettering 71445ae75b core: send out "Reloading" signal before and after doing a full reload/reexec of PID 1
Since we'll unload all units/job during a reload, and then readd them it
is really useful for clients to be aware of this phase hence sent a
signal out before and after. This signal is called "Reloading" (despite
the fact that it is also sent out during reexecution, which we consider
a special case in this context) and has one boolean parameter which is
true for the signal sent before the reload, and false for the signal
after the reload. The UnitRemoved/JobRremoved and UnitNew/JobNew due to
the reloading are guranteed to be between the pair of Reloading
messages.
2013-07-10 23:41:03 +02:00
Lennart Poettering 6fa4853328 core: serialize/deserialize bus subscribers 2013-07-10 23:41:03 +02:00
Lennart Poettering c2756a6840 core: add transient units
Transient units can be created via the bus API. They are configured via
the method call parameters rather than on-disk files. They are subject
to normal GC. Transient units currently may only be created for
services (however, we will extend this), and currently only ExecStart=
and the cgroup parameters can be configured (also to be extended).

Transient units require a unique name, that previously had no
configuration file on disk.

A tool systemd-run is added that makes use of this functionality to run
arbitrary command lines as transient services:

$ systemd-run /bin/ping www.heise.de

Will cause systemd to create a new transient service and run ping in it.
2013-06-28 04:12:58 +02:00
Lennart Poettering 241da3287d unit: make sure the dropins we write are high-priority 2013-06-28 00:41:24 +02:00
Lennart Poettering 8e2af47840 dbus: add infrastructure for changing multiple properties at once on units and hook some cgroup attributes up to it
This introduces two bus calls to make runtime changes to selected bus
properties, optionally with persistence.

This currently hooks this up only for three cgroup atributes, but this
brings the infrastructure to add more changable attributes.

This allows setting multiple attributes at once, and takes an array
rather than a dictionary of properties, in order to implement simple
resetting of lists using the same approach as when they are sourced from
unit files. This means, that list properties are appended to by this
call, unless they are first reset via assigning the empty list.
2013-06-27 21:14:56 +02:00
Lennart Poettering 4ad490007b core: general cgroup rework
Replace the very generic cgroup hookup with a much simpler one. With
this change only the high-level cgroup settings remain, the ability to
set arbitrary cgroup attributes is removed, so is support for adding
units to arbitrary cgroup controllers or setting arbitrary paths for
them (especially paths that are different for the various controllers).

This also introduces a new -.slice root slice, that is the parent of
system.slice and friends. This enables easy admin configuration of
root-level cgrouo properties.

This replaces DeviceDeny= by DevicePolicy=, and implicitly adds in
/dev/null, /dev/zero and friends if DeviceAllow= is used (unless this is
turned off by DevicePolicy=).
2013-06-27 04:17:34 +02:00
Lennart Poettering 9444b1f20e logind: add infrastructure to keep track of machines, and move to slices
- This changes all logind cgroup objects to use slice objects rather
  than fixed croup locations.

- logind can now collect minimal information about running
  VMs/containers. As fixed cgroup locations can no longer be used we
  need an entity that keeps track of machine cgroups in whatever slice
  they might be located. Since logind already keeps track of users,
  sessions and seats this is a trivial addition.

- nspawn will now register with logind and pass various bits of metadata
  along. A new option "--slice=" has been added to place the container
  in a specific slice.

- loginctl gained commands to list, introspect and terminate machines.

- user.slice and machine.slice will now be pulled in by logind.service,
  since only logind.service requires this slice.
2013-06-20 03:49:59 +02:00
Thomas Hindoe Paaboel Andersen d9acfb71db analyze: show unit file loading on plot
This will add another color to the legend called "Loading unit files"
Like the generators it will mark a part of the systemd bar indicating
the time spent while loading unit files.
2013-06-02 22:26:13 +02:00
Umut Tezduyar 518d10e985 analyze: show generators on plot 2013-06-02 22:26:05 +02:00
Václav Pavlín 99504dd4c1 systemctl: add commands set-default and get-default
systemctl set-default NAME links the default.target to the given unit,
get-default prints out the path to the currently set default target.
2013-05-30 20:44:41 -04:00
Harald Hoyer 17f5e4577b dbus-manager.c: log error, why switch-root is refused 2013-04-26 13:33:28 +02:00
Zbigniew Jędrzejewski-Szmek ef42202ac8 Add set_consume which always takes ownership
Freeing in error path is the common pattern with set_put().
2013-04-24 00:25:04 -04:00
Lennart Poettering 6606089752 path-util: unify code for detecting OS trees
This also makes sure we always detect an OS tree the same way, by
checking for /etc/os-release.
2013-04-16 05:47:04 +02:00
Ronny Chevalier d4b7fecb05 dbus-manager: fix variable type introspection 2013-04-08 18:27:55 +02:00
Colin Walters c6a818c820 Use bus_maybe_send_reply() where applicable
This is a followup to: commit 1a37b9b904

It will fix denial messages from dbus-daemon between gdm and
systemd-logind on logging into GNOME due to this.

See the previous commit for more details.
2013-03-18 19:59:32 -04:00
Lennart Poettering 26d04f86a3 unit: rework resource management API
This introduces a new static list of known attributes and their special
semantics. This means that cgroup attribute values can now be
automatically translated from user to kernel notation for command line
set settings, too.

This also adds proper support for multi-line attributes.
2013-02-27 18:50:41 +01:00
Lennart Poettering 123b964a53 manager: validate environment parameters for SetEnvironment(), UnsetEnvironment() bus calls 2013-02-11 23:54:30 +01:00
Lennart Poettering 4d1a690438 env: considerably beef up environment cleaning logic
Now, actually check if the environment variable names and values used
are valid, before accepting them. With this in place are at some places
more rigid than POSIX, and less rigid at others. For example, this code
allows lower-case environment variables (which POSIX suggests not to
use), but it will not allow non-UTF8 variable values.

All in all this should be a good middle ground of what to allow and what
not to allow as environment variables.

(This also splits out all environment related calls into env-util.[ch])
2013-02-11 03:54:50 +01:00
Lennart Poettering d2a3097582 systemctl: add new "get-cgroup-attr" to query current cgroup attribute value
Also adds a pair of bus calls for this to the daemon.
2013-01-18 01:44:41 +01:00
Lennart Poettering 246aa6dd9d core: add bus API and systemctl commands for altering cgroup parameters during runtime 2013-01-14 21:24:57 +01:00
Lennart Poettering 5dd9014faf dbus: duplicate Job.Cancel() as CancelJob() and Snapshot.Remove() as RemoveSnapshot() on the Manager interface
For all other object mehtods there are already counterparts on the
manager object, as they help us reduce round-trips. So let's complete
this, and reduce complexity on the client side a bit.

As a side effect this also makes "systemctl snapshot" without arguments
work again.
2013-01-10 23:03:48 +01:00
Lennart Poettering bc2708414b build-sys: drop all distribution specfic checks
Yay, we now have a completely generic systemd. No distribution specific checks anymore!
2013-01-04 23:26:21 +01:00
Zbigniew Jędrzejewski-Szmek f72daa64dc dbus-manager: modernize style 2012-11-15 16:30:24 +01:00
Eelco Dolstra 645a9e5a2b dbus-manager: fix a fatal dbus abort in bus_manager_message_handler()
If ListUnitFiles fails, or an OOM occurs, then dbus_message_unref()
will be called twice on "reply", causing systemd to crash.  So remove
the call to dbus_message_unref(); it is unnecessary because of
the cleanup attribute on "reply".

[zj: modified to leave one dbus_message_unref() alone, per Colin
Walters' comment.]
2012-11-15 16:29:53 +01:00
Michal Schmidt f8b69d1dfc shared, core: do not always accept numbers in string lookups
The behaviour of the common name##_from_string conversion is surprising.
It accepts not only the strings from name##_table but also any number
that falls within the range of the table. The order of items in most of
our tables is an internal affair. It should not be visible to the user.

I know of a case where the surprising numeric conversion leads to a crash.

We will allow the direct numeric conversion only for the tables where the
mapping of strings to numeric values has an external meaning. This holds
for the following lookup tables:
 - netlink_family, ioprio_class, ip_tos, sched_policy - their numeric
   values are stable as they are defined by the Linux kernel interface.
 - log_level, log_facility_unshifted - the well-known syslog interface.

We allow the user to use numeric values whose string names systemd does
not know. For instance, the user may want to test a new kernel featuring
a scheduling policy that did not exist when his systemd version was
released. A slightly unpleasant effect of this is that the
name##_to_string conversion cannot return pointers to constant strings
anymore. The strings have to be allocated on demand and freed by the
caller.
2012-10-30 15:41:15 +01:00
Lukas Nykryn b3c2cf3d8e dbus-manager: check return of unit_dbus_path
Reply of dbus_message_new_method_return was check twice and
path from unit_dbus_path was not.
2012-10-08 14:35:46 +02:00
Lennart Poettering dfae3488f7 dbus: expose Virtualization ID on PID1's bus interface
This allows unprivileged clients to check for the used virtualization
even when lacking the privileges that some of the virtualization tests
require.

https://bugzilla.gnome.org/show_bug.cgi?id=684801
2012-10-04 14:09:25 -04:00
Lennart Poettering ffc227c956 selinux: remove anything PID1-specific from selinux-access.[ch] so that we can reuse it in logind 2012-10-02 17:56:54 -04:00
Lennart Poettering cad45ba11e selinux: rework selinux access check logic
a) Instead of parsing the bus messages inside of selinux-access.c
simply pass everything pre-parsed in the functions

b) implement the access checking with a macro that resolves to nothing
on non-selinux builds

c) split out the selinux checks into their own sources
selinux-util.[ch]

d) this unifies the job creation code behind the D-Bus calls
Manager.StartUnit() and Unit.Start().
2012-10-02 17:07:00 -04:00
Zbigniew Jędrzejewski-Szmek 67445f4e22 core: move ManagerRunningAs to shared
Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the
patch quite verbose. Nevertheless, keeping MANAGER prefix in some
places, and SYSTEMD prefix in others would just lead to confusion down
the road. Better to rip off the band-aid now.
2012-09-18 19:53:34 +02:00
Lennart Poettering c309067483 selinux: use existing library calls for audit data 2012-09-18 01:55:49 +02:00
Daniel J Walsh e2417e4143 selinux: add bus service access control
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This patch adds the ability to look at the calling process that is trying to
do dbus calls into systemd, then it checks with the SELinux policy to see if
the calling process is allowed to do the activity.

The basic idea is we want to allow NetworkManager_t to be able to start and
stop ntpd.service, but not necessarly mysqld.service.

Similarly we want to allow a root admin webadm_t that can only manage the
apache environment.  systemctl enable httpd.service, systemctl disable
iptables.service bad.

To make this code cleaner, we really need to refactor the dbus-manager.c code.
 This has just become a huge if-then-else blob, which makes doing the correct
check difficult.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://www.enigmail.net/

iEYEARECAAYFAlBJBi8ACgkQrlYvE4MpobOzTwCdEUikbvRWUCwOb83KlVF0Nuy5
lRAAnjZZNuc19Z+aNxm3k3nwD4p/JYco
=yops
-----END PGP SIGNATURE-----
2012-09-18 01:21:17 +02:00
Lennart Poettering 915b375388 manager: extend performance measurement interface to include firmware/loader times
This only adds the fields to the D-Bus interfaces but doesn't fill them
in with anything useful yet. Gummiboot exposes the necessary bits of
information to use however and as soon as I get my fingers on a proper
UEFI laptop I'll hook up the remaining bits.

Since we want to stabilize the D-Bus interface soon and include it in
the stability promise we should get the last fixes in, hence this change
now.
2012-09-13 18:54:32 +02:00
Lennart Poettering c74f17d96c core: drop KillMode parameter from KillUnit() bus call
It made no sense, and since we are documenting the bus calls now and
want to include them in our stability promise we really should get it
cleaned up sooner, not later.
2012-07-20 00:10:32 +02:00
Lennart Poettering e616d1c674 core: fix name of dbus call parameter 2012-07-16 19:11:27 +02:00
Lennart Poettering b7def68494 util: rename join() to strjoin()
This is to match strappend() and the other string related functions.
2012-07-13 13:41:01 +02:00
Lennart Poettering b4efdf9720 remount-fs: also remount /usr according to fstab 2012-06-29 16:14:43 +02:00
Lennart Poettering 2aac569ab4 bus: drop HaveWatchdog option
Clients should always watch /dev/watchdog directly, instead of going
indirect. Let's keep our stacks small.
2012-06-26 00:03:43 +02:00
Lennart Poettering a3a3e5b6ae dbus: don't expose SysVInitPath and SysVRcndPath on the bus
People should use systemd.pc if anything at all to determine these
directories, and people should not assume that the bus fields are part
of the supported API, so let's just drop this.
2012-06-22 16:18:51 +02:00
Lennart Poettering d081dffbd3 core: remove sysv_console option
This option never made much sense. It was originally intended to make
sure that the usual startup output of sysv scripts goes to the terminal.
However, since SysV scripts started from a terminal would not output to
that terminal, but rather /dev/console this effect was more often than
not actually taking place. Nowadays systemd has much nicer boot time
status output than SysV which makes the sysv output redundant. Finally,
all output of services goes to the journal anyway, and is not lost.

Hence, let's drop this option, and simplify things a bit.
2012-06-22 13:16:28 +02:00