Go to file
Christian Brauner 07385df53e lxc-ls: check for ENOMEM and tweaking
- If lxc_container_new() fails we check for ENOMEM and if so goto out. If
  ENOMEM is not set we will simply continue. The same goes for the call to
  regcomp() but instead of checking for ENOMEM we need to check for REG_ESPACE.

- Tweaking: Since lxc-ls might have to gather a lot of containers and I don't
  know if compilers will always optimize this let's move *some* variable
  declarations outside of the loop when it does not hinder readability

- Set ls_nesting to 0 initially. Otherwise users will always see nested
  containers printed.

- ls_get() gains an argument char **lockpath which is a string pointing us to
  the lock we put under /run/lxc/lock/.../... so that we can remove the lock
  when we no longer need it. To avoid pointless memory allocation in each new
  recursion level we share lockpath amongst all non-fork()ing recursive call to
  ls_get().  As it is not guaranteed that realloc() does not do any memory
  moving when newlen == len_lockpath, we give ls_get() an additional argument
  size_t len_lockpath). Every time we have a non-fork()ing recursive call to
  ls_get() we check if newlen > len_lockpath and only then do we
  realloc(*lockpath, newlen * 2) a reasonable chunk of memory (as the path will
  keep growing) and set len_lockpath = newlen * 2 to pass to the next
  non-fork()ing recursive call to ls_get().
  To avoid keeping a variable char *lockpath in main() which serves no purpose
  whatsoever and might be abused later we use a compound literal
  &(char *){NULL} which gives us an anonymous pointer which we can use for
  memory allocation in ls_get() for lockpath. We can conveniently free() it in
  ls_get() when the nesting level parameter lvl == 0 after exiting the loop.
  The advantage is that the variable is only accessible within ls_get() and not
  in main() while at the same time giving us an easy way to share lockpath
  amongst all non-fork()ing recursive calls to ls_get().

Signed-off-by: Christian Brauner <christian.brauner@mailbox.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2016-01-28 12:33:17 +01:00
config bash completion: the 'have' command was deprecated in favor of '_have' 2016-01-11 18:28:09 +01:00
doc update overlayfs and aufs in lxc.container.conf 2016-01-28 12:02:23 +01:00
hooks hooks: put binary hooks into $libexecdir/lxc/hooks 2015-11-06 13:28:22 -05:00
src lxc-ls: check for ENOMEM and tweaking 2016-01-28 12:33:17 +01:00
templates Fix Comment inside Fedora Template 2016-01-20 00:32:37 +05:30
.gitignore Refactor .gitignore section for templates/* - no need to specifiy individual templates anymore 2016-01-20 14:20:56 +00:00
.travis.yml enable cgmanager support for Travis CI 2015-05-26 13:01:41 -04:00
AUTHORS Initial revision 2008-08-06 14:32:29 +00:00
autogen.sh Whitespace fix 2014-02-07 19:36:50 -05:00
configure.ac Add support for Linux for SPARC distribution host and template 2016-01-04 12:51:21 -05:00
CONTRIBUTING Fresh CONTRIBUTING 2015-08-05 21:08:28 +02:00
COPYING Minor documentation updates 2012-12-06 00:02:36 -05:00
INSTALL Minor documentation updates 2012-12-06 00:02:36 -05:00
lxc.pc.in Update maintainers and URLs 2013-10-20 00:48:48 -04:00
lxc.spec.in doc: Add Korean man pages 2015-06-11 20:08:58 +09:00
MAINTAINERS Update MAINTAINERS 2015-01-19 16:23:21 -05:00
Makefile.am Drop runapitests.sh 2014-01-23 14:08:44 -05:00
NEWS Initial revision 2008-08-06 14:32:29 +00:00
README Correct typo. 2015-03-30 20:44:29 +02:00

Please see the COPYING file for details on copying and usage.
Please refer to the INSTALL file for instructions on how to build.

What is lxc:

  The container technology is actively being pushed into the mainstream linux
  kernel. It provides the resource management through the control groups  aka
  process containers and resource isolation through the namespaces.

  The  linux  containers, lxc, aims to use these new functionalities to pro-
  vide a userspace container object which provides full  resource  isolation
  and resource control for an application or a system.

  The first objective of this project is to make the life easier for the ker-
  nel developers involved in the containers project and  especially  to  con-
  tinue  working  on  the  Checkpoint/Restart  new features. The lxc is small
  enough to easily manage a container with simple command lines and  complete
  enough to be used for other purposes.

Using lxc:

  Refer the lxc* man pages (generated from doc/* files)

Downloading the current source code:

  Source for the latest released version can always be downloaded from
  http://linuxcontainers.org/downloads/

  You can browse the up to the minute source code and change history online.
  http://github.com/lxc/lxc

  For detailed build instruction refer to INSTALL and man lxc man page
  but a short command line should work:
  ./autogen.sh && ./configure && make && sudo make install
  preceded by ./autogen.sh if configure do not exist yet.

Troubleshooting:

  If you get an error message at the autogen.sh or configure stage, make
  sure you have, autoconf, automake, pkg-config, make and gcc installed on
  your machine.

  The configure script will usually give you hints as to what you are missing,
  looking for those in your package manager will usually give you the package
  that you need to install.

  Also pay a close attention to the feature summary showed at the end of
  the configure run, features are automatically enabled/disabled based on
  whether the needed development packages are installed on your machine.
  If you want a feature but don't know what to install, force it with
  --enable-<feature> and look at the error message from configure.

Getting help:

  when you find you need help, you can check out one of the two
  lxc mailing list archives and register if interested:
  http://lists.linuxcontainers.org/listinfo/lxc-devel
  http://lists.linuxcontainers.org/listinfo/lxc-users

Portability:

  lxc  is  still  in  development, so the command syntax and the API can
  change. The version 1.0.0 will be the frozen version.

  lxc is developed and tested on Linux since kernel mainline version 2.6.27
  (without network) and 2.6.29 with network isolation.
  It's compiled with gcc, and should work on most architectures as long as the
  required kernel features are available. This includes (but isn't limited to):
  i686, x86_64, ppc, ppc64, S390, armel and armhf.

AUTHOR
       Daniel Lezcano <daniel.lezcano@free.fr>

Seccomp with LXC
----------------

To restrict a container with seccomp, you must specify a profile which is
basically a whitelist of system calls it may execute.  In the container
config file, add a line like

lxc.seccomp = /var/lib/lxc/q1/seccomp.full

I created a usable (but basically worthless) seccomp.full file using

cat > seccomp.full << EOF
1
whitelist
EOF
for i in `seq 0 300`; do
    echo $i >> seccomp.full
done
for i in `seq 1024 1079`; do
    echo $i >> seccomp.full
done

 -- Serge Hallyn <serge.hallyn@ubuntu.com>  Fri, 27 Jul 2012 15:47:02 +0600