Commit Graph

2861 Commits

Author SHA1 Message Date
S.Çağlar Onur
ccef566eb0 call fclose() for pid_fp on failure
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 15:04:40 -05:00
Bogdan Purcareata
7f1dea04a4 lxc-busybox: make securityfs bind-mount optional
Prevent container start from failing when running Busybox containers on hosts without securityfs support.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 14:59:08 -05:00
Bogdan Purcareata
d2bf794591 lxc-clone: proper type for getopt_long result
While char is a signed type and should have no trouble
storing a "-1" value, getopt_long() will return a value of 255
instead of -1. This has been noticed on powerpc; there's also
some upstream talk about it at [1].

Change variable type from char to int, since it's also the
documented use.

[1] http://stackoverflow.com/questions/17070958/c-why-does-getopt-return-255-on-linux

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 14:59:05 -05:00
KATOH Yasufumi
359c71b65f doc: Update Japanese lxc-monitor(1)
Update for commit 2afd1dc05b

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 14:58:51 -05:00
Serge Logvinov
44b430e2c5 altlinux: Use relative paths and fix rootfs variable.
Change paths in fstab to be relative to the root and fix a wrong
rootfs_path value.

Signed-off-by: Serge Logvinov <serge.logvinov@gmail.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-09 14:55:58 -05:00
Stéphane Graber
4ed0b62273
Update mailing-list addresses
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-08 17:51:28 -05:00
Stéphane Graber
fd580e6deb
lxc_monitor: Add missing include (errno.h)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 18:24:41 -05:00
Stéphane Graber
8e63ce3004 lxc_monitor: Check return value of write
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 17:31:51 -05:00
Dwight Engen
fbbc15397a busybox template: set mode when creating device nodes
Ensure mode 666 is set for tty1 and tty5

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 16:58:47 -05:00
Dwight Engen
2afd1dc05b let lxc-monitor command ask a lxc-monitord instance to quit
Once lxc-monitord receives a quit request from lxc-monitor, it will then
return from the mainloop every time an event occurs on any of its fds and
check if it has any clients left. When there are no more it exits. This
allows lxc-monitord to quit immediately instead of waiting the normal 30
seconds for more clients, potentially freeing up lxcpath for unmounting.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 16:03:23 -05:00
Dwight Engen
84c92abdd1 add epoll events to mainloop callback handlers
Adding the epoll events allows the handler to determine what events
happened on the fd.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 16:03:20 -05:00
Dwight Engen
341c971806 oracle: fix chcon warning when selinux disabled
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 15:36:19 -05:00
Stéphane Graber
64994c030c
confile: Fix invalid lxc.network.ipv6 address
The writer code was using AF_INET instead of AF_INET6 when converting
the address to ascii.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 15:28:55 -05:00
Stéphane Graber
f2a95ee1bf Move some common Ubuntu config
This introduces a new /usr/share/lxc/config directory containing common
configuration snippets.

The two Ubuntu templates are then simplified to just include the
relevant entries avoiding a whole lot of hardcoded cgroup, capabilities
and mount points configuration.

An extra comment is also added at the top of all generated configuration
files telling the user to look at lxc.conf(5) for more information.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 11:21:46 -05:00
Stéphane Graber
34cfffb385 Add support for new create=(dir,file) mount option
Just like we already had "optional", this adds two new LXC-specific
mount flags:
 - create=dir (will do a mkdir_p on the path)
 - create=file (will do a mkdir_p on the dirname + a fopen on the path)

This was motivated by some of the needed bind-mounts for the
unprivileged containers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 11:21:38 -05:00
Stéphane Graber
d6eca24027 conffile.c: Also clear text entries with no value
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-06 11:21:13 -05:00
KATOH Yasufumi
53251299b8 doc: Update Japanese lxc.conf(5)
translate the untranslated paragraph

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-06 09:43:55 -05:00
Stéphane Graber
a026568526 Make lxc-user-nic use mkifname
NetworkManager at least expects all veth devices to be called veth*
otherwise it'll consider them as physical interface and try to do DHCP
on them.

This change makes lxc-user-nic use the same function that we use for LXC
itself which will give us standard vethXXXXX kind of interfaces.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-05 14:56:25 -05:00
S.Çağlar Onur
00194067f1 add destroy option to lxc-snapshot
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-04 12:16:15 -06:00
Stéphane Graber
2b25068a3d Fix Makefile.am to produce usable dist tarball
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-03 17:08:16 -05:00
Stéphane Graber
af7d9cc56c python3: Drop duplicate add_device_node function
It is now natively implemented in C, the new function takes the same
arguments (same order, different names) and has been confirmed to work
with lxc-device.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-03 16:47:55 -05:00
Stéphane Graber
2edd7a881d python3: Fix PEP8 and avoid crash when listing
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-03 16:47:52 -05:00
Stéphane Graber
c5d32181c5 lxc-ubuntu: Replace the hostname in ssh pubkey
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-12-03 16:47:48 -05:00
Andrey Mazo
ebec9176c8 run_buffer(): unblock all signals for spawned scripts.
Currently, all scripts, specified as "lxc.network.script.up", inherit
lxc-execute's signal mask.
This, for example, includes blocked SIGALRM signal which, in turn, makes
alarm(2), sleep(3) and setitimer(2) functions silently unusable in all programs,
invoked in turn by the "lxc.network.script.up".
To fix this, run_buffer() should restore default signal mask prior to
executing "lxc.network.script.up".

A naive implementation would temprorary unblock all signals just before
calling popen() and block them back immediately after it.
But that would result in an immediate delivery of all pending signals just
after their unblocking.
Thus, we should restore default signal mask exactly in child (after fork())
just before calling exec().
To achieve this, a home-brewed popen() alternative is needed.
The added lxc_popen() and lxc_pclose() are mostly taken from glibc with
several simplifications (as we currently need only "re" mode).
The implementation uses Linux-specific pipe2() system-call,
which is only available since Linux 2.6.27 and supported by glibc since
version 2.9 (according to pipe(2) man-page), but this shouldn't be a
problem as lxc requires a fairly recent kernel too.

lxc_popen()/lxc_pclose() are meant to be direct replacements for their
stdio counterparts, so they perform no process_lock() locking
themselves. (as fopen_cloexec() does)
All existing users of popen()/pclose() are converted to the new
lxc_popen()/lxc_pclose().

(mazo: don't clear close-on-exec flag for parent's end;
place the new functions in utils.c;
convert bdev.c to use the new functions;
coding style fixes;
comments fixes;
commit message tweaks)

Signed-off-by: Ivan Bolsunov <bolsunov@telum.ru>
Signed-off-by: Andrey Mazo <mazo@telum.ru>
2013-12-03 15:47:21 +04:00
Stéphane Graber
95ee490bbd
Reduce public API (V2)
This removes all but the following headers from our includes:
 - attach_options.h
 - lxccontainer.h
 - version.h

This also removes the duplicate lxc_version function (lxc_get_version
has been preferred for a while).

lxclock.h is now considered private.

As a result quite a lot of files needed addition of extra includes
previously inherited from lxclock.h.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-12-02 18:17:41 -05:00
S.Çağlar Onur
a22185ddda
Add LXC version information to version.h
So that applications can get the LXC version number at compile time.

This can be used to make applications/bindings that support compiling against
multiple versions of LXC.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 18:17:21 -05:00
Stéphane Graber
0a3673e807
Some tweak on previous change (timezone)
This adds the same code to the Debian-based templates (Ubuntu and Ubuntu
Cloud) and also avoids a needless fork.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 17:42:48 -05:00
funditus
f7365a247b lxc-debian: Make timezone match the host
Set timezone in container as on the host

Signed-off-by: funditus <funditus@mail.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-12-02 17:39:25 -05:00
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