Commit Graph

2150 Commits

Author SHA1 Message Date
Serge Hallyn
025f59ab98 add basic lxc-test-ubuntu (v3)
Some features of lxc - networking and LSM configuration for instance -
are generally configured by the distro packages.  This program
tests the Ubuntu configuration.

changelog v2:
  Switch to lxc-info -i to detect ip address as stgraber suggested
  Don't look for 'expect' as I'm not using it yet.
changelog v3:
  Make sure to only read one ip address from container.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-03 12:23:07 -05:00
Serge Hallyn
a5a8250854 confile.c: cast size_t to prevent compile failure on 386
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-03 12:10:07 -05:00
Stéphane Graber
f5abd74d1a Improve behaviour for unprivileged users
This mostly changes two things:
 - Only log to the container's logfile on start/stop/restart/execute
 - Call may_control() every time we use the API and return
   "Insufficient privileges" on failure.

NOTE: I didn't test every single one of those but I'm fairly confident
      in my copy/paste abilities and I confirmed they all build fine at least.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-03 09:34:55 -05:00
Serge Hallyn
17232fefae add new tests to .gitignore
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-03 09:34:54 -05:00
Serge Hallyn
2aa123185e add reboot test
It's really more of a kernel check, but worth having.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-03 09:34:52 -05:00
Stéphane Graber
8111adfde0
lxc-checkconfig: suggest modprobe configs
give hint to user to modprobe configs (altho could just modprobe it?)

Signed-off-by: Elan Ruusamäe <glen@delfi.ee>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 17:22:52 -04:00
Stéphane Graber
51e7a87468
Check return value of ifa_get_local_ip
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-02 17:18:48 -04:00
Stéphane Graber
c61eaadcf8
lxc-fedora: Show usage when no name is passed
Reported-by: Anatoly Techtonik
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 13:11:24 -04:00
Stéphane Graber
a8aa709c9d
lxc_init: Use sig_atomic_t for was_interrupted
Suggested-by: Markus Elfring
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 12:32:52 -04:00
Andrey Mazo
01660cccb9 Avoid ldconfig due to cross-compilation problems.
Otherwise, it cases problems on cbuild endianness != ctarget endianness
setups because /sbin/ldconfig expects elf header in the wrong endianness.

Signed-off-by: Andrey Mazo <ahippo@yandex.ru>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 12:28:33 -04:00
Dwight Engen
bd79cb223d fix lxc-info segv on stopped container
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 12:21:31 -04:00
Stéphane Graber
8983aa6e1e
fedora: Use consistent tab/space indent
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 11:47:33 -04:00
Renich Bon Ciric
431fdc4272 Update lxc-fedora.in
Fedora 19's release has no -1 revision; it's a -2 revision actually:
ftp://mirrors.kernel.org/fedora/releases/19/Fedora/x86_64/os/Packages/f/

Signed-off-by: Renich Bon Ciric <renich@woralelandia.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 11:45:52 -04:00
KATOH Yasufumi
99282c429a doc: Fix some typos
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 11:43:55 -04:00
KATOH Yasufumi
cab158ed3c doc: Remove unnecessary Diagnostic entry in lxc-stop(1)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-10-02 11:43:43 -04:00
KATOH Yasufumi
996c63c73e doc: Update lxc-monitor(1) man page
- Update to commit 'fbf050e4c211030eb343008583f76605dfaaef38'
- Improve translation

Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-10-02 09:09:45 -05:00
Dwight Engen
fbf050e4c2 lxc-monitor default name to .* to monitor all containers
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-01 10:31:41 -05:00
Dwight Engen
291c42dac0 gitignore doc/ja/legacy/*.1
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-10-01 09:21:31 -05:00
KATOH Yasufumi
492d0d55c3 doc: Update Japanese lxc.conf(5) man page
Add description of automatic mounting options
2013-09-30 19:22:07 -05:00
KATOH Yasufumi
3fd391243e doc: Update Japanese lxc-info(1) man page
Add description of '-i' option
2013-09-30 19:22:07 -05:00
KATOH Yasufumi
a5ba96715d doc: Update Japanese man pages translation
* sync current English man pages on master branch
* delete lxc-shutdown.sgml.in
* add lxc-snapshot.sgml.in
* update FSF address (same as 250b1eec71)
* remove trailing whitespaces in legacy/lxc-ls.sgml.in (same as 8900b9eb25)
2013-09-30 19:22:07 -05:00
Dwight Engen
6d03d92ab7 refactor string conf items into common function
- When doing the selinux change, I noticed that there was a lot of
  duplication of code in handing string configuration items, so I
  refactored this into a common function.

- Added a config_string_max that can be passed a maximum acceptable
  length, used to limit ttydir to NAME_MAX.

- The behavior of config_seccomp was different than other strings: if the
  item was already defined, then the second attempt to set it would fail
  instead of just replacing the value. Changed to just replace the value.

- Remove unused key and lxc_conf arguments to config_path_item().

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-30 17:21:11 -05:00
Serge Hallyn
e59536145c RFC: lxclock: drop the chown+chmod of lockdir
The original rationale for this was to make sure that if
lxcpath was /home/serge/lxcbase, then then lockdir
(/run/user/serge/lock/lxc/home/serge/lxcbase) would be
owned by the same user as /home/serge/lxcbase.

The only user who can chown to other uids (without CAP_CHOWN
added to fP) is root, who shouldn't be mucking with non-root
owned containers anyway.  In the meantime this causes a bunch
of noise for arguably no benefit.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-30 16:23:34 -05:00
Serge Hallyn
243cae25b5 tests/getkeys: return 0 on success
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-30 15:53:11 -05:00
Serge Hallyn
b494d2ddf7 add c->may_control
This is an api function which will return false if the container
is running, and the caller may not talk to its monitor over its
command socket.  Otherwise - if the container is not running, or
the caller may access it - it returns true.

We can use this in several tools early on to prevent the segvs
etc which we currently get.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-30 13:21:52 -05:00
Stéphane Graber
fe218ca383
Fix crasher in get_ips
Check that the interface structure is not NULL before trying to access
its members.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-29 19:41:52 -04:00
Stéphane Graber
a24b871206
Fix typo
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-27 16:00:40 -04:00
Dwight Engen
8bfcb981de valgrind: fix small leak in cgroup
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 12:09:18 -05:00
Christian Seiler
a2ff31c710 Automatic mounting: document options in lxc.conf(5) manpage
Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 10:14:14 -05:00
Christian Seiler
7997d7da4d Automatic mounting: add more ways to mount the cgroup filesystem
This adds quite a few more ways to mount the cgroup filesystem
automatically:

 - Specify ro/rw/mixed:
       - ro: everything mounted read-only
       - rw: everything mounted read-write
       - mixed: only container's own cgroup is rw, rest ro
                (default)
 - Add cgroup-full that mounts the entire cgroup tree to the
   corresponding directories. ro/rw/mixed also apply here.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 10:14:14 -05:00
Christian Seiler
5f62730e91 Automatic mounting: write lxc.mount.auto in write_config
Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 10:14:14 -05:00
Christian Seiler
b06b851168 Automatic mounts: improvements for /proc and /sys
Improve lxc.mount.auto code: allow the user to specify whether to mount
certain things read-only or read-write. Also make the code much more
easily extensible for the future.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 10:14:14 -05:00
Stéphane Graber
211e51e81e
lxc-info: Allow printing IP addresses
This adds a new -i flag to lxc-info to print the container's IP
addresses using get_ips().

Example:
$ lxc-info -n lxc-dev -s -p -i
state:  RUNNING
pid:    21331
ip:     10.0.3.165
ip:     2607:f2c0:f00f:2751:e9ca:842f:efa9:97d1
ip:     2607:f2c0:f00f:2751:216:3eff:fe3a:f1c1

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 09:31:17 -04:00
Stéphane Graber
a9ac16e2cc
lxc-info: Port to LXC API
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-27 09:30:52 -04:00
Serge Hallyn
566981770e drop now-useless have_tpath bool
(Which will also break failure-to-build in the !HAVE_LIBGNUTLS
case)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-26 08:14:50 -05:00
Dwight Engen
85db5535c3 fix segfault on lxc-create with bad template name
- change get_template_path() to only return NULL or non-NULL since one of
  the callers was doing a free(-1) which caused the segfault. Handle the
  NULL template case in the lxcapi_create() caller.

- make sure to free(tpath) in the sha1sum_file() failure case

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-09-26 08:11:59 -05:00
Dwight Engen
fe4de9a66d refactor AppArmor into LSM backend, add SELinux support
Currently, a maximum of one LSM within LXC will be initialized and
used. If in the future stacked LSMs become a reality, we can support it
without changing the configuration syntax and add support for more than
a single LSM at a time to the lsm code.

Generic LXC code should note that lsm_process_label_set() will take
effect "now" for AppArmor, and upon exec() for SELinux.

- fix Oracle template mounting of proc and sysfs, needed when using SELinux

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 17:12:36 -05:00
Serge Hallyn
3a0abb3aa2 free kernel_subsystems in success case
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 15:23:49 -05:00
Serge Hallyn
0ccf7c2a63 REALLY always free(line)
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 15:05:52 -05:00
Serge Hallyn
2cdafc545c fix up a few snafu's in forward-port of last commit
Make sure to free line.

Don't free 'info' when freeing base_info will later free info.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 15:01:54 -05:00
Dwight Engen
178938fe0a fix some larger memory leaks in cgroup code
Don't worry about saved_errno since none of the *_free routines will set it

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 11:07:38 -05:00
Serge Hallyn
b653309a4a split up lxc_cgroup_load_meta2
This one's easier to review by looking at the before and after files.  It
splits up lxc_cgroup_load_meta2() by adding 3 helpers.

The result seems easier to reason about.  A question I had, is, should
the kernel_subsystems ** be freed in the success case?  I assumed it was
being used elsewhere but I can't find where.  Currently it is only being
freed in the error case.  I suspect we want to free it in the success
case as well.

Cc: Christian Seiler <christian@iwakd.de>
Cc: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-25 11:07:35 -05:00
KATOH Yasufumi
7cb14f34a9 doc: Japanese man pages is not generated when docbook-utils is used
Character encoding of Japanese man pages is UTF-8. But docbook-utils
can't treat it (and don't have --encoding option that use in
Makefile). So change to Japanese man pages is not generated when
docbook-utils is used.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-09-25 09:50:26 -04:00
Qiang Huang
89cd779348 utils: move remove_trailing_slashes to utils
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-24 09:37:18 -05:00
Qiang Huang
e555005b15 arguments: remove trailing slashes for the input lxcpath
In lxc_cmd(), we use
snprintf(path, len, "%s/%s/command", lxcpath ? lxcpath : inpath, name);
to fill sock name, this assume lxcpath have no trailing slashes, so
if we use
lxc-info -n test -P /usr/local/var/lib/lxc_anon/
to get a running container's state, we will get state: STOPPED which
is wrong, because we combine a wrong sock name.

To fix this, just remove trailing slashes when parsing arguments.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-24 09:37:09 -05:00
Stéphane Graber
9d0cda4f22 doc: Fixed my first name
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-23 15:30:45 -05:00
Stéphane Graber
faefa7f858 doc: Make everything use the @docdtd@ variable
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-23 15:30:35 -05:00
Stéphane Graber
c75c30ec73 Add some missing comments to configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-23 15:30:24 -05:00
Stéphane Graber
948955a2d6 Consistently use <lxc/lxccontainer.h> for the API
The API header was included in a variety of ways before, standardize
those to "include <lxc/lxccontainer.h>" as this will always work both in
tree and on a system with the headers installed.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-23 15:30:05 -05:00
Qiang Huang
48e2f384e0 When callback of one config line fail, we'd better give the exactly
info to help users locate the misconfig.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-09-23 11:23:27 -05:00