Commit graph

56 commits

Author SHA1 Message Date
Lennart Poettering 0370612e05 machined: make "machinectl copy-to" and "machinectl copy-from" server side operations
This way, any bus client can make use of these calls.
2015-02-17 19:22:36 +01:00
Lennart Poettering 90adaa25e8 machined: move logic for bind mounting into containers from machinectl to machined
This extends the bus interface, adding BindMountMachine() for bind
mounting directories from the host into the container.
2015-02-17 17:49:21 +01:00
Lennart Poettering c19de71113 machined: refer to the disk space allocated for an image to "usage" rather than "size"
After all, it's closer to the "du"-reported value than to the file
sizes...
2015-01-19 20:24:09 +01:00
Lennart Poettering c00a4c8f55 Revert "machined: don't force terminate registered machines"
This reverts commit 206e7a5f7b.

We actually want to allow shutting down containers that use
RegisterMachine() rather than CreateMachine() to register their own
unit. It should be safe to do so, since the primary usecase for
RegisterMachine() are container managers that run only a single
container within their own unit, such as systemd-nspawn.
2014-12-29 20:13:58 +01:00
Lennart Poettering e5f5b5b9c9 machined: ignore spurious error 2014-12-29 19:08:50 +01:00
Lennart Poettering 1ddb263d21 machined: don't look for images on each property get, but cache the image object inbetween 2014-12-28 02:44:37 +01:00
Lennart Poettering b6b1849830 machined: add support for reporting image size via btrfs quota 2014-12-28 02:08:40 +01:00
Lennart Poettering ebd93cb684 machinectl/machined: implement "rename", "clone", "read-only" verbs for machine images 2014-12-28 02:08:40 +01:00
Lennart Poettering 086821244b machined: add "machinectl remove" for removing images 2014-12-28 02:08:40 +01:00
Lennart Poettering 003dffde2c machined: Move image discovery logic into src/shared, so that we can make use of it from nspawn 2014-12-28 02:08:40 +01:00
Filipe Brandenburger 9bb0c7cfbb machined: remove spurious include of <sys/capability.h>
They do not use any functions from libcap directly. The CAP_KILL constant in
use by these files comes from <linux/capability.h> imported through
"missing.h".

Tested that "systemd-machined" builds cleanly and works after this change.
2014-12-25 10:56:34 -05:00
Lennart Poettering 10f9c75519 machined: beef up machined image listing with creation/modification times of subvolumes
We make use of the btrfs subvol crtime for this, and for gpt images of a
manually managed xattr, if we can.
2014-12-25 03:19:19 +01:00
Lennart Poettering d04c1fb8e2 machined: introduce polkit for OpenLogin() call
This way "machinectl login" can be opened up to run without privileges.
2014-12-23 21:28:48 +01:00
Lennart Poettering 5f8cc96a03 machined: add new call OpenMachineLogin() that starts a getty in a container on a pty and returns the pty master fd to the client
This is a one-stop solution for "machinectl login", and should simplify
getting logins in containers.
2014-12-23 19:15:27 +01:00
Lennart Poettering 40205d706e machined: add OpenMachinePTY() bus call for allocating a PTY device within a container
Then, port "machinectl" over to make use of it.
2014-12-23 03:26:24 +01:00
Lennart Poettering c2ce6a3d82 machined: add new GetImage() bus call for retrieving the bus path for an image 2014-12-19 20:07:23 +01:00
Lennart Poettering cd61c3bfd7 machined/machinectl: add logic to show list of available images
This adds a new bus call to machined that enumerates /var/lib/container
and returns all trees stored in it, distuingishing three types:

        - GPT disk images, which are files suffixed with ".gpt"
        - directory trees
        - btrfs subvolumes
2014-12-19 19:19:29 +01:00
Lennart Poettering 96aad8d15a sd-bus: move common errors src/shared/bus-errors.h → src/libsystemd/sd-bus/bus-common-errors.h
Stuff in src/shared/ should not use stuff from src/libsystemd/ really.
2014-12-10 19:07:48 +01:00
Lennart Poettering 8d07a7c471 machined: reorder method calls in vtable 2014-11-06 20:00:14 +01:00
Lennart Poettering a931ad47a8 core: introduce new Delegate=yes/no property controlling creation of cgroup subhierarchies
For priviliged units this resource control property ensures that the
processes have all controllers systemd manages enabled.

For unpriviliged services (those with User= set) this ensures that
access rights to the service cgroup is granted to the user in question,
to create further subgroups. Note that this only applies to the
name=systemd hierarchy though, as access to other controllers is not
safe for unpriviliged processes.

Delegate=yes should be set for container scopes where a systemd instance
inside the container shall manage the hierarchies below its own cgroup
and have access to all controllers.

Delegate=yes should also be set for user@.service, so that systemd
--user can run, controlling its own cgroup tree.

This commit changes machined, systemd-nspawn@.service and user@.service
to set this boolean, in order to ensure that container management will
just work, and the user systemd instance can run fine.
2014-11-05 18:49:14 +01:00
Lennart Poettering 3a6fb33c54 machined: fix address API signatures 2014-08-04 19:05:06 +02:00
Lennart Poettering 9b5ed6feda machined: allow registering host-side network interfaces for communication with containers 2014-07-10 22:47:55 +02:00
Lennart Poettering 8d90c8a8d6 machine: properly distuingish created and registered machines 2014-07-03 20:19:58 +02:00
Lennart Poettering 717603e391 machinectl: show /etc/os-release information of container in status output 2014-07-03 17:54:24 +02:00
Lennart Poettering 206e7a5f7b machined: don't force terminate registered machines
When a machine is registered in machined with CreateMachine it is OK to
kill the machine when it is terminated, but when an existing unit is
simply registered via RegisterMachine we shouldn't do that, as the unit
is controlled by somebody else.
2014-07-03 12:51:07 +02:00
Lennart Poettering 7f0d207d2c sd-bus: support connecting to remote hosts, directly into containers
systemctl -H root@foobar:waldi

will now show a list of services running on container "waldi" on host
"foobar", using "root" for authenticating at "foobar".

Since entereing a container requires priviliges, this will only work
correctly for root logins.
2014-07-03 01:17:26 +02:00
Lennart Poettering 878cd7e95c machined: add logic to query IP addresses of containers 2014-05-18 20:52:49 +09:00
Zbigniew Jędrzejewski-Szmek de0671ee7f Remove unnecessary casts in printfs
No functional change expected :)
2014-05-15 15:29:58 +02:00
Lennart Poettering de58a50e24 machined: fix Kill() bus call on machine objects when "what" is specified as "leader" 2014-03-18 04:48:26 +01:00
Lennart Poettering 151b9b9662 api: in constructor function calls, always put the returned object pointer first (or second)
Previously the returned object of constructor functions where sometimes
returned as last, sometimes as first and sometimes as second parameter.
Let's clean this up a bit. Here are the new rules:

1. The object the new object is derived from is put first, if there is any

2. The object we are creating will be returned in the next arguments

3. This is followed by any additional arguments

Rationale:

For functions that operate on an object we always put that object first.
Constructors should probably not be too different in this regard. Also,
if the additional parameters might want to use varargs which suggests to
put them last.

Note that this new scheme only applies to constructor functions, not to
all other functions. We do give a lot of freedom for those.

Note that this commit only changes the order of the new functions we
added, for old ones we accept the wrong order and leave it like that.
2014-02-20 00:03:10 +01:00
Lennart Poettering 89f7c8465c machined: optionally, allow registration of pre-existing units (scopes
or services) as machine with machined
2014-02-11 17:16:08 +01:00
Lennart Poettering 4e05c4951a machined: since we can now somewhat reliable get notifications for dying
scopes we don't need to lower the stop timeout anymore
2014-02-07 16:18:16 +01:00
Lennart Poettering adacb9575a bus: introduce "trusted" bus concept and encode access control in object vtables
Introduces a new concept of "trusted" vs. "untrusted" busses. For the
latter libsystemd-bus will automatically do per-method access control,
for the former all access is automatically granted. Per-method access
control is encoded in the vtables: by default all methods are only
accessible to privileged clients. If the SD_BUS_VTABLE_UNPRIVILEGED flag
is set for a method it is accessible to unprivileged clients too. By
default whether a client is privileged is determined via checking for
its CAP_SYS_ADMIN capability, but this can be altered via the
SD_BUS_VTABLE_CAPABILITY() macro that can be ORed into the flags field
of the method.

Writable properties are also subject to SD_BUS_VTABLE_UNPRIVILEGED and
SD_BUS_VTABLE_CAPABILITY() for controlling write access to them. Note
however that read access is unrestricted, as PropertiesChanged messages
might send out the values anyway as an unrestricted broadcast.

By default the system bus is set to "untrusted" and the user bus is
"trusted" since per-method access control on the latter is unnecessary.

On dbus1 busses we check the UID of the caller rather than the
configured capability since the capability cannot be determined without
race. On kdbus the capability is checked if possible from the attached
meta-data of a message and otherwise queried from the sending peer.

This also decorates the vtables of the various daemons we ship with
these flags.
2013-12-10 16:52:49 +00:00
Lennart Poettering 5b12334d35 bus: add new sd_bus_creds object to encapsulate process credentials
This way we can unify handling of credentials that are attached to
messages, or can be queried for bus name owners or connection peers.

This also adds the ability to extend incomplete credential information
with data from /proc,

Also, provide a convenience call that will automatically determine the
most appropriate credential object for an incoming message, by using the
the attached information if possible, the sending name information if
available and otherwise the peer's credentials.
2013-11-28 18:42:18 +01:00
Lennart Poettering 86b8d28971 logind,machined,run: properly invoke StartTransientUnit() bus call 2013-11-21 21:12:36 +01:00
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
Lennart Poettering c49b30a235 bus: rename sd_bus_send_with_reply_and_block() to sd_bus_call()
The call is one of the most important ones we expose, where we place
major emphasis on. We should make sure to give it a short, memorable
name.
2013-11-12 00:12:43 +01:00
Kay Sievers 23c80348e6 machine: add missing header include 2013-11-07 15:19:39 +01:00
Kay Sievers ab49725fd8 machine: move symbols referenced by shared code from main to shared file
With --enable-address-sanitizer we get:
  machined-dbus.c:228: undefined reference to 'manager_add_machine'
2013-11-07 14:56:31 +01:00
Lennart Poettering 927b164944 logind: add virtual object paths that always can be used to refer to the callers session, user, seat or machine object
This way clients can skip invoking GetSessionByPID() for their own PID
or a similar call to access these objects.
2013-11-05 20:52:39 +01:00
Lennart Poettering 4e724d9c5a logind: automatically determine client side PID if GetSessionByPID() is called with a PID == 0 2013-11-05 20:44:27 +01:00
Lennart Poettering a658cafa98 machined: simplifications 2013-11-05 01:13:05 +01:00
Lennart Poettering c335068380 machined: port over to libsystemd-bus 2013-10-30 02:08:57 +01:00
Zbigniew Jędrzejewski-Szmek a3e7f417d7 bus: fix access to unitialized variable in error path
src/machine/machined-dbus.c:237:13: warning: Branch condition evaluates to a garbage value
        if (m)
            ^
2013-10-13 17:56:54 -04:00
Zbigniew Jędrzejewski-Szmek bd16acf35e Move functions around to fix underlinking in test-machine-tables 2013-09-26 11:12:04 +02:00
Zbigniew Jędrzejewski-Szmek 1dc2ced464 Remove six unused variables and add annotation
clang FTW!
2013-09-17 19:08:51 -04:00
Lennart Poettering 76e665855e logind: update the session state file before we send out the CreateSession() reply
https://bugs.freedesktop.org/show_bug.cgi?id=67273
2013-07-26 19:03:54 +02:00
Lennart Poettering cba38758b4 logind: update state file after generating the session fifo, not before
https://bugs.freedesktop.org/show_bug.cgi?id=67273
2013-07-26 17:33:01 +02:00