Commit Graph

89 Commits

Author SHA1 Message Date
Michael Crosby cb6ba4dbfb Set apparmor profile in execin
The set of the apparmor profile for the setns codepath was missing.
Selinux was being called but apparmor was forgotten.  This was causing
no profiles to be applied to the extra process spawn inside an existing
container.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-10-14 05:53:44 +00:00
Saied Kazemi ae81ea069f Add RootFs field to configuration options in libcontainer's Config
Since currently the container.json file does not include the pathname
to a container's root filesystem, we need to parse /proc/mounts which
is slow and error-prone.  This patch addresses this issue by adding a
new RootFs field.

Signed-off-by: Saied Kazemi <saied@google.com>
2014-09-23 16:16:13 -07:00
Michael Crosby 781855b62a Cleanup systemd cgroup code
The current paths for the different systemd cgroup subsystems that
systemd manages and that we have to manage are very inconsistent.  This
patch cleans up those differences and allows consistent paths to be
used.

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-13 18:16:51 -07:00
Vishnu Kannan ad16526d7f Store all the cgroups paths as part of the state. This simplifies entering cgroups and will be useful for
cleanups too in the future.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Vishnu Kannan ae08910fde Enter cgroups as part of nsenter while using systemd.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Vishnu Kannan ae64fd1e58 Enter cgroups while entering namespaces as part of NsEnter.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-13 23:26:27 +00:00
Michael Crosby 70367b2cf3 Improve execin to support registering funcs
This also changes the functionality of the default exec in to just be an
existing func that is called than handles the implementation to exec a
user user's process inside the container.  This implements this
functionallity in nsinit but is a base for how we will be handling these
types of features inside docker.

Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-12 11:43:12 -07:00
Michael Crosby fc05554fdb Allow comparison based on strlen of "nsenter"
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-08 15:44:18 -07:00
Michael Crosby 4d1d6185ab Add unsupported file for cross compile
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-08 12:14:48 -07:00
Michael Crosby cdff060b63 Nsenter checks for argv 0 before running
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-08 11:11:23 -07:00
Michael Crosby 86f6df8993 Move nsenter code into separate package
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-08 10:42:19 -07:00
Michael Crosby ae9af437f0 After parsing flags check that the command is nsenter
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-07 10:48:29 -07:00
Michael Crosby 5226b39d15 Fix issues in nsenter.c and console handling
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 22:04:28 -07:00
Michael Crosby a48b001013 Refactor execin code to be simpler
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 18:44:41 -07:00
Michael Crosby 390f413a92 Make syncpipe transport generic data
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-06 18:00:52 -07:00
Michael Crosby 8b6c0b7ec6 Add linux style formatting
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-05 16:04:18 -07:00
Michael Crosby f3b0a3a0e6 Move nsenter C code to separate file
Signed-off-by: Michael Crosby <michael@docker.com>
2014-08-05 16:04:08 -07:00
Vishnu Kannan f90eee10ef Remove debug message.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Vishnu Kannan 74b99b8dd6 Check for "nsenter" in args before parsing flags. Addressed comments.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Vishnu Kannan e5e40b6ef0 Docker 'runin' demands passing flags before 'nsenter' cli option.
Docker does not require RunIn API. Hence that API has been removed.
nsinit CLI has been modified to work around the nsenter changes.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-08-05 22:13:23 +00:00
Mrunal Patel 7f3bbbb47b Move locking to caller.
Docker-DCO-1.1-Signed-off-by: Mrunal Patel <mrunalp@gmail.com> (github: mrunalp)
2014-08-01 19:06:56 -04:00
Bernerd Schaefer 041fafc763 DefaultCreateCommand supports command w/ flags
namespaces.DefaultCreateCommand prepends the user-supplied command to
execute with "--", so that "nsinit init" does not attempt to interpret
it.

Docker-DCO-1.1-Signed-off-by: Bernerd Schaefer <bj.schaefer@gmail.com> (github: bernerdschaefer)
2014-07-31 21:32:10 +02:00
Tianon Gravi e31771fa42 Move "pkg/user" into libcontainer and add support for GetUserGroupSupplementary to return "Home" too
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
2014-07-29 10:59:18 -06:00
Victor Marmol 7dc9dc3473 Merge pull request #58 from maebashi/fix-setns-order
fix the order of setns()
2014-07-29 09:45:13 -07:00
maebashi f333c5ce9b remove unnecessary headers
Docker-DCO-1.1-Signed-off-by: Takahiro Maebashi <maebashi@iij.ad.jp> (github: maebashi)
2014-07-28 11:02:35 +09:00
Aleksa Sarai 01a7f19afe namespaces: nsenter: ignore nonexistent namespaces
If a particular kernel doesn't have namespace directories that
libcontainer tries to attain during nsenter(), ignore the error (this is
consistent with the previous implementation of nsenter()).

Docker-DCO-1.1-Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-07-28 11:02:17 +09:00
Michael Crosby 52e7350c9d Correct nsenter fprintf syntax
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-24 14:54:05 -07:00
Michael Crosby 4568ca76c8 Update imports for new docker location
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-24 14:28:49 -07:00
Vishnu Kannan 1f2828770d Updated RunIn API to match the new console handling behavior in HEAD.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-07-22 19:49:59 +00:00
Vishnu Kannan 145299f9d8 Adding RunIn to run a user specified command in an existing container, wait for it to exit and return the exit code.
RunIn will connect to a user specified Terminal before running the command.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-07-22 19:49:59 +00:00
Michael Crosby 0dcae82acb Initially mount /sys as ro instead of remount
The issue with doing a remount as ro with sysfs is that if a container
is still in one of the hosts namepsaces, commonly with the NET
namespace, the remount will cause the host's systems sysfs to be
remounted as ro also.  We can fix this correctly by not doing the
remount and just mount sys as ro in the first place.

The other remounts are individual files within proc so they will not
have this issue.

For context please see:
https://github.com/dotcloud/docker/issues/7101
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-18 14:13:38 -07:00
Michael Crosby b56aa0658a Don't open slave in parent
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-15 18:24:15 -07:00
Michael Crosby d661720fd7 Remove terminal handling in libcontainer
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-15 16:55:11 -07:00
Michael Crosby e9ec77ab34 Migrate selinux system xattr calls and prctl calls
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 16:55:49 -07:00
Michael Crosby a2dc64cf30 Add initial system pkg to libcontainer
Port over console and ptmx code into console package
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 16:46:51 -07:00
Michael Crosby 0ebcbde911 Remove unsupported file
This is no longer needed and is not properly built with the cross
compile scripts anyways.
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-14 12:50:51 -07:00
Paul Morie ea6e255f45 Remove unused arg from namespaces.NsEnter
Docker-DCO-1.1-Signed-off-by: Paul Morie <pmorie@gmail.com> (github: pmorie)
2014-07-13 17:48:27 -04:00
Michael Crosby 422824c9d8 Move syncpipe into separate package
This moves the sync pipe into a separate package to help the changes
when moving the API around.

Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-07-11 11:06:00 -07:00
maebashi 16f939a958 fix the order of setns()
Docker-DCO-1.1-Signed-off-by: Takahiro Maebashi <maebashi@iij.ad.jp> (github: maebashi)
2014-06-29 20:05:09 +09:00
Michael Crosby a980a961c1 Return error on shutdown call
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:18:39 -07:00
Michael Crosby bd7d1eb7b6 Fix parent type in sync pipe
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:08:49 -07:00
Michael Crosby e098c02ef7 Update tests for network state
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:06:26 -07:00
Michael Crosby 73ff1addf9 Fix cross compile with syscall
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:03:49 -07:00
Michael Crosby e7916505a3 Add unit test for sync pipe
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:03:49 -07:00
Michael Crosby eb9a561b18 Address review comments
Ensure that the command is killed if we receive an error from the child
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@docker.com> (github: crosbymichael)
2014-06-26 14:02:43 -07:00
Alexander Larsson ca9544522e Report child error better (and later)
We use a unix domain socketpair instead of a pipe for the sync pipe,
which allows us to use two-way shutdown. After sending the
context we shut down the write side which lets the child know
it finished reading.

We then block on a read in the parent for the child closing the file
(ensuring we close our version of it too) to sync for when the child
is finished initializing. If the read is non-empty we assume this
is an error report and fail with an error. Otherwise we continue as
before.

This also means we're now calling back the start callback later,
meaning at that point its more likely to have succeeded, as well as
having consumed all the container resources (like volume mounts,
making it safe to e.g. unmount them when the start callback is
called).

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
2014-06-26 14:02:43 -07:00
Michael Crosby f975ff9159 Merge pull request #25 from vishh/network_stats
Adding per container network stats
2014-06-26 13:58:18 -07:00
Glyn Normington 29adc8c29f Improve nsinit usage instructions
nsinit must be run as root.

Tidy up the README somewhat to clarify the distinction between
libcontainer and the nsinit CLI.

Fix some typos in other files.

Docker-DCO-1.1-Signed-off-by: Glyn Normington <gnormington@gopivotal.com> (github: glyn)
2014-06-26 11:57:09 +01:00
Vishnu Kannan 98c2593cdc Refactores network Interface a bit to use NetworkState struct instead of a map for passing runtime information around.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 22:51:28 +00:00
Vishnu Kannan edf1e856a0 RuntimeCkpt is now State and the checkpoint file is called state.json.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-06-25 21:29:04 +00:00