Commit Graph

1197 Commits

Author SHA1 Message Date
Dwight Engen
a1bd64823c display warning when yum missing in fedora template
This early exit is preventing the warning message that follows it from
being shown.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:36:49 +02:00
Serge Hallyn
bf7d76cf3a templates: mount devtmpfs in ubuntu containers
That way /dev/disk/ exists, and update-grub can succeed.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1060404
2012-10-25 10:36:42 +02:00
Dwight Engen
d4eb4ab129 handle clone of btrfs snapshots
Fix determination of $oldroot from the config file. The old code had the '
in the wrong place and didn't account for whitespace between the = and
the rootfs.

Set $rootfs based on $oldroot instead of forcing it to be in
$lxc_path/$lxc_new/rootfs. This allows for btrfs snapshot to be made even if
$lxc_path isn't on the same filesystem. If $oldroot isn't a subvolume,
fall back to making a copy.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:36:35 +02:00
Dwight Engen
5ae26abb52 if the rootfs is a btrfs subvolume, delete it instead of rm -rf
Check if the rootfs is btrfs subvolume, and if so delete it. Otherwise
fall back to the rm -rf.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:36:28 +02:00
Stéphane Graber
06a1e1db99 lxc-debian: replace isc-dhcp-server by isc-dhcp-client
The DHCP client should be isc-dhcp-client, not isc-dhcp-server.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:36:07 +02:00
Christian Seiler
3b9bad3d63 lxc-ls: Scan cgroup mount points from fstype and not device
lxc-ls --active now scans mount points that have the 'cgroup' filesystem
type and not the 'cgroup' device name (which is ignored anyway and may be
anything).

Signed-off-by: Christian Seiler <christian@iwakd.de>
Cc: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:36:01 +02:00
Dwight Engen
c12e775237 Allow short -h and -n options to lxc-ps
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:35:53 +02:00
Serge Hallyn
c6ed4d048d lxc-ubuntu: fix printing of default user
If a user is bound into the container, don't claim the default user is
ubuntu.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1052315

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:35:47 +02:00
Serge Hallyn
3f16e26c70 lxc-debian: specify isc-dhcp-server in package list
dhcp3-client does not exist in testing.

Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1052972

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:35:32 +02:00
Serge Hallyn
91a5df88ad try to better handle out of date container caches.
For a lucid container, apt-get update before installing the source package for
add-apt-repository, so that apt-get does not fail.

If apt-get dist-upgrade fails, suggest running lxc-create with -F.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:35:22 +02:00
Serge Hallyn
1bd051a6b0 link /dev/kmsg to /dev/console in the container
This way init log messages can be seen on the console.  If containerized
syslog ever comes around, we can get rid of this.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:35:08 +02:00
Serge Hallyn
5d38621d0b lxc-clone: fix the '--name' parameter
The long opt for --name was being incorrectly compared to --new.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:34:58 +02:00
Stéphane Graber
8aba484aea lxc-ls: Use readlink on $directory
lxc-ls was failing in cases where $directory is a symlink to another
directory. Instead have $directory be generated from the output of
readlink -f "$lxc_path".

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:34:51 +02:00
Stéphane Graber
5d01f6167c lxc-busybox: Use relative mounts in lxc.mount.entry
To make it easier to clone/rename the container, replace hardcoded
entries (with rootfs in the destination path) by rootfs-relative entries.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:34:45 +02:00
Stuart Yoder
6bc424b5c7 busybox: for all lib dirs create mounts only if directories exist
Signed-off-by: Stuart Yoder <stuart.yoder@freescale.com>
2012-10-25 10:34:38 +02:00
Dwight Engen
d595c68add fix expansion of LXCPATH,LXCROOTFSMOUNT,LXCTEMPLATEDIR
These variables are not expanded correctly in doc/lxc-create.sgml.in
and a workaround is in place to ensure ${localstatedir}, and ${datadir}
are set in the various shell scripts that use it. There is no workaround
to ensure ${datadir} is set in src/lxc/lxc-create.in, nor is
${localstatedir} set in templates/lxc-altlinux.in so I think that these
are currently broken.

Using AS_AC_EXPAND instead of AC_SUBST fixes these problems and removes
the need for the workarounds. In addition the lxc-start-ephemeral.in
script can be autoconf'ed instead of sed'ed by the makefile.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:34:28 +02:00
Dwight Engen
b9cb4325d7 lxc-rpm-build
Fix building of rpm by non-root user. Include templates in rpm, fix rpm path of
lxc-init.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:32:48 +02:00
Dwight Engen
b4578c5b38 lxc-doc-synopsis-args
I was getting raw nroff ".SH DESCRIPTION" in my man pages. This fixes
the synopsis cmd args so that doesn't happen. Added replaceable to a few
arguments.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:32:37 +02:00
Dwight Engen
b97b78abda lxc-pkgconfig-dir
Put pkg-config .pc file in libdir.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
2012-10-25 10:30:39 +02:00
Serge Hallyn
87af3ecd48 log errno when pclose fails
When lxc is executing a script and pclose fails, log the
errno to help debug what happened.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:29:53 +02:00
Stéphane Graber
435d40f7e3 Pass the container name to copy_configuration in lxc-lenny
This fixes a case where lxc.utsname would be set empty as copy_configuration
wasn't getting the container name.

Signed-off-by: Rex Tsai (蔡志展) <rex.tsai@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:29:44 +02:00
Stéphane Graber
6bf8daf9a2 Add SIGINT and SIGPWR handler in lxc-debian
This adds a SIGINIT and SIGPWR handler in the default inittab for
the Debian template. This allows lxc-shutdown/lxc-restart and their API calls
to properly shutdown or reboot the container.

Signed-off-by: Rex Tsai (蔡志展) <rex.tsai@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:29:36 +02:00
Stéphane Graber
70542ef9a1 Don't hardcode path to templates
configure.ac used to set the template path to /usr/share/lxc/templates.
Instead use ${datadir} to make it follow ${prefix}.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:29:30 +02:00
Serge Hallyn
55116c42e7 lxc-destroy: Separately rm rootfs if it is a symlink
If rootfs is a symbolic link but not to a block device, then do a separate
rm of its contents.  We have to do this because, out of cowardice, we call
rm with --one-filesystem.

Removing the '-o -h $rootdev' is ok, because if $rootdev is a symbolic
link to a block device (including lvm blockdev) then -b will still return
true.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:27:26 +02:00
Scott Moser
b942e67226 ubuntu-cloud template cleanups
Fix for quantal images which do not have the user 'ubuntu' present.
Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1045955

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:25:30 +02:00
Serge Hallyn
fbef4590b7 add prototype for clone(2) as per manpage
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:24:34 +02:00
Stéphane Graber
d0a36f2c8b Add missing include for apparmor.h in conf.c
This include is conditional on apparmor being selected.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:22:50 +02:00
Stéphane Graber
cb26f1a5ee Various fedora template improvements
1. don't add network segment to config
2. check for 'curl'
3. don't add $name to $path, it's already in there
4. don't add devpts to fstab, that's wrong.
5. $UTSNAME doesn't exist
6. set root pwd to root instead of rooter.
7. install fedora-release package.
8. add a console on /dev/console.
9. create empty fstab
10. don't mount devpts in rc.sysinit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:21:39 +02:00
Stéphane Graber
337e14712e sshd: run dhclient; allow adding a root ssh key
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:20:09 +02:00
Stéphane Graber
9ac3ffb517 Make lxc-execute without rootfs work.
That means, don't try to pin a null rootfs, and don't try to mount /proc
since /var/lib/lxc/root/proc doesn't exist to be mounted onto.
The apparmor patches are not yet upstream, so this patch will not go
upstream by itself.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:19:37 +02:00
Serge Hallyn
10f73bfa4a lxc-ubuntu-cloud: get full pathname to userdata file
When passing '--userdata somefile' to the ubuntu-cloud template, a user
may pass a relative pathname.  The template uses the filename after
changing current directory, so store the full pathname for the userdata
file instead of a potential relative pathname.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:19:17 +02:00
Stéphane Graber
e7f40d8aab When creating the lxc cgroup directory, ignore -EEXIST
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com
2012-10-25 10:18:56 +02:00
Stéphane Graber
f02ce27d4b Add lxc.aa_profile example to all templates
LXC has optional apparmor support, default profile is lxc-container-default.
This change adds a commented "lxc.aa_profile = default" line to all templates,
uncommenting this will bypass apparmor for the container.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:16:23 +02:00
Stéphane Graber
33f3de4eaa Don't update the host-name field in dhclient.conf when not hardcoded.
On Debian and Ubuntu, the default host-name field in dhclient.conf is
set to either "<hostname>" or "gethostname()" both of which get replaced
by the machine's hostname at query time.

The sed call currently present in lxc-clone hardcodes the hostname in
dhclient.conf, causing dpkg to prompt on isc-dhcp updates.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:10:00 +02:00
Stéphane Graber
e470cba076 Use lxc_putold as the pivot_root put dir in the ubuntu templates
By default we use mnt, but that means that lxc fstab entries do not work
when placed under the container's /mnt/.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:09:30 +02:00
Stéphane Graber
542939c31b Fix lxc-ubuntu and lxc-ubuntu-cloud to properly deal with /dev/shm.
Now that initscripts in Debian and Ubuntu has been updated to no longer
do silly things with /dev/shm and /run/shm on installation/update, the
check needs updating to detect any remaining broken case and fix it.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2012-10-25 10:09:25 +02:00
Serge Hallyn
b4df0a1eda lxc_start: exit early if insufficient privs in daemon mode
Starting a container with insufficient privilege (correctly) fails
during lxc_init.  However, if starting a daemonized container, we
daemonize before we get to that check.  Therefore while the
container will fail to start, and the logfile will show this, the
'lxc-start -n x -d' command will return success.  For ease of
scripting, do a check for the required privilege before we exit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:07:30 +02:00
Serge Hallyn
06f5c6328b ubuntu template: apt-get clean after debootstrapping a cache
This saves quite a bit of space in the cache and containers.

See https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1037626 for the
original bug report.

Reported-by: Fajar A. Nugraha <list@fajar.net>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:07:16 +02:00
Serge Hallyn
f1ccde27c0 ubuntu and debian templates: Clean up cache if cache build is interrupted
Otherwise the next lxc-create may rsync a bad cache.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:07:04 +02:00
Serge Hallyn
4a311c1241 Cleanup partial container if -h was passed to template
If user calls 'lxc-create -t ubuntu -- -h' (as opposed to
'lxc-create -t ubuntu -h') then the ubuntu template will print its
help then exit 0.  Then lxc-create does not cleanup.  So detect this
in lxc-create.
2012-10-25 10:06:41 +02:00
Serge Hallyn
4d5fb23ad8 lxc-clone: fix handling of lxc.mount entries
The 'lxc.mount =' entry can have more than one space, or tabs, before the =.
We only need to disambiguate from 'lxc.mount.entry'.  So just check for a
space or tab after mount.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:06:11 +02:00
Serge Hallyn
8b892c55b0 lxc-clone: change uuid on xfs
Otherwise after cloning an lvm+xfs container you can't run the
original and clone at the same time.

Based on a patch by Maurizio Sambati posted at
https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/1013549

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2012-10-25 10:05:59 +02:00
Serge Hallyn
60a742e0af remove unused lastcap variable
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
2b657f10ca Fix lxc's handling of CAP_LAST_CAP
CAP_LAST_CAP in linux/capability.h doesn't always match what the kernel
actually supports.  If the kernel supports fewer capabilities, then a
cap_get_flag for an unsupported capability returns -EINVAL.

Recognize that, and don't fail when initializing capabilities when this
happens, rather accept that we've reached the last capability.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
d80cfe7188 apparmor support: fix compilation with --disable-apparmor
Make the prototypes and functions match between apparmor.{c,h}

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
40f6ee0088 lxc-ubuntu: Use dpkg --add-architecture
When a container has dpkg >= 1.16.2, use dpkg --add-architecture
for multi-arch configuration on foreign architecture containers.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
add1d11833 templates: don't fail on busy flock
Just wait until the lock is available.  That is a nicer behavior
for concurrent lxc-creates.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
e7f0d73311 lxc-ls: prepend container name with -- when calling ls
Otherwise a container name with a dash confuses ls

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
a11a544f5f lxc-unshare: require an argument
It segfaults otherwise trying to execute &NULL.

We could alternatively guess at a command to execute, such as a
shell, but invariably there would be cases where the command we
guess does not exist.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00
Serge Hallyn
30c5d29201 use lxc_putold as pivot_dir put dir, not mnt
Using mnt means that lxc fstab entries do not work when placed under
the container's /mnt/ (i.e. /mnt/etc).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2012-07-31 16:07:18 +02:00