Commit Graph

706 Commits

Author SHA1 Message Date
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
Daniel Lezcano
743ecd2efb close prctl window
If the pdeath signal is set after the synchro we have a window where
the parent exits with the pdeath signal not set.

In order to avoid that, we have to move the prctl before the synchro with
the parent so if the parent exits before we can set the pdeath signal, the
synchro will fail in any case and the container startup will be aborted.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-07-06 21:26:31 +02:00
Daniel Lezcano
cba56779c8 lxc-0.7.1
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-24 21:04:09 +02:00
Daniel Lezcano
78bdcd081e remove bad default console option in ubuntu template
Remove this options as by default container console goes to the tty
or /dev/null if not available.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-24 09:47:14 +02:00
Ciprian Dorin, Craciun
e76b8764fa lxc to apply mount options for bind mounts
Hello all!

    This bug stalked me for a while, but only now it bit me quite
badly... (Lost about an hour of work...)

    So the culprit: inside the fstab file for the `lxc.mount` option I
can use options like `ro` together with `bind`. Unfortunately the
kernel just laughs in my face and ignores any options I've put in
there... :) But not any more: I've updated `./src/lxc/conf.c`
(`mount_file_entries` function) so that when it encounters a `bind`
option it executes it twice (one without any extra options, and a
second time with the remount flag set.)

I've marginally (as in my particular case) tested it and it works.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-24 09:47:14 +02:00
Daniel Lezcano
a7dff83460 fix /proc not mounted in debian container
Mount some systemm fs for the container. By default, /proc
is no longer mounted in debian.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-23 00:44:13 +02:00
Daniel Lezcano
cd453b38b7 fix default console to /dev/tty
Fix default console output fall into the current tty.
Otherwise fall to /dev/null if no tty is available.

Fix at the same time, Xorg take 100% cpu.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-23 00:44:13 +02:00
Daniel Lezcano
8119235833 fix bad free when reading the configuration file
We change the initial pointer when parsing the line, the address
we are trying to free is modified in case there are blanks before
an option.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-17 22:44:23 +02:00
Daniel Lezcano
70e279574c fix sshd template
Fixed the sshd template example.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-17 22:44:23 +02:00
Daniel Lezcano
f7a5fb7cf5 change version number to 0.7.0
Finally, I did it :)

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-17 14:04:15 +02:00
Daniel Lezcano
411c76ce0f fix lxc.spec.in
Changed the directory location for documents.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-17 14:04:15 +02:00
Daniel Lezcano
765a4e0783 add lxc.console documentation
Add missing documenation about the console output.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-17 14:04:15 +02:00
Panagiotis H.M. Issaris
0830689d86 Forgotten @LIBEXECDIR@ replacement
Forgotten part of commit d674be08d4

Signed-off-by: Panagiotis H.M. Issaris <takis@issaris.org>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-16 09:19:15 +02:00
Ferenc Wagner
4d67c1301b correct template directory documentation
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-16 09:19:15 +02:00
Ferenc Wagner
a52c4b8cac remove misleading copy&paste comment
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-16 09:19:15 +02:00
Daniel Lezcano
3f9cf2ad5e Fix lxc-checkconfig
Fix bad comparison.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-16 09:19:15 +02:00
Andrew Phillips
b0badabd2d support shutdown/reboot with upstart within a system container
Improve resiliency of utmp.c to removal of /var/run/utmp
Add shutdown timer as we transition to shutdown from running to check for the
number of tasks remaining. Improve container state handling. We can't rely on
the previous runlevel being maintained properly.

Signed-off-by: Andrew Phillips <Andrew.Phillips@lmax.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-14 11:34:50 +02:00
Ferenc Wagner
4f9293b1f0 fix comment
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-11 15:56:25 +02:00
Ferenc Wagner
3103609ddc change pivotdir default to mnt
The mnt directory has a good chance to already exist in the new root
filesystem, so creation and removal can be avoided.  This also eases
use of read only root filesystems (no configuration necessary).

Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-11 15:56:25 +02:00
Ferenc Wagner
64b90b3d1e document rootfs options
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-11 15:56:25 +02:00
Daniel Lezcano
89875e177f update .gitignore
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 14:31:56 +02:00
Daniel Lezcano
7ddc8f2451 fix return code
Return a negative instead of a positive value.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 14:31:56 +02:00
Daniel Lezcano
79881dc61f fix ipv6 acast / mcast restriction
Pointer comparison is buggy as they are never null.
For an ipv6 address configuration, we always zeroed the structure,
hence the bcast and acast structure are equal to in6addr_any.

Any change of this value means the user specified something different
in the configuration file, so we fail gracefully.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 13:25:30 +02:00
Daniel Lezcano
dd04402dd9 update .gitignore with new location
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:56 +02:00
Ferenc Wagner
09d1bd237e uint32_t is defined in stdint.h
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:56 +02:00
Ferenc Wagner
9527e566fc conditional use of new capabilities
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:56 +02:00
Ferenc Wagner
91e7929dc4 .gitignore new components
Signed-off-by: Ferenc Wagner <wferi@niif.hu>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:56 +02:00
Daniel Lezcano
b6e91b6717 update the fedora template
Update the fedora template in order to call it from the lxc-create
script.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:55 +02:00
Daniel Lezcano
f1fa1a0866 generate locales on debian
Let's do like the ubuntu template and generate locales automatically.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:55 +02:00
Daniel Lezcano
5bad66ba56 ubunutu - fix ssh runlevel stop condition
The default ssh upstart configuration makes the daemon to respawn
either if we are shutdowning.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-06-07 11:33:55 +02:00