diff -Nru lxc-0.7.2/aclocal.m4 lxc-0.7.4/aclocal.m4 --- lxc-0.7.2/aclocal.m4 2010-07-26 08:58:48.000000000 +0000 +++ lxc-0.7.4/aclocal.m4 2011-02-26 09:20:19.000000000 +0000 @@ -13,8 +13,8 @@ m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl -m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],, -[m4_warning([this file was generated for autoconf 2.65. +m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.67],, +[m4_warning([this file was generated for autoconf 2.67. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically `autoreconf'.])]) @@ -997,3 +997,4 @@ ]) # _AM_PROG_TAR m4_include([config/acinclude.m4]) +m4_include([config/linux.m4]) diff -Nru lxc-0.7.2/config/linux.m4 lxc-0.7.4/config/linux.m4 --- lxc-0.7.2/config/linux.m4 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/config/linux.m4 2011-02-01 14:12:40.000000000 +0000 @@ -0,0 +1,73 @@ +AC_DEFUN([AC_LINUX], +[ + AC_LINUX_DIR() + AC_LINUX_SRCARCH() +]) + +AC_DEFUN([AS_TRY_LINUX_DIR], + [AC_MSG_CHECKING(for Linux in $1) + + if test -f "$1/Makefile" ; then + result=yes + $2 + else + result="not found" + $3 + fi + + AC_MSG_RESULT($result) +]) + +AC_DEFUN([AC_LINUX_DIR], +[ + AC_ARG_WITH([linuxdir], + [AC_HELP_STRING([--with-linuxdir=DIR], + [specify path to Linux source directory])], + [LINUX_DIR="${withval}"], + [LINUX_DIR=default]) + + dnl if specified, use the specified one + if test "${LINUX_DIR}" != "default" ; then + AS_TRY_LINUX_DIR([${LINUX_DIR}], , AC_MSG_ERROR([Linux dir not found]) ) + fi + + dnl if not specified, first try with previously set LINUX_KERNEL_RELEASE + if test "${LINUX_DIR}" = "default" ; then + dir="/lib/modules/$LINUX_KERNEL_RELEASE/build"; + AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], ) + fi + + dnl next try using the kernel source dir + if test "${LINUX_DIR}" = "default" ; then + dir="/usr/src/linux-$LINUX_KERNEL_RELEASE"; + AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], ) + fi + + dnl then try a common default of /usr/src/linux + if test "${LINUX_DIR}" = "default" ; then + dir="/usr/src/linux"; + AS_TRY_LINUX_DIR([${dir}], [LINUX_DIR=${dir}], ) + fi + + dnl if still nothing found, fail + if test "${LINUX_DIR}" = "default" ; then + AC_MSG_WARN([Linux source directory not found]) + fi + + AC_SUBST(LINUX_DIR) +]) + +AC_DEFUN([AC_LINUX_SRCARCH],[ + AC_MSG_CHECKING(for linux SRCARCH) + + case "${host}" in + i[[3456]]86-*) LINUX_SRCARCH=x86;; + x86_64-*) LINUX_SRCARCH=x86;; + powerpc*-*) LINUX_SRCARCH=powerpc;; + s390*-*) LINUX_SRCARCH=s390;; + *) AC_MSG_ERROR([architecture ${host} not supported]);; + esac + + AC_MSG_RESULT(${LINUX_SRCARCH}) + AC_SUBST(LINUX_SRCARCH) +]) diff -Nru lxc-0.7.2/config/Makefile.in lxc-0.7.4/config/Makefile.in --- lxc-0.7.2/config/Makefile.in 2010-07-26 08:58:50.000000000 +0000 +++ lxc-0.7.4/config/Makefile.in 2011-02-26 09:20:20.000000000 +0000 @@ -38,7 +38,7 @@ config.guess config.sub depcomp install-sh missing ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -82,6 +82,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ diff -Nru lxc-0.7.2/configure lxc-0.7.4/configure --- lxc-0.7.2/configure 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/configure 2011-02-26 09:20:20.000000000 +0000 @@ -1,11 +1,11 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.65 for lxc 0.7.2. +# Generated by GNU Autoconf 2.67 for lxc 0.7.4. # # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, -# Inc. +# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software +# Foundation, Inc. # # # This configure script is free software; the Free Software Foundation @@ -316,7 +316,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -356,19 +356,19 @@ fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -530,7 +530,7 @@ exec 6>&1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -549,8 +549,8 @@ # Identity of this package. PACKAGE_NAME='lxc' PACKAGE_TARNAME='lxc' -PACKAGE_VERSION='0.7.2' -PACKAGE_STRING='lxc 0.7.2' +PACKAGE_VERSION='0.7.4' +PACKAGE_STRING='lxc 0.7.4' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -595,6 +595,8 @@ am__EXEEXT_TRUE LTLIBOBJS LIBOBJS +LINUX_SRCARCH +LINUX_DIR CAP_LIBS LXCTEMPLATEDIR LXCINITDIR @@ -711,6 +713,7 @@ enable_examples with_config_path with_rootfs_path +with_linuxdir ' ac_precious_vars='build_alias host_alias @@ -783,8 +786,9 @@ fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -829,7 +833,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -855,7 +859,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1059,7 +1063,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1075,7 +1079,7 @@ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1105,8 +1109,8 @@ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1114,7 +1118,7 @@ # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1132,13 +1136,13 @@ if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1161,7 +1165,7 @@ [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1175,8 +1179,8 @@ if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 + $as_echo "$as_me: WARNING: if you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used" >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1191,9 +1195,9 @@ ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1232,11 +1236,11 @@ fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1262,7 +1266,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures lxc 0.7.2 to adapt to many kinds of systems. +\`configure' configures lxc 0.7.4 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1276,7 +1280,7 @@ --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1332,7 +1336,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of lxc 0.7.2:";; + short | recursive ) echo "Configuration of lxc 0.7.4:";; esac cat <<\_ACEOF @@ -1351,6 +1355,7 @@ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-config-path=dir lxc configuration repository path --with-rootfs-path=dir lxc rootfs mount point + --with-linuxdir=DIR specify path to Linux source directory Some influential environment variables: CC C compiler command @@ -1428,10 +1433,10 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -lxc configure 0.7.2 -generated by GNU Autoconf 2.65 +lxc configure 0.7.4 +generated by GNU Autoconf 2.67 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1501,7 +1506,7 @@ mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1525,10 +1530,10 @@ ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + if eval "test \"\${$3+set}\"" = set; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1564,7 +1569,7 @@ else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1591,7 +1596,7 @@ esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1655,7 +1660,7 @@ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1723,15 +1728,18 @@ } # ac_fn_c_try_link -# ac_fn_c_check_decl LINENO SYMBOL VAR -# ------------------------------------ -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 -$as_echo_n "checking whether $2 is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval "test \"\${$3+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1740,8 +1748,12 @@ int main () { -#ifndef $2 - (void) $2; +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif #endif ; @@ -1765,8 +1777,8 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by lxc $as_me 0.7.2, which was -generated by GNU Autoconf 2.65. Invocation command line was +It was created by lxc $as_me 0.7.4, which was +generated by GNU Autoconf 2.67. Invocation command line was $ $0 $@ @@ -1876,11 +1888,9 @@ { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -1914,11 +1924,9 @@ ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -1931,11 +1939,9 @@ echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -1949,11 +1955,9 @@ fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2008,7 +2012,12 @@ ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2023,7 +2032,11 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5 ; } fi done @@ -2099,7 +2112,7 @@ $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2116,16 +2129,22 @@ ac_aux_dir= for ac_dir in config "$srcdir"/config; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in config \"$srcdir\"/config" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -2245,11 +2264,11 @@ ' case `pwd` in *[\\\"\#\$\&\'\`$am_lf]*) - as_fn_error "unsafe absolute working directory name" "$LINENO" 5;; + as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5 ;; esac case $srcdir in *[\\\"\#\$\&\'\`$am_lf\ \ ]*) - as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;; + as_fn_error $? "unsafe srcdir value: \`$srcdir'" "$LINENO" 5 ;; esac # Do `set' in a subshell so we don't clobber the current shell's @@ -2271,7 +2290,7 @@ # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - as_fn_error "ls -t appears to fail. Make sure there is not a broken + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken alias in your environment" "$LINENO" 5 fi @@ -2281,7 +2300,7 @@ # Ok. : else - as_fn_error "newly created file is older than distributed files! + as_fn_error $? "newly created file is older than distributed files! Check your system clock" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 @@ -2519,7 +2538,7 @@ $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${ac_cv_prog_make_${ac_make}_set+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2527,7 +2546,7 @@ all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2561,7 +2580,7 @@ am__isrc=' -I$(srcdir)' # test to see if srcdir already configured if test -f $srcdir/config.status; then - as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi fi @@ -2577,7 +2596,7 @@ # Define the identity of the package. PACKAGE='lxc' - VERSION='0.7.2' + VERSION='0.7.4' cat >>confdefs.h <<_ACEOF @@ -2619,7 +2638,7 @@ # Make sure we can run config.sub. $SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || - as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 $as_echo_n "checking build system type... " >&6; } @@ -2630,16 +2649,16 @@ test "x$ac_build_alias" = x && ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` test "x$ac_build_alias" = x && - as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5 + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 $as_echo "$ac_cv_build" >&6; } case $ac_cv_build in *-*-*) ;; -*) as_fn_error "invalid value of canonical build" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5 ;; esac build=$ac_cv_build ac_save_IFS=$IFS; IFS='-' @@ -2664,7 +2683,7 @@ ac_cv_host=$ac_cv_build else ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` || - as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5 fi fi @@ -2672,7 +2691,7 @@ $as_echo "$ac_cv_host" >&6; } case $ac_cv_host in *-*-*) ;; -*) as_fn_error "invalid value of canonical host" "$LINENO" 5;; +*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5 ;; esac host=$ac_cv_host ac_save_IFS=$IFS; IFS='-' @@ -3050,8 +3069,8 @@ test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5 ; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3165,9 +3184,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5 ; } else { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } @@ -3209,8 +3227,8 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 @@ -3267,9 +3285,9 @@ else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. +as_fn_error $? "cannot run C compiled programs. If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } +See \`config.log' for more details" "$LINENO" 5 ; } fi fi fi @@ -3320,8 +3338,8 @@ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5 ; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -3677,7 +3695,7 @@ fi set dummy $CC; ac_cc=`$as_echo "$2" | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'` -if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval "test \"\${ac_cv_prog_cc_${ac_cc}_c_o+set}\"" = set; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3837,7 +3855,7 @@ # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3853,11 +3871,11 @@ ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -3896,7 +3914,7 @@ # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3912,18 +3930,18 @@ ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5 ; } fi ac_ext=c @@ -3984,7 +4002,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -4050,7 +4068,7 @@ done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -4182,8 +4200,7 @@ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4343,7 +4360,7 @@ test "x$have_docbook" = "xno" -a "x$enable_doc" = "xyes" && \ - as_fn_error "docbook2man required by man request, but not found" "$LINENO" 5 + as_fn_error $? "docbook2man required by man request, but not found" "$LINENO" 5 fi if test "x$have_docbook" = "xyes"; then @@ -4778,14 +4795,13 @@ ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF else - as_fn_error "netlink headers not found. Please install the linux kernel headers." "$LINENO" 5 + as_fn_error $? "netlink headers not found. Please install the linux kernel headers." "$LINENO" 5 fi done @@ -4802,7 +4818,7 @@ _ACEOF else - as_fn_error "please install libcap-devel." "$LINENO" 5 + as_fn_error $? "please install libcap-devel." "$LINENO" 5 fi done @@ -4856,7 +4872,7 @@ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CAP_LIBS" >&5 $as_echo "$CAP_LIBS" >&6; } else - as_fn_error "not found" "$LINENO" 5 + as_fn_error $? "not found" "$LINENO" 5 fi @@ -4930,11 +4946,118 @@ fi + + + +# Check whether --with-linuxdir was given. +if test "${with_linuxdir+set}" = set; then : + withval=$with_linuxdir; LINUX_DIR="${withval}" +else + LINUX_DIR=default +fi + + + if test "${LINUX_DIR}" != "default" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux in ${LINUX_DIR}" >&5 +$as_echo_n "checking for Linux in ${LINUX_DIR}... " >&6; } + + if test -f "${LINUX_DIR}/Makefile" ; then + result=yes + + else + result="not found" + as_fn_error $? "Linux dir not found" "$LINENO" 5 + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $result" >&5 +$as_echo "$result" >&6; } + + fi + + if test "${LINUX_DIR}" = "default" ; then + dir="/lib/modules/$LINUX_KERNEL_RELEASE/build"; + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux in ${dir}" >&5 +$as_echo_n "checking for Linux in ${dir}... " >&6; } + + if test -f "${dir}/Makefile" ; then + result=yes + LINUX_DIR=${dir} + else + result="not found" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $result" >&5 +$as_echo "$result" >&6; } + + fi + + if test "${LINUX_DIR}" = "default" ; then + dir="/usr/src/linux-$LINUX_KERNEL_RELEASE"; + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux in ${dir}" >&5 +$as_echo_n "checking for Linux in ${dir}... " >&6; } + + if test -f "${dir}/Makefile" ; then + result=yes + LINUX_DIR=${dir} + else + result="not found" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $result" >&5 +$as_echo "$result" >&6; } + + fi + + if test "${LINUX_DIR}" = "default" ; then + dir="/usr/src/linux"; + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Linux in ${dir}" >&5 +$as_echo_n "checking for Linux in ${dir}... " >&6; } + + if test -f "${dir}/Makefile" ; then + result=yes + LINUX_DIR=${dir} + else + result="not found" + + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $result" >&5 +$as_echo "$result" >&6; } + + fi + + if test "${LINUX_DIR}" = "default" ; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Linux source directory not found" >&5 +$as_echo "$as_me: WARNING: Linux source directory not found" >&2;} + fi + + + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for linux SRCARCH" >&5 +$as_echo_n "checking for linux SRCARCH... " >&6; } + + case "${host}" in + i[3456]86-*) LINUX_SRCARCH=x86;; + x86_64-*) LINUX_SRCARCH=x86;; + powerpc*-*) LINUX_SRCARCH=powerpc;; + s390*-*) LINUX_SRCARCH=s390;; + *) as_fn_error $? "architecture ${host} not supported" "$LINENO" 5 ;; + esac + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LINUX_SRCARCH}" >&5 +$as_echo "${LINUX_SRCARCH}" >&6; } + + + + if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -Wall" fi -ac_config_files="$ac_config_files Makefile lxc.pc lxc.spec config/Makefile doc/Makefile doc/lxc-create.sgml doc/lxc-destroy.sgml doc/lxc-execute.sgml doc/lxc-start.sgml doc/lxc-checkpoint.sgml doc/lxc-restart.sgml doc/lxc-stop.sgml doc/lxc-console.sgml doc/lxc-freeze.sgml doc/lxc-unfreeze.sgml doc/lxc-monitor.sgml doc/lxc-wait.sgml doc/lxc-ls.sgml doc/lxc-ps.sgml doc/lxc-cgroup.sgml doc/lxc-kill.sgml doc/lxc.conf.sgml doc/lxc.sgml doc/common_options.sgml doc/see_also.sgml doc/rootfs/Makefile doc/examples/Makefile doc/examples/lxc-macvlan.conf doc/examples/lxc-vlan.conf doc/examples/lxc-no-netns.conf doc/examples/lxc-empty-netns.conf doc/examples/lxc-phys.conf doc/examples/lxc-veth.conf doc/examples/lxc-complex.conf templates/Makefile templates/lxc-debian templates/lxc-ubuntu templates/lxc-busybox templates/lxc-fedora templates/lxc-sshd src/Makefile src/lxc/Makefile src/lxc/lxc-ps src/lxc/lxc-ls src/lxc/lxc-netstat src/lxc/lxc-checkconfig src/lxc/lxc-setcap src/lxc/lxc-setuid src/lxc/lxc-version src/lxc/lxc-create src/lxc/lxc-destroy" +ac_config_files="$ac_config_files Makefile lxc.pc lxc.spec config/Makefile doc/Makefile doc/lxc-create.sgml doc/lxc-destroy.sgml doc/lxc-execute.sgml doc/lxc-start.sgml doc/lxc-checkpoint.sgml doc/lxc-restart.sgml doc/lxc-stop.sgml doc/lxc-console.sgml doc/lxc-freeze.sgml doc/lxc-unfreeze.sgml doc/lxc-monitor.sgml doc/lxc-wait.sgml doc/lxc-ls.sgml doc/lxc-ps.sgml doc/lxc-cgroup.sgml doc/lxc-kill.sgml doc/lxc.conf.sgml doc/lxc.sgml doc/common_options.sgml doc/see_also.sgml doc/rootfs/Makefile doc/examples/Makefile doc/examples/lxc-macvlan.conf doc/examples/lxc-vlan.conf doc/examples/lxc-no-netns.conf doc/examples/lxc-empty-netns.conf doc/examples/lxc-phys.conf doc/examples/lxc-veth.conf doc/examples/lxc-complex.conf templates/Makefile templates/lxc-lenny templates/lxc-debian templates/lxc-lucid templates/lxc-maverick templates/lxc-natty templates/lxc-busybox templates/lxc-fedora templates/lxc-sshd src/Makefile src/lxc/Makefile src/lxc/lxc-ps src/lxc/lxc-ls src/lxc/lxc-netstat src/lxc/lxc-checkconfig src/lxc/lxc-setcap src/lxc/lxc-setuid src/lxc/lxc-version src/lxc/lxc-create src/lxc/lxc-destroy" ac_config_commands="$ac_config_commands default" @@ -5021,6 +5144,7 @@ ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -5044,19 +5168,19 @@ fi if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - as_fn_error "conditional \"AMDEP\" was never defined. + as_fn_error $? "conditional \"AMDEP\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - as_fn_error "conditional \"am__fastdepCC\" was never defined. + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_DOCBOOK_TRUE}" && test -z "${ENABLE_DOCBOOK_FALSE}"; then - as_fn_error "conditional \"ENABLE_DOCBOOK\" was never defined. + as_fn_error $? "conditional \"ENABLE_DOCBOOK\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${ENABLE_EXAMPLES_TRUE}" && test -z "${ENABLE_EXAMPLES_FALSE}"; then - as_fn_error "conditional \"ENABLE_EXAMPLES\" was never defined. + as_fn_error $? "conditional \"ENABLE_EXAMPLES\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi @@ -5206,19 +5330,19 @@ (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -5414,7 +5538,7 @@ test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -5467,8 +5591,8 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by lxc $as_me 0.7.2, which was -generated by GNU Autoconf 2.65. Invocation command line was +This file was extended by lxc $as_me 0.7.4, which was +generated by GNU Autoconf 2.67. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -5533,11 +5657,11 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -lxc config.status 0.7.2 -configured by $0, generated by GNU Autoconf 2.65, +lxc config.status 0.7.4 +configured by $0, generated by GNU Autoconf 2.67, with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2010 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -5555,11 +5679,16 @@ while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -5581,6 +5710,7 @@ $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -5593,7 +5723,7 @@ ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -5602,7 +5732,7 @@ ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -5694,8 +5824,11 @@ "doc/examples/lxc-veth.conf") CONFIG_FILES="$CONFIG_FILES doc/examples/lxc-veth.conf" ;; "doc/examples/lxc-complex.conf") CONFIG_FILES="$CONFIG_FILES doc/examples/lxc-complex.conf" ;; "templates/Makefile") CONFIG_FILES="$CONFIG_FILES templates/Makefile" ;; + "templates/lxc-lenny") CONFIG_FILES="$CONFIG_FILES templates/lxc-lenny" ;; "templates/lxc-debian") CONFIG_FILES="$CONFIG_FILES templates/lxc-debian" ;; - "templates/lxc-ubuntu") CONFIG_FILES="$CONFIG_FILES templates/lxc-ubuntu" ;; + "templates/lxc-lucid") CONFIG_FILES="$CONFIG_FILES templates/lxc-lucid" ;; + "templates/lxc-maverick") CONFIG_FILES="$CONFIG_FILES templates/lxc-maverick" ;; + "templates/lxc-natty") CONFIG_FILES="$CONFIG_FILES templates/lxc-natty" ;; "templates/lxc-busybox") CONFIG_FILES="$CONFIG_FILES templates/lxc-busybox" ;; "templates/lxc-fedora") CONFIG_FILES="$CONFIG_FILES templates/lxc-fedora" ;; "templates/lxc-sshd") CONFIG_FILES="$CONFIG_FILES templates/lxc-sshd" ;; @@ -5712,7 +5845,7 @@ "src/lxc/lxc-destroy") CONFIG_FILES="$CONFIG_FILES src/lxc/lxc-destroy" ;; "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5 ;; esac done @@ -5750,7 +5883,7 @@ { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -5767,7 +5900,7 @@ fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi @@ -5781,18 +5914,18 @@ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -5881,20 +6014,28 @@ else cat fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -5922,7 +6063,7 @@ if test -z "$ac_t"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -6007,7 +6148,7 @@ _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -6020,7 +6161,7 @@ esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5 ;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -6048,7 +6189,7 @@ [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5 ;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -6075,7 +6216,7 @@ case $ac_tag in *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -6212,22 +6353,22 @@ $ac_datarootdir_hack " eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} rm -f "$tmp/stdin" case $ac_file in -) cat "$tmp/out" && rm -f "$tmp/out";; *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -6238,19 +6379,19 @@ $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_arg="$ac_file" @@ -6401,7 +6542,7 @@ ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -6422,7 +6563,7 @@ exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 diff -Nru lxc-0.7.2/configure.ac lxc-0.7.4/configure.ac --- lxc-0.7.2/configure.ac 2010-07-26 08:58:37.000000000 +0000 +++ lxc-0.7.4/configure.ac 2011-02-26 09:18:19.000000000 +0000 @@ -1,7 +1,7 @@ # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. -AC_INIT([lxc], [0.7.2]) +AC_INIT([lxc], [0.7.4]) AC_CONFIG_SRCDIR([configure.ac]) AC_CONFIG_AUX_DIR([config]) @@ -91,6 +91,8 @@ AC_PROG_GCC_TRADITIONAL +AC_LINUX + if test "x$GCC" = "xyes"; then CFLAGS="$CFLAGS -Wall" fi @@ -135,8 +137,11 @@ doc/examples/lxc-complex.conf templates/Makefile + templates/lxc-lenny templates/lxc-debian - templates/lxc-ubuntu + templates/lxc-lucid + templates/lxc-maverick + templates/lxc-natty templates/lxc-busybox templates/lxc-fedora templates/lxc-sshd diff -Nru lxc-0.7.2/debian/changelog lxc-0.7.4/debian/changelog --- lxc-0.7.2/debian/changelog 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/changelog 2011-06-22 20:45:33.000000000 +0000 @@ -1,3 +1,129 @@ +lxc (0.7.4-0ubuntu10~maverick1) maverick; urgency=low + + * Backport oneiric lxc to lucid. + + -- Serge Hallyn Tue, 21 Jun 2011 09:48:26 -0500 + +lxc (0.7.4-0ubuntu10) oneiric; urgency=low + + * Import patch from stgraber to use dpkg to decide arch in lxc templates. + This is necessary for templates to work on arm. + + -- Serge Hallyn Fri, 27 May 2011 13:38:19 -0400 + +lxc (0.7.4-0ubuntu9) oneiric; urgency=low + + * lxcguest: Recognize 'LIBVIRT_LXC_UUID' in place of 'container=libvirt' + as proving that upstart is running in a container. + + -- Serge Hallyn Mon, 16 May 2011 14:03:52 -0500 + +lxc (0.7.4-0ubuntu8) oneiric; urgency=low + + * debian/patches/0009-templates-dont-use-devpts-in-fstab: remove devpts + entry from $confdir/container/fstab, as it is not needed, and can + cause the host devpts mount options to change, because it happens + before lxc has done a mount -o newinstance. (LP: #607636) + + -- Serge Hallyn Fri, 06 May 2011 12:08:07 -0500 + +lxc (0.7.4-0ubuntu7) natty; urgency=low + + * lxcguest: for libvirt containers, offer console on /dev/pts/0 rather + than /dev/console. + * lxcguest: offer alternate jobs for libvirt-lxc. Libvirt-lxc doesn't watch + guest's utmp (doesn't support clean shutdown at all) so it can safely + mount its own /var/run and such. Hopefully this can go away after lxc + supports clean shutdown/reboot without the utmp-watching hack. + (LP: #757752) + * debian/fstab.lxc: comment out all entries. /sys gets mounted anyway, + and we need to not overmount /var because otherwise the container parent + won't see utmp, can't see the container is shutdown, and won't kill + the init. Note that when expected kernel functionality to help clean up + container reboot and shutdown comes, these can be uncommented. + (LP: #754655) + + -- Serge Hallyn Fri, 08 Apr 2011 09:02:48 -0500 + +lxc (0.7.4-0ubuntu5) natty; urgency=low + + * Add ARM to list of supported archs - LP: #745884 + + -- Marcin Juszkiewicz Wed, 06 Apr 2011 16:49:15 +0200 + +lxc (0.7.4-0ubuntu4) natty; urgency=low + + * Add lxcguest to the list of packages installed by the natty template. + (LP: #745907) + * Since lxcguest will be installed, don't install our own console.conf, + and don't clear out /lib/init/fstab. + + -- Serge Hallyn Fri, 01 Apr 2011 08:50:36 -0500 + +lxc (0.7.4-0ubuntu3) natty; urgency=low + + * Fix an error in the syntax in the ubuntu templates - they were using + upstart job syntax which is not valid in bash for including the + /etc/default files. (LP: #742770) + * debian/lxc.default: Comment out the example defines so as not to cause + trouble, and fix the default MIRROR. + + -- Serge Hallyn Fri, 25 Mar 2011 15:55:05 -0500 + +lxc (0.7.4-0ubuntu2) natty; urgency=low + + * Fix an error in the syntax in the ubuntu templates - they were using + upstart job syntax which is not valid in bash for including the + /etc/default files. (LP: #742770) + * Now that the /etc/default file is actually sourced, comment out + the example defines. + + -- Serge Hallyn Fri, 25 Mar 2011 15:55:05 -0500 + +lxc (0.7.4-0ubuntu2) natty; urgency=low + + * lxc-natty.in: Adding package "netbase" to debootstrap (LP: #740167) + + -- Ahmed Kamal Tue, 22 Mar 2011 18:47:29 +0200 + +lxc (0.7.4-0ubuntu1) natty; urgency=low + + * New upstream version. + * Refreshed patches, dropped 0005-env.patch since it was already + accepted upstream. + + -- Chuck Short Thu, 10 Mar 2011 07:25:34 -0500 + +lxc (0.7.3.1-0ubuntu1) natty; urgency=low + + * Base on new upstream git tree with new maverick and natty templates, + and able to run without ns cgroup. + * Send a 'container=lxc' variable to upstart. The upstream git has + the same patch, though this tree has it as a quilt patch. + * Add lxcguest package which converts a system into one which can + boot upstart both as a container and a (kvm or bare-metal) host. + * Add a MIRROR default in /etc/default/lxc, and use that in the + debootstrap command in the lucid, maverick and natty templates. + * Remove 0004-restore-lxc.mount-lxc.mount.entry-functionality.patch + which prevents containers from starting. + + -- Serge Hallyn Sun, 23 Jan 2011 17:28:55 -0600 + +lxc (0.7.3-1) unstable; urgency=low + + * New upstream version (closes: #602631) + - Support for specifying debian suite (closes: #600459) + - Support for declaring a different architecture (closes: #597875) + * Fix restart init.d action sequence (closes: #597998) + * Move too-deep /usr/lib/lxc/lxc path to a proper patch + * Disable checkroot script in debian template (closes: #601001) + * Create missing tty devices under squeeze (closes: #600466) + * Restore bindmount functionality in newer kernels (closes: #604475) + * Make debian mirror configurable (closes: #601422) + * Default to cdn.debian.net as a debian mirror (closes: #600464) + + -- Guido Trotter Mon, 06 Dec 2010 16:24:31 +0100 + lxc (0.7.2-1) unstable; urgency=low * New upstream version diff -Nru lxc-0.7.2/debian/control lxc-0.7.4/debian/control --- lxc-0.7.2/debian/control 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/control 2011-04-12 01:53:26.000000000 +0000 @@ -1,8 +1,9 @@ Source: lxc Section: admin Priority: optional -Maintainer: Guido Trotter -Build-Depends: cdbs, debhelper (>= 7), autotools-dev, libcap-dev (>= 1:2.17-2), linux-libc-dev +Maintainer: Ubuntu Developers +XSBC-Original-Maintainer: Guido Trotter +Build-Depends: cdbs, debhelper (>= 7), autotools-dev, libcap-dev (>= 1:2.17-2), linux-libc-dev, docbook-utils Standards-Version: 3.9.1 Homepage: http://lxc.sourceforge.net/ Vcs-Git: git://git.debian.org/git/collab-maint/lxc.git @@ -22,3 +23,16 @@ daemon in a container, or to boot an entire "containerized" system, and to successively manage and debug your containers. +Package: lxcguest +Section: admin +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Linux container guest package + Containers are insulated areas inside a system, which have their own namespace + for filesystem, network, pids, ipc, cpu and memory allocation and which can be + created using the Control Group and Namespace features included in recent Linux + Kernels. + . + This package contains the upstart scripts required to allow an Ubuntu + system to boot in lxc. + diff -Nru lxc-0.7.2/debian/dirs lxc-0.7.4/debian/dirs --- lxc-0.7.2/debian/dirs 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/dirs 1970-01-01 00:00:00.000000000 +0000 @@ -1,6 +0,0 @@ -usr/bin -usr/sbin -usr/share/lintian/overrides -usr/share/doc/lxc/examples -var/lib/lxc -etc/lxc diff -Nru lxc-0.7.2/debian/docs lxc-0.7.4/debian/docs --- lxc-0.7.2/debian/docs 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/docs 1970-01-01 00:00:00.000000000 +0000 @@ -1,3 +0,0 @@ -NEWS -README -TODO diff -Nru lxc-0.7.2/debian/fstab.libvirt lxc-0.7.4/debian/fstab.libvirt --- lxc-0.7.2/debian/fstab.libvirt 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/fstab.libvirt 2011-04-12 01:53:41.000000000 +0000 @@ -0,0 +1,6 @@ +# /lib/init/fstab.lxc: static file system information. + +none /sys sysfs nodev,noexec,nosuid 0 0 +none /tmp none defaults 0 0 +none /lib/init/rw tmpfs mode=0755,nosuid,optional 0 0 +none /var/lock tmpfs nodev,noexec,nosuid,showthrough 0 0 diff -Nru lxc-0.7.2/debian/fstab.lxc lxc-0.7.4/debian/fstab.lxc --- lxc-0.7.2/debian/fstab.lxc 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/fstab.lxc 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,6 @@ +# /lib/init/fstab.lxc: static file system information. + +#none /sys sysfs nodev,noexec,nosuid 0 0 +#none /tmp none defaults 0 0 +#none /lib/init/rw tmpfs mode=0755,nosuid,optional 0 0 +#none /var/lock tmpfs nodev,noexec,nosuid,showthrough 0 0 diff -Nru lxc-0.7.2/debian/lxc.default lxc-0.7.4/debian/lxc.default --- lxc-0.7.2/debian/lxc.default 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/lxc.default 2011-04-12 01:53:26.000000000 +0000 @@ -5,5 +5,6 @@ CONF_DIR=/etc/lxc # Start /etc/lxc/example.conf, /etc/lxc/autostart.conf, etc. -CONTAINERS="example autostart container" +#CONTAINERS="example autostart container" +#MIRROR="http://archive.ubuntu.com/ubuntu" diff -Nru lxc-0.7.2/debian/lxc.dirs lxc-0.7.4/debian/lxc.dirs --- lxc-0.7.2/debian/lxc.dirs 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxc.dirs 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,6 @@ +usr/bin +usr/sbin +usr/share/lintian/overrides +usr/share/doc/lxc/examples +var/lib/lxc +etc/lxc diff -Nru lxc-0.7.2/debian/lxc.docs lxc-0.7.4/debian/lxc.docs --- lxc-0.7.2/debian/lxc.docs 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxc.docs 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,3 @@ +NEWS +README +TODO diff -Nru lxc-0.7.2/debian/lxcguest.console.upstart lxc-0.7.4/debian/lxcguest.console.upstart --- lxc-0.7.2/debian/lxcguest.console.upstart 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxcguest.console.upstart 2011-05-16 19:57:17.000000000 +0000 @@ -0,0 +1,29 @@ +# /dev/console - getty +# +# This service maintains a getty on /dev/console from the point the +# system is started until it is shut down again. +# It only runs in lxc containers. + +start on stopped rc RUNLEVEL=[2345] +stop on runlevel [!2345] + +env container +env LIBVIRT_LXC_UUID +pre-start script + [ -z $container ] && [ -z $LIBVIRT_LXC_UUID ] && stop + exit 0; +end script + +respawn + +script + # Pre-start stops us from getting here if it's neither lxc nor libvirt + # So empty $container means it's libvirt from (>= oneiric) + [ -z $container ] && container="libvirt" + if [ "$container" = "lxc" ]; then + dev=/dev/console + else + dev=/dev/pts/0 + fi + exec /sbin/getty -8 38400 $dev +end script diff -Nru lxc-0.7.2/debian/lxcguest.install lxc-0.7.4/debian/lxcguest.install --- lxc-0.7.2/debian/lxcguest.install 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxcguest.install 2011-04-12 01:53:41.000000000 +0000 @@ -0,0 +1,2 @@ +debian/fstab.lxc lib/init +debian/fstab.libvirt lib/init diff -Nru lxc-0.7.2/debian/lxcguest.lxcmount.upstart lxc-0.7.4/debian/lxcguest.lxcmount.upstart --- lxc-0.7.2/debian/lxcguest.lxcmount.upstart 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxcguest.lxcmount.upstart 2011-05-16 19:26:15.000000000 +0000 @@ -0,0 +1,36 @@ +description "redirect builtin fstab for lxc" + +start on starting mountall +console output +task + +env container +env LIBVIRT_LXC_UUID + +pre-start script + # liblxc sends 'container=lxc' + # natty and older libvirt send (only) 'container=libvirt' + # oneiric and newer libvirt send (only) 'LIBVIRT_LXC_UUID=' + if [ -z $container ]; then + if [ ! -z $LIBVIRT_LXC_UUID ]; then + container="libvirt" + else + stop + exit 0 + fi + fi + if [ ! -r /lib/init/fstab.$container ]; then + echo "lxcmount: no /lib/init/fstab.$container found" + stop + exit 0 + fi + + exit 0; +end script + +script + # Pre-start stops us from getting here if it's neither lxc nor libvirt + # So empty $container means it's libvirt from (>= oneiric) + [ -z $container ] && container="libvirt" + exec mount --bind /lib/init/fstab.$container /lib/init/fstab +end script diff -Nru lxc-0.7.2/debian/lxc.init lxc-0.7.4/debian/lxc.init --- lxc-0.7.2/debian/lxc.init 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/lxc.init 2011-04-12 01:53:26.000000000 +0000 @@ -58,8 +58,8 @@ ;; restart|force-reload) log_daemon_msg "Restarting $DESC" - action_all start_one action_all "lxc-stop -n" + action_all start_one ;; destroy) log_daemon_msg "Destroying $DESC" diff -Nru lxc-0.7.2/debian/lxc.install lxc-0.7.4/debian/lxc.install --- lxc-0.7.2/debian/lxc.install 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxc.install 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,4 @@ +usr/include/lxc +usr/lib/lxc +usr/bin +usr/share diff -Nru lxc-0.7.2/debian/lxc-start.sh lxc-0.7.4/debian/lxc-start.sh --- lxc-0.7.2/debian/lxc-start.sh 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/lxc-start.sh 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,4 @@ +#!/bin/sh +export container=lxc +export builtinfstab=/lib/init/fstab.lxc +lxc-start.real $* diff -Nru lxc-0.7.2/debian/patches/0001-fix-too-deep-lib-dir.patch lxc-0.7.4/debian/patches/0001-fix-too-deep-lib-dir.patch --- lxc-0.7.2/debian/patches/0001-fix-too-deep-lib-dir.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0001-fix-too-deep-lib-dir.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,68 @@ +Description: fix-too-deep-lib-dir +Author: Guido Trotter +Forwarded: no +diff -Naurp lxc-0.7.4.orig//configure lxc-0.7.4//configure +--- lxc-0.7.4.orig//configure 2011-02-26 04:20:20.000000000 -0500 ++++ lxc-0.7.4//configure 2011-03-10 07:15:22.841352510 -0500 +@@ -4719,7 +4719,7 @@ fi + + + EXP_VAR=LXCINITDIR +- FROM_VAR=$libdir/lxc ++ FROM_VAR=$libdir + + prefix_save=$prefix + exec_prefix_save=$exec_prefix +@@ -4747,7 +4747,7 @@ fi + + + EXP_VAR=LXCTEMPLATEDIR +- FROM_VAR=$libdir/lxc/templates ++ FROM_VAR=$libdir/templates + + prefix_save=$prefix + exec_prefix_save=$exec_prefix +diff -Naurp lxc-0.7.4.orig//configure.ac lxc-0.7.4//configure.ac +--- lxc-0.7.4.orig//configure.ac 2011-02-26 04:18:19.000000000 -0500 ++++ lxc-0.7.4//configure.ac 2011-03-10 07:15:22.845352361 -0500 +@@ -56,8 +56,8 @@ AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date) + + AS_AC_EXPAND(LXCPATH, "${with_config_path}") + AS_AC_EXPAND(LXCROOTFSMOUNT, "${with_rootfs_path}") +-AS_AC_EXPAND(LXCINITDIR, $libdir/lxc) +-AS_AC_EXPAND(LXCTEMPLATEDIR, $libdir/lxc/templates) ++AS_AC_EXPAND(LXCINITDIR, $libdir) ++AS_AC_EXPAND(LXCTEMPLATEDIR, $libdir/templates) + AH_TEMPLATE([LXCPATH], [lxc configuration repository]) + AH_TEMPLATE([LXCINITDIR], [lxc-init directory location]) + AH_TEMPLATE([LXCROOTFSMOUNT], [lxc default rootfs mount point]) +diff -Naurp lxc-0.7.4.orig//src/lxc/Makefile.am lxc-0.7.4//src/lxc/Makefile.am +--- lxc-0.7.4.orig//src/lxc/Makefile.am 2011-02-01 09:12:40.000000000 -0500 ++++ lxc-0.7.4//src/lxc/Makefile.am 2011-03-10 07:15:22.845352361 -0500 +@@ -15,6 +15,7 @@ pkginclude_HEADERS = \ + setns.h + + sodir=$(libdir) ++pkglibdir = $(libdir) + # use PROGRAMS to avoid complains from automake + so_PROGRAMS = liblxc.so + +diff -Naurp lxc-0.7.4.orig//src/lxc/Makefile.in lxc-0.7.4//src/lxc/Makefile.in +--- lxc-0.7.4.orig//src/lxc/Makefile.in 2011-02-26 04:20:20.000000000 -0500 ++++ lxc-0.7.4//src/lxc/Makefile.in 2011-03-10 07:15:22.849352212 -0500 +@@ -20,7 +20,6 @@ + VPATH = @srcdir@ + pkgdatadir = $(datadir)/@PACKAGE@ + pkgincludedir = $(includedir)/@PACKAGE@ +-pkglibdir = $(libdir)/@PACKAGE@ + pkglibexecdir = $(libexecdir)/@PACKAGE@ + am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd + install_sh_DATA = $(install_sh) -c -m 644 +@@ -198,6 +197,7 @@ HEADERS = $(pkginclude_HEADERS) + ETAGS = etags + CTAGS = ctags + DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ++pkglibdir = $(libdir) + ACLOCAL = @ACLOCAL@ + AMTAR = @AMTAR@ + AUTOCONF = @AUTOCONF@ diff -Nru lxc-0.7.2/debian/patches/0002-disable-debian-checkroot-script.patch lxc-0.7.4/debian/patches/0002-disable-debian-checkroot-script.patch --- lxc-0.7.2/debian/patches/0002-disable-debian-checkroot-script.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0002-disable-debian-checkroot-script.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,14 @@ +Description: disable debian checkroot script +Author: Daniel Baumann +Fowarded: no +diff -Naurp lxc-0.7.4.orig//templates/lxc-debian.in lxc-0.7.4//templates/lxc-debian.in +--- lxc-0.7.4.orig//templates/lxc-debian.in 2011-02-19 03:45:32.000000000 -0500 ++++ lxc-0.7.4//templates/lxc-debian.in 2011-03-10 07:19:07.980962998 -0500 +@@ -84,7 +84,6 @@ EOF + fi + + # remove pointless services in a container +- chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove diff -Nru lxc-0.7.2/debian/patches/0003-squeeze-missing-tty.patch lxc-0.7.4/debian/patches/0003-squeeze-missing-tty.patch --- lxc-0.7.2/debian/patches/0003-squeeze-missing-tty.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0003-squeeze-missing-tty.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,20 @@ +Description: Fix squeeze missing tty +Author: Daniel Baumann +Forwarded: no +diff -Naurp lxc-0.7.4.orig//templates/lxc-debian.in lxc-0.7.4//templates/lxc-debian.in +--- lxc-0.7.4.orig//templates/lxc-debian.in 2011-02-19 03:45:32.000000000 -0500 ++++ lxc-0.7.4//templates/lxc-debian.in 2011-03-10 07:20:05.330827350 -0500 +@@ -36,6 +36,13 @@ configure_debian() + fi + done + ++ # Squeeze only has /dev/tty and /dev/tty0 by default, ++ # therefore creating missing device nodes for tty1-4. ++ test -e $rootfs/dev/tty1 || mknod $rootfs/dev/tty1 c 4 1 ++ test -e $rootfs/dev/tty2 || mknod $rootfs/dev/tty2 c 4 2 ++ test -e $rootfs/dev/tty3 || mknod $rootfs/dev/tty3 c 4 3 ++ test -e $rootfs/dev/tty4 || mknod $rootfs/dev/tty4 c 4 4 ++ + # configure the inittab + cat < $rootfs/etc/inittab + id:3:initdefault: diff -Nru lxc-0.7.2/debian/patches/0004-add-ubuntu-mirrors.patch lxc-0.7.4/debian/patches/0004-add-ubuntu-mirrors.patch --- lxc-0.7.2/debian/patches/0004-add-ubuntu-mirrors.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0004-add-ubuntu-mirrors.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,69 @@ +Description: Add a MIRROR default in /etc/default/lxc. +Author: Serge Hallyn +Forwarded: no +Index: lxc-fix-3bugs2/templates/lxc-lucid.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-lucid.in 2011-04-01 08:57:25.948110000 -0500 ++++ lxc-fix-3bugs2/templates/lxc-lucid.in 2011-04-01 08:57:25.948110000 -0500 +@@ -23,6 +23,8 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + ++[ -r /etc/default/lxc && . /etc/default/lxc ] ++ + configure_ubuntu() + { + rootfs=$1 +@@ -158,7 +160,7 @@ + + # download a mini ubuntu into a cache + echo "Downloading ubuntu lucid minimal ..." +- debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages lucid $cache/partial-$arch ++ debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages lucid $cache/partial-$arch $MIRROR + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 +Index: lxc-fix-3bugs2/templates/lxc-maverick.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-maverick.in 2011-04-01 08:57:25.948110000 -0500 ++++ lxc-fix-3bugs2/templates/lxc-maverick.in 2011-04-01 08:57:25.948110000 -0500 +@@ -23,6 +23,8 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + ++[ -r /etc/default/lxc && . /etc/default/lxc ] ++ + configure_ubuntu() + { + rootfs=$1 +@@ -81,7 +83,7 @@ + + # download a mini ubuntu into a cache + echo "Downloading ubuntu maverick minimal ..." +- debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages maverick $cache/partial-$arch ++ debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages maverick $cache/partial-$arch $MIRROR + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 +Index: lxc-fix-3bugs2/templates/lxc-natty.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-natty.in 2011-04-01 08:57:25.948110000 -0500 ++++ lxc-fix-3bugs2/templates/lxc-natty.in 2011-04-01 08:59:03.816970000 -0500 +@@ -23,6 +23,8 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + ++[ -r /etc/default/lxc && . /etc/default/lxc ] ++ + configure_ubuntu() + { + rootfs=$1 +@@ -82,7 +84,7 @@ + + # download a mini ubuntu into a cache + echo "Downloading ubuntu natty minimal ..." +- debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages natty $cache/partial-$arch ++ debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages natty $cache/partial-$arch $MIRROR + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 diff -Nru lxc-0.7.2/debian/patches/0005-add-netbase-to-templates.patch lxc-0.7.4/debian/patches/0005-add-netbase-to-templates.patch --- lxc-0.7.2/debian/patches/0005-add-netbase-to-templates.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0005-add-netbase-to-templates.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,31 @@ +Description: add netbase to the maverick and natty packages +Author: Ahmed Kamal +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/debootstrap/+bug/740167 +Forwarded: no + +Index: lxc-fix-3bugs2/templates/lxc-maverick.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-maverick.in 2011-04-01 09:01:15.609154276 -0500 ++++ lxc-fix-3bugs2/templates/lxc-maverick.in 2011-04-01 09:01:23.101133352 -0500 +@@ -69,7 +69,7 @@ + + download_ubuntu() + { +- packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg ++ packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg,netbase + + cache=$1 + arch=$2 +Index: lxc-fix-3bugs2/templates/lxc-natty.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-natty.in 2011-04-01 09:01:26.157131322 -0500 ++++ lxc-fix-3bugs2/templates/lxc-natty.in 2011-04-01 09:01:32.053146318 -0500 +@@ -70,7 +70,7 @@ + + download_ubuntu() + { +- packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg ++ packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase + + cache=$1 + arch=$2 diff -Nru lxc-0.7.2/debian/patches/0006-fix-template-syntax-error.patch lxc-0.7.4/debian/patches/0006-fix-template-syntax-error.patch --- lxc-0.7.2/debian/patches/0006-fix-template-syntax-error.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0006-fix-template-syntax-error.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,50 @@ +Description: Fix syntax error in including /etc/default/lxc +Author: Serge Hallyn +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/742770 +Forwarded: no + +Index: lxc-fix-3bugs2/templates/lxc-lucid.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-lucid.in 2011-04-01 09:08:07.050140137 -0500 ++++ lxc-fix-3bugs2/templates/lxc-lucid.in 2011-04-01 09:08:20.421130521 -0500 +@@ -23,7 +23,9 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + +-[ -r /etc/default/lxc && . /etc/default/lxc ] ++if [ -r /etc/default/lxc ]; then ++ . /etc/default/lxc ++fi + + configure_ubuntu() + { +Index: lxc-fix-3bugs2/templates/lxc-maverick.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-maverick.in 2011-04-01 09:08:41.698149527 -0500 ++++ lxc-fix-3bugs2/templates/lxc-maverick.in 2011-04-01 09:09:19.345261946 -0500 +@@ -23,7 +23,9 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + +-[ -r /etc/default/lxc && . /etc/default/lxc ] ++if [ -r /etc/default/lxc ]; then ++ . /etc/default/lxc ++fi + + configure_ubuntu() + { +Index: lxc-fix-3bugs2/templates/lxc-natty.in +=================================================================== +--- lxc-fix-3bugs2.orig/templates/lxc-natty.in 2011-04-01 09:08:44.937153853 -0500 ++++ lxc-fix-3bugs2/templates/lxc-natty.in 2011-04-01 09:09:30.454231512 -0500 +@@ -23,7 +23,9 @@ + # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + # + +-[ -r /etc/default/lxc && . /etc/default/lxc ] ++if [ -r /etc/default/lxc ]; then ++ . /etc/default/lxc ++fi + + configure_ubuntu() + { diff -Nru lxc-0.7.2/debian/patches/0007-natty-template-install-lxcguest.patch lxc-0.7.4/debian/patches/0007-natty-template-install-lxcguest.patch --- lxc-0.7.2/debian/patches/0007-natty-template-install-lxcguest.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0007-natty-template-install-lxcguest.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,34 @@ +Description: Use lxcuest package in natty template +Author: Serge Hallyn +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/745907 +Forwarded: no + +Index: lxc-fix-3bugs/templates/lxc-natty.in +=================================================================== +--- lxc-fix-3bugs.orig/templates/lxc-natty.in 2011-04-01 08:49:21.246147115 -0500 ++++ lxc-fix-3bugs/templates/lxc-natty.in 2011-04-01 08:50:13.605237786 -0500 +@@ -56,13 +56,9 @@ + # suppress log level output for udev + sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf + +- # tweak consoles ++ # remove jobs for consoles 5 and 6 since we only create 4 consoles in ++ # this template + rm -f $rootfs/etc/init/tty{5,6}.conf +- cp $rootfs/etc/init/tty1.conf $rootfs/etc/init/console.conf +- sed -i 's/tty1/\/dev\/console/' $rootfs/etc/init/console.conf +- +- # don't let upstart mount anything from its builtin fs +- echo "#Emptied out by lxc-natty template" > $rootfs/lib/init/fstab + + echo "Please change root-password !" + echo "root:root" | chroot $rootfs chpasswd +@@ -72,7 +68,7 @@ + + download_ubuntu() + { +- packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase ++ packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg,netbase,lxcguest + + cache=$1 + arch=$2 diff -Nru lxc-0.7.2/debian/patches/0008-add-arm-to-supported-archs.patch lxc-0.7.4/debian/patches/0008-add-arm-to-supported-archs.patch --- lxc-0.7.2/debian/patches/0008-add-arm-to-supported-archs.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0008-add-arm-to-supported-archs.patch 2011-04-12 01:53:26.000000000 +0000 @@ -0,0 +1,24 @@ +Index: lxc-0.7.4/config/linux.m4 +=================================================================== +--- lxc-0.7.4.orig/config/linux.m4 2011-02-01 15:12:40.000000000 +0100 ++++ lxc-0.7.4/config/linux.m4 2011-04-06 16:48:10.765324503 +0200 +@@ -65,6 +65,7 @@ + x86_64-*) LINUX_SRCARCH=x86;; + powerpc*-*) LINUX_SRCARCH=powerpc;; + s390*-*) LINUX_SRCARCH=s390;; ++ arm*-*) LINUX_SRCARCH=arm;; + *) AC_MSG_ERROR([architecture ${host} not supported]);; + esac + +Index: lxc-0.7.4/configure +=================================================================== +--- lxc-0.7.4.orig/configure 2011-04-06 16:48:16.335637003 +0200 ++++ lxc-0.7.4/configure 2011-04-06 16:48:31.382512002 +0200 +@@ -5044,6 +5044,7 @@ + x86_64-*) LINUX_SRCARCH=x86;; + powerpc*-*) LINUX_SRCARCH=powerpc;; + s390*-*) LINUX_SRCARCH=s390;; ++ arm*-*) LINUX_SRCARCH=arm;; + *) as_fn_error $? "architecture ${host} not supported" "$LINENO" 5 ;; + esac + diff -Nru lxc-0.7.2/debian/patches/0009-templates-dont-use-devpts-in-fstab lxc-0.7.4/debian/patches/0009-templates-dont-use-devpts-in-fstab --- lxc-0.7.2/debian/patches/0009-templates-dont-use-devpts-in-fstab 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0009-templates-dont-use-devpts-in-fstab 2011-05-06 17:08:05.000000000 +0000 @@ -0,0 +1,81 @@ +Description: templates: don't put devpts in $confdir/container/fstab + src/lxc/conf.c will explicitly mount it anyway. Furthermore, the fstab + entry, which is getting processed first, did not specify -o newinstance. + This can cause the host's devpts entry mount options to change, as in + https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/607636. +Author: Serge Hallyn +Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/607636 +Forwarded: yes + +Index: lxc-0.7.4/templates/lxc-debian.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-debian.in 2011-05-06 12:06:20.906240318 -0500 ++++ lxc-0.7.4/templates/lxc-debian.in 2011-05-06 12:06:45.056240324 -0500 +@@ -224,7 +224,6 @@ + + # mounts point + lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 + lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 + EOF + +Index: lxc-0.7.4/templates/lxc-fedora.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-fedora.in 2011-05-06 12:06:17.556240318 -0500 ++++ lxc-0.7.4/templates/lxc-fedora.in 2011-05-06 12:06:49.436240326 -0500 +@@ -225,7 +225,6 @@ + + cat < $path/fstab + proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-devpts $rootfs/dev/pts devpts defaults 0 0 + sysfs $rootfs/sys sysfs defaults 0 0 + EOF + +Index: lxc-0.7.4/templates/lxc-lenny.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-lenny.in 2011-05-06 12:06:15.646240318 -0500 ++++ lxc-0.7.4/templates/lxc-lenny.in 2011-05-06 12:06:47.126240324 -0500 +@@ -208,7 +208,6 @@ + + # mounts point + lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 + lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 + EOF + +Index: lxc-0.7.4/templates/lxc-lucid.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-lucid.in 2011-05-06 12:06:08.036240316 -0500 ++++ lxc-0.7.4/templates/lxc-lucid.in 2011-05-06 12:06:30.836240320 -0500 +@@ -264,7 +264,6 @@ + + cat < $path/fstab + proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-devpts $rootfs/dev/pts devpts defaults 0 0 + sysfs $rootfs/sys sysfs defaults 0 0 + EOF + +Index: lxc-0.7.4/templates/lxc-maverick.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-maverick.in 2011-05-06 12:06:11.506240316 -0500 ++++ lxc-0.7.4/templates/lxc-maverick.in 2011-05-06 12:06:36.866240322 -0500 +@@ -187,7 +187,6 @@ + + cat < $path/fstab + proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-devpts $rootfs/dev/pts devpts defaults 0 0 + sysfs $rootfs/sys sysfs defaults 0 0 + EOF + +Index: lxc-0.7.4/templates/lxc-natty.in +=================================================================== +--- lxc-0.7.4.orig/templates/lxc-natty.in 2011-05-06 12:06:13.556240316 -0500 ++++ lxc-0.7.4/templates/lxc-natty.in 2011-05-06 12:06:38.916240322 -0500 +@@ -184,7 +184,6 @@ + + cat < $path/fstab + proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +-devpts $rootfs/dev/pts devpts defaults 0 0 + sysfs $rootfs/sys sysfs defaults 0 0 + EOF + diff -Nru lxc-0.7.2/debian/patches/0010-templates-use-dpkg.patch lxc-0.7.4/debian/patches/0010-templates-use-dpkg.patch --- lxc-0.7.2/debian/patches/0010-templates-use-dpkg.patch 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/debian/patches/0010-templates-use-dpkg.patch 2011-05-27 17:37:36.000000000 +0000 @@ -0,0 +1,116 @@ +From 3930b7453e9b6d3cc77bf8433f04c446da949060 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?St=C3=A9phane=20Graber?= +Date: Tue, 24 May 2011 14:19:08 -0400 +Subject: [PATCH 1/2] Convert all Debian (and derivative) templates from using 'arch' to using 'dpkg --print-architecture' as debootstrap does + +--- + templates/lxc-debian.in | 9 +-------- + templates/lxc-lenny.in | 9 +-------- + templates/lxc-lucid.in | 9 +-------- + templates/lxc-maverick.in | 9 +-------- + templates/lxc-natty.in | 9 +-------- + 5 files changed, 5 insertions(+), 40 deletions(-) + +diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in +index 27c041e..75a33a4 100644 +--- a/templates/lxc-debian.in ++++ b/templates/lxc-debian.in +@@ -158,14 +158,7 @@ install_debian() + return 1 + fi + +- arch=$(arch) +- if [ "$arch" == "x86_64" ]; then +- arch=amd64 +- fi +- +- if [ "$arch" == "i686" ]; then +- arch=i386 +- fi ++ arch=$(dpkg --print-architecture) + + echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " + if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then +diff --git a/templates/lxc-lenny.in b/templates/lxc-lenny.in +index 0f37988..3720dce 100644 +--- a/templates/lxc-lenny.in ++++ b/templates/lxc-lenny.in +@@ -148,14 +148,7 @@ install_debian() + return 1 + fi + +- arch=$(arch) +- if [ "$arch" == "x86_64" ]; then +- arch=amd64 +- fi +- +- if [ "$arch" == "i686" ]; then +- arch=i386 +- fi ++ arch=$(dpkg --print-architecture) + + echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " + if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then +diff --git a/templates/lxc-lucid.in b/templates/lxc-lucid.in +index fe61313..88a4618 100644 +--- a/templates/lxc-lucid.in ++++ b/templates/lxc-lucid.in +@@ -194,14 +194,7 @@ install_ubuntu() + return 1 + fi + +- arch=$(arch) +- if [ "$arch" == "x86_64" ]; then +- arch=amd64 +- fi +- +- if [ "$arch" == "i686" ]; then +- arch=i386 +- fi ++ arch=$(dpkg --print-architecture) + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then +diff --git a/templates/lxc-maverick.in b/templates/lxc-maverick.in +index 0a8ac8e..23ecefa 100644 +--- a/templates/lxc-maverick.in ++++ b/templates/lxc-maverick.in +@@ -117,14 +117,7 @@ install_ubuntu() + return 1 + fi + +- arch=$(arch) +- if [ "$arch" == "x86_64" ]; then +- arch=amd64 +- fi +- +- if [ "$arch" == "i686" ]; then +- arch=i386 +- fi ++ arch=$(dpkg --print-architecture) + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then +diff --git a/templates/lxc-natty.in b/templates/lxc-natty.in +index e7e3859..8211c1e 100644 +--- a/templates/lxc-natty.in ++++ b/templates/lxc-natty.in +@@ -118,14 +118,7 @@ install_ubuntu() + return 1 + fi + +- arch=$(arch) +- if [ "$arch" == "x86_64" ]; then +- arch=amd64 +- fi +- +- if [ "$arch" == "i686" ]; then +- arch=i386 +- fi ++ arch=$(dpkg --print-architecture) + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then +-- +1.7.4.1 + diff -Nru lxc-0.7.2/debian/patches/debian-changes-0.7.2-1 lxc-0.7.4/debian/patches/debian-changes-0.7.2-1 --- lxc-0.7.2/debian/patches/debian-changes-0.7.2-1 2010-08-04 17:27:43.000000000 +0000 +++ lxc-0.7.4/debian/patches/debian-changes-0.7.2-1 1970-01-01 00:00:00.000000000 +0000 @@ -1,95 +0,0 @@ -Description: Upstream changes introduced in version 0.7.2-1 - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - lxc (0.7.2-1) unstable; urgency=low - . - * New upstream version - * Convert libcap dependency to versioned (closes: #571527) - * Bump up standards version to 3.9.0 - * Fix too-deep /usr/lib/lxc/lxc path (closes: #587847) - * Add init script (closes: #573830) - Thanks to PrzemysÅ‚aw Knycz for the base example - * Bump up standards version (3.9.1) - . - The person named in the Author field signed this changelog entry. -Author: Guido Trotter -Bug-Debian: http://bugs.debian.org/571527 -Bug-Debian: http://bugs.debian.org/573830 -Bug-Debian: http://bugs.debian.org/587847 - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- lxc-0.7.2.orig/configure.ac -+++ lxc-0.7.2/configure.ac -@@ -56,8 +56,8 @@ AS_AC_EXPAND(LXC_GENERATE_DATE, "$(date) - - AS_AC_EXPAND(LXCPATH, "${with_config_path}") - AS_AC_EXPAND(LXCROOTFSMOUNT, "${with_rootfs_path}") --AS_AC_EXPAND(LXCINITDIR, $libdir/lxc) --AS_AC_EXPAND(LXCTEMPLATEDIR, $libdir/lxc/templates) -+AS_AC_EXPAND(LXCINITDIR, $libdir) -+AS_AC_EXPAND(LXCTEMPLATEDIR, $libdir/templates) - AH_TEMPLATE([LXCPATH], [lxc configuration repository]) - AH_TEMPLATE([LXCINITDIR], [lxc-init directory location]) - AH_TEMPLATE([LXCROOTFSMOUNT], [lxc default rootfs mount point]) ---- lxc-0.7.2.orig/configure -+++ lxc-0.7.2/configure -@@ -4702,7 +4702,7 @@ fi - - - EXP_VAR=LXCINITDIR -- FROM_VAR=$libdir/lxc -+ FROM_VAR=$libdir - - prefix_save=$prefix - exec_prefix_save=$exec_prefix -@@ -4730,7 +4730,7 @@ fi - - - EXP_VAR=LXCTEMPLATEDIR -- FROM_VAR=$libdir/lxc/templates -+ FROM_VAR=$libdir/templates - - prefix_save=$prefix - exec_prefix_save=$exec_prefix ---- lxc-0.7.2.orig/src/lxc/Makefile.am -+++ lxc-0.7.2/src/lxc/Makefile.am -@@ -14,6 +14,7 @@ pkginclude_HEADERS = \ - state.h - - sodir=$(libdir) -+pkglibdir = $(libdir) - # use PROGRAMS to avoid complains from automake - so_PROGRAMS = liblxc.so - ---- lxc-0.7.2.orig/src/lxc/Makefile.in -+++ lxc-0.7.2/src/lxc/Makefile.in -@@ -20,7 +20,6 @@ - VPATH = @srcdir@ - pkgdatadir = $(datadir)/@PACKAGE@ - pkgincludedir = $(includedir)/@PACKAGE@ --pkglibdir = $(libdir)/@PACKAGE@ - pkglibexecdir = $(libexecdir)/@PACKAGE@ - am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd - install_sh_DATA = $(install_sh) -c -m 644 -@@ -197,6 +196,7 @@ HEADERS = $(pkginclude_HEADERS) - ETAGS = etags - CTAGS = ctags - DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) -+pkglibdir = $(libdir) - ACLOCAL = @ACLOCAL@ - AMTAR = @AMTAR@ - AUTOCONF = @AUTOCONF@ diff -Nru lxc-0.7.2/debian/patches/series lxc-0.7.4/debian/patches/series --- lxc-0.7.2/debian/patches/series 2010-08-04 17:27:43.000000000 +0000 +++ lxc-0.7.4/debian/patches/series 2011-05-27 17:37:36.000000000 +0000 @@ -1 +1,10 @@ -debian-changes-0.7.2-1 +0001-fix-too-deep-lib-dir.patch +0002-disable-debian-checkroot-script.patch +0003-squeeze-missing-tty.patch +0004-add-ubuntu-mirrors.patch +0005-add-netbase-to-templates.patch +0006-fix-template-syntax-error.patch +0007-natty-template-install-lxcguest.patch +0008-add-arm-to-supported-archs.patch +0009-templates-dont-use-devpts-in-fstab +0010-templates-use-dpkg.patch diff -Nru lxc-0.7.2/debian/rules lxc-0.7.4/debian/rules --- lxc-0.7.2/debian/rules 2010-08-04 17:23:58.000000000 +0000 +++ lxc-0.7.4/debian/rules 2011-04-12 01:53:26.000000000 +0000 @@ -8,7 +8,14 @@ # Install liblxc in out private area, for now, until it's stable. LIBDIR="\$${prefix}/lib/lxc" DEB_CONFIGURE_EXTRA_FLAGS=--libdir=$(LIBDIR) \ - --with-rootfs-path=$(LIBDIR) + --with-rootfs-path=$(LIBDIR) \ + --enable-doc binary-install/lxc:: cp debian/lxc.overrides debian/lxc/usr/share/lintian/overrides/lxc + dh_install + +binary-install/lxcguest:: + dh_install + dh_installinit --no-start --name=console + dh_installinit --no-start --name=lxcmount diff -Nru lxc-0.7.2/doc/examples/Makefile.in lxc-0.7.4/doc/examples/Makefile.in --- lxc-0.7.2/doc/examples/Makefile.in 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/doc/examples/Makefile.in 2011-02-26 09:20:19.000000000 +0000 @@ -43,7 +43,7 @@ $(srcdir)/lxc-vlan.conf.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -112,6 +112,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ diff -Nru lxc-0.7.2/doc/lxc.7 lxc-0.7.4/doc/lxc.7 --- lxc-0.7.2/doc/lxc.7 2010-07-26 08:59:07.000000000 +0000 +++ lxc-0.7.4/doc/lxc.7 2011-02-26 09:20:28.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC" "7" "26 July 2010" "Version 0.7.2" "" +.TH "LXC" "7" "26 February 2011" "Version 0.7.4" "" .SH NAME lxc \- linux containers diff -Nru lxc-0.7.2/doc/lxc-cgroup.1 lxc-0.7.4/doc/lxc-cgroup.1 --- lxc-0.7.2/doc/lxc-cgroup.1 2010-07-26 08:59:07.000000000 +0000 +++ lxc-0.7.4/doc/lxc-cgroup.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-CGROUP" "1" "26 July 2010" "" "" +.TH "LXC-CGROUP" "1" "26 February 2011" "" "" .SH NAME lxc-cgroup \- manage the control group associated with a container diff -Nru lxc-0.7.2/doc/lxc-checkpoint.1 lxc-0.7.4/doc/lxc-checkpoint.1 --- lxc-0.7.2/doc/lxc-checkpoint.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-checkpoint.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-CHECKPOINT" "1" "26 July 2010" "IBM" "" +.TH "LXC-CHECKPOINT" "1" "26 February 2011" "IBM" "" .SH NAME lxc-checkpoint \- checkpoint a running container (not implemented yet) diff -Nru lxc-0.7.2/doc/lxc-checkpoint.sgml.in lxc-0.7.4/doc/lxc-checkpoint.sgml.in --- lxc-0.7.2/doc/lxc-checkpoint.sgml.in 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/doc/lxc-checkpoint.sgml.in 2011-02-17 09:07:44.000000000 +0000 @@ -165,7 +165,7 @@ - Notes + Notes Actually, this command does not operate. Its description helps to define a CLI api for future Checkpoint / Restart solution diff -Nru lxc-0.7.2/doc/lxc.conf.5 lxc-0.7.4/doc/lxc.conf.5 --- lxc-0.7.2/doc/lxc.conf.5 2010-07-26 08:59:07.000000000 +0000 +++ lxc-0.7.4/doc/lxc.conf.5 2011-02-26 09:20:28.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC.CONF" "5" "26 July 2010" "" "" +.TH "LXC.CONF" "5" "26 February 2011" "" "" .SH NAME lxc.conf \- linux container configuration file @@ -29,6 +29,22 @@ Each option in the configuration file has the form \fBkey = value\fR fitting in one line. The '#' character means the line is a comment. +.SS "ARCHITECTURE" +.PP +Allows to set the architecture for the container. For example, +set a 32bits architecture for a container running 32bits +binaries on a 64bits host. That fix the container scripts +which rely on the architecture to do some work like +downloading the packages. +.TP +\fB lxc.arch \fR +Specify the architecture for the container. + +Valid options are +\fBx86\fR, +\fBi686\fR, +\fBx86_64\fR, +\fBamd64\fR .SS "HOSTNAME" .PP The utsname section defines the hostname to be set for the @@ -142,13 +158,27 @@ specify the ipv4 address to assign to the virtualized interface. Several lines specify several ipv4 addresses. The address is in format x.y.z.t/m, -eg. 192.168.1.123/24. +eg. 192.168.1.123/24. The broadcast address should be +specified on the same line, right after the ipv4 +address. .TP \fB lxc.network.ipv6 \fR specify the ipv6 address to assign to the virtualized interface. Several lines specify several ipv6 addresses. The address is in format x::y/m, eg. 2003:db8:1:0:214:1234:fe0b:3596/64 +.TP +\fB lxc.network.script.up \fR +add a configuration option to specify a script to be +executed after creating and configuring the network used +from the host side. The following arguments are passed +to the script: container name and 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. And finally (host-sided) device name. .SS "NEW PSEUDO TTY INSTANCE (DEVPTS)" .PP For stricter isolation the container can have its own private @@ -193,7 +223,13 @@ \fB lxc.mount \fR specify a file location in the \fIfstab\fR format, containing the -mount informations. +mount informations. If the rootfs is an image file or a +device block and the fstab is used to mount a point +somewhere in this rootfs, the path of the rootfs mount +point should be prefixed with the +\fI/usr/lib64/lxc/rootfs\fR default path or +the value of \fBlxc.rootfs.mount\fR if +specified. .TP \fB lxc.mount.entry \fR specify a mount point corresponding to a line in the @@ -204,9 +240,10 @@ of the host system. .TP \fB lxc.rootfs \fR -specify a directory to become the root of the container. -If not specified, the container shares its root file -system with the host. +specify the root file system for the container. It can +be an image file, a directory or a block device. If not +specified, the container shares its root file system +with the host. .TP \fB lxc.rootfs.mount \fR where to recursively bind \fBlxc.rootfs\fR @@ -270,7 +307,7 @@ lxc.network.link = br0 lxc.network.name = eth0 lxc.network.hwaddr = 4a:49:43:49:79:bf - lxc.network.ipv4 = 1.2.3.5/24 + lxc.network.ipv4 = 1.2.3.5/24 1.2.3.255 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 .fi @@ -301,7 +338,7 @@ lxc.network.flags = up lxc.network.link = br0 lxc.network.hwaddr = 4a:49:43:49:79:bf - lxc.network.ipv4 = 1.2.3.5/24 + lxc.network.ipv4 = 1.2.3.5/24 1.2.3.255 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 lxc.network.ipv6 = 2003:db8:1:0:214:5432:feab:3588 lxc.network.type = macvlan diff -Nru lxc-0.7.2/doc/lxc.conf.sgml.in lxc-0.7.4/doc/lxc.conf.sgml.in --- lxc-0.7.2/doc/lxc.conf.sgml.in 2010-06-17 20:42:15.000000000 +0000 +++ lxc-0.7.4/doc/lxc.conf.sgml.in 2011-02-06 20:30:17.000000000 +0000 @@ -76,6 +76,38 @@ + Architecture + + Allows to set the architecture for the container. For example, + set a 32bits architecture for a container running 32bits + binaries on a 64bits host. That fix the container scripts + which rely on the architecture to do some work like + downloading the packages. + + + + + + + + + + Specify the architecture for the container. + + + Valid options are + , + , + , + + + + + + + + + Hostname The utsname section defines the hostname to be set for the @@ -259,7 +291,9 @@ specify the ipv4 address to assign to the virtualized interface. Several lines specify several ipv4 addresses. The address is in format x.y.z.t/m, - eg. 192.168.1.123/24. + eg. 192.168.1.123/24. The broadcast address should be + specified on the same line, right after the ipv4 + address. @@ -278,8 +312,26 @@ + + + + + + + add a configuration option to specify a script to be + executed after creating and configuring the network used + from the host side. The following arguments are passed + to the script: container name and 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. And finally (host-sided) device name. + + + - @@ -372,7 +424,13 @@ specify a file location in the fstab format, containing the - mount informations. + mount informations. If the rootfs is an image file or a + device block and the fstab is used to mount a point + somewhere in this rootfs, the path of the rootfs mount + point should be prefixed with the + @LXCROOTFSMOUNT@ default path or + the value of if + specified. @@ -405,9 +463,10 @@ - specify a directory to become the root of the container. - If not specified, the container shares its root file - system with the host. + specify the root file system for the container. It can + be an image file, a directory or a block device. If not + specified, the container shares its root file system + with the host. @@ -528,7 +587,7 @@ lxc.network.link = br0 lxc.network.name = eth0 lxc.network.hwaddr = 4a:49:43:49:79:bf - lxc.network.ipv4 = 1.2.3.5/24 + lxc.network.ipv4 = 1.2.3.5/24 1.2.3.255 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 @@ -559,7 +618,7 @@ lxc.network.flags = up lxc.network.link = br0 lxc.network.hwaddr = 4a:49:43:49:79:bf - lxc.network.ipv4 = 1.2.3.5/24 + lxc.network.ipv4 = 1.2.3.5/24 1.2.3.255 lxc.network.ipv6 = 2003:db8:1:0:214:1234:fe0b:3597 lxc.network.ipv6 = 2003:db8:1:0:214:5432:feab:3588 lxc.network.type = macvlan diff -Nru lxc-0.7.2/doc/lxc-console.1 lxc-0.7.4/doc/lxc-console.1 --- lxc-0.7.2/doc/lxc-console.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-console.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-CONSOLE" "1" "26 July 2010" "" "" +.TH "LXC-CONSOLE" "1" "26 February 2011" "" "" .SH NAME lxc-console \- Launch a console for the specified container diff -Nru lxc-0.7.2/doc/lxc-create.1 lxc-0.7.4/doc/lxc-create.1 --- lxc-0.7.2/doc/lxc-create.1 2010-07-26 08:59:04.000000000 +0000 +++ lxc-0.7.4/doc/lxc-create.1 2011-02-26 09:20:25.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-CREATE" "1" "26 July 2010" "" "" +.TH "LXC-CREATE" "1" "26 February 2011" "" "" .SH NAME lxc-create \- creates a container @@ -41,7 +41,7 @@ \fB -t \fItemplate\fB \fR \&'template' is the short name of an existing 'lxc-template' script that is called by lxc-create, -eg. busybox, debian, fedora, ubuntu or sshd. +eg. busybox, debian, fedora, lucid, maverick, natty or sshd. Refer to the examples in \fI/usr/lib64/lxc/templates\fR for details of the expected script structure. .SH "DIAGNOSTIC" diff -Nru lxc-0.7.2/doc/lxc-create.sgml.in lxc-0.7.4/doc/lxc-create.sgml.in --- lxc-0.7.2/doc/lxc-create.sgml.in 2010-06-16 07:19:15.000000000 +0000 +++ lxc-0.7.4/doc/lxc-create.sgml.in 2011-02-01 14:12:40.000000000 +0000 @@ -107,7 +107,7 @@ 'template' is the short name of an existing 'lxc-template' script that is called by lxc-create, - eg. busybox, debian, fedora, ubuntu or sshd. + eg. busybox, debian, fedora, lucid, maverick, natty or sshd. Refer to the examples in @LXCTEMPLATEDIR@ for details of the expected script structure. diff -Nru lxc-0.7.2/doc/lxc-destroy.1 lxc-0.7.4/doc/lxc-destroy.1 --- lxc-0.7.2/doc/lxc-destroy.1 2010-07-26 08:59:04.000000000 +0000 +++ lxc-0.7.4/doc/lxc-destroy.1 2011-02-26 09:20:25.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-DESTROY" "1" "26 July 2010" "" "" +.TH "LXC-DESTROY" "1" "26 February 2011" "" "" .SH NAME lxc-destroy \- destroy a container. diff -Nru lxc-0.7.2/doc/lxc-execute.1 lxc-0.7.4/doc/lxc-execute.1 --- lxc-0.7.2/doc/lxc-execute.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-execute.1 2011-02-26 09:20:25.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-EXECUTE" "1" "26 July 2010" "" "" +.TH "LXC-EXECUTE" "1" "26 February 2011" "" "" .SH NAME lxc-execute \- run an application inside a container. diff -Nru lxc-0.7.2/doc/lxc-freeze.1 lxc-0.7.4/doc/lxc-freeze.1 --- lxc-0.7.2/doc/lxc-freeze.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-freeze.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-FREEZE" "1" "26 July 2010" "" "" +.TH "LXC-FREEZE" "1" "26 February 2011" "" "" .SH NAME lxc-freeze \- freeze all the container's processes diff -Nru lxc-0.7.2/doc/lxc-kill.1 lxc-0.7.4/doc/lxc-kill.1 --- lxc-0.7.2/doc/lxc-kill.1 2010-07-26 08:59:07.000000000 +0000 +++ lxc-0.7.4/doc/lxc-kill.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-KILL" "1" "26 July 2010" "IBM" "" +.TH "LXC-KILL" "1" "26 February 2011" "IBM" "" .SH NAME lxc-kill \- Send a signal to the process 1 of the container. diff -Nru lxc-0.7.2/doc/lxc-ls.1 lxc-0.7.4/doc/lxc-ls.1 --- lxc-0.7.2/doc/lxc-ls.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-ls.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-LS" "1" "26 July 2010" "" "" +.TH "LXC-LS" "1" "26 February 2011" "" "" .SH NAME lxc-ls \- list the containers existing on the system diff -Nru lxc-0.7.2/doc/lxc-monitor.1 lxc-0.7.4/doc/lxc-monitor.1 --- lxc-0.7.2/doc/lxc-monitor.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-monitor.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-MONITOR" "1" "26 July 2010" "" "" +.TH "LXC-MONITOR" "1" "26 February 2011" "" "" .SH NAME lxc-monitor \- monitor the container state diff -Nru lxc-0.7.2/doc/lxc-ps.1 lxc-0.7.4/doc/lxc-ps.1 --- lxc-0.7.2/doc/lxc-ps.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-ps.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-PS" "1" "26 July 2010" "" "" +.TH "LXC-PS" "1" "26 February 2011" "" "" .SH NAME lxc-ps \- list the processes belonging to a specific container. diff -Nru lxc-0.7.2/doc/lxc-restart.1 lxc-0.7.4/doc/lxc-restart.1 --- lxc-0.7.2/doc/lxc-restart.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-restart.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-RESTART" "1" "26 July 2010" "IBM" "" +.TH "LXC-RESTART" "1" "26 February 2011" "IBM" "" .SH NAME lxc-restart \- restart a container from a file (not implemented yet) diff -Nru lxc-0.7.2/doc/lxc-restart.sgml.in lxc-0.7.4/doc/lxc-restart.sgml.in --- lxc-0.7.2/doc/lxc-restart.sgml.in 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/doc/lxc-restart.sgml.in 2011-02-17 09:07:44.000000000 +0000 @@ -53,7 +53,7 @@ config_file-s KEY=VAL --statefile=FILE --statefd=FD - + @@ -177,7 +177,7 @@ - Notes + Notes Actually, this command does not operate. Its description helps to define a CLI api for future Checkpoint / Restart solution diff -Nru lxc-0.7.2/doc/lxc-start.1 lxc-0.7.4/doc/lxc-start.1 --- lxc-0.7.2/doc/lxc-start.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-start.1 2011-02-26 09:20:25.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-START" "1" "26 July 2010" "" "" +.TH "LXC-START" "1" "26 February 2011" "" "" .SH NAME lxc-start \- run an application inside a container. @@ -11,7 +11,9 @@ \fBlxc-start \fI-n name\fB [-f -config_file] [-s KEY=VAL] +config_file] [-c +console_file] [-d] [-s +KEY=VAL] [command]\fR .SH "DESCRIPTION" @@ -49,6 +51,11 @@ already a configuration file present in the previously created container (via lxc-create). .TP +\fB -c, --console \fIconsole_file\fB \fR +Specify a file to output the container console. If the +option is not specified the output will go the terminal +except if the \fB-d\fR is specified. +.TP \fB -s, --define \fIKEY=VAL\fB \fR Assign value \fIVAL\fR to configuration variable \fIKEY\fR\&. This overrides any diff -Nru lxc-0.7.2/doc/lxc-start.sgml.in lxc-0.7.4/doc/lxc-start.sgml.in --- lxc-0.7.2/doc/lxc-start.sgml.in 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/doc/lxc-start.sgml.in 2011-02-01 14:12:40.000000000 +0000 @@ -49,7 +49,9 @@ lxc-start -n name -f - config_file -s KEY=VAL + config_file -c + console_file -d -s + KEY=VAL command @@ -120,6 +122,20 @@ + + + + + Specify a file to output the container console. If the + option is not specified the output will go the terminal + except if the is specified. + + + + + + diff -Nru lxc-0.7.2/doc/lxc-stop.1 lxc-0.7.4/doc/lxc-stop.1 --- lxc-0.7.2/doc/lxc-stop.1 2010-07-26 08:59:05.000000000 +0000 +++ lxc-0.7.4/doc/lxc-stop.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-STOP" "1" "26 July 2010" "" "" +.TH "LXC-STOP" "1" "26 February 2011" "" "" .SH NAME lxc-stop \- stop the application running inside a container diff -Nru lxc-0.7.2/doc/lxc-unfreeze.1 lxc-0.7.4/doc/lxc-unfreeze.1 --- lxc-0.7.2/doc/lxc-unfreeze.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-unfreeze.1 2011-02-26 09:20:26.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-UNFREEZE" "1" "26 July 2010" "" "" +.TH "LXC-UNFREEZE" "1" "26 February 2011" "" "" .SH NAME lxc-unfreeze \- thaw all the container's processes diff -Nru lxc-0.7.2/doc/lxc-wait.1 lxc-0.7.4/doc/lxc-wait.1 --- lxc-0.7.2/doc/lxc-wait.1 2010-07-26 08:59:06.000000000 +0000 +++ lxc-0.7.4/doc/lxc-wait.1 2011-02-26 09:20:27.000000000 +0000 @@ -3,7 +3,7 @@ .\" .\" Please send any bug reports, improvements, comments, patches, .\" etc. to Steve Cheng . -.TH "LXC-WAIT" "1" "26 July 2010" "" "" +.TH "LXC-WAIT" "1" "26 February 2011" "" "" .SH NAME lxc-wait \- wait for a specific container state diff -Nru lxc-0.7.2/doc/Makefile.in lxc-0.7.4/doc/Makefile.in --- lxc-0.7.2/doc/Makefile.in 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/doc/Makefile.in 2011-02-26 09:20:19.000000000 +0000 @@ -47,7 +47,7 @@ $(srcdir)/lxc.sgml.in $(srcdir)/see_also.sgml.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -163,6 +163,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ diff -Nru lxc-0.7.2/doc/rootfs/Makefile.in lxc-0.7.4/doc/rootfs/Makefile.in --- lxc-0.7.2/doc/rootfs/Makefile.in 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/doc/rootfs/Makefile.in 2011-02-26 09:20:19.000000000 +0000 @@ -38,7 +38,7 @@ DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -105,6 +105,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ diff -Nru lxc-0.7.2/lxc.pc.in lxc-0.7.4/lxc.pc.in --- lxc-0.7.2/lxc.pc.in 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/lxc.pc.in 2010-10-08 09:54:53.000000000 +0000 @@ -2,6 +2,7 @@ libdir=@LIBDIR@ localstatedir=@LXCPATH@ includedir=@INCLUDEDIR@ +rootfsmountdir=@LXCROOTFSMOUNT@ Name: lxc Description: linux container tools diff -Nru lxc-0.7.2/lxc.spec lxc-0.7.4/lxc.spec --- lxc-0.7.2/lxc.spec 2010-07-26 08:58:59.000000000 +0000 +++ lxc-0.7.4/lxc.spec 2011-02-26 09:20:22.000000000 +0000 @@ -21,7 +21,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Name: lxc -Version: 0.7.2 +Version: 0.7.4 Release: 1 URL: http://lxc.sourceforge.net Source: http://dl.sourceforge.net/sourceforge/%{name}/%{name}-%{version}.tar.gz @@ -56,7 +56,8 @@ %prep %setup %build -PATH=$PATH:/usr/sbin:/sbin %configure +test "%{ksrc}" != "none" && args="--with-linuxdir=%{ksrc}" +PATH=$PATH:/usr/sbin:/sbin %configure $args make %{?_smp_mflags} %install diff -Nru lxc-0.7.2/lxc.spec.in lxc-0.7.4/lxc.spec.in --- lxc-0.7.2/lxc.spec.in 2010-07-23 13:10:38.000000000 +0000 +++ lxc-0.7.4/lxc.spec.in 2011-02-01 14:12:40.000000000 +0000 @@ -56,7 +56,8 @@ %prep %setup %build -PATH=$PATH:/usr/sbin:/sbin %configure +test "%{ksrc}" != "none" && args="--with-linuxdir=%{ksrc}" +PATH=$PATH:/usr/sbin:/sbin %configure $args make %{?_smp_mflags} %install diff -Nru lxc-0.7.2/Makefile.am lxc-0.7.4/Makefile.am --- lxc-0.7.2/Makefile.am 2010-06-07 09:33:55.000000000 +0000 +++ lxc-0.7.4/Makefile.am 2011-02-01 14:12:40.000000000 +0000 @@ -13,4 +13,4 @@ @touch ChangeLog rpm: dist - rpmbuild --clean -ta ${distdir}.tar.gz + rpmbuild --clean -ta --define "ksrc ${LINUX_DIR}" ${distdir}.tar.gz diff -Nru lxc-0.7.2/Makefile.in lxc-0.7.4/Makefile.in --- lxc-0.7.2/Makefile.in 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/Makefile.in 2011-02-26 09:20:19.000000000 +0000 @@ -43,7 +43,7 @@ ChangeLog INSTALL NEWS TODO ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ @@ -161,6 +161,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ @@ -741,7 +743,7 @@ @touch ChangeLog rpm: dist - rpmbuild --clean -ta ${distdir}.tar.gz + rpmbuild --clean -ta --define "ksrc ${LINUX_DIR}" ${distdir}.tar.gz # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. diff -Nru lxc-0.7.2/src/lxc/arguments.c lxc-0.7.4/src/lxc/arguments.c --- lxc-0.7.2/src/lxc/arguments.c 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/arguments.c 2011-02-01 14:12:40.000000000 +0000 @@ -168,6 +168,7 @@ case 'n': args->name = optarg; break; case 'o': args->log_file = optarg; break; case 'l': args->log_priority = optarg; break; + case 'c': args->console = optarg; break; case 'q': args->quiet = 1; break; case OPT_USAGE: print_usage(args->options, args); case '?': print_help(args, 1); diff -Nru lxc-0.7.2/src/lxc/arguments.h lxc-0.7.4/src/lxc/arguments.h --- lxc-0.7.2/src/lxc/arguments.h 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/arguments.h 2011-02-01 14:12:40.000000000 +0000 @@ -44,6 +44,7 @@ int quiet; int daemonize; const char *rcfile; + const char *console; /* for lxc-checkpoint/restart */ const char *statefile; diff -Nru lxc-0.7.2/src/lxc/caps.c lxc-0.7.4/src/lxc/caps.c --- lxc-0.7.2/src/lxc/caps.c 2010-07-20 11:45:44.000000000 +0000 +++ lxc-0.7.4/src/lxc/caps.c 2010-10-26 15:42:37.000000000 +0000 @@ -54,6 +54,11 @@ cap_t caps; int ret; + /* when we are run as root, we don't want to play + * with the capabilities */ + if (!getuid()) + return 0; + caps = cap_get_proc(); if (!caps) { ERROR("failed to cap_get_proc: %m"); @@ -83,6 +88,11 @@ cap_value_t cap; int ret; + /* when we are run as root, we don't want to play + * with the capabilities */ + if (!getuid()) + return 0; + caps = cap_get_proc(); if (!caps) { ERROR("failed to cap_get_proc: %m"); diff -Nru lxc-0.7.2/src/lxc/cgroup.c lxc-0.7.4/src/lxc/cgroup.c --- lxc-0.7.2/src/lxc/cgroup.c 2010-07-19 15:07:27.000000000 +0000 +++ lxc-0.7.4/src/lxc/cgroup.c 2011-02-01 14:12:40.000000000 +0000 @@ -45,10 +45,15 @@ lxc_log_define(lxc_cgroup, lxc); -#define MTAB "/etc/mtab" +#define MTAB "/proc/mounts" static char nsgroup_path[MAXPATHLEN]; +enum { + CGROUP_NS_CGROUP = 1, + CGROUP_CLONE_CHILDREN, +}; + static int get_cgroup_mount(const char *mtab, char *mnt) { struct mntent *mntent; @@ -58,7 +63,7 @@ file = setmntent(mtab, "r"); if (!file) { SYSERROR("failed to open %s", mtab); - goto out; + return -1; } while ((mntent = getmntent(file))) { @@ -81,65 +86,207 @@ DEBUG("using cgroup mounted at '%s'", mnt); fclose(file); -out: + + return err; +} + +static int get_cgroup_flags(const char *mtab, int *flags) +{ + struct mntent *mntent; + FILE *file = NULL; + int err = -1; + + file = setmntent(mtab, "r"); + if (!file) { + SYSERROR("failed to open %s", mtab); + return -1; + } + + *flags = 0; + + while ((mntent = getmntent(file))) { + + /* there is a cgroup mounted named "lxc" */ + if (!strcmp(mntent->mnt_fsname, "lxc") && + !strcmp(mntent->mnt_type, "cgroup")) { + + if (hasmntopt(mntent, "ns")) + *flags |= CGROUP_NS_CGROUP; + + if (hasmntopt(mntent, "clone_children")) + *flags |= CGROUP_CLONE_CHILDREN; + + err = 0; + break; + } + + /* fallback to the first non-lxc cgroup found */ + if (!strcmp(mntent->mnt_type, "cgroup") && err) { + + if (hasmntopt(mntent, "ns")) + *flags |= CGROUP_NS_CGROUP; + + if (hasmntopt(mntent, "clone_children")) + *flags |= CGROUP_CLONE_CHILDREN; + + err = 0; + } + }; + + DEBUG("cgroup flags is 0x%x", *flags); + + fclose(file); + return err; } -int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler) +static int cgroup_rename_nsgroup(const char *mnt, const char *name, pid_t pid) { char oldname[MAXPATHLEN]; - char *newname = handler->nsgroup; - char cgroup[MAXPATHLEN]; - int ret; - if (get_cgroup_mount(MTAB, cgroup)) { - ERROR("cgroup is not mounted"); + snprintf(oldname, MAXPATHLEN, "%s/%d", mnt, pid); + + if (rename(oldname, name)) { + SYSERROR("failed to rename cgroup %s->%s", oldname, name); return -1; } - snprintf(oldname, MAXPATHLEN, "%s/%d", cgroup, handler->pid); - snprintf(newname, MAXPATHLEN, "%s/%s", cgroup, name); + DEBUG("'%s' renamed to '%s'", oldname, name); - /* there is a previous cgroup, assume it is empty, otherwise - * that fails */ - if (!access(newname, F_OK)) { - ret = rmdir(newname); - if (ret) { - SYSERROR("failed to remove previous cgroup '%s'", - newname); - return ret; - } + return 0; +} + +static int cgroup_enable_clone_children(const char *path) +{ + FILE *f; + int ret = 0; + + f = fopen(path, "w"); + if (!f) { + SYSERROR("failed to open '%s'", path); + return -1; } - ret = rename(oldname, newname); - if (ret) - SYSERROR("failed to rename cgroup %s->%s", oldname, newname); - else - DEBUG("'%s' renamed to '%s'", oldname, newname); + if (fprintf(f, "1") < 1) { + ERROR("failed to write flag to '%s'", path); + ret = -1; + } + fclose(f); return ret; } -int lxc_unlink_nsgroup(const char *name) +static int cgroup_attach(const char *path, pid_t pid) { - char nsgroup[MAXPATHLEN]; - char cgroup[MAXPATHLEN]; - int ret; + FILE *f; + char tasks[MAXPATHLEN]; + int ret = 0; + + snprintf(tasks, MAXPATHLEN, "%s/tasks", path); + + f = fopen(tasks, "w"); + if (!f) { + SYSERROR("failed to open '%s'", tasks); + return -1; + } - if (get_cgroup_mount(MTAB, cgroup)) { + if (fprintf(f, "%d", pid) <= 0) { + SYSERROR("failed to write pid '%d' to '%s'", pid, tasks); + ret = -1; + } + + fclose(f); + + return ret; +} + +int lxc_cgroup_create(const char *name, pid_t pid) +{ + char cgmnt[MAXPATHLEN]; + char cgname[MAXPATHLEN]; + char clonechild[MAXPATHLEN]; + int flags; + + if (get_cgroup_mount(MTAB, cgmnt)) { ERROR("cgroup is not mounted"); return -1; } - snprintf(nsgroup, MAXPATHLEN, "%s/%s", cgroup, name); - ret = rmdir(nsgroup); - if (ret) - SYSERROR("failed to remove cgroup '%s'", nsgroup); - else - DEBUG("'%s' unlinked", nsgroup); + snprintf(cgname, MAXPATHLEN, "%s/%s", cgmnt, name); - return ret; + /* + * There is a previous cgroup, assume it is empty, + * otherwise that fails + */ + if (!access(cgname, F_OK) && rmdir(cgname)) { + SYSERROR("failed to remove previous cgroup '%s'", cgname); + return -1; + } + + if (get_cgroup_flags(MTAB, &flags)) { + SYSERROR("failed to get cgroup flags"); + return -1; + } + + /* We have the deprecated ns_cgroup subsystem */ + if (flags & CGROUP_NS_CGROUP) { + WARN("using deprecated ns_cgroup"); + return cgroup_rename_nsgroup(cgmnt, cgname, pid); + } + + snprintf(clonechild, MAXPATHLEN, "%s/cgroup.clone_children", cgmnt); + + /* we check if the kernel has clone_children, at this point if there + * no clone_children neither ns_cgroup, that means the cgroup is mounted + * without the ns_cgroup and it has not the compatibility flag + */ + if (access(clonechild, F_OK)) { + ERROR("no ns_cgroup option specified"); + return -1; + } + + /* we enable the clone_children flag of the cgroup */ + if (cgroup_enable_clone_children(clonechild)) { + SYSERROR("failed to enable 'clone_children flag"); + return -1; + } + + /* Let's create the cgroup */ + if (mkdir(cgname, 0700)) { + SYSERROR("failed to create '%s' directory", cgname); + return -1; + } + + /* Let's add the pid to the 'tasks' file */ + if (cgroup_attach(cgname, pid)) { + SYSERROR("failed to attach pid '%d' to '%s'", pid, cgname); + rmdir(cgname); + return -1; + } + + return 0; +} + +int lxc_cgroup_destroy(const char *name) +{ + char cgmnt[MAXPATHLEN]; + char cgname[MAXPATHLEN]; + + if (get_cgroup_mount(MTAB, cgmnt)) { + ERROR("cgroup is not mounted"); + return -1; + } + + snprintf(cgname, MAXPATHLEN, "%s/%s", cgmnt, name); + if (rmdir(cgname)) { + SYSERROR("failed to remove cgroup '%s'", cgname); + return -1; + } + + DEBUG("'%s' unlinked", cgname); + + return 0; } int lxc_cgroup_path_get(char **path, const char *name) diff -Nru lxc-0.7.2/src/lxc/cgroup.h lxc-0.7.4/src/lxc/cgroup.h --- lxc-0.7.2/src/lxc/cgroup.h 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/cgroup.h 2011-02-01 14:12:40.000000000 +0000 @@ -26,8 +26,8 @@ #define MAXPRIOLEN 24 struct lxc_handler; -int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler); -int lxc_unlink_nsgroup(const char *name); +int lxc_cgroup_create(const char *name, pid_t pid); +int lxc_cgroup_destroy(const char *name); int lxc_cgroup_path_get(char **path, const char *name); int lxc_cgroup_nrtasks(const char *name); #endif diff -Nru lxc-0.7.2/src/lxc/commands.c lxc-0.7.4/src/lxc/commands.c --- lxc-0.7.2/src/lxc/commands.c 2010-06-14 09:29:56.000000000 +0000 +++ lxc-0.7.4/src/lxc/commands.c 2010-10-26 15:42:38.000000000 +0000 @@ -69,8 +69,8 @@ return ret; } -extern int lxc_command(const char *name, struct lxc_command *command, - int *stopped) +static int __lxc_command(const char *name, struct lxc_command *command, + int *stopped, int stay_connected) { int sock, ret = -1; char path[sizeof(((struct sockaddr_un *)0)->sun_path)] = { 0 }; @@ -103,10 +103,25 @@ ret = receive_answer(sock, &command->answer); out: - close(sock); + if (!stay_connected || ret < 0) + close(sock); + return ret; } +extern int lxc_command(const char *name, + struct lxc_command *command, int *stopped) +{ + return __lxc_command(name, command, stopped, 0); +} + +extern int lxc_command_connected(const char *name, + struct lxc_command *command, int *stopped) +{ + return __lxc_command(name, command, stopped, 1); +} + + pid_t get_init_pid(const char *name) { struct lxc_command command = { diff -Nru lxc-0.7.2/src/lxc/commands.h lxc-0.7.4/src/lxc/commands.h --- lxc-0.7.2/src/lxc/commands.h 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/commands.h 2010-10-26 15:42:38.000000000 +0000 @@ -48,9 +48,13 @@ }; extern pid_t get_init_pid(const char *name); + extern int lxc_command(const char *name, struct lxc_command *command, int *stopped); +extern int lxc_command_connected(const char *name, struct lxc_command *command, + int *stopped); + struct lxc_epoll_descr; struct lxc_handler; diff -Nru lxc-0.7.2/src/lxc/conf.c lxc-0.7.4/src/lxc/conf.c --- lxc-0.7.2/src/lxc/conf.c 2010-07-23 13:10:38.000000000 +0000 +++ lxc-0.7.4/src/lxc/conf.c 2011-02-02 20:55:49.000000000 +0000 @@ -24,13 +24,17 @@ #include #undef _GNU_SOURCE #include +#include #include #include #include #include #include +#include #include +#include + #include #include #include @@ -40,6 +44,7 @@ #include #include #include +#include #include #include @@ -63,6 +68,10 @@ #define MAXMTULEN 16 #define MAXLINELEN 128 +#ifndef MS_DIRSYNC +#define MS_DIRSYNC 128 +#endif + #ifndef MS_REC #define MS_REC 16384 #endif @@ -89,7 +98,7 @@ extern int pivot_root(const char * new_root, const char * put_old); -typedef int (*instanciate_cb)(struct lxc_netdev *); +typedef int (*instanciate_cb)(struct lxc_handler *, struct lxc_netdev *); struct mount_opt { char *name; @@ -102,11 +111,11 @@ int value; }; -static int instanciate_veth(struct lxc_netdev *); -static int instanciate_macvlan(struct lxc_netdev *); -static int instanciate_vlan(struct lxc_netdev *); -static int instanciate_phys(struct lxc_netdev *); -static int instanciate_empty(struct lxc_netdev *); +static int instanciate_veth(struct lxc_handler *, struct lxc_netdev *); +static int instanciate_macvlan(struct lxc_handler *, struct lxc_netdev *); +static int instanciate_vlan(struct lxc_handler *, struct lxc_netdev *); +static int instanciate_phys(struct lxc_handler *, struct lxc_netdev *); +static int instanciate_empty(struct lxc_handler *, struct lxc_netdev *); static instanciate_cb netdev_conf[LXC_NET_MAXCONFTYPE + 1] = { [LXC_NET_VETH] = instanciate_veth, @@ -128,6 +137,7 @@ { "noexec", 0, MS_NOEXEC }, { "sync", 0, MS_SYNCHRONOUS }, { "async", 1, MS_SYNCHRONOUS }, + { "dirsync", 0, MS_DIRSYNC }, { "remount", 0, MS_REMOUNT }, { "mand", 0, MS_MANDLOCK }, { "nomand", 1, MS_MANDLOCK }, @@ -141,7 +151,7 @@ }; static struct caps_opt caps_opt[] = { - { "chown", CAP_CHOWN }, + { "chown", CAP_CHOWN }, { "dac_override", CAP_DAC_OVERRIDE }, { "dac_read_search", CAP_DAC_READ_SEARCH }, { "fowner", CAP_FOWNER }, @@ -181,13 +191,70 @@ { "mac_admin", CAP_MAC_ADMIN }, }; -#if 0 /* will be reactivated with image mounting support */ -static int configure_find_fstype_cb(char* buffer, void *data) +static int run_script(const char *name, const char *section, + const char *script, ...) +{ + int ret; + FILE *f; + char *buffer, *p, *output; + size_t size = 0; + va_list ap; + + INFO("Executing script '%s' for container '%s', config section '%s'", + script, name, section); + + va_start(ap, script); + while ((p = va_arg(ap, char *))) + size += strlen(p); + va_end(ap); + + size += strlen(script); + size += strlen(name); + size += strlen(section); + + buffer = alloca(size + 1); + if (!buffer) { + ERROR("failed to allocate memory"); + return -1; + } + + ret = sprintf(buffer, "%s %s %s", script, name, section); + + va_start(ap, script); + while ((p = va_arg(ap, char *))) + ret += sprintf(buffer + ret, " %s", p); + va_end(ap); + + f = popen(buffer, "r"); + if (!f) { + SYSERROR("popen failed"); + return -1; + } + + output = malloc(LXC_LOG_BUFFER_SIZE); + if (!output) { + ERROR("failed to allocate memory for script output"); + return -1; + } + + while(fgets(output, LXC_LOG_BUFFER_SIZE, f)) + DEBUG("script output: %s", output); + + free(output); + + if (pclose(f)) { + ERROR("Script exited on error"); + return -1; + } + + return 0; +} + +static int find_fstype_cb(char* buffer, void *data) { struct cbarg { const char *rootfs; - const char *testdir; - char *fstype; + const char *target; int mntopt; } *cbarg = data; @@ -201,33 +268,37 @@ fstype += lxc_char_left_gc(fstype, strlen(fstype)); fstype[lxc_char_right_gc(fstype, strlen(fstype))] = '\0'; - if (mount(cbarg->rootfs, cbarg->testdir, fstype, cbarg->mntopt, NULL)) + DEBUG("trying to mount '%s'->'%s' with fstype '%s'", + cbarg->rootfs, cbarg->target, fstype); + + if (mount(cbarg->rootfs, cbarg->target, fstype, cbarg->mntopt, NULL)) { + DEBUG("mount failed with error: %s", strerror(errno)); return 0; + } - /* found ! */ - umount(cbarg->testdir); - strcpy(cbarg->fstype, fstype); + INFO("mounted '%s' on '%s', with fstype '%s'", + cbarg->rootfs, cbarg->target, fstype); return 1; } -/* find the filesystem type with brute force */ -static int configure_find_fstype(const char *rootfs, char *fstype, int mntopt) +static int mount_unknow_fs(const char *rootfs, const char *target, int mntopt) { - int i, found; + int i; struct cbarg { const char *rootfs; - const char *testdir; - char *fstype; + const char *target; int mntopt; } cbarg = { .rootfs = rootfs, - .fstype = fstype, + .target = target, .mntopt = mntopt, }; - /* first we check with /etc/filesystems, in case the modules + /* + * find the filesystem type with brute force: + * first we check with /etc/filesystems, in case the modules * are auto-loaded and fall back to the supported kernel fs */ char *fsfile[] = { @@ -235,79 +306,144 @@ "/proc/filesystems", }; - cbarg.testdir = tempnam("/tmp", "lxc-"); - if (!cbarg.testdir) { - SYSERROR("failed to build a temp name"); - return -1; + for (i = 0; i < sizeof(fsfile)/sizeof(fsfile[0]); i++) { + + int ret; + + if (access(fsfile[i], F_OK)) + continue; + + ret = lxc_file_for_each_line(fsfile[i], find_fstype_cb, &cbarg); + if (ret < 0) { + ERROR("failed to parse '%s'", fsfile[i]); + return -1; + } + + if (ret) + return 0; } - if (mkdir(cbarg.testdir, 0755)) { - SYSERROR("failed to create temporary directory"); + ERROR("failed to determine fs type for '%s'", rootfs); + return -1; +} + +static int mount_rootfs_dir(const char *rootfs, const char *target) +{ + return mount(rootfs, target, "none", MS_BIND | MS_REC, NULL); +} + +static int setup_lodev(const char *rootfs, int fd, struct loop_info64 *loinfo) +{ + int rfd; + int ret = -1; + + rfd = open(rootfs, O_RDWR); + if (rfd < 0) { + SYSERROR("failed to open '%s'", rootfs); return -1; } - for (i = 0; i < sizeof(fsfile)/sizeof(fsfile[0]); i++) { + memset(loinfo, 0, sizeof(*loinfo)); - found = lxc_file_for_each_line(fsfile[i], - configure_find_fstype_cb, - &cbarg); + loinfo->lo_flags = LO_FLAGS_AUTOCLEAR; - if (found < 0) { - SYSERROR("failed to read '%s'", fsfile[i]); - goto out; - } - - if (found) - break; + if (ioctl(fd, LOOP_SET_FD, rfd)) { + SYSERROR("failed to LOOP_SET_FD"); + goto out; } - if (!found) { - ERROR("failed to determine fs type for '%s'", rootfs); + if (ioctl(fd, LOOP_SET_STATUS64, loinfo)) { + SYSERROR("failed to LOOP_SET_STATUS64"); goto out; } + ret = 0; out: - rmdir(cbarg.testdir); - return found - 1; -} + close(rfd); -static int configure_rootfs_dir_cb(const char *rootfs, const char *absrootfs, - FILE *f) -{ - return fprintf(f, "%s %s none rbind 0 0\n", absrootfs, rootfs); + return ret; } -static int configure_rootfs_blk_cb(const char *rootfs, const char *absrootfs, - FILE *f) +static int mount_rootfs_file(const char *rootfs, const char *target) { - char fstype[MAXPATHLEN]; + struct dirent dirent, *direntp; + struct loop_info64 loinfo; + int ret = -1, fd = -1; + DIR *dir; + char path[MAXPATHLEN]; - if (configure_find_fstype(absrootfs, fstype, 0)) { - ERROR("failed to configure mount for block device '%s'", - absrootfs); + dir = opendir("/dev"); + if (!dir) { + SYSERROR("failed to open '/dev'"); return -1; } - return fprintf(f, "%s %s %s defaults 0 0\n", absrootfs, rootfs, fstype); + while (!readdir_r(dir, &dirent, &direntp)) { + + if (!direntp) + break; + + if (!strcmp(direntp->d_name, ".")) + continue; + + if (!strcmp(direntp->d_name, "..")) + continue; + + if (strncmp(direntp->d_name, "loop", 4)) + continue; + + sprintf(path, "/dev/%s", direntp->d_name); + fd = open(path, O_RDWR); + if (fd < 0) + continue; + + if (ioctl(fd, LOOP_GET_STATUS64, &loinfo) == 0) { + close(fd); + continue; + } + + if (errno != ENXIO) { + WARN("unexpected error for ioctl on '%s': %m", + direntp->d_name); + continue; + } + + DEBUG("found '%s' free lodev", path); + + ret = setup_lodev(rootfs, fd, &loinfo); + if (!ret) + ret = mount_unknow_fs(path, target, 0); + close(fd); + + break; + } + + if (closedir(dir)) + WARN("failed to close directory"); + + return ret; } -static int configure_rootfs(const char *name, const char *rootfs) +static int mount_rootfs_block(const char *rootfs, const char *target) +{ + return mount_unknow_fs(rootfs, target, 0); +} + +static int mount_rootfs(const char *rootfs, const char *target) { - char path[MAXPATHLEN]; char absrootfs[MAXPATHLEN]; - char fstab[MAXPATHLEN]; struct stat s; - FILE *f; - int i, ret; + int i; - typedef int (*rootfs_cb)(const char *, const char *, FILE *); + typedef int (*rootfs_cb)(const char *, const char *); struct rootfs_type { int type; rootfs_cb cb; } rtfs_type[] = { - { __S_IFDIR, configure_rootfs_dir_cb }, - { __S_IFBLK, configure_rootfs_blk_cb }, + { S_IFDIR, mount_rootfs_dir }, + { S_IFBLK, mount_rootfs_block }, + { S_IFREG, mount_rootfs_file }, }; if (!realpath(rootfs, absrootfs)) { @@ -315,13 +451,6 @@ return -1; } - snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs", name); - - if (mkdir(path, 0755)) { - SYSERROR("failed to create the '%s' directory", path); - return -1; - } - if (access(absrootfs, F_OK)) { SYSERROR("'%s' is not accessible", absrootfs); return -1; @@ -337,32 +466,12 @@ if (!__S_ISTYPE(s.st_mode, rtfs_type[i].type)) continue; - snprintf(fstab, MAXPATHLEN, LXCPATH "/%s/fstab", name); - - f = fopen(fstab, "a+"); - if (!f) { - SYSERROR("failed to open fstab file"); - return -1; - } - - ret = rtfs_type[i].cb(path, absrootfs, f); - - fclose(f); - - if (ret < 0) { - ERROR("failed to add rootfs mount in fstab"); - return -1; - } - - snprintf(path, MAXPATHLEN, LXCPATH "/%s/rootfs/rootfs", name); - - return symlink(absrootfs, path); + return rtfs_type[i].cb(absrootfs, target); } ERROR("unsupported rootfs type for '%s'", absrootfs); return -1; } -#endif static int setup_utsname(struct utsname *utsname) { @@ -385,12 +494,15 @@ char path[MAXPATHLEN]; int i; + if (!rootfs->path) + return 0; + for (i = 0; i < tty_info->nbtty; i++) { struct lxc_pty_info *pty_info = &tty_info->pty_info[i]; snprintf(path, sizeof(path), "%s/dev/tty%d", - rootfs->path ? rootfs->path : "", i + 1); + rootfs->mount, i + 1); /* At this point I can not use the "access" function * to check the file is present or not because it fails @@ -585,35 +697,36 @@ if (remove_pivotdir && rmdir(pivotdir)) WARN("can't remove mountpoint '%s': %m", pivotdir); - INFO("pivoted to '%s'", rootfs); - return 0; } static int setup_rootfs(const struct lxc_rootfs *rootfs) { - char *mpath = LXCROOTFSMOUNT; - if (!rootfs->path) return 0; - if (rootfs->mount) - mpath = rootfs->mount; - - if (access(mpath, F_OK)) { + if (access(rootfs->mount, F_OK)) { SYSERROR("failed to access to '%s', check it is present", - mpath); + rootfs->mount); return -1; } - if (mount(rootfs->path, mpath, "none", MS_BIND|MS_REC, NULL)) { - SYSERROR("failed to mount '%s'->'%s'", rootfs->path, mpath); + if (mount_rootfs(rootfs->path, rootfs->mount)) { + ERROR("failed to mount rootfs"); return -1; } - DEBUG("mounted '%s' on '%s'", rootfs->path, mpath); + DEBUG("mounted '%s' on '%s'", rootfs->path, rootfs->mount); + + return 0; +} + +int setup_pivot_root(const struct lxc_rootfs *rootfs) +{ + if (!rootfs->path) + return 0; - if (setup_rootfs_pivot_root(mpath, rootfs->pivot)) { + if (setup_rootfs_pivot_root(rootfs->mount, rootfs->pivot)) { ERROR("failed to setup pivot root"); return -1; } @@ -631,7 +744,8 @@ return -1; } - if (mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, "newinstance,ptmxmode=0666")) { + if (mount("devpts", "/dev/pts", "devpts", MS_MGC_VAL, + "newinstance,ptmxmode=0666")) { SYSERROR("failed to mount a new instance of '/dev/pts'"); return -1; } @@ -655,6 +769,21 @@ return 0; } +static int setup_personality(int persona) +{ + if (persona == -1) + return 0; + + if (personality(persona) < 0) { + SYSERROR("failed to set personality to '0x%x'", persona); + return -1; + } + + INFO("set personality to '0x%x'", persona); + + return 0; +} + static int setup_console(const struct lxc_rootfs *rootfs, const struct lxc_console *console) { @@ -665,10 +794,10 @@ if (!rootfs->path) return 0; - snprintf(path, sizeof(path), "%s/dev/console", rootfs->path); + snprintf(path, sizeof(path), "%s/dev/console", rootfs->mount); if (access(path, F_OK)) { - WARN("rootfs specified but no console found"); + WARN("rootfs specified but no console found at '%s'", path); return 0; } @@ -745,16 +874,19 @@ strcat(*data, opt); } -static int parse_mntopts(struct mntent *mntent, unsigned long *mntflags, +static int parse_mntopts(const char *mntopts, unsigned long *mntflags, char **mntdata) { char *s, *data; char *p, *saveptr = NULL; - if (!mntent->mnt_opts) + *mntdata = NULL; + *mntflags = 0L; + + if (!mntopts) return 0; - s = strdup(mntent->mnt_opts); + s = strdup(mntopts); if (!s) { SYSERROR("failed to allocate memory"); return -1; @@ -781,50 +913,130 @@ return 0; } -static int mount_file_entries(FILE *file) +static int mount_entry(const char *fsname, const char *target, + const char *fstype, unsigned long mountflags, + const char *data) { - struct mntent *mntent; - int ret = -1; - unsigned long mntflags; - char *mntdata; + if (mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data)) { + SYSERROR("failed to mount '%s' on '%s'", fsname, target); + return -1; + } - while ((mntent = getmntent(file))) { + if ((mountflags & MS_REMOUNT) || (mountflags & MS_BIND)) { - mntflags = 0; - mntdata = NULL; - if (parse_mntopts(mntent, &mntflags, &mntdata) < 0) { - ERROR("failed to parse mount option '%s'", - mntent->mnt_opts); - goto out; - } + DEBUG("remounting %s on %s to respect bind or remount options", + fsname, target); - if (mount(mntent->mnt_fsname, mntent->mnt_dir, - mntent->mnt_type, mntflags & ~MS_REMOUNT, mntdata)) { + if (mount(fsname, target, fstype, + mountflags | MS_REMOUNT, data)) { SYSERROR("failed to mount '%s' on '%s'", - mntent->mnt_fsname, mntent->mnt_dir); - goto out; + fsname, target); + return -1; } + } + + DEBUG("mounted '%s' on '%s', type '%s'", fsname, target, fstype); + + return 0; +} + +static inline int mount_entry_on_systemfs(struct mntent *mntent) +{ + unsigned long mntflags; + char *mntdata; + int ret; + + if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { + ERROR("failed to parse mount option '%s'", mntent->mnt_opts); + return -1; + } + + ret = mount_entry(mntent->mnt_fsname, mntent->mnt_dir, + mntent->mnt_type, mntflags, mntdata); + + free(mntdata); + + return ret; +} + +static int mount_entry_on_absolute_rootfs(struct mntent *mntent, + const struct lxc_rootfs *rootfs) +{ + char *aux; + char path[MAXPATHLEN]; + unsigned long mntflags; + char *mntdata; + int ret = 0; + + if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { + ERROR("failed to parse mount option '%s'", mntent->mnt_opts); + return -1; + } + + aux = strstr(mntent->mnt_dir, rootfs->path); + if (!aux) { + WARN("ignoring mount point '%s'", mntent->mnt_dir); + goto out; + } - if ((mntflags & MS_REMOUNT) == MS_REMOUNT || - ((mntflags & MS_BIND) == MS_BIND)) { + snprintf(path, MAXPATHLEN, "%s%s", rootfs->mount, + aux + strlen(rootfs->path)); - DEBUG ("remounting %s on %s to respect bind " \ - "or remount options", - mntent->mnt_fsname, mntent->mnt_dir); - - if (mount(mntent->mnt_fsname, mntent->mnt_dir, - mntent->mnt_type, - mntflags | MS_REMOUNT, mntdata)) { - SYSERROR("failed to mount '%s' on '%s'", - mntent->mnt_fsname, mntent->mnt_dir); + ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type, + mntflags, mntdata); + +out: + free(mntdata); + return ret; +} + +static int mount_entry_on_relative_rootfs(struct mntent *mntent, + const char *rootfs) +{ + char path[MAXPATHLEN]; + unsigned long mntflags; + char *mntdata; + int ret; + + if (parse_mntopts(mntent->mnt_opts, &mntflags, &mntdata) < 0) { + ERROR("failed to parse mount option '%s'", mntent->mnt_opts); + return -1; + } + + /* relative to root mount point */ + snprintf(path, sizeof(path), "%s/%s", rootfs, mntent->mnt_dir); + + ret = mount_entry(mntent->mnt_fsname, path, mntent->mnt_type, + mntflags, mntdata); + + free(mntdata); + + return ret; +} + +static int mount_file_entries(const struct lxc_rootfs *rootfs, FILE *file) +{ + struct mntent *mntent; + int ret = -1; + + while ((mntent = getmntent(file))) { + + if (!rootfs->path) { + if (mount_entry_on_systemfs(mntent)) goto out; - } + continue; } - DEBUG("mounted %s on %s, type %s", mntent->mnt_fsname, - mntent->mnt_dir, mntent->mnt_type); + /* We have a separate root, mounts are relative to it */ + if (mntent->mnt_dir[0] != '/') { + if (mount_entry_on_relative_rootfs(mntent, + rootfs->mount)) + goto out; + continue; + } - free(mntdata); + if (mount_entry_on_absolute_rootfs(mntent, rootfs)) + goto out; } ret = 0; @@ -834,7 +1046,7 @@ return ret; } -static int setup_mount(const char *fstab) +static int setup_mount(const struct lxc_rootfs *rootfs, const char *fstab) { FILE *file; int ret; @@ -848,13 +1060,13 @@ return -1; } - ret = mount_file_entries(file); + ret = mount_file_entries(rootfs, file); endmntent(file); return ret; } -static int setup_mount_entries(struct lxc_list *mount) +static int setup_mount_entries(const struct lxc_rootfs *rootfs, struct lxc_list *mount) { FILE *file; struct lxc_list *iterator; @@ -874,7 +1086,7 @@ rewind(file); - ret = mount_file_entries(file); + ret = mount_file_entries(rootfs, file); fclose(file); return ret; @@ -1005,15 +1217,15 @@ /* empty network namespace */ if (!netdev->ifindex) { - if (netdev->flags | IFF_UP) { + if (netdev->flags & IFF_UP) { err = lxc_device_up("lo"); if (err) { ERROR("failed to set the loopback up : %s", strerror(-err)); return -1; } - return 0; } + return 0; } /* retrieve the name of the interface */ @@ -1069,7 +1281,7 @@ } /* set the network device up */ - if (netdev->flags | IFF_UP) { + if (netdev->flags & IFF_UP) { int err; err = lxc_device_up(current_ifname); @@ -1125,11 +1337,13 @@ } memset(new, 0, sizeof(*new)); + new->personality = -1; new->console.path = NULL; new->console.peer = -1; new->console.master = -1; new->console.slave = -1; new->console.name[0] = '\0'; + new->rootfs.mount = LXCROOTFSMOUNT; lxc_list_init(&new->cgroup); lxc_list_init(&new->network); lxc_list_init(&new->mount_list); @@ -1138,7 +1352,7 @@ return new; } -static int instanciate_veth(struct lxc_netdev *netdev) +static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netdev) { char veth1buf[IFNAMSIZ], *veth1; char veth2buf[IFNAMSIZ], *veth2; @@ -1192,13 +1406,17 @@ goto out_delete; } - if (netdev->flags & IFF_UP) { - err = lxc_device_up(veth1); - if (err) { - ERROR("failed to set %s up : %s", veth1, - strerror(-err)); + err = lxc_device_up(veth1); + if (err) { + ERROR("failed to set %s up : %s", veth1, strerror(-err)); + goto out_delete; + } + + if (netdev->upscript) { + err = run_script(handler->name, "net", netdev->upscript, "up", + "veth", veth1, (char*) NULL); + if (err) goto out_delete; - } } DEBUG("instanciated veth '%s/%s', index is '%d'", @@ -1211,7 +1429,7 @@ return -1; } -static int instanciate_macvlan(struct lxc_netdev *netdev) +static int instanciate_macvlan(struct lxc_handler *handler, struct lxc_netdev *netdev) { char peerbuf[IFNAMSIZ], *peer; int err; @@ -1244,6 +1462,13 @@ return -1; } + if (netdev->upscript) { + err = run_script(handler->name, "net", netdev->upscript, "up", + "macvlan", netdev->link, (char*) NULL); + if (err) + return -1; + } + DEBUG("instanciated macvlan '%s', index is '%d' and mode '%d'", peer, netdev->ifindex, netdev->priv.macvlan_attr.mode); @@ -1251,7 +1476,7 @@ } /* XXX: merge with instanciate_macvlan */ -static int instanciate_vlan(struct lxc_netdev *netdev) +static int instanciate_vlan(struct lxc_handler *handler, struct lxc_netdev *netdev) { char peer[IFNAMSIZ]; int err; @@ -1283,7 +1508,7 @@ return 0; } -static int instanciate_phys(struct lxc_netdev *netdev) +static int instanciate_phys(struct lxc_handler *handler, struct lxc_netdev *netdev) { if (!netdev->link) { ERROR("no link specified for the physical interface"); @@ -1296,17 +1521,33 @@ return -1; } + if (netdev->upscript) { + int err; + err = run_script(handler->name, "net", netdev->upscript, + "up", "phys", netdev->link, (char*) NULL); + if (err) + return -1; + } + return 0; } -static int instanciate_empty(struct lxc_netdev *netdev) +static int instanciate_empty(struct lxc_handler *handler, struct lxc_netdev *netdev) { netdev->ifindex = 0; + if (netdev->upscript) { + int err; + err = run_script(handler->name, "net", netdev->upscript, + "up", "empty", (char*) NULL); + if (err) + return -1; + } return 0; } -int lxc_create_network(struct lxc_list *network) +int lxc_create_network(struct lxc_handler *handler) { + struct lxc_list *network = &handler->conf->network; struct lxc_list *iterator; struct lxc_netdev *netdev; @@ -1320,10 +1561,11 @@ return -1; } - if (netdev_conf[netdev->type](netdev)) { + if (netdev_conf[netdev->type](handler, netdev)) { ERROR("failed to create netdev"); return -1; } + } return 0; @@ -1440,21 +1682,26 @@ return -1; } - if (setup_cgroup(name, &lxc_conf->cgroup)) { - ERROR("failed to setup the cgroups for '%s'", name); + if (setup_rootfs(&lxc_conf->rootfs)) { + ERROR("failed to setup rootfs for '%s'", name); return -1; } - if (setup_mount(lxc_conf->fstab)) { + if (setup_mount(&lxc_conf->rootfs, lxc_conf->fstab)) { ERROR("failed to setup the mounts for '%s'", name); return -1; } - if (setup_mount_entries(&lxc_conf->mount_list)) { + if (setup_mount_entries(&lxc_conf->rootfs, &lxc_conf->mount_list)) { ERROR("failed to setup the mount entries for '%s'", name); return -1; } + if (setup_cgroup(name, &lxc_conf->cgroup)) { + ERROR("failed to setup the cgroups for '%s'", name); + return -1; + } + if (setup_console(&lxc_conf->rootfs, &lxc_conf->console)) { ERROR("failed to setup the console for '%s'", name); return -1; @@ -1465,7 +1712,7 @@ return -1; } - if (setup_rootfs(&lxc_conf->rootfs)) { + if (setup_pivot_root(&lxc_conf->rootfs)) { ERROR("failed to set rootfs for '%s'", name); return -1; } @@ -1475,6 +1722,11 @@ return -1; } + if (setup_personality(lxc_conf->personality)) { + ERROR("failed to setup personality"); + return -1; + } + if (setup_caps(&lxc_conf->caps)) { ERROR("failed to drop capabilities"); return -1; diff -Nru lxc-0.7.2/src/lxc/conf.h lxc-0.7.4/src/lxc/conf.h --- lxc-0.7.2/src/lxc/conf.h 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/conf.h 2010-10-12 08:52:47.000000000 +0000 @@ -28,6 +28,8 @@ #include +#include /* for lxc_handler */ + enum { LXC_NET_EMPTY, LXC_NET_VETH, @@ -94,11 +96,12 @@ /* * Defines a structure to configure a network device - * @link : lxc.network.link, name of bridge or host iface to attach if any - * @name : lxc.network.name, name of iface on the container side - * @flags : flag of the network device (IFF_UP, ... ) - * @ipv4 : a list of ipv4 addresses to be set on the network device - * @ipv6 : a list of ipv6 addresses to be set on the network device + * @link : lxc.network.link, name of bridge or host iface to attach if any + * @name : lxc.network.name, name of iface on the container side + * @flags : flag of the network device (IFF_UP, ... ) + * @ipv4 : a list of ipv4 addresses to be set on the network device + * @ipv6 : a list of ipv6 addresses to be set on the network device + * @upscript : a script filename to be executed during interface configuration */ struct lxc_netdev { int type; @@ -111,6 +114,7 @@ union netdev_p priv; struct lxc_list ipv4; struct lxc_list ipv6; + char *upscript; }; /* @@ -194,6 +198,7 @@ int tty; int pts; int reboot; + int personality; struct utsname *utsname; struct lxc_list cgroup; struct lxc_list network; @@ -209,7 +214,7 @@ */ extern struct lxc_conf *lxc_conf_init(void); -extern int lxc_create_network(struct lxc_list *networks); +extern int lxc_create_network(struct lxc_handler *handler); extern void lxc_delete_network(struct lxc_list *networks); extern int lxc_assign_network(struct lxc_list *networks, pid_t pid); @@ -220,8 +225,5 @@ * Configure the container from inside */ -struct lxc_handler; - extern int lxc_setup(const char *name, struct lxc_conf *lxc_conf); - #endif diff -Nru lxc-0.7.2/src/lxc/confile.c lxc-0.7.4/src/lxc/confile.c --- lxc-0.7.2/src/lxc/confile.c 2010-07-22 13:59:44.000000000 +0000 +++ lxc-0.7.4/src/lxc/confile.c 2011-02-14 08:22:08.000000000 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ lxc_log_define(lxc_confile, lxc); +static int config_personality(const char *, char *, struct lxc_conf *); static int config_pts(const char *, char *, struct lxc_conf *); static int config_tty(const char *, char *, struct lxc_conf *); static int config_cgroup(const char *, char *, struct lxc_conf *); @@ -61,6 +63,7 @@ static int config_network_vlan_id(const char *, char *, struct lxc_conf *); static int config_network_mtu(const char *, char *, struct lxc_conf *); static int config_network_ipv4(const char *, char *, struct lxc_conf *); +static int config_network_script(const char *, char *, struct lxc_conf *); static int config_network_ipv6(const char *, char *, struct lxc_conf *); static int config_cap_drop(const char *, char *, struct lxc_conf *); static int config_console(const char *, char *, struct lxc_conf *); @@ -74,6 +77,7 @@ static struct config config[] = { + { "lxc.arch", config_personality }, { "lxc.pts", config_pts }, { "lxc.tty", config_tty }, { "lxc.cgroup", config_cgroup }, @@ -88,6 +92,7 @@ { "lxc.network.name", config_network_name }, { "lxc.network.macvlan.mode", config_network_macvlan_mode }, { "lxc.network.veth.pair", config_network_veth_pair }, + { "lxc.network.script.up", config_network_script }, { "lxc.network.hwaddr", config_network_hwaddr }, { "lxc.network.mtu", config_network_mtu }, { "lxc.network.vlan.id", config_network_vlan_id }, @@ -418,9 +423,9 @@ * prefix and address */ if (!bcast) { - inetdev->bcast.s_addr = - htonl(INADDR_BROADCAST << (32 - inetdev->prefix)); - inetdev->bcast.s_addr &= inetdev->addr.s_addr; + inetdev->bcast.s_addr = inetdev->addr.s_addr; + inetdev->bcast.s_addr |= + htonl(INADDR_BROADCAST >> inetdev->prefix); } lxc_list_add(&netdev->ipv4, list); @@ -475,6 +480,57 @@ return 0; } +static int config_network_script(const char *key, char *value, + struct lxc_conf *lxc_conf) +{ + struct lxc_netdev *netdev; + + netdev = network_netdev(key, value, &lxc_conf->network); + if (!netdev) + return -1; + + char *copy = strdup(value); + if (!copy) { + SYSERROR("failed to dup string '%s'", value); + return -1; + } + if (strcmp(key, "lxc.network.script.up") == 0) { + netdev->upscript = copy; + return 0; + } + SYSERROR("Unknown key: %s", key); + free(copy); + return -1; +} + +static int config_personality(const char *key, char *value, + struct lxc_conf *lxc_conf) +{ + struct per_name { + char *name; + int per; + } pername[4] = { + { "x86", PER_LINUX32 }, + { "i686", PER_LINUX32 }, + { "x86_64", PER_LINUX }, + { "amd64", PER_LINUX }, + }; + + int i; + + for (i = 0; i < sizeof(pername); i++) { + + if (strcmp(pername[i].name, value)) + continue; + + lxc_conf->personality = pername[i].per; + return 0; + } + + ERROR("unsupported personality '%s'", value); + return -1; +} + static int config_pts(const char *key, char *value, struct lxc_conf *lxc_conf) { int maxpts = atoi(value); diff -Nru lxc-0.7.2/src/lxc/console.c lxc-0.7.4/src/lxc/console.c --- lxc-0.7.2/src/lxc/console.c 2010-07-23 15:17:14.000000000 +0000 +++ lxc-0.7.4/src/lxc/console.c 2011-01-07 19:13:43.000000000 +0000 @@ -47,7 +47,7 @@ .request = { .type = LXC_COMMAND_TTY, .data = ttynum }, }; - ret = lxc_command(name, &command, &stopped); + ret = lxc_command_connected(name, &command, &stopped); if (ret < 0 && stopped) { ERROR("'%s' is stopped", name); return -1; diff -Nru lxc-0.7.2/src/lxc/lxc-checkconfig.in lxc-0.7.4/src/lxc/lxc-checkconfig.in --- lxc-0.7.2/src/lxc/lxc-checkconfig.in 2010-06-16 07:19:15.000000000 +0000 +++ lxc-0.7.4/src/lxc/lxc-checkconfig.in 2011-02-26 09:18:19.000000000 +0000 @@ -74,10 +74,12 @@ echo -n "Veth pair device: " && is_enabled CONFIG_VETH echo -n "Macvlan: " && is_enabled CONFIG_MACVLAN echo -n "Vlan: " && is_enabled CONFIG_VLAN_8021Q -KVER_MINOR=$($GREP '^# Linux kernel version:' $CONFIG | \ +KVER_MINOR=$($GREP '^# Linux' $CONFIG | \ sed -r 's/.*2.6.([0-9]{2}).*/\1/') -[[ ${KVER_MINOR} < 33 ]] && echo -n "File capabilities: " && is_enabled \ - CONFIG_SECURITY_FILE_CAPABILITIES +echo -n "File capabilities: " && + [[ ${KVER_MINOR} < 33 ]] && is_enabled CONFIG_SECURITY_FILE_CAPABILITIES || + [[ ${KVER_MINOR} > 32 ]] && $SETCOLOR_SUCCESS && echo -e "enabled" && + $SETCOLOR_NORMAL echo echo "Note : Before booting a new kernel, you can check its configuration" diff -Nru lxc-0.7.2/src/lxc/lxc_checkpoint.c lxc-0.7.4/src/lxc/lxc_checkpoint.c --- lxc-0.7.2/src/lxc/lxc_checkpoint.c 2010-07-22 13:57:08.000000000 +0000 +++ lxc-0.7.4/src/lxc/lxc_checkpoint.c 2010-10-12 13:11:45.000000000 +0000 @@ -36,6 +36,7 @@ #include "arguments.h" #include "config.h" +#include "caps.h" lxc_log_define(lxc_checkpoint_ui, lxc_checkpoint); @@ -107,6 +108,9 @@ int ret; int sfd = -1; + if (lxc_caps_init()) + return -1; + ret = lxc_arguments_parse(&my_args, argc, argv); if (ret) return ret; diff -Nru lxc-0.7.2/src/lxc/lxc_restart.c lxc-0.7.4/src/lxc/lxc_restart.c --- lxc-0.7.2/src/lxc/lxc_restart.c 2010-07-22 13:57:08.000000000 +0000 +++ lxc-0.7.4/src/lxc/lxc_restart.c 2010-10-12 13:11:45.000000000 +0000 @@ -31,6 +31,7 @@ #include "log.h" #include "lxc.h" +#include "caps.h" #include "conf.h" #include "config.h" #include "confile.h" @@ -115,6 +116,9 @@ lxc_list_init(&defines); + if (lxc_caps_init()) + return -1; + if (lxc_arguments_parse(&my_args, argc, argv)) return -1; diff -Nru lxc-0.7.2/src/lxc/lxc_start.c lxc-0.7.4/src/lxc/lxc_start.c --- lxc-0.7.2/src/lxc/lxc_start.c 2010-07-20 11:45:44.000000000 +0000 +++ lxc-0.7.4/src/lxc/lxc_start.c 2011-02-01 14:12:40.000000000 +0000 @@ -57,6 +57,7 @@ static int my_parser(struct lxc_arguments* args, int c, char* arg) { switch (c) { + case 'c': args->console = arg; break; case 'd': args->daemonize = 1; break; case 'f': args->rcfile = arg; break; case 's': return lxc_config_define_add(&defines, arg); @@ -68,6 +69,7 @@ {"daemon", no_argument, 0, 'd'}, {"rcfile", required_argument, 0, 'f'}, {"define", required_argument, 0, 's'}, + {"console", required_argument, 0, 'c'}, LXC_COMMON_OPTIONS }; @@ -82,6 +84,7 @@ -n, --name=NAME NAME for name of the container\n\ -d, --daemon daemonize the container\n\ -f, --rcfile=FILE Load configuration file FILE\n\ + -c, --console=FILE Set the file output for the container console\n\ -s, --define KEY=VAL Assign VAL to configuration variable KEY\n", .options = my_longopts, .parser = my_parser, @@ -117,6 +120,11 @@ my_args.progname, my_args.quiet)) return err; + if (putenv("container=lxc")) { + SYSERROR("failed to set environment variable"); + return err; + } + /* rcfile is specified in the cli option */ if (my_args.rcfile) rcfile = (char *)my_args.rcfile; @@ -155,28 +163,40 @@ return err; } - if (my_args.daemonize) { + if (my_args.console) { + + char *console, fd; + + if (access(my_args.console, W_OK)) { + + fd = creat(my_args.console, 0600); + if (fd < 0) { + SYSERROR("failed to touch file '%s'", + my_args.console); + return err; + } + close(fd); + } - /* do not chdir as we want to open the log file, - * change the directory right after. - * do not close 0, 1, 2, we want to do that - * ourself because we don't want /dev/null - * being reopened. - */ - if (daemon(1, 1)) { - SYSERROR("failed to daemonize '%s'", my_args.name); + console = realpath(my_args.console, NULL); + if (!console) { + SYSERROR("failed to get the real path of '%s'", + my_args.console); return err; } - close(0); - close(1); - close(2); - - if (my_args.log_file) { - open(my_args.log_file, O_WRONLY | O_CLOEXEC); - open(my_args.log_file, O_RDONLY | O_CLOEXEC); - open(my_args.log_file, O_RDONLY | O_CLOEXEC); + conf->console.path = strdup(console); + if (!conf->console.path) { + ERROR("failed to dup string '%s'", console); + return err; } + + free(console); + } + + if (my_args.daemonize && daemon(0, 0)) { + SYSERROR("failed to daemonize '%s'", my_args.name); + return err; } err = lxc_start(my_args.name, args, conf); diff -Nru lxc-0.7.2/src/lxc/lxc_unshare.c lxc-0.7.4/src/lxc/lxc_unshare.c --- lxc-0.7.2/src/lxc/lxc_unshare.c 2010-07-23 13:10:38.000000000 +0000 +++ lxc-0.7.4/src/lxc/lxc_unshare.c 2011-02-01 14:12:40.000000000 +0000 @@ -214,7 +214,7 @@ ERROR("pid_name: failed to allocate memory"); return -1; } - lxc_unlink_nsgroup(pid_name); + lxc_cgroup_destroy(pid_name); free(pid_name); return lxc_error_set_and_log(pid, status); diff -Nru lxc-0.7.2/src/lxc/Makefile.am lxc-0.7.4/src/lxc/Makefile.am --- lxc-0.7.2/src/lxc/Makefile.am 2010-07-26 08:57:29.000000000 +0000 +++ lxc-0.7.4/src/lxc/Makefile.am 2011-02-01 14:12:40.000000000 +0000 @@ -11,7 +11,8 @@ conf.h \ list.h \ log.h \ - state.h + state.h \ + setns.h sodir=$(libdir) # use PROGRAMS to avoid complains from automake @@ -59,7 +60,7 @@ -shared \ -Wl,-soname,liblxc.so.$(firstword $(subst ., ,$(VERSION))) -liblxc_so_LDADD = -lutil +liblxc_so_LDADD = -lutil $(CAP_LIBS) bin_SCRIPTS = \ lxc-ps \ @@ -120,3 +121,14 @@ uninstall-local: $(RM) $(DESTDIR)$(libdir)/liblxc.so* + +namespace.c: setns.h + +setns.h: + -$(CC) $(CPPFLAGS) -M -MT$@ $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h >setns.P + -$(CPP) $(CPPFLAGS) -dM $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h |grep setns > $@ + +clean-local: + $(RM) setns.h setns.P + +-include setns.P diff -Nru lxc-0.7.2/src/lxc/Makefile.in lxc-0.7.4/src/lxc/Makefile.in --- lxc-0.7.2/src/lxc/Makefile.in 2010-07-26 08:58:50.000000000 +0000 +++ lxc-0.7.4/src/lxc/Makefile.in 2011-02-26 09:20:20.000000000 +0000 @@ -53,7 +53,7 @@ $(srcdir)/lxc-setuid.in $(srcdir)/lxc-version.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -80,7 +80,8 @@ liblxc_so-caps.$(OBJEXT) liblxc_so-mainloop.$(OBJEXT) \ liblxc_so-af_unix.$(OBJEXT) liblxc_so-utmp.$(OBJEXT) liblxc_so_OBJECTS = $(am_liblxc_so_OBJECTS) -liblxc_so_DEPENDENCIES = +am__DEPENDENCIES_1 = +liblxc_so_DEPENDENCIES = $(am__DEPENDENCIES_1) liblxc_so_LINK = $(CCLD) $(liblxc_so_CFLAGS) $(CFLAGS) \ $(liblxc_so_LDFLAGS) $(LDFLAGS) -o $@ am_lxc_attach_OBJECTS = lxc_attach.$(OBJEXT) @@ -231,6 +232,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ @@ -320,7 +323,8 @@ conf.h \ list.h \ log.h \ - state.h + state.h \ + setns.h sodir = $(libdir) liblxc_so_SOURCES = \ @@ -363,7 +367,7 @@ -shared \ -Wl,-soname,liblxc.so.$(firstword $(subst ., ,$(VERSION))) -liblxc_so_LDADD = -lutil +liblxc_so_LDADD = -lutil $(CAP_LIBS) bin_SCRIPTS = \ lxc-ps \ lxc-netstat \ @@ -1220,8 +1224,8 @@ @echo "it deletes files that may require special tools to rebuild." clean: clean-am -clean-am: clean-binPROGRAMS clean-generic clean-pkglibPROGRAMS \ - clean-soPROGRAMS mostlyclean-am +clean-am: clean-binPROGRAMS clean-generic clean-local \ + clean-pkglibPROGRAMS clean-soPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) @@ -1294,22 +1298,22 @@ .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ - clean-generic clean-pkglibPROGRAMS clean-soPROGRAMS ctags \ - distclean distclean-compile distclean-generic distclean-tags \ - distdir dvi dvi-am html html-am info info-am install \ - install-am install-binPROGRAMS install-binSCRIPTS install-data \ - install-data-am install-dvi install-dvi-am install-exec \ - install-exec-am install-exec-local install-html \ - install-html-am install-info install-info-am install-man \ - install-pdf install-pdf-am install-pkgincludeHEADERS \ - install-pkglibPROGRAMS install-ps install-ps-am \ - install-soPROGRAMS install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ - uninstall-binSCRIPTS uninstall-local \ - uninstall-pkgincludeHEADERS uninstall-pkglibPROGRAMS \ - uninstall-soPROGRAMS + clean-generic clean-local clean-pkglibPROGRAMS \ + clean-soPROGRAMS ctags distclean distclean-compile \ + distclean-generic distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-binPROGRAMS \ + install-binSCRIPTS install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-exec-local \ + install-html install-html-am install-info install-info-am \ + install-man install-pdf install-pdf-am \ + install-pkgincludeHEADERS install-pkglibPROGRAMS install-ps \ + install-ps-am install-soPROGRAMS install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-binSCRIPTS \ + uninstall-local uninstall-pkgincludeHEADERS \ + uninstall-pkglibPROGRAMS uninstall-soPROGRAMS install-exec-local: install-soPROGRAMS @@ -1321,6 +1325,17 @@ uninstall-local: $(RM) $(DESTDIR)$(libdir)/liblxc.so* +namespace.c: setns.h + +setns.h: + -$(CC) $(CPPFLAGS) -M -MT$@ $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h >setns.P + -$(CPP) $(CPPFLAGS) -dM $(LINUX_DIR)/arch/$(LINUX_SRCARCH)/include/asm/unistd.h |grep setns > $@ + +clean-local: + $(RM) setns.h setns.P + +-include setns.P + # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: diff -Nru lxc-0.7.2/src/lxc/namespace.c lxc-0.7.4/src/lxc/namespace.c --- lxc-0.7.2/src/lxc/namespace.c 2010-07-19 15:07:27.000000000 +0000 +++ lxc-0.7.4/src/lxc/namespace.c 2011-02-01 14:12:40.000000000 +0000 @@ -34,19 +34,7 @@ #include "namespace.h" #include "log.h" -#ifndef __NR_setns -# if __i386__ -# define __NR_setns 338 -# elif __x86_64__ -# define __NR_setns 300 -# elif __powerpc__ -# define __NR_setns 323 -# elif __s390__ -# define __NR_setns 332 -# else -# warning "architecture not supported for setns" -# endif -#endif +#include "setns.h" lxc_log_define(lxc_namespace, lxc); @@ -102,6 +90,12 @@ int fd[size]; int i; + sprintf(path, "/proc/%d/ns", pid); + if (access(path, R_OK)) { + ERROR("Does this kernel version support 'attach' ?"); + return -1; + } + for (i = 0; i < size; i++) { sprintf(path, "/proc/%d/ns/%s", pid, ns[i]); fd[i] = open(path, O_RDONLY); diff -Nru lxc-0.7.2/src/lxc/network.c lxc-0.7.4/src/lxc/network.c --- lxc-0.7.2/src/lxc/network.c 2010-07-23 13:10:17.000000000 +0000 +++ lxc-0.7.4/src/lxc/network.c 2011-02-14 08:22:02.000000000 +0000 @@ -742,7 +742,7 @@ if (nla_put_buffer(nlmsg, IFA_ADDRESS, addr, addrlen)) goto out; - if (bcast && nla_put_buffer(nlmsg, IFA_BROADCAST, bcast, addrlen)) + if (nla_put_buffer(nlmsg, IFA_BROADCAST, bcast, addrlen)) goto out; /* TODO : multicast, anycast with ipv6 */ diff -Nru lxc-0.7.2/src/lxc/parse.c lxc-0.7.4/src/lxc/parse.c --- lxc-0.7.2/src/lxc/parse.c 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/parse.c 2010-10-08 09:54:53.000000000 +0000 @@ -81,10 +81,8 @@ while (getline(&line, &len, f) != -1) { err = callback(line, data); - if (err) { - ERROR("failed to process '%s'", line); + if (err) break; - } } if (line) diff -Nru lxc-0.7.2/src/lxc/setns.h lxc-0.7.4/src/lxc/setns.h --- lxc-0.7.2/src/lxc/setns.h 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/src/lxc/setns.h 2011-01-19 13:53:05.000000000 +0000 @@ -0,0 +1 @@ +#define __NR_setns 303 diff -Nru lxc-0.7.2/src/lxc/start.c lxc-0.7.4/src/lxc/start.c --- lxc-0.7.2/src/lxc/start.c 2010-07-23 10:41:02.000000000 +0000 +++ lxc-0.7.4/src/lxc/start.c 2011-02-01 14:12:40.000000000 +0000 @@ -114,7 +114,6 @@ #include "start.h" #include "conf.h" -#include "cgroup.h" #include "log.h" #include "cgroup.h" #include "error.h" @@ -487,7 +486,7 @@ /* that should be done before the clone because we will * fill the netdev index and use them in the child */ - if (lxc_create_network(&handler->conf->network)) { + if (lxc_create_network(handler)) { ERROR("failed to create the network"); lxc_sync_fini(handler); return -1; @@ -507,7 +506,7 @@ if (lxc_sync_wait_child(handler, LXC_SYNC_CONFIGURE)) failed_before_rename = 1; - if (lxc_rename_nsgroup(name, handler)) + if (lxc_cgroup_create(name, handler->pid)) goto out_delete_net; if (failed_before_rename) @@ -586,7 +585,7 @@ out_fini: LXC_TTY_DEL_HANDLER(SIGQUIT); LXC_TTY_DEL_HANDLER(SIGINT); - lxc_unlink_nsgroup(name); + lxc_cgroup_destroy(name); lxc_fini(name, handler); return err; diff -Nru lxc-0.7.2/src/lxc/start.h lxc-0.7.4/src/lxc/start.h --- lxc-0.7.2/src/lxc/start.h 2010-06-07 08:51:51.000000000 +0000 +++ lxc-0.7.4/src/lxc/start.h 2011-02-01 14:12:40.000000000 +0000 @@ -40,7 +40,6 @@ char *name; lxc_state_t state; int sigfd; - char nsgroup[MAXPATHLEN]; sigset_t oldmask; struct lxc_conf *conf; struct lxc_operations *ops; diff -Nru lxc-0.7.2/src/lxc/utmp.c lxc-0.7.4/src/lxc/utmp.c --- lxc-0.7.2/src/lxc/utmp.c 2010-06-16 07:17:30.000000000 +0000 +++ lxc-0.7.4/src/lxc/utmp.c 2011-01-18 23:27:19.000000000 +0000 @@ -82,8 +82,10 @@ struct lxc_utmp *utmp_data = (struct lxc_utmp *)data; - /* we're monitoring a directory. ie->name is not included in sizeof(struct inotify_event) - * if we don't read it all at once, read gives us EINVAL, so we read and cast to struct ie + /* + * we're monitoring a directory. ie->name is not included in + * sizeof(struct inotify_event) if we don't read it all at once, + * read gives us EINVAL, so we read and cast to struct ie */ char buffer[MAXPATHLEN]; @@ -100,7 +102,13 @@ ie = (struct inotify_event *)buffer; if (ie->len <= 0) { - SYSERROR("inotify event with no name"); + + if (ie->mask & IN_UNMOUNT) { + DEBUG("watched directory removed"); + goto out; + } + + SYSERROR("inotify event with no name (mask %d)", ie->mask); return -1; } @@ -161,10 +169,9 @@ struct utmpx *utmpx; char path[MAXPATHLEN]; struct lxc_handler *handler = utmp_data->handler; - struct lxc_conf *conf = handler->conf; - if (snprintf(path, MAXPATHLEN, "%s/var/run/utmp", conf->rootfs.path) > - MAXPATHLEN) { + if (snprintf(path, MAXPATHLEN, "/proc/%d/root/var/run/utmp", + handler->pid) > MAXPATHLEN) { ERROR("path is too long"); return -1; } @@ -211,19 +218,20 @@ int lxc_utmp_mainloop_add(struct lxc_epoll_descr *descr, struct lxc_handler *handler) { - struct lxc_conf *conf = handler->conf; char path[MAXPATHLEN]; int fd, wd; struct lxc_utmp *utmp_data; + struct lxc_conf *conf = handler->conf; if (!conf->rootfs.path) return 0; - /* We set up a watch for the /var/run directory. We're only interested in - * utmp at the moment, but want to watch for delete and create events as well. + /* We set up a watch for the /var/run directory. We're only interested + * in utmp at the moment, but want to watch for delete and create + * events as well. */ - if (snprintf(path, MAXPATHLEN, "%s/var/run", conf->rootfs.path) > - MAXPATHLEN) { + if (snprintf(path, MAXPATHLEN, "/proc/%d/root/var/run", + handler->pid) > MAXPATHLEN) { ERROR("path is too long"); return -1; } @@ -286,13 +294,16 @@ struct lxc_epoll_descr *descr) { int ntasks; + ssize_t nread; struct lxc_utmp *utmp_data = (struct lxc_utmp *)data; struct lxc_handler *handler = utmp_data->handler; struct lxc_conf *conf = handler->conf; uint64_t expirations; /* read and clear notifications */ - read(fd, &expirations, sizeof(expirations)); + nread = read(fd, &expirations, sizeof(expirations)); + if (nread < 0) + SYSERROR("Failed to read timer notification"); ntasks = utmp_get_ntasks(handler); diff -Nru lxc-0.7.2/src/Makefile.in lxc-0.7.4/src/Makefile.in --- lxc-0.7.2/src/Makefile.in 2010-07-26 08:58:49.000000000 +0000 +++ lxc-0.7.4/src/Makefile.in 2011-02-26 09:20:19.000000000 +0000 @@ -38,7 +38,7 @@ $(srcdir)/config.h.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d @@ -122,6 +122,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ diff -Nru lxc-0.7.2/templates/lxc-busybox.in lxc-0.7.4/templates/lxc-busybox.in --- lxc-0.7.2/templates/lxc-busybox.in 2010-06-07 09:33:55.000000000 +0000 +++ lxc-0.7.4/templates/lxc-busybox.in 2011-02-01 14:12:40.000000000 +0000 @@ -78,9 +78,9 @@ # mount everything cat <> $rootfs/etc/init.d/rcS #!/bin/sh -syslogd -mount -a -udhcpc +/bin/syslogd +/bin/mount -a +/bin/udhcpc EOF # executable @@ -100,8 +100,8 @@ # not needed cat <> $rootfs/etc/inittab ::sysinit:/etc/init.d/rcS -::respawn:/bin/getty -L tty1 115200 vt100 -::askfirst:/bin/sh +tty1::respawn:/bin/getty -L tty1 115200 vt100 +console::askfirst:/bin/sh EOF # writable and readable for other chmod 644 $rootfs/etc/inittab || return 1 @@ -242,7 +242,7 @@ EOF fi -if [ -d "$rootfs/lib64" ]; then +if [ -d "/lib64" ] && [ -d "$rootfs/lib64" ]; then cat <> $path/config lxc.mount.entry=/lib64 $rootfs/lib64 none ro,bind 0 0 lxc.mount.entry=/usr/lib64 $rootfs/usr/lib64 none ro,bind 0 0 diff -Nru lxc-0.7.2/templates/lxc-debian.in lxc-0.7.4/templates/lxc-debian.in --- lxc-0.7.2/templates/lxc-debian.in 2010-06-24 07:47:14.000000000 +0000 +++ lxc-0.7.4/templates/lxc-debian.in 2011-02-19 08:45:32.000000000 +0000 @@ -20,11 +20,22 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +SUITE=${SUITE:-squeeze} +MIRROR=${MIRROR:-http://cdn.debian.net/debian} + configure_debian() { rootfs=$1 hostname=$2 + # squeeze only has /dev/tty and /dev/tty0 by default, + # therefore creating missing device nodes for tty1-4. + for tty in $(seq 1 4); do + if [ ! -e $rootfs/dev/tty$tty ]; then + mknod $rootfs/dev/tty$tty c 4 $tty + fi + done + # configure the inittab cat < $rootfs/etc/inittab id:3:initdefault: @@ -65,14 +76,15 @@ # reconfigure some services if [ -z "$LANG" ]; then - chroot $rootfs locale-gen en_US.UTF-8 + chroot $rootfs locale-gen en_US.UTF-8 UTF-8 chroot $rootfs update-locale LANG=en_US.UTF-8 else - chroot $rootfs locale-gen $LANG + chroot $rootfs locale-gen $LANG $(echo $LANG | cut -d. -f2) chroot $rootfs update-locale LANG=$LANG fi # remove pointless services in a container + chroot $rootfs /usr/sbin/update-rc.d -f checkroot.sh remove chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove @@ -90,7 +102,7 @@ locales,\ libui-dialog-perl,\ dialog,\ -dhcp-client,\ +dhcp3-client,\ netbase,\ net-tools,\ iproute,\ @@ -100,23 +112,23 @@ arch=$2 # check the mini debian was not already downloaded - mkdir -p "$cache/partial-$arch" + mkdir -p "$cache/partial-$SUITE-$arch" if [ $? -ne 0 ]; then - echo "Failed to create '$cache/partial-$arch' directory" + echo "Failed to create '$cache/partial-$SUITE-$arch' directory" return 1 fi # download a mini debian into a cache echo "Downloading debian minimal ..." debootstrap --verbose --variant=minbase --arch=$arch \ - --include $packages \ - lenny $cache/partial-$arch http://ftp.debian.org/debian + --include=$packages \ + "$SUITE" "$cache/partial-$SUITE-$arch" $MIRROR if [ $? -ne 0 ]; then echo "Failed to download the rootfs, aborting." return 1 fi - mv "$1/partial-$arch" "$1/rootfs-$arch" + mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch" echo "Download complete." return 0 @@ -130,7 +142,7 @@ # make a local copy of the minidebian echo -n "Copying rootfs to $rootfs..." - cp -a $cache/rootfs-$arch $rootfs || return 1 + cp -a "$cache/rootfs-$SUITE-$arch" $rootfs || return 1 return 0 } @@ -155,8 +167,8 @@ arch=i386 fi - echo "Checking cache download in $cache/rootfs-$arch ... " - if [ ! -e "$cache/rootfs-$arch" ]; then + echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " + if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then download_debian $cache $arch if [ $? -ne 0 ]; then echo "Failed to download 'debian base'" diff -Nru lxc-0.7.2/templates/lxc-lenny.in lxc-0.7.4/templates/lxc-lenny.in --- lxc-0.7.2/templates/lxc-lenny.in 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/templates/lxc-lenny.in 2011-02-01 14:12:40.000000000 +0000 @@ -0,0 +1,317 @@ +#!/bin/bash + +# +# lxc: linux Container library + +# Authors: +# Daniel Lezcano + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +SUITE=${SUITE:-lenny} + +configure_debian() +{ + rootfs=$1 + hostname=$2 + + # configure the inittab + cat < $rootfs/etc/inittab +id:3:initdefault: +si::sysinit:/etc/init.d/rcS +l0:0:wait:/etc/init.d/rc 0 +l1:1:wait:/etc/init.d/rc 1 +l2:2:wait:/etc/init.d/rc 2 +l3:3:wait:/etc/init.d/rc 3 +l4:4:wait:/etc/init.d/rc 4 +l5:5:wait:/etc/init.d/rc 5 +l6:6:wait:/etc/init.d/rc 6 +# Normally not reached, but fallthrough in case of emergency. +z6:6:respawn:/sbin/sulogin +1:2345:respawn:/sbin/getty 38400 console +c1:12345:respawn:/sbin/getty 38400 tty1 linux +c2:12345:respawn:/sbin/getty 38400 tty2 linux +c3:12345:respawn:/sbin/getty 38400 tty3 linux +c4:12345:respawn:/sbin/getty 38400 tty4 linux +EOF + + # disable selinux in debian + mkdir -p $rootfs/selinux + echo 0 > $rootfs/selinux/enforce + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + + # reconfigure some services + if [ -z "$LANG" ]; then + chroot $rootfs locale-gen en_US.UTF-8 + chroot $rootfs update-locale LANG=en_US.UTF-8 + else + chroot $rootfs locale-gen $LANG + chroot $rootfs update-locale LANG=$LANG + fi + + # remove pointless services in a container + chroot $rootfs /usr/sbin/update-rc.d -f umountfs remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclock.sh remove + chroot $rootfs /usr/sbin/update-rc.d -f hwclockfirst.sh remove + + echo "root:root" | chroot $rootfs chpasswd + echo "Root password is 'root', please change !" + + return 0 +} + +download_debian() +{ + packages=\ +ifupdown,\ +locales,\ +libui-dialog-perl,\ +dialog,\ +dhcp3-client,\ +netbase,\ +net-tools,\ +iproute,\ +openssh-server + + cache=$1 + arch=$2 + + # check the mini debian was not already downloaded + mkdir -p "$cache/partial-$SUITE-$arch" + if [ $? -ne 0 ]; then + echo "Failed to create '$cache/partial-$SUITE-$arch' directory" + return 1 + fi + + # download a mini debian into a cache + echo "Downloading debian minimal ..." + debootstrap --verbose --variant=minbase --arch=$arch \ + --include $packages \ + "$SUITE" "$cache/partial-$SUITE-$arch" http://ftp.debian.org/debian + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi + + mv "$1/partial-$SUITE-$arch" "$1/rootfs-$SUITE-$arch" + echo "Download complete." + + return 0 +} + +copy_debian() +{ + cache=$1 + arch=$2 + rootfs=$3 + + # make a local copy of the minidebian + echo -n "Copying rootfs to $rootfs..." + cp -a "$cache/rootfs-$SUITE-$arch" $rootfs || return 1 + return 0 +} + +install_debian() +{ + cache="@LOCALSTATEDIR@/cache/lxc/$SUITE" + rootfs=$1 + mkdir -p @LOCALSTATEDIR@/lock/subsys/ + ( + flock -n -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + arch=$(arch) + if [ "$arch" == "x86_64" ]; then + arch=amd64 + fi + + if [ "$arch" == "i686" ]; then + arch=i386 + fi + + echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... " + if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then + download_debian $cache $arch + if [ $? -ne 0 ]; then + echo "Failed to download 'debian base'" + return 1 + fi + fi + + copy_debian $cache $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>@LOCALSTATEDIR@/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + + cat <> $path/config +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = $rootfs +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +lxc.cgroup.devices.allow = c 4:0 rwm +lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm + +# mounts point +lxc.mount.entry=proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +lxc.mount.entry=devpts $rootfs/dev/pts devpts defaults 0 0 +lxc.mount.entry=sysfs $rootfs/sys sysfs defaults 0 0 +EOF + + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi + + return 0 +} + +clean() +{ + cache="@LOCALSTATEDIR@/cache/lxc/$SUITE" + + if [ ! -e $cache ]; then + exit 0 + fi + + # lock, so we won't purge while someone is creating a repository + ( + flock -n -x 200 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi + + echo -n "Purging the download cache..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + + ) 200>@LOCALSTATEDIR@/lock/subsys/lxc +} + +usage() +{ + cat < --clean +EOF + return 0 +} + +options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ ! -z "$clean" -a -z "$path" ]; then + clean || exit 1 + exit 0 +fi + +type debootstrap +if [ $? -ne 0 ]; then + echo "'debootstrap' command is missing" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +rootfs=$path/rootfs + +install_debian $rootfs +if [ $? -ne 0 ]; then + echo "failed to install debian" + exit 1 +fi + +configure_debian $rootfs $name +if [ $? -ne 0 ]; then + echo "failed to configure debian for a container" + exit 1 +fi + +copy_configuration $path $rootfs +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +if [ ! -z $clean ]; then + clean || exit 1 + exit 0 +fi diff -Nru lxc-0.7.2/templates/lxc-lucid.in lxc-0.7.4/templates/lxc-lucid.in --- lxc-0.7.2/templates/lxc-lucid.in 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/templates/lxc-lucid.in 2011-02-01 14:12:40.000000000 +0000 @@ -0,0 +1,369 @@ +#!/bin/bash + +# +# template script for generating ubuntu/lucid container for LXC +# +# This script is based on lxc-debian (Daniel Lezcano ) +# + +# Copyright © 2010 Wilhelm Meier +# Author: Wilhelm Meier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +configure_ubuntu() +{ + rootfs=$1 + hostname=$2 + + # disable selinux in ubuntu + mkdir -p $rootfs/selinux + echo 0 > $rootfs/selinux/enforce + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + # set minimal hosts + cat < $rootfs/etc/hosts +127.0.0.1 localhost $hostname +EOF + + # provide the lxc service + cat < $rootfs/etc/init/lxc.conf +# fake some events needed for correct startup other services + +description "Container Upstart" + +start on startup + +script + rm -rf /var/run/*.pid + rm -rf /var/run/network/* + /sbin/initctl emit stopped JOB=udevtrigger --no-wait + /sbin/initctl emit started JOB=udev --no-wait +end script +EOF + + # fix buggus runlevel with sshd + cat < $rootfs/etc/init/ssh.conf +# ssh - OpenBSD Secure Shell server +# +# The OpenSSH server provides secure shell access to the system. + +description "OpenSSH server" + +start on filesystem +stop on runlevel [!2345] + +expect fork +respawn +respawn limit 10 5 +umask 022 +# replaces SSHD_OOM_ADJUST in /etc/default/ssh +oom never + +pre-start script + test -x /usr/sbin/sshd || { stop; exit 0; } + test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; } + test -c /dev/null || { stop; exit 0; } + + mkdir -p -m0755 /var/run/sshd +end script + +# if you used to set SSHD_OPTS in /etc/default/ssh, you can change the +# 'exec' line here instead +exec /usr/sbin/sshd +EOF + + cat < $rootfs/etc/init/console.conf +# console - getty +# +# This service maintains a console on tty1 from the point the system is +# started until it is shut down again. + +start on stopped rc RUNLEVEL=[2345] +stop on runlevel [!2345] + +respawn +exec /sbin/getty -8 38400 /dev/console +EOF + + cat < $rootfs/lib/init/fstab +# /lib/init/fstab: lxc system fstab +none /spu spufs gid=spu,optional 0 0 +none /tmp none defaults 0 0 +none /var/lock tmpfs nodev,noexec,nosuid,showthrough 0 0 +none /lib/init/rw tmpfs mode=0755,nosuid,optional 0 0 +EOF + + # reconfigure some services + if [ -z "$LANG" ]; then + chroot $rootfs locale-gen en_US.UTF-8 + chroot $rootfs update-locale LANG=en_US.UTF-8 + else + chroot $rootfs locale-gen $LANG + chroot $rootfs update-locale LANG=$LANG + fi + + # remove pointless services in a container + chroot $rootfs /usr/sbin/update-rc.d -f ondemand remove + + chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls u*.conf); do mv $f $f.orig; done' + chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls tty[2-9].conf); do mv $f $f.orig; done' + chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls plymouth*.conf); do mv $f $f.orig; done' + chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls hwclock*.conf); do mv $f $f.orig; done' + chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls module*.conf); do mv $f $f.orig; done' + + echo "Please change root-password !" + echo "root:root" | chroot $rootfs chpasswd + + return 0 +} + +download_ubuntu() +{ + packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg + + cache=$1 + arch=$2 + + # check the mini ubuntu was not already downloaded + mkdir -p "$cache/partial-$arch" + if [ $? -ne 0 ]; then + echo "Failed to create '$cache/partial-$arch' directory" + return 1 + fi + + # download a mini ubuntu into a cache + echo "Downloading ubuntu lucid minimal ..." + debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages lucid $cache/partial-$arch + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi + + mv "$1/partial-$arch" "$1/rootfs-$arch" + echo "Download complete." + + return 0 +} + +copy_ubuntu() +{ + cache=$1 + arch=$2 + rootfs=$3 + + # make a local copy of the miniubuntu + echo -n "Copying rootfs to $rootfs ..." + cp -a $cache/rootfs-$arch $rootfs || return 1 + return 0 +} + +install_ubuntu() +{ + cache="/var/cache/lxc/lucid" + rootfs=$1 + mkdir -p /var/lock/subsys/ + ( + flock -n -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + arch=$(arch) + if [ "$arch" == "x86_64" ]; then + arch=amd64 + fi + + if [ "$arch" == "i686" ]; then + arch=i386 + fi + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then + download_ubuntu $cache $arch + if [ $? -ne 0 ]; then + echo "Failed to download 'ubuntu lucid base'" + return 1 + fi + fi + + echo "Copy $cache/rootfs-$arch to $rootfs ... " + copy_ubuntu $cache $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>/var/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + + cat <> $path/config +lxc.utsname = $name + +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = $rootfs +lxc.mount = $path/fstab + +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +lxc.cgroup.devices.allow = c 4:0 rwm +lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm +EOF + + cat < $path/fstab +proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +devpts $rootfs/dev/pts devpts defaults 0 0 +sysfs $rootfs/sys sysfs defaults 0 0 +EOF + + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi + + return 0 +} + +clean() +{ + cache="/var/cache/lxc/lucid" + + if [ ! -e $cache ]; then + exit 0 + fi + + # lock, so we won't purge while someone is creating a repository + ( + flock -n -x 200 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi + + echo -n "Purging the download cache..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + + ) 200>/var/lock/subsys/lxc +} + +usage() +{ + cat < --clean +EOF + return 0 +} + +options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ ! -z "$clean" -a -z "$path" ]; then + clean || exit 1 + exit 0 +fi + +type debootstrap +if [ $? -ne 0 ]; then + echo "'debootstrap' command is missing" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +rootfs=$path/rootfs + +install_ubuntu $rootfs +if [ $? -ne 0 ]; then + echo "failed to install ubuntu lucid" + exit 1 +fi + +configure_ubuntu $rootfs $name +if [ $? -ne 0 ]; then + echo "failed to configure ubuntu lucid for a container" + exit 1 +fi + +copy_configuration $path $rootfs $name +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +if [ ! -z $clean ]; then + clean || exit 1 + exit 0 +fi diff -Nru lxc-0.7.2/templates/lxc-maverick.in lxc-0.7.4/templates/lxc-maverick.in --- lxc-0.7.2/templates/lxc-maverick.in 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/templates/lxc-maverick.in 2011-02-01 14:12:40.000000000 +0000 @@ -0,0 +1,292 @@ +#!/bin/bash + +# +# template script for generating ubuntu/maverick container for LXC +# +# This script is based on lxc-debian (Daniel Lezcano ) +# + +# Copyright © 2010 Wilhelm Meier +# Author: Wilhelm Meier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +configure_ubuntu() +{ + rootfs=$1 + hostname=$2 + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + + sed -i "s//$hostname/" $rootfs/etc/dhcp3/dhclient.conf + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + # set minimal hosts + cat < $rootfs/etc/hosts +127.0.0.1 localhost $hostname +EOF + + # suppress log level output for udev + sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf + + # tweak consoles + rm -f $rootfs/etc/init/tty{5,6}.conf + cp $rootfs/etc/init/tty1.conf $rootfs/etc/init/console.conf + sed -i 's/tty1/\/dev\/console/' $rootfs/etc/init/console.conf + + # don't let upstart mount anything from its builtin fs + echo "#Emptied out by lxc-maverick template" > $rootfs/lib/init/fstab + + echo "Please change root-password !" + echo "root:root" | chroot $rootfs chpasswd + + return 0 +} + +download_ubuntu() +{ + packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release,gnupg + + cache=$1 + arch=$2 + + # check the mini ubuntu was not already downloaded + mkdir -p "$cache/partial-$arch" + if [ $? -ne 0 ]; then + echo "Failed to create '$cache/partial-$arch' directory" + return 1 + fi + + # download a mini ubuntu into a cache + echo "Downloading ubuntu maverick minimal ..." + debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages maverick $cache/partial-$arch + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi + + mv "$1/partial-$arch" "$1/rootfs-$arch" + echo "Download complete." + + return 0 +} + +copy_ubuntu() +{ + cache=$1 + arch=$2 + rootfs=$3 + + # make a local copy of the miniubuntu + echo -n "Copying rootfs to $rootfs ..." + cp -a $cache/rootfs-$arch $rootfs || return 1 + return 0 +} + +install_ubuntu() +{ + cache="/var/cache/lxc/maverick" + rootfs=$1 + mkdir -p /var/lock/subsys/ + ( + flock -n -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + arch=$(arch) + if [ "$arch" == "x86_64" ]; then + arch=amd64 + fi + + if [ "$arch" == "i686" ]; then + arch=i386 + fi + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then + download_ubuntu $cache $arch + if [ $? -ne 0 ]; then + echo "Failed to download 'ubuntu maverick base'" + return 1 + fi + fi + + echo "Copy $cache/rootfs-$arch to $rootfs ... " + copy_ubuntu $cache $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>/var/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + + cat <> $path/config +lxc.utsname = $name + +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = $rootfs +lxc.mount = $path/fstab + +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +#lxc.cgroup.devices.allow = c 4:0 rwm +#lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm +EOF + + cat < $path/fstab +proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +devpts $rootfs/dev/pts devpts defaults 0 0 +sysfs $rootfs/sys sysfs defaults 0 0 +EOF + + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi + + return 0 +} + +clean() +{ + cache="/var/cache/lxc/maverick" + + if [ ! -e $cache ]; then + exit 0 + fi + + # lock, so we won't purge while someone is creating a repository + ( + flock -n -x 200 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi + + echo -n "Purging the download cache..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + + ) 200>/var/lock/subsys/lxc +} + +usage() +{ + cat < --clean +EOF + return 0 +} + +options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ ! -z "$clean" -a -z "$path" ]; then + clean || exit 1 + exit 0 +fi + +type debootstrap +if [ $? -ne 0 ]; then + echo "'debootstrap' command is missing" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +rootfs=$path/rootfs + +install_ubuntu $rootfs +if [ $? -ne 0 ]; then + echo "failed to install ubuntu maverick" + exit 1 +fi + +configure_ubuntu $rootfs $name +if [ $? -ne 0 ]; then + echo "failed to configure ubuntu maverick for a container" + exit 1 +fi + +copy_configuration $path $rootfs $name +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +if [ ! -z $clean ]; then + clean || exit 1 + exit 0 +fi diff -Nru lxc-0.7.2/templates/lxc-natty.in lxc-0.7.4/templates/lxc-natty.in --- lxc-0.7.2/templates/lxc-natty.in 1970-01-01 00:00:00.000000000 +0000 +++ lxc-0.7.4/templates/lxc-natty.in 2011-02-01 14:12:40.000000000 +0000 @@ -0,0 +1,293 @@ +#!/bin/bash + +# +# template script for generating ubuntu/natty container for LXC +# +# This script is based on lxc-debian (Daniel Lezcano ) +# + +# Copyright © 2010 Wilhelm Meier +# Author: Wilhelm Meier +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 2, as +# published by the Free Software Foundation. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +configure_ubuntu() +{ + rootfs=$1 + hostname=$2 + + # configure the network using the dhcp + cat < $rootfs/etc/network/interfaces +auto lo +iface lo inet loopback + +auto eth0 +iface eth0 inet dhcp +EOF + + # so you can 'ssh $hostname.' or 'ssh $hostname.local' + sed -i "s//$hostname/" $rootfs/etc/dhcp/dhclient.conf + + # set the hostname + cat < $rootfs/etc/hostname +$hostname +EOF + # set minimal hosts + cat < $rootfs/etc/hosts +127.0.0.1 localhost $hostname +EOF + + # suppress log level output for udev + sed -i "s/=\"err\"/=0/" $rootfs/etc/udev/udev.conf + + # tweak consoles + rm -f $rootfs/etc/init/tty{5,6}.conf + cp $rootfs/etc/init/tty1.conf $rootfs/etc/init/console.conf + sed -i 's/tty1/\/dev\/console/' $rootfs/etc/init/console.conf + + # don't let upstart mount anything from its builtin fs + echo "#Emptied out by lxc-natty template" > $rootfs/lib/init/fstab + + echo "Please change root-password !" + echo "root:root" | chroot $rootfs chpasswd + + return 0 +} + +download_ubuntu() +{ + packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,isc-dhcp-client,isc-dhcp-common,ssh,lsb-release,gnupg + + cache=$1 + arch=$2 + + # check the mini ubuntu was not already downloaded + mkdir -p "$cache/partial-$arch" + if [ $? -ne 0 ]; then + echo "Failed to create '$cache/partial-$arch' directory" + return 1 + fi + + # download a mini ubuntu into a cache + echo "Downloading ubuntu natty minimal ..." + debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages natty $cache/partial-$arch + if [ $? -ne 0 ]; then + echo "Failed to download the rootfs, aborting." + return 1 + fi + + mv "$1/partial-$arch" "$1/rootfs-$arch" + echo "Download complete." + + return 0 +} + +copy_ubuntu() +{ + cache=$1 + arch=$2 + rootfs=$3 + + # make a local copy of the miniubuntu + echo -n "Copying rootfs to $rootfs ..." + cp -a $cache/rootfs-$arch $rootfs || return 1 + return 0 +} + +install_ubuntu() +{ + cache="/var/cache/lxc/natty" + rootfs=$1 + mkdir -p /var/lock/subsys/ + ( + flock -n -x 200 + if [ $? -ne 0 ]; then + echo "Cache repository is busy." + return 1 + fi + + arch=$(arch) + if [ "$arch" == "x86_64" ]; then + arch=amd64 + fi + + if [ "$arch" == "i686" ]; then + arch=i386 + fi + + echo "Checking cache download in $cache/rootfs-$arch ... " + if [ ! -e "$cache/rootfs-$arch" ]; then + download_ubuntu $cache $arch + if [ $? -ne 0 ]; then + echo "Failed to download 'ubuntu natty base'" + return 1 + fi + fi + + echo "Copy $cache/rootfs-$arch to $rootfs ... " + copy_ubuntu $cache $arch $rootfs + if [ $? -ne 0 ]; then + echo "Failed to copy rootfs" + return 1 + fi + + return 0 + + ) 200>/var/lock/subsys/lxc + + return $? +} + +copy_configuration() +{ + path=$1 + rootfs=$2 + name=$3 + + cat <> $path/config +lxc.utsname = $name + +lxc.tty = 4 +lxc.pts = 1024 +lxc.rootfs = $rootfs +lxc.mount = $path/fstab + +lxc.cgroup.devices.deny = a +# /dev/null and zero +lxc.cgroup.devices.allow = c 1:3 rwm +lxc.cgroup.devices.allow = c 1:5 rwm +# consoles +lxc.cgroup.devices.allow = c 5:1 rwm +lxc.cgroup.devices.allow = c 5:0 rwm +#lxc.cgroup.devices.allow = c 4:0 rwm +#lxc.cgroup.devices.allow = c 4:1 rwm +# /dev/{,u}random +lxc.cgroup.devices.allow = c 1:9 rwm +lxc.cgroup.devices.allow = c 1:8 rwm +lxc.cgroup.devices.allow = c 136:* rwm +lxc.cgroup.devices.allow = c 5:2 rwm +# rtc +lxc.cgroup.devices.allow = c 254:0 rwm +EOF + + cat < $path/fstab +proc $rootfs/proc proc nodev,noexec,nosuid 0 0 +devpts $rootfs/dev/pts devpts defaults 0 0 +sysfs $rootfs/sys sysfs defaults 0 0 +EOF + + if [ $? -ne 0 ]; then + echo "Failed to add configuration" + return 1 + fi + + return 0 +} + +clean() +{ + cache="/var/cache/lxc/natty" + + if [ ! -e $cache ]; then + exit 0 + fi + + # lock, so we won't purge while someone is creating a repository + ( + flock -n -x 200 + if [ $? != 0 ]; then + echo "Cache repository is busy." + exit 1 + fi + + echo -n "Purging the download cache..." + rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 + exit 0 + + ) 200>/var/lock/subsys/lxc +} + +usage() +{ + cat < --clean +EOF + return 0 +} + +options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") +if [ $? -ne 0 ]; then + usage $(basename $0) + exit 1 +fi +eval set -- "$options" + +while true +do + case "$1" in + -h|--help) usage $0 && exit 0;; + -p|--path) path=$2; shift 2;; + -n|--name) name=$2; shift 2;; + -c|--clean) clean=$2; shift 2;; + --) shift 1; break ;; + *) break ;; + esac +done + +if [ ! -z "$clean" -a -z "$path" ]; then + clean || exit 1 + exit 0 +fi + +type debootstrap +if [ $? -ne 0 ]; then + echo "'debootstrap' command is missing" + exit 1 +fi + +if [ -z "$path" ]; then + echo "'path' parameter is required" + exit 1 +fi + +if [ "$(id -u)" != "0" ]; then + echo "This script should be run as 'root'" + exit 1 +fi + +rootfs=$path/rootfs + +install_ubuntu $rootfs +if [ $? -ne 0 ]; then + echo "failed to install ubuntu natty" + exit 1 +fi + +configure_ubuntu $rootfs $name +if [ $? -ne 0 ]; then + echo "failed to configure ubuntu natty for a container" + exit 1 +fi + +copy_configuration $path $rootfs $name +if [ $? -ne 0 ]; then + echo "failed write configuration file" + exit 1 +fi + +if [ ! -z $clean ]; then + clean || exit 1 + exit 0 +fi diff -Nru lxc-0.7.2/templates/lxc-ubuntu.in lxc-0.7.4/templates/lxc-ubuntu.in --- lxc-0.7.2/templates/lxc-ubuntu.in 2010-06-24 19:03:49.000000000 +0000 +++ lxc-0.7.4/templates/lxc-ubuntu.in 1970-01-01 00:00:00.000000000 +0000 @@ -1,369 +0,0 @@ -#!/bin/bash - -# -# template script for generating ubuntu/lucid container for LXC -# -# This script is based on lxc-debian (Daniel Lezcano ) -# - -# Copyright © 2010 Wilhelm Meier -# Author: Wilhelm Meier -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 2, as -# published by the Free Software Foundation. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -configure_ubuntu() -{ - rootfs=$1 - hostname=$2 - - # disable selinux in ubuntu - mkdir -p $rootfs/selinux - echo 0 > $rootfs/selinux/enforce - - # configure the network using the dhcp - cat < $rootfs/etc/network/interfaces -auto lo -iface lo inet loopback - -auto eth0 -iface eth0 inet dhcp -EOF - - # set the hostname - cat < $rootfs/etc/hostname -$hostname -EOF - # set minimal hosts - cat < $rootfs/etc/hosts -127.0.0.1 localhost $hostname -EOF - - # provide the lxc service - cat < $rootfs/etc/init/lxc.conf -# fake some events needed for correct startup other services - -description "Container Upstart" - -start on startup - -script - rm -rf /var/run/*.pid - rm -rf /var/run/network/* - /sbin/initctl emit stopped JOB=udevtrigger --no-wait - /sbin/initctl emit started JOB=udev --no-wait -end script -EOF - - # fix buggus runlevel with sshd - cat < $rootfs/etc/init/ssh.conf -# ssh - OpenBSD Secure Shell server -# -# The OpenSSH server provides secure shell access to the system. - -description "OpenSSH server" - -start on filesystem -stop on runlevel [!2345] - -expect fork -respawn -respawn limit 10 5 -umask 022 -# replaces SSHD_OOM_ADJUST in /etc/default/ssh -oom never - -pre-start script - test -x /usr/sbin/sshd || { stop; exit 0; } - test -e /etc/ssh/sshd_not_to_be_run && { stop; exit 0; } - test -c /dev/null || { stop; exit 0; } - - mkdir -p -m0755 /var/run/sshd -end script - -# if you used to set SSHD_OPTS in /etc/default/ssh, you can change the -# 'exec' line here instead -exec /usr/sbin/sshd -EOF - - cat < $rootfs/etc/init/console.conf -# console - getty -# -# This service maintains a console on tty1 from the point the system is -# started until it is shut down again. - -start on stopped rc RUNLEVEL=[2345] -stop on runlevel [!2345] - -respawn -exec /sbin/getty -8 38400 /dev/console -EOF - - cat < $rootfs/lib/init/fstab -# /lib/init/fstab: lxc system fstab -none /spu spufs gid=spu,optional 0 0 -none /tmp none defaults 0 0 -none /var/lock tmpfs nodev,noexec,nosuid,showthrough 0 0 -none /lib/init/rw tmpfs mode=0755,nosuid,optional 0 0 -EOF - - # reconfigure some services - if [ -z "$LANG" ]; then - chroot $rootfs locale-gen en_US.UTF-8 - chroot $rootfs update-locale LANG=en_US.UTF-8 - else - chroot $rootfs locale-gen $LANG - chroot $rootfs update-locale LANG=$LANG - fi - - # remove pointless services in a container - chroot $rootfs /usr/sbin/update-rc.d -f ondemand remove - - chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls u*.conf); do mv $f $f.orig; done' - chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls tty[2-9].conf); do mv $f $f.orig; done' - chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls plymouth*.conf); do mv $f $f.orig; done' - chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls hwclock*.conf); do mv $f $f.orig; done' - chroot $rootfs /bin/bash -c 'cd /etc/init; for f in $(ls module*.conf); do mv $f $f.orig; done' - - echo "Please change root-password !" - echo "root:root" | chroot $rootfs chpasswd - - return 0 -} - -download_ubuntu() -{ - packages=dialog,apt,apt-utils,resolvconf,iproute,inetutils-ping,vim,dhcp3-client,ssh,lsb-release - - cache=$1 - arch=$2 - - # check the mini ubuntu was not already downloaded - mkdir -p "$cache/partial-$arch" - if [ $? -ne 0 ]; then - echo "Failed to create '$cache/partial-$arch' directory" - return 1 - fi - - # download a mini ubuntu into a cache - echo "Downloading ubuntu minimal ..." - debootstrap --verbose --variant=minbase --components=main,universe --arch=$arch --include=$packages lucid $cache/partial-$arch - if [ $? -ne 0 ]; then - echo "Failed to download the rootfs, aborting." - return 1 - fi - - mv "$1/partial-$arch" "$1/rootfs-$arch" - echo "Download complete." - - return 0 -} - -copy_ubuntu() -{ - cache=$1 - arch=$2 - rootfs=$3 - - # make a local copy of the miniubuntu - echo -n "Copying rootfs to $rootfs ..." - cp -a $cache/rootfs-$arch $rootfs || return 1 - return 0 -} - -install_ubuntu() -{ - cache="/var/cache/lxc/ubuntu" - rootfs=$1 - mkdir -p /var/lock/subsys/ - ( - flock -n -x 200 - if [ $? -ne 0 ]; then - echo "Cache repository is busy." - return 1 - fi - - arch=$(arch) - if [ "$arch" == "x86_64" ]; then - arch=amd64 - fi - - if [ "$arch" == "i686" ]; then - arch=i386 - fi - - echo "Checking cache download in $cache/rootfs-$arch ... " - if [ ! -e "$cache/rootfs-$arch" ]; then - download_ubuntu $cache $arch - if [ $? -ne 0 ]; then - echo "Failed to download 'ubuntu base'" - return 1 - fi - fi - - echo "Copy $cache/rootfs-$arch to $rootfs ... " - copy_ubuntu $cache $arch $rootfs - if [ $? -ne 0 ]; then - echo "Failed to copy rootfs" - return 1 - fi - - return 0 - - ) 200>/var/lock/subsys/lxc - - return $? -} - -copy_configuration() -{ - path=$1 - rootfs=$2 - name=$3 - - cat <> $path/config -lxc.utsname = $name - -lxc.tty = 4 -lxc.pts = 1024 -lxc.rootfs = $rootfs -lxc.mount = $path/fstab - -lxc.cgroup.devices.deny = a -# /dev/null and zero -lxc.cgroup.devices.allow = c 1:3 rwm -lxc.cgroup.devices.allow = c 1:5 rwm -# consoles -lxc.cgroup.devices.allow = c 5:1 rwm -lxc.cgroup.devices.allow = c 5:0 rwm -lxc.cgroup.devices.allow = c 4:0 rwm -lxc.cgroup.devices.allow = c 4:1 rwm -# /dev/{,u}random -lxc.cgroup.devices.allow = c 1:9 rwm -lxc.cgroup.devices.allow = c 1:8 rwm -lxc.cgroup.devices.allow = c 136:* rwm -lxc.cgroup.devices.allow = c 5:2 rwm -# rtc -lxc.cgroup.devices.allow = c 254:0 rwm -EOF - - cat < $path/fstab -proc $rootfs/proc proc nodev,noexec,nosuid 0 0 -devpts $rootfs/dev/pts devpts defaults 0 0 -sysfs $rootfs/sys sysfs defaults 0 0 -EOF - - if [ $? -ne 0 ]; then - echo "Failed to add configuration" - return 1 - fi - - return 0 -} - -clean() -{ - cache="/var/cache/lxc/ubuntu" - - if [ ! -e $cache ]; then - exit 0 - fi - - # lock, so we won't purge while someone is creating a repository - ( - flock -n -x 200 - if [ $? != 0 ]; then - echo "Cache repository is busy." - exit 1 - fi - - echo -n "Purging the download cache..." - rm --preserve-root --one-file-system -rf $cache && echo "Done." || exit 1 - exit 0 - - ) 200>/var/lock/subsys/lxc -} - -usage() -{ - cat < --clean -EOF - return 0 -} - -options=$(getopt -o hp:n:c -l help,path:,name:,clean -- "$@") -if [ $? -ne 0 ]; then - usage $(basename $0) - exit 1 -fi -eval set -- "$options" - -while true -do - case "$1" in - -h|--help) usage $0 && exit 0;; - -p|--path) path=$2; shift 2;; - -n|--name) name=$2; shift 2;; - -c|--clean) clean=$2; shift 2;; - --) shift 1; break ;; - *) break ;; - esac -done - -if [ ! -z "$clean" -a -z "$path" ]; then - clean || exit 1 - exit 0 -fi - -type debootstrap -if [ $? -ne 0 ]; then - echo "'debootstrap' command is missing" - exit 1 -fi - -if [ -z "$path" ]; then - echo "'path' parameter is required" - exit 1 -fi - -if [ "$(id -u)" != "0" ]; then - echo "This script should be run as 'root'" - exit 1 -fi - -rootfs=$path/rootfs - -install_ubuntu $rootfs -if [ $? -ne 0 ]; then - echo "failed to install ubuntu" - exit 1 -fi - -configure_ubuntu $rootfs $name -if [ $? -ne 0 ]; then - echo "failed to configure ubuntu for a container" - exit 1 -fi - -copy_configuration $path $rootfs $name -if [ $? -ne 0 ]; then - echo "failed write configuration file" - exit 1 -fi - -if [ ! -z $clean ]; then - clean || exit 1 - exit 0 -fi diff -Nru lxc-0.7.2/templates/Makefile.am lxc-0.7.4/templates/Makefile.am --- lxc-0.7.2/templates/Makefile.am 2010-06-07 09:33:55.000000000 +0000 +++ lxc-0.7.4/templates/Makefile.am 2011-02-01 14:12:40.000000000 +0000 @@ -2,7 +2,10 @@ templates_SCRIPTS = \ lxc-debian \ - lxc-ubuntu \ + lxc-lenny \ + lxc-lucid \ + lxc-maverick \ + lxc-natty \ lxc-fedora \ lxc-busybox \ lxc-sshd diff -Nru lxc-0.7.2/templates/Makefile.in lxc-0.7.4/templates/Makefile.in --- lxc-0.7.2/templates/Makefile.in 2010-07-26 08:58:50.000000000 +0000 +++ lxc-0.7.4/templates/Makefile.in 2011-02-26 09:20:20.000000000 +0000 @@ -37,17 +37,18 @@ subdir = templates DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \ $(srcdir)/lxc-busybox.in $(srcdir)/lxc-debian.in \ - $(srcdir)/lxc-fedora.in $(srcdir)/lxc-sshd.in \ - $(srcdir)/lxc-ubuntu.in + $(srcdir)/lxc-fedora.in $(srcdir)/lxc-lenny.in \ + $(srcdir)/lxc-lucid.in $(srcdir)/lxc-maverick.in \ + $(srcdir)/lxc-natty.in $(srcdir)/lxc-sshd.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/config/acinclude.m4 \ - $(top_srcdir)/configure.ac + $(top_srcdir)/config/linux.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/src/config.h -CONFIG_CLEAN_FILES = lxc-debian lxc-ubuntu lxc-busybox lxc-fedora \ - lxc-sshd +CONFIG_CLEAN_FILES = lxc-lenny lxc-debian lxc-lucid lxc-maverick \ + lxc-natty lxc-busybox lxc-fedora lxc-sshd CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -109,6 +110,8 @@ LIBDIR = @LIBDIR@ LIBOBJS = @LIBOBJS@ LIBS = @LIBS@ +LINUX_DIR = @LINUX_DIR@ +LINUX_SRCARCH = @LINUX_SRCARCH@ LOCALSTATEDIR = @LOCALSTATEDIR@ LTLIBOBJS = @LTLIBOBJS@ LXCINITDIR = @LXCINITDIR@ @@ -188,7 +191,10 @@ templatesdir = @LXCTEMPLATEDIR@ templates_SCRIPTS = \ lxc-debian \ - lxc-ubuntu \ + lxc-lenny \ + lxc-lucid \ + lxc-maverick \ + lxc-natty \ lxc-fedora \ lxc-busybox \ lxc-sshd @@ -226,9 +232,15 @@ $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): +lxc-lenny: $(top_builddir)/config.status $(srcdir)/lxc-lenny.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ lxc-debian: $(top_builddir)/config.status $(srcdir)/lxc-debian.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ -lxc-ubuntu: $(top_builddir)/config.status $(srcdir)/lxc-ubuntu.in +lxc-lucid: $(top_builddir)/config.status $(srcdir)/lxc-lucid.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +lxc-maverick: $(top_builddir)/config.status $(srcdir)/lxc-maverick.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +lxc-natty: $(top_builddir)/config.status $(srcdir)/lxc-natty.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ lxc-busybox: $(top_builddir)/config.status $(srcdir)/lxc-busybox.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@