Commit Graph

2483 Commits

Author SHA1 Message Date
Serge Hallyn
7d0eb87eef confile.c: clear entries if no value
For list configuration entries like capabilities and cgroups
entries, if there is a 'key =' value (i.e. "lxc.cap.drop =")
then clear any loaded entries.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 13:33:11 -06:00
Stéphane Graber
5ff337745e ubuntu: Actually attempt to remove /dev/shm
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-02 12:36:57 -05:00
KATOH Yasufumi
a6daed42f7 doc: Update Japanese lxc-start(1)
Update for commit 7faa7f5200

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 10:00:45 -05:00
Stéphane Graber
c9d845b518 Update doxygen doc for previous change
Reported-by: James Hunt <james.hunt@ubuntu.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-29 16:05:45 -05:00
Stéphane Graber
540f932aeb Allow unsetting daemonize and close_fds
As mentioned in a previous commit, this does two changes:
 - Make want_daemonize return a bool (false on failure, true on success)
 - Make both want_daemonize and want_close_all_fds take a "state"
   argument so the user can choose to unset those flags.

This commit also updates all occurences of those two functions and turns
the daemonize attribute from an int to a bool.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-29 16:05:07 -05:00
Stéphane Graber
c1ee94cfd3 python3: Use FSConverter for all paths
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-29 10:47:46 -05:00
Stéphane Graber
a15877ce80 python3: Allow setting daemonize and close_fds
This extends the list of arguments of start() allowing the user to
request the container be started in the foreground and have control on
whether fds will be closed or not (daemonize=True implies that too).

One problem at the moment however is that while we have functions to set
close_fds and daemonize in the API, we don't have functions to unset
those flags, so those new parameters will only work on the initial call
to start() any further call will use the values of the previous one.

I think it'd make sense to change lxcapi slightly to have daemonize and
close_fds offer a similar interface, both returning booleans and both
accepting a value as a parameter so API users can set the value they
want.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-29 10:43:35 -05:00
Stéphane Graber
956f23e332 python3: Add snapshot_* to the binding
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-29 10:43:02 -05:00
Serge Hallyn
98e5ba5156 chown_mapped_root: fix assumption that calling uid == gid
Because if they are not, then we'll fail trying to map that gid into the
container.

The function doesn't change any gids, but lxc-usernsexec always does
setgid(0), so just map getgid() to 0 in the container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-28 23:57:34 -05:00
Stéphane Graber
e1a2f89809 python3: Export some missing constants
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 22:13:24 -05:00
Stéphane Graber
bb711f3927 python3: Allow passing create flags
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 22:12:44 -05:00
Stéphane Graber
1314b689ec python3: Add clone() to the binding
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 22:12:00 -05:00
Stéphane Graber
7ed86e4486
ubuntu: Fix regression in post-process
THe recent reorg of lxc-ubuntu introduced some package installation in
post-process but without first disabling service startup.

As a result, if the cache is a bit out of date and a ssh update is
available, post-process will apply that update (as it does apt-get
install ssh vim) which in turn will attemp to start sshd. This will
either lead to ssh on the host being restarted or if there's no sshd on
the host, will fail the container creation as the postinst will get an
error from upstart.

The fix is very simply to add the same policy-rc.d trick when running
post-process.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-27 19:46:18 -05:00
Stéphane Graber
cf642e1085
Fix typo in doxygen comment
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-27 17:59:35 -05:00
Stéphane Graber
b2b91754e6
python3: Sort list of exports
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-27 17:51:09 -05:00
Stéphane Graber
47a611a4fc python3: Add (add|remove)_device_node
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:45:11 -05:00
Stéphane Graber
de86840aa0 python3: Add controllable property to the binding
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:45:05 -05:00
Stéphane Graber
5d15c21a4e python3: Add clear_config() to the binding
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:44:57 -05:00
Stéphane Graber
b6c70e430a python3: Re-order all functions
This properly regroups the module functions together and then sorts all
other functions alphabetically to match the function and property lists.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:44:49 -05:00
Stéphane Graber
02cfe84c85 python3: Add reboot() to the binding
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:44:41 -05:00
Stéphane Graber
d7de719ca1 python3: Sort all method/property lists
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:44:34 -05:00
Stéphane Graber
df9e22ea54 python3: Code style
Drop any tab as spaces are preferred, get everything to fit the 80char
limit.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-27 17:44:27 -05:00
Stéphane Graber
44b97d6191 python3: Add list_containers to C API
This adds a new list_containers function to the python3 binding and a
matching override in __init__.py that adds the as_object parameter.

This should be compatible to the previous pure python implementation
with the advantage of also listing active non-defined containers (fixing
github issue #68).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-26 22:29:43 -05:00
Michael H. Warfield
164105f656
Added templates/lxc-centos for CentOS containers.
This adds an lxc-centos template for crreating CentOS 5+ templates.  It
does NOT create CentOS 4 or earlier containers as these are way past
end of life and no longer supported.  It is based on the work of
Fajar A. Nugraha <github@fajar.net> who modified an earlier Fedora
template.  His work has been brought LARGELY into congruence with
the current Fedora template.  It still lacks the distro agnostic
bootstrap and systemd code from the Fedora template but those should
only be relevant with CentOS 7 when that can of worms pops open
sometime next year or so.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-26 13:48:24 -05:00
Stéphane Graber
fc739df565 Some tweaks to direct route to gateway
The previous patch added code to add a static route prior to adding the
gateway to the interface.

This commit simply changes the logic so that this is only done on
failure to add the gateway.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-26 10:22:55 -05:00
Guilhem Lettron
77dcf03a79 Add gateway as direct route for interface
Signed-off-by: Guilhem Lettron <guilhem.lettron@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-26 10:22:47 -05:00
Stéphane Graber
7ee37fac5e
usernsexec: Include utils.h for unshare
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 18:24:03 -05:00
Stéphane Graber
5c5e32fdd3
usernsexec: Add missing getline.h include
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 18:22:05 -05:00
hallyn
7faa7f5200 Merge pull request #92 from majek/share-namespaces
Add options to `lxc-start` to inherit network, ipc and uts namespaces
2013-11-25 13:55:30 -08:00
Michael H. Warfield
5266cf0a64 lxc-fedora: Fixes for selinux and pam_loginuid.so
Just some additional catches for disabling selinux and pam_loginuid.so
thanks to Dwight Engen and the Oracle template.

Also add ssh and ssh-server to the default installation.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 15:22:49 -05:00
Michael H. Warfield
6a59920b64 Fix stupid architecture error.
From 38cfabdbe0e46f5a0ed20687fcda48424b4a7b6d Mon Sep 17 00:00:00 2001
From: "Michael H. Warfield" <mhw@WittsEnd.com>
Date: Mon, 25 Nov 2013 10:34:48 -0500
Subject: [PATCH 1/2] Fix stupid architecture error.
Organization: Thaumaturgy & Speculums Technology

Fix stupid architecture error.

Stupid error and I did it!  Fixed hard coded x86_64 in several spots.

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 15:12:14 -05:00
Serge Hallyn
8befa924f8 lxc-user-nic: use common code from network.c
This pulls a lot of common code out of lxc_user_nic.c.  It also
moves one function from conf.c that was duplicated in lxc_user_nic.c
(It removes a DEBUG statement because (a) it doesn't seem actually
useful and (b) DEBUG doesn't work in network.c).

Also replace the old test of only parsing code with a skeleton for
a full test.  (Note - the test will need some work, it's just there
as do-what-i-mean code example)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 15:12:11 -05:00
Serge Hallyn
8f7b58d68f lxc-user-nic: dont risk passing EOF
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 15:12:07 -05:00
Stéphane Graber
8cd80b50ef
Convert all files to utf-8
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 12:59:07 -05:00
Dwight Engen
db3392c017 add lxc-devsetup to EXTRA_DIST
fixes rpm build

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 12:18:56 -05:00
Stéphane Graber
c01c25fcdd
Tab/spaces consistency for templates
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:57:34 -05:00
Stéphane Graber
f7f1ba77b7
Drop trailing white spaces.
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:52:43 -05:00
James Hunt
953e611cea Add '--enable-api-docs' for doxygen-generated public API docs.
Signed-off-by: James Hunt <james.hunt@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:50:01 -05:00
Guilhem Lettron
703d065d52 lxc-ubuntu: Factorize @LOCALSTATEDIR@ variable
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:55 -05:00
Guilhem Lettron
5eb28ae492 lxc-ubuntu: Add mirror and security-mirror options
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:46 -05:00
Guilhem Lettron
28b62856db lxc-ubuntu: Move package install to post-process
Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:29:30 -05:00
Guilhem Lettron
2004e7da82 lxc-ubuntu: Add extra options
This adds support for "packages", "user" and "password"

Signed-off-by: Guilhem Lettron <guilhem.lettron@optiflows.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:28:47 -05:00
Elan Ruusamäe
853d58fdf5 use awk, instead of 'grep | awk'
Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:15:12 -05:00
KATOH Yasufumi
1b29d73cba doc: Update Japanese lxc-attach(1)
Update for commit 4d69b2939c

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-25 11:13:22 -05:00
Serge Hallyn
ea0da52972 don't fail lxc-init if we couldn't mount proc
In general proc gets mounted ahead of time, so init shouldn't
have to do it.  Without this patch, you cannot

	lxc-execute -n x1 -s lxc.cap.drop=sys_admin /bin/bash

(See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1253669 for
a bug about this)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-22 15:52:57 -06:00
Serge Hallyn
4355ab5fab lxcapi_destroy: run in a namespace if we are unprivileged
This is necessary to have the rights to remove files owned by our subuids.

Also update lxc_rmdir_onedev to return 0 on success, -1 on failure.
Callers were not consistent in using it correctly, and this is more
in keeping with the rest of our code.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-22 15:20:16 -06:00
Stéphane Graber
dfd6d8f019
Add lxc.service to extra_DIST
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-22 14:35:33 -05:00
S.Çağlar Onur
d3d35117e3 add lxc-usernsexec to .gitignore
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-22 13:08:51 -06:00
Serge Hallyn
59328d58d3 remove HAVE_NEWUIDMAP and NEWUIDMAP
Always build lxc-usernsexec.  Else we require having uidmap
installed on the build host for no good reason.  And we never
actually used the NEWUIDMAP path we detected.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-22 08:32:37 -06:00
Serge Hallyn
94272b7104 lxc_usernsexec: fix build breakage
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-21 21:55:06 -06:00