Commit Graph

114 Commits

Author SHA1 Message Date
Andrey Vagin dcb3bca32c namespaces: destroy cgroups only on error paths
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-19 17:38:26 +03:00
Andrey Vagin 76d395eff2 new-api: add Console to ProcessConfig
Add ability to execute a process with a specified terminal.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 18:22:47 +03:00
Andrey Vagin 083d91f8c3 cgroups: Add comments for methods of cgroup managers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 01:45:49 +03:00
Andrey Vagin 6dd7552537 new-api: implement fs and systemd cgroup managers
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2015-01-15 00:43:13 +03:00
Andrey Vagin 195a08efbc new-api: set Cloneflags in namespace.Exec()
This place looks more suitable.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-25 18:44:10 +03:00
Andrey Vagin d572094b75 new-api: execute a process inside an existing container
A new constructor function (like nsenter) is added in this patch.  This
function gets arguments from environment variables and its behaviour doesn't
depend on a command line arguments.

A program which calls factory.StartInitialization() must import the nsenter
package. It looks ugly, but I don't know another way how to enter into CT from
a go code.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-25 18:44:10 +03:00
Andrey Vagin c912207636 namespaces: combine Process.Env and Container.Env
Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-19 14:48:16 +03:00
Andrey Vagin 5ecd29c1f2 linux_container: fork an init process in a new set of namespaces
Use namespace.Exec() and namespace.Init() to execute processes in CT.

Now an init process is actually executed in a new container. This series
doesn't change code about creating containers, it only reworks code according
with new API.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-19 14:47:04 +03:00
Andrey Vagin ce9d63376f libcontainer: move State in the configs package
We are going to import the namespaces package into libcontainer,
so libcontainer should not be imported into namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-19 12:32:34 +03:00
Andrey Vagin 7038ddbc8c libcontainer: move Config in a separate package
We are going to import the namespaces package into libcontainer,
so libcontainer should not be imported into namespaces.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
2014-12-19 12:32:34 +03:00
Mrunal Patel 6ffd59a784 Merge pull request #279 from crosbymichael/namespaces-join
Change namespaces config to include path for setns
2014-12-04 11:19:48 -08:00
Michael Crosby 12124f731d Remove unused namespace types
This removes the unsued namespace types from the namespace package
and simplifies getting the values for the namespaces.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-12-03 15:47:26 -08:00
Michael Crosby 549f508d5b Change namespaces config to include path for setns
This changes the namespace configuration on the config to include the
name of the namespace along with an optional path.  This path is used to
point to a file of another namespace for the namespace so that it can be
joined in place of the empty, initialized namespace.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-12-03 12:00:43 -08:00
Mrunal Patel 53eca435e6 Merge pull request #273 from vishh/prctl
Set child sub reaper option on nsenter
2014-12-02 15:28:38 -08:00
Brian Goff e6cc8fc713 Add support for setting rlimit for contianer
Adds a new item to the config struct []*Rlimit
Rlimit takes a type (ie, syscall.RLIMIT_NOFILE) and the hard/soft limit
(As max/cur)

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2014-11-26 14:10:01 -05:00
Vishnu Kannan 4c6df516ae Set child sub reaper option on nsenter to help cleanup all processes orphaned via ExecIn.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
2014-11-19 20:14:20 +00:00
Michael Crosby 29b1d2b23f Move RemovePaths into cgroups pkg for reuse
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 11:56:19 -08:00
Michael Crosby bc7efa6b81 Have cgroup.Apply return paths to setup cgroups
There is no reason to have a special type returned from the cgroups
Apply function for getting the paths and cleanup.  With access to the
paths we can just delete what we need.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-17 11:56:19 -08:00
Michael Crosby 933fc88943 Provide better sethostname error message
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-14 17:46:11 -08:00
Daniel, Dao Quang Minh f61288fe37 use os.Environ() to set exec command's env
because `LoadContainerEnvironment` is already run, os.Environ() will return the
correct environment variables for the exec command (i.e. removed duplicated
envs, set HOME for user etc...)

Docker-DCO-1.1-Signed-off-by: Daniel, Dao Quang Minh <dqminh89@gmail.com> (github: dqminh)
2014-11-14 12:51:14 -05:00
Aleksa Sarai 195d8d544a user: lookup: added os/user-like lookup API
This patch adds an os/user-like user lookup API, implemented in pure Go.
It also has some features not present in the standard library
implementation (such as group lookups).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-11-07 11:07:21 +11:00
Aleksa Sarai 50b68c9b4f user: *: refactor and expand libcontainer/user API
This patch refactors most of GetUserGroupSupplementaryHome and its
signature, to make using it much simpler. The private parsing ftunctions
have also been exposed (parsePasswdFile, parseGroupFile) to allow custom
data source to be used (increasing the versatility of the user/ tools).

In addition, file path wrappers around the formerly private API
functions have been added to make usage of the API for callers easier if
the files that are being parsed are on the filesystem (while the
io.Reader APIs are exposed for non-traditional usecases).

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com> (github: cyphar)
2014-11-07 11:07:21 +11:00
Michael Crosby 2be676643e Remove syncpipe pkg
This removes the entire syncpipe package and replaces it with standard
operations on the pipes.  The syncpipe type just never felt right and
probably should not have been there.

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
2014-11-06 00:08:10 +00:00
unclejack 59584e5ba1 use system.Set{u,g}id to fix Set{u,g}id on Go 1.4
Docker-DCO-1.1-Signed-off-by: Cristian Staretu <cristian.staretu@gmail.com> (github: unclejack)
2014-11-03 21:50:36 +02:00
Dan Walsh b6a9bdb38f Allow IPC namespace to be shared between containers or with the host
Some workloads rely on IPC for communications with other processes.  We
would like to split workloads between two container but still allow them
to communicate though shared IPC.

This patch allows us to mimic the --net code to allow --ipc=host to not split off
the IPC Namespace.  ipc=container:CONTAINERID to share ipc between containers

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
2014-10-25 06:16:20 -04:00
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