Commit Graph

935 Commits

Author SHA1 Message Date
Daniel Lezcano
6ecad93f96 update the man page with the net script hook
Update the man page wrt the hook script added for the host side
network configuration.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2010-10-26 18:14:47 +02:00
Daniel Lezcano
43eb6f2931 fix multiple console for a container
Don't close the socket when we ask for a console, otherwise this will
make the console slot to be freed, so the next console will use the same
slot leading to an erratic behavior.

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2010-10-26 17:42:38 +02:00
Daniel Lezcano
7ee895e428 don't play with the capabilities when we are root
We don't want to drop the capabilities when we are root because that
leads to some problems. For exemple, sudo lxc-start -n foo -o $(tty) fails with
"permission denied".

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
2010-10-26 17:42:37 +02:00
Daniel Lezcano
b3ecde1ec3 Fix compilation error on fc12
The capability header makes the inclusion of the loop header to 
fail. Moving the inclusion of loop.h before capability.h fixes the
problem.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 15:11:45 +02:00
Daniel Lezcano
6ca5b95ef7 Fix compilation warning
Fix some compilation warnings:
 * include caps.h in lxc_checkpoint and lxc_restart
 * check the return of the timer notification read

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 15:11:45 +02:00
Daniel Lezcano
2656d23127 reduce function name
Cosmetic change by reducing the function names.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 14:57:57 +02:00
Daniel Lezcano
abbfd20baa use popen and redirect script output
Change the run_script function to use popen and to redirect
the output of the script to the log file.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Daniel Lezcano
751d9dcd39 fix Coding Style
Fix the coding style, 80 chars lines, etc ...
Fix indentation blocks if ... then ... else ... fi

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Stefan Tomanek
e3b4c4c44a add lxc.network.script.up configuration hook
This commit adds an configuration option to specify a script to be
executed after creating and configuring the network used by the
container. The following arguments are passed to the script:

	* container name
	* config section name (net)

Additional arguments depend on the config section employing a
script hook; the following are used by the network system:

	* execution context (up)
	* network type (empty/veth/macvlan/phys)

Depending on the network type, other arguments may be passed:

veth/macvlan/phys:
	* (host-sided) device name

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-12 10:52:47 +02:00
Daniel Lezcano
49d3e78dce update the lxc.conf man page
Update the man page regarding the image or block device
supported as a rootfs.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-05 10:28:31 +02:00
Daniel Lezcano
a6afdde95c allow to specify a image or a device block as rootfs
This patch allows to specify an image or a block device.

The image or the block device is mounted on rootfs->mount.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:36 +02:00
Daniel Lezcano
b57c2211eb add rootfs mount dir variable to pkg-config
In the case we use an image for rootfs, if we need to do extra mount
from the host to the rootfs, we have to specify the place where the
image is mounted. This value is configured by the user with the
lxc.rootfs.mount otherwise defaulting to @LXCROOTFSMOUNT@. Let's 
export this variable to pkg-config, so the user can use it to build
a correct path to the rootfs.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:36 +02:00
Daniel Lezcano
75b08dddec Don't display an error in lxc_file_for_each_line
Don't display an error when the callback returns an error different
from zero. A value greater than zero may means "stop". Let's the caller
to check the error.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:36 +02:00
Daniel Lezcano
599916790a Use container's proc to setup the utmp watching
The <rootfs>/var/run/utmp is located in:

/proc/<containerinit>/root/var/run/utmp, let's use it.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
12297168e9 Initialize default mount point
Let's initialize rootfs->mount to LXCROOTFSMOUNT. The value
will be overwritten by the configuration in case it is specified.

That will make the code nicer, instead of the ugly rootfs->mount checks.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
bc9bd0e31e use the rootfs mount point for the tty's
The rootfs is always located in rootfs->mount, let's use it for
the tty.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
466978b083 use the rootfs mount point for the console
The rootfs is always located in the mount point now, let's
use it.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
ac7787080c mount the rootfs to the mount directory first
Split the rootfs setup by mounting the rootfs to the mount
point. This mount point will be used as the facto place where
the rootfs is placed.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-03 23:09:35 +02:00
Daniel Lezcano
2a7c16dc03 improve lxc-debian template to specify the suite
The attached patch adds a variable at the top of lxc-debian to change the SUITE.
Currently tested suites are lenny, squeeze, sid.

Also, the patch uses the dhcp3-client package instead of dhcp-client which is
deprecated in lenny and removed in squeeze.

Patch initialy from Mathieu Parent.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-01 17:07:03 +02:00
Ozan Caglayan
a52455f2d5 Fix linking problems with libcap
Correctly link to libcap to avoid underlinking and unused direct
dependency problems.

Signed-off-by: Ozan Caglayan <ozan@pardus.org.tr>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-01 17:07:03 +02:00
Cedric Le Goater
1e499b1158 initialize capabilities in checkpoint and restart commands
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-10-01 17:00:45 +02:00
Daniel Lezcano
cccc74b514 configure container architecture
When a container is installed with 32bits binaries while we are
running on a 64bits host, inside the container we are seen as
64bits arch. That leads to some problems for the package updates
because the scripts will download 64bits packages instead of 32bits.

This patch defines a configuration variable to set the architecture
of the container.

lxc.arch = i686 | x86 | x86_64 | amd64

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-09-13 15:36:20 +02:00
Daniel Lezcano
547467bddb version 0.7.2
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-26 11:01:20 +02:00
Michel Normand
9de28746a5 avoid compile warning in src/lxc/console.c
src/lxc/console.c:143: warning : return type defaults to ‘int’

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 17:17:14 +02:00
Daniel Lezcano
e239ff31a5 Fix bad returned value
In case of error the message will be always truncated.
We check the message was truncated with the total size
received which means the kernel as more info to give.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
96bcd56ae2 Dont' try to remove a physical nic on error
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
6168e99fff fix core dump when using physical interface
If the physical link is not specified in the configuration
the check in if_nametoindex(netdev->link) leads to a segfault.

Check the link is specified.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Ferenc Wagner <wferi@niif.hu>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
7ef6e44073 set rights to lxc-init
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
47ed344ad1 fix compilation warning
Add missing include

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
c702934457 initialize the capabilties for attach and unshare
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
dc456e995f fix setuid to attach, create and start
Fix the setuid bit root script.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
5da9e545b5 fix lxc.spec file
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-23 15:10:38 +02:00
Daniel Lezcano
fb6d9b2f40 keep the name of the physical interface
When the interface used in the container is a physical
interface from the host, we keep the initial name.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Reported-by: Sabdar <sabdar@wellspringsys.com>
2010-07-22 15:59:44 +02:00
Daniel Lezcano
bac8958311 fix inverted network interface creation
The list is 'lifo', so when we create the network interfaces, we
do this in the reverse order of the expected one. That is confusing.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-22 15:59:44 +02:00
Daniel Lezcano
7a82e9236d provide a script to set uid bit on cli
Some file systems do not support the file posix capabilities.
The following script set the setuid bit root on the different
cli.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
00dbc43e30 fix console overwrite any file
Prevent to specify a file not belonging to us as the output for the console

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
28f602ff47 fix log appending to any file
With the capabilities, the open of the log file can be done on any
file, making possible to modifify the content of the file.

Let's drop the privilege when opening the file, so we ensure that is
no longer possible.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
05cda563bf move the capabilities function to caps.c
Move the reset of the capabilities to the caps.c file and
initialize correctly the capabilities for lxc-init.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
0ed9cc8b00 initialize capabilities for lxc-start and lxc-execute
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
7d40e69bd7 add a macro to wrap a privilegied function
This macro is a helper to call a function into a [un]privilegied section.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
b3357a6f5b remove/restore effective capabilities
This patch adds the functions to drop the 'effective' capabilities and
restore them from the 'permitted' capabilities.

When the command is run as 'root' we do nothing.
When the command is run as 'lambda' user, we drop the effective capabilities
When the command is run as 'root' but real uid is not root, we keep the capabilies,
switch to real uid, and drop the effective capabilities.

This approach is compatible for root user, lambda + file capabilities
and lambda + setuid.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-20 13:45:44 +02:00
Daniel Lezcano
1c4a945262 Remove dead code
This function is no longer used.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-19 16:04:41 +02:00
Daniel Lezcano
6f0a42008d lxc-init finishes the remaining processes with SIGKILL
If lxc-init receives a SIGALRM, a timeout, it kills all the processes
of the container with SIGKILL. That will prevent the container to be
stuck when one process ignore the SIGTERM signal.

Each time a process exits, the timeout is resetted.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-13 14:51:45 +02:00
Daniel Lezcano
6fd1668e7f lxc-init kills all processes with SIGTERM
When lxc-init receives a SIGTERM, let's kill all the processes of
the pid namespace with kill -1. So the exit of the container will
happen gracefully with processes death cascade.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-13 14:51:45 +02:00
Ferenc Wagner
83ee787579 generalize the name of the signal handler
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-13 14:51:45 +02:00
Ferenc Wagner
f3304a29eb forward signals to the container init
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-13 14:51:45 +02:00
Daniel Lezcano
d1c383f390 fix compilation warning
Add missing include.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-12 15:13:18 +02:00
Sukadev Bhattiprolu
371828c4a0 Must unfreeze while stopping container
As pointed out by Dan Smith, when a container is being stopped, it must
also be unfrozen after posting the SIGKILL. Otherwise if the container
is frozen when the SIGKILL is posted, the SIGKILL will remain pending
and the lxc-stop command will block until lxc-unfreeze is explicitly
called).

(lxc-stop waits for the container to exit and close the socket but since
the container is frozen, lxc-stop will block).

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Acked-by: Matt Helsley <matthltc@us.ibm.com>
Acked-by: Dan Smith <danms@us.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-12 15:13:18 +02:00
Sukadev Bhattiprolu
ba31511e05 Ensure frezer state has changed
A write to the freezer.state file does not gurantee that the state has
changed. To ensure that the freezer state is either FROZEN or THAWED,
read the freezer state and if it has not changed, repeat the write.

Changelog[v2]:
	- Minor reorg of code
	- Comments from Daniel Lezcano:
		- lseek() before each read/write of freezer.state
		- Have lxc_freeze_unfreeze() return -1 on error

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-12 15:13:18 +02:00
Tushar Gohad
ebb9ec72ce Minor resource name array fix in src/lxc/namespace.c
Signed-off-by: Tushar Gohad <tgohad@mvista.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-06 23:45:52 +02:00