Commit graph

128 commits

Author SHA1 Message Date
Lennart Poettering 7e2270246b nspawn: check with udev before we take possession of an interface 2014-02-13 14:38:02 +01:00
Lennart Poettering b88eb17a7a nspawn: no need to subscribe to netlink messages if we just want to execute one operation 2014-02-13 14:08:16 +01:00
Lennart Poettering a42c8b54b1 nspawn: --private-network should imply CAP_NET_ADMIN 2014-02-13 14:07:59 +01:00
Lennart Poettering d595c5cc9e rtnl: rename constructors from the form sd_rtnl_xxx_yyy_new() to sd_rtnl_xxx_new_yyy()
So far we followed the rule to always indicate the "flavour" of
constructors after the "_new_" or "_open_" in the function name, so
let's keep things in sync here for rtnl and do the same.
2014-02-13 13:53:25 +01:00
Lennart Poettering cf6a891173 rtnl: drop "sd_" prefix from cleanup macros
The "sd_" prefix is supposed to be used on exported symbols only, and
not in the middle of names. Let's drop it from the cleanup macros hence,
to make things simpler.

The bus cleanup macros don't carry the "sd_" either, so this brings the
APIs a bit nearer.
2014-02-13 03:44:14 +01:00
Lennart Poettering aa28aefe61 nspawn: add new --network-interface= switch to move an existing interface into the container 2014-02-13 03:27:39 +01:00
Lennart Poettering 39ed67d146 nspawn: introduce --capability=all for retaining all capabilities 2014-02-13 02:45:11 +01:00
Lennart Poettering db999e0f92 nspawn: newer kernels (>= 3.14) allow resetting the audit loginuid, make use of this 2014-02-12 03:02:09 +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 eb91eb187b nspawn: add --register=yes|no switch to optionally disable registration of the container with machined 2014-02-11 17:16:07 +01:00
Lennart Poettering 8a96d94e4c nspawn: add new --share-system switch to run a container without PID/UTS/IPC namespacing 2014-02-10 13:18:16 +01:00
Lennart Poettering 82adf6af7c nspawn,man: use a common vocabulary when referring to selinux security contexts
Let's always call the security labels the same way:

  SMACK: "Smack Label"
  SELINUX: "SELinux Security Context"

And the low-level encapsulation is called "seclabel". Now let's hope we
stick to this vocabulary in future, too, and don't mix "label"s and
"security contexts" and so on wildly.
2014-02-10 13:18:16 +01:00
Vincent Batts fcf90586a2 nspawn: require /etc/os-release only for init
/etc/os-release is expected for the case for booting a full system, and
need not be required for thin container execution.
2014-02-10 11:57:53 +01:00
Lennart Poettering ba978d7b32 nspawn: rename --file-label to --apifs-label since it's really just about the API file systems, nothing else 2014-02-07 19:29:28 +01:00
Tom Gundersen 5d63309cf5 nspawn: fix HAVE_SELINUX ifdef 2014-02-06 17:30:01 +01:00
Lennart Poettering 284c0b9176 nspawn: add --quiet switch for turning off any output noise 2014-02-06 00:43:14 +01:00
Lennart Poettering 1c03020cc4 nspawn: always use default bus 2014-02-05 23:06:34 +01:00
Lennart Poettering d002827b03 nspawn: various fixes in selinux hookup
- As suggested, prefix argument variables with "arg_" how we do this
  usually.

- As suggested, don't involve memory allocations when storing command
  line arguments.

- Break --help text at 80 chars

- man: explain that this is about SELinux

- don't do unnecessary memory allocations when putting together mount
  option string
2014-02-04 22:56:07 +01:00
Dan Walsh a8828ed938 Add SELinux support to systemd-nspawn
This patch adds to new options:

-Z PROCESS_LABEL

This specifies the process label to run on processes run within the container.

-L FILE_LABEL

The file label to assign to memory file systems created within the container.

For example if you wanted to wrap an container with SELinux sandbox labels, you could execute a command line the following

chcon system_u:object_r:svirt_sandbox_file_t:s0:c0,c1 -R /srv/container
systemd-nspawn -L system_u:object_r:svirt_sandbox_file_t:s0:c0,c1 -Z system_u:system_r:svirt_lxc_net_t:s0:c0,c1 -D /srv/container /bin/sh
2014-02-04 13:33:15 -08:00
Kay Sievers 486e99a387 bus: update kdbus.h (ABI break) 2014-02-01 17:21:36 +01:00
Lennart Poettering 40ddbdf85b nspawn: fix reboot event fd reuse 2014-01-29 20:58:50 +01:00
Lennart Poettering 7f112f50fe exec: introduce PrivateDevices= switch to provide services with a private /dev
Similar to PrivateNetwork=, PrivateTmp= introduce PrivateDevices= that
sets up a private /dev with only the API pseudo-devices like /dev/null,
/dev/zero, /dev/random, but not any physical devices in them.
2014-01-20 21:28:37 +01:00
Lennart Poettering 354bfd2b16 nspawn: do not invoke RegisterMachine on machined from inside the new PID namespace
On kdbus user credentials are not translated across PID namespaces, but
simply invalidated if sender and receiver namespaces don't match. This
makes it impossible to properly authenticate requests from different PID
namespaces (which is probably a good thing). Hence, register the machine
in the parent and not the client and properly synchronize this.
2014-01-09 08:46:23 +08:00
Shawn Landden e10a55fd72 DEFAULT_PATH_SPLIT_USR macro 2013-12-20 23:14:21 -05:00
Lennart Poettering f4889f656b nspawn: add new --setenv= switch to set an environment variable for the container to spawn 2013-12-13 16:37:16 +01:00
Zbigniew Jędrzejewski-Szmek 4d680aeea1 nspawn: complain and continue if machine has same id
If --link-journal=host or --link-journal=guest is used, this totally
cannot work and we exit with an error. If however --link-journal=auto
or --link-journal=no is used, just display a warning.

Having the same machine id can happen if booting from the same
filesystem as the host. Since other things mostly function correctly,
let's allow that.

https://bugs.freedesktop.org/show_bug.cgi?id=68369
2013-12-11 22:39:41 -05:00
Lennart Poettering 9e5548644f bus: connect directly via kdbus in sd_bus_open_system_container()
kdbus fortunately exposes the container's busses in the host fs, hence
we can access it directly instead of doing the namespacing dance.
2013-12-12 00:07:49 +01:00
Zbigniew Jędrzejewski-Szmek 2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Shawn Landden 2ed4e5e0b8 nspawn: fix buggy mount_binds, now works for bind-mounted files 2013-12-06 00:38:13 -05:00
Lennart Poettering 9bd37b40fa nspawn: set up a kdbus namespace when starting a container 2013-11-30 16:36:46 +01:00
Lennart Poettering 898d5c9137 nspawn: improve error message when we cannot resolve the root directory argument 2013-11-26 03:50:32 +01:00
Lennart Poettering 420c7379fb nspawn: add new --drop-capability= switch 2013-11-20 22:10:42 +01:00
Lennart Poettering 76b543756e bus: introduce concept of a default bus for each thread and make use of it everywhere
We want to emphasize bus connections as per-thread communication
primitives, hence introduce a concept of a per-thread default bus, and
make use of it everywhere.
2013-11-12 00:12:43 +01:00
Lennart Poettering 5b30bef856 bus: log message parsing errors everywhere with a generalized bus_log_parse_error() 2013-11-07 21:26:31 +01:00
Lennart Poettering eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Lennart Poettering 1f0cd86b3d nspawn: explicitly terminate machines when we exit nspawn
https://bugs.freedesktop.org/show_bug.cgi?id=68370
https://bugzilla.redhat.com/show_bug.cgi?id=988883
2013-11-06 02:31:35 +01:00
Djalal Harouni b3451bed41 nspawn: log out of memory errors 2013-11-05 18:06:44 +01:00
Lennart Poettering 04d3927924 machinectl: add new command to spawn a getty inside a container 2013-10-31 01:43:38 +01:00
Lennart Poettering 4ba9328022 nspawn: split out pty forwaring logic into ptyfwd.c 2013-10-31 01:43:38 +01:00
Lennart Poettering 88212f7bd1 nspawn: only pass in slice setting if it is set 2013-10-30 18:40:21 +01:00
Lennart Poettering 40ca29a137 timedated: use libsystemd-bus instead of libdbus for bus communication
Among other things this also adds a few things necessary for the change:

- Considerably more powerful error returning APIs in libsystemd-bus

- Adapter for connecting an sd_bus to an sd_event

- As I reworked the PolicyKit logic to the new library I also made it
  asynchronous, so that PolicyKit requests of one user cannot block out
  another user anymore.

- We always use the macro names for common bus error. That way it is
  harder to mistype them since the compiler will notice
2013-10-16 06:15:02 +02:00
Zbigniew Jędrzejewski-Szmek 51d122af23 Introduce _cleanup_fdset_free_ 2013-10-13 17:56:54 -04:00
Lennart Poettering 51045322c4 nspawn: always copy /etc/resolv.conf rather than bind mount
We were already creating the file if it was missing, and this way
containers can reconfigure the file without running into problems.

This also makes resolv.conf handling more alike to handling of
/etc/localtime, which is also not a bind mount.
2013-10-02 19:45:12 +02:00
Dave Reisner cecf24e7f0 fix grammatical error 2013-09-19 14:55:35 -04:00
Dave Reisner d2421337f6 nspawn: be less liberal about creating bind mount destinations
Previously, if a file's bind mount destination didn't exist, nspawn
would blindly create a directory, and the subsequent bind mount would
fail. Examine the filetype of the source and ensure that, if the
destination does not exist, that it is created appropriately.

Also go one step further and ensure that the filetypes of the source
and destination match.
2013-09-19 14:48:43 -04:00
Zbigniew Jędrzejewski-Szmek d182614649 nspawn: trivial simplification 2013-08-23 12:48:14 -04:00
Jesper Larsen aea38d8047 nspawn: Reorder includes to fix compilation
Commit 2e996f4d4b added an include
of linux/netlink.h

This kernel header is not self contained in the linux 2.6 kernel
which breaks compilation with an unknown type sa_family_t

A workaround is to include linux/netlink.h after sys/socket.h
2013-07-19 08:25:50 -04:00
Lennart Poettering 6a4e0b1347 nspawn: use the corect method signature for CreateMachine() 2013-07-02 15:02:54 +02:00
Lennart Poettering 1ee306e124 machined: split out machine registration stuff from logind
Embedded folks don't need the machine registration stuff, hence it's
nice to make this optional. Also, I'd expect that machinectl will grow
additional commands quickly, for example to join existing containers and
suchlike, hence it's better keeping that separate from loginctl.
2013-07-02 03:47:23 +02:00
Zbigniew Jędrzejewski-Szmek bd5a54582a nspawn: '-C' option has been removed
Fixup for 9444b1f "logind: add infrastructure to keep track of
machines, and move to slices."
2013-06-20 00:05:52 -04:00