diff --git a/Makefile b/Makefile index 3f6b4fd..a896a1c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,8 @@ RELEASE=4.2 PACKAGE=lxc-pve -LXCVER=2.0.3 -DEBREL=4 +LXCVER=2.0.4 +DEBREL=1 SRCDIR=lxc SRCTAR=${SRCDIR}.tgz @@ -30,7 +30,7 @@ deb ${DEBS}: ${SRCTAR} .PHONY: download download ${SRCTAR}: rm -rf ${SRCDIR} ${SRCTAR} - git clone -b stable-2.0 git://github.com/lxc/lxc + git clone -b lxc-${LXCVER} git://github.com/lxc/lxc tar czf ${SRCTAR}.tmp ${SRCDIR} mv ${SRCTAR}.tmp ${SRCTAR} diff --git a/debian/changelog b/debian/changelog index 9819b65..ff4794a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +lxc (2.0.4-1) unstable; urgency=medium + + * update to lxc-2.0.4 + + * add --rcfile to the common options list + + -- Proxmox Support Team Tue, 16 Aug 2016 09:43:59 +0200 + lxc (2.0.3-4) unstable; urgency=medium * use dh_apparmor for the lxc-containers profile diff --git a/debian/patches/0001-conf-set-pty_info-to-NULL-after-free.patch b/debian/patches/0001-conf-set-pty_info-to-NULL-after-free.patch deleted file mode 100644 index 795ad9c..0000000 --- a/debian/patches/0001-conf-set-pty_info-to-NULL-after-free.patch +++ /dev/null @@ -1,30 +0,0 @@ -From e00c024230e457a0f37ea5c90bd8caac0c30020e Mon Sep 17 00:00:00 2001 -From: Wolfgang Bumiller -Date: Thu, 28 Jul 2016 11:52:18 +0200 -Subject: [PATCH] conf: set pty_info to NULL after free - -This fixes a double free corruption on container-requested -reboots when lxc_spawn() fails before receiving the ttys, as -lxc_fini() (part of __lxc_start()'s cleanup) calls -lxc_delete_tty(). - -Signed-off-by: Wolfgang Bumiller ---- - src/lxc/conf.c | 1 + - 1 file changed, 1 insertion(+) - -diff --git a/src/lxc/conf.c b/src/lxc/conf.c -index 48a2978..1e330ac 100644 ---- a/src/lxc/conf.c -+++ b/src/lxc/conf.c -@@ -3327,6 +3327,7 @@ void lxc_delete_tty(struct lxc_tty_info *tty_info) - } - - free(tty_info->pty_info); -+ tty_info->pty_info = NULL; - tty_info->nbtty = 0; - } - --- -2.1.4 - diff --git a/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch b/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch new file mode 100644 index 0000000..a1e2e2f --- /dev/null +++ b/debian/patches/0001-tools-move-rcfile-to-the-common-options-list.patch @@ -0,0 +1,427 @@ +From dacc363d7d21434b764d95e4bd3d740c8995e951 Mon Sep 17 00:00:00 2001 +From: Wolfgang Bumiller +Date: Fri, 12 Aug 2016 12:21:22 +0200 +Subject: [PATCH 1/3] tools: move --rcfile to the common options list + +In almost all commands it's a useful addition to the -n +switch which is a common option, too. + +Signed-off-by: Wolfgang Bumiller +--- + src/lxc/arguments.c | 1 + + src/lxc/arguments.h | 2 ++ + src/lxc/tools/lxc_attach.c | 1 - + src/lxc/tools/lxc_cgroup.c | 12 +++++++++++- + src/lxc/tools/lxc_checkpoint.c | 10 ++++++++++ + src/lxc/tools/lxc_console.c | 12 +++++++++++- + src/lxc/tools/lxc_copy.c | 11 ++++++++++- + src/lxc/tools/lxc_destroy.c | 12 +++++++++++- + src/lxc/tools/lxc_device.c | 11 ++++++++++- + src/lxc/tools/lxc_freeze.c | 12 +++++++++++- + src/lxc/tools/lxc_info.c | 12 +++++++++++- + src/lxc/tools/lxc_snapshot.c | 12 +++++++++++- + src/lxc/tools/lxc_stop.c | 11 ++++++++++- + src/lxc/tools/lxc_unfreeze.c | 12 +++++++++++- + src/lxc/tools/lxc_wait.c | 12 +++++++++++- + 15 files changed, 131 insertions(+), 12 deletions(-) + +diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c +index c2f7b67..0d2b203 100644 +--- a/src/lxc/arguments.c ++++ b/src/lxc/arguments.c +@@ -203,6 +203,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args, + case 'o': args->log_file = optarg; break; + case 'l': args->log_priority = optarg; break; + case 'q': args->quiet = 1; break; ++ case OPT_RCFILE: args->rcfile = optarg; break; + case 'P': + remove_trailing_slashes(optarg); + ret = lxc_arguments_lxcpath_add(args, optarg); +diff --git a/src/lxc/arguments.h b/src/lxc/arguments.h +index f68f8ab..39bedf5 100644 +--- a/src/lxc/arguments.h ++++ b/src/lxc/arguments.h +@@ -151,11 +151,13 @@ struct lxc_arguments { + {"logfile", required_argument, 0, 'o'}, \ + {"logpriority", required_argument, 0, 'l'}, \ + {"lxcpath", required_argument, 0, 'P'}, \ ++ {"rcfile", required_argument, 0, OPT_RCFILE}, \ + {0, 0, 0, 0} + + /* option keys for long only options */ + #define OPT_USAGE 0x1000 + #define OPT_VERSION OPT_USAGE-1 ++#define OPT_RCFILE OPT_USAGE-2 + + extern int lxc_arguments_parse(struct lxc_arguments *args, + int argc, char *const argv[]); +diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c +index 281f97a..14c724a 100644 +--- a/src/lxc/tools/lxc_attach.c ++++ b/src/lxc/tools/lxc_attach.c +@@ -65,7 +65,6 @@ static const struct option my_longopts[] = { + {"keep-var", required_argument, 0, 502}, + {"set-var", required_argument, 0, 'v'}, + {"pty-log", required_argument, 0, 'L'}, +- {"rcfile", required_argument, 0, 'f'}, + LXC_COMMON_OPTIONS + }; + +diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c +index dd60fd1..c644501 100644 +--- a/src/lxc/tools/lxc_cgroup.c ++++ b/src/lxc/tools/lxc_cgroup.c +@@ -56,7 +56,8 @@ Get or set the value of a state object (for example, 'cpuset.cpus')\n\ + in the container's cgroup for the corresponding subsystem.\n\ + \n\ + Options :\n\ +- -n, --name=NAME NAME of the container", ++ -n, --name=NAME NAME of the container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = NULL, + .checker = my_checker, +@@ -84,6 +85,15 @@ int main(int argc, char *argv[]) + if (!c) + return 1; + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ ERROR("Failed to load rcfile"); ++ lxc_container_put(c); ++ return 1; ++ } ++ } ++ + if (!c->may_control(c)) { + ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c +index 7130245..bc18b80 100644 +--- a/src/lxc/tools/lxc_checkpoint.c ++++ b/src/lxc/tools/lxc_checkpoint.c +@@ -114,6 +114,7 @@ Options :\n\ + Restore options:\n\ + -d, --daemon Daemonize the container (default)\n\ + -F, --foreground Start with the current tty attached to /dev/console\n\ ++ --rcfile=FILE Load configuration file FILE\n\ + ", + .options = my_longopts, + .parser = my_parser, +@@ -214,6 +215,15 @@ int main(int argc, char *argv[]) + exit(1); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ exit(1); ++ } ++ } ++ + if (!c->may_control(c)) { + fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c +index adbd7e0..8a4d1c0 100644 +--- a/src/lxc/tools/lxc_console.c ++++ b/src/lxc/tools/lxc_console.c +@@ -80,7 +80,8 @@ lxc-console logs on the container with the identifier NAME\n\ + Options :\n\ + -n, --name=NAME NAME of the container\n\ + -t, --tty=NUMBER console tty number\n\ +- -e, --escape=PREFIX prefix for escape command\n", ++ -e, --escape=PREFIX prefix for escape command\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .checker = NULL, +@@ -112,6 +113,15 @@ int main(int argc, char *argv[]) + exit(EXIT_FAILURE); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } ++ } ++ + if (!c->may_control(c)) { + fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c +index 3257ab7..c81c077 100644 +--- a/src/lxc/tools/lxc_copy.c ++++ b/src/lxc/tools/lxc_copy.c +@@ -126,7 +126,8 @@ Options :\n\ + -D, --keedata pass together with -e start a persistent snapshot \n\ + -K, --keepname keep the hostname of the original container\n\ + -- hook options arguments passed to the hook program\n\ +- -M, --keepmac keep the MAC address of the original container\n", ++ -M, --keepmac keep the MAC address of the original container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .task = CLONE, +@@ -210,6 +211,14 @@ int main(int argc, char *argv[]) + if (!c) + exit(ret); + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ goto out; ++ } ++ } ++ + if (!c->may_control(c)) { + if (!my_args.quiet) + fprintf(stderr, "Insufficent privileges to control %s\n", c->name); +diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c +index b521739..50fd708 100644 +--- a/src/lxc/tools/lxc_destroy.c ++++ b/src/lxc/tools/lxc_destroy.c +@@ -53,7 +53,8 @@ lxc-destroy destroys a container with the identifier NAME\n\ + Options :\n\ + -n, --name=NAME NAME of the container\n\ + -s, --snapshots destroy including all snapshots\n\ +- -f, --force wait for the container to shut down\n", ++ -f, --force wait for the container to shut down\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .checker = NULL, +@@ -88,6 +89,15 @@ int main(int argc, char *argv[]) + exit(EXIT_FAILURE); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } ++ } ++ + if (!c->may_control(c)) { + if (!quiet) + fprintf(stderr, "Insufficent privileges to control %s\n", my_args.name); +diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c +index 0c9e066..0f1ee8b 100644 +--- a/src/lxc/tools/lxc_device.c ++++ b/src/lxc/tools/lxc_device.c +@@ -53,7 +53,8 @@ static struct lxc_arguments my_args = { + lxc-device attach or detach DEV to or from container.\n\ + \n\ + Options :\n\ +- -n, --name=NAME NAME of the container", ++ -n, --name=NAME NAME of the container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = NULL, + .checker = NULL, +@@ -125,6 +126,14 @@ int main(int argc, char *argv[]) + goto err; + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ ERROR("Failed to load rcfile"); ++ goto err1; ++ } ++ } ++ + if (!c->is_running(c)) { + ERROR("Container %s is not running.", c->name); + goto err1; +diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c +index ea8bd3e..d0239bf 100644 +--- a/src/lxc/tools/lxc_freeze.c ++++ b/src/lxc/tools/lxc_freeze.c +@@ -47,7 +47,8 @@ static struct lxc_arguments my_args = { + lxc-freeze freezes a container with the identifier NAME\n\ + \n\ + Options :\n\ +- -n, --name=NAME NAME of the container", ++ -n, --name=NAME NAME of the container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = NULL, + .checker = NULL, +@@ -74,6 +75,15 @@ int main(int argc, char *argv[]) + exit(1); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ ERROR("Failed to load rcfile"); ++ lxc_container_put(c); ++ exit(1); ++ } ++ } ++ + if (!c->may_control(c)) { + ERROR("Insufficent privileges to control %s:%s", my_args.lxcpath[0], my_args.name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c +index 58ff619..e833697 100644 +--- a/src/lxc/tools/lxc_info.c ++++ b/src/lxc/tools/lxc_info.c +@@ -93,7 +93,8 @@ Options :\n\ + -p, --pid shows the process id of the init container\n\ + -S, --stats shows usage stats\n\ + -H, --no-humanize shows stats as raw numbers, not humanized\n\ +- -s, --state shows the state of the container\n", ++ -s, --state shows the state of the container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .name = NULL, + .options = my_longopts, + .parser = my_parser, +@@ -295,6 +296,15 @@ static int print_info(const char *name, const char *lxcpath) + return -1; + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ return -1; ++ } ++ } ++ + if (!c->may_control(c)) { + fprintf(stderr, "Insufficent privileges to control %s\n", c->name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c +index 8f44891..aa9b6fe 100644 +--- a/src/lxc/tools/lxc_snapshot.c ++++ b/src/lxc/tools/lxc_snapshot.c +@@ -62,7 +62,8 @@ Options :\n\ + -d, --destroy=NAME destroy snapshot NAME, e.g. 'snap0'\n\ + use ALL to destroy all snapshots\n\ + -c, --comment=FILE add FILE as a comment\n\ +- -C, --showcomments show snapshot comments\n", ++ -C, --showcomments show snapshot comments\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .checker = NULL, +@@ -107,6 +108,15 @@ int main(int argc, char *argv[]) + exit(EXIT_FAILURE); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } ++ } ++ + if (!c->may_control(c)) { + fprintf(stderr, "Insufficent privileges to control %s\n", + my_args.name); +diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c +index 10ddce6..bbe1f1c 100644 +--- a/src/lxc/tools/lxc_stop.c ++++ b/src/lxc/tools/lxc_stop.c +@@ -75,7 +75,8 @@ Options :\n\ + -t, --timeout=T wait T seconds before hard-stopping\n\ + -k, --kill kill container rather than request clean shutdown\n\ + --nolock Avoid using API locks\n\ +- --nokill Only request clean shutdown, don't force kill after timeout\n", ++ --nokill Only request clean shutdown, don't force kill after timeout\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .checker = NULL, +@@ -203,6 +204,14 @@ int main(int argc, char *argv[]) + goto out; + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ goto out; ++ } ++ } ++ + if (!c->may_control(c)) { + fprintf(stderr, "Insufficent privileges to control %s\n", c->name); + goto out; +diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c +index 3a13d37..b7bbea6 100644 +--- a/src/lxc/tools/lxc_unfreeze.c ++++ b/src/lxc/tools/lxc_unfreeze.c +@@ -45,7 +45,8 @@ static struct lxc_arguments my_args = { + lxc-unfreeze unfreezes a container with the identifier NAME\n\ + \n\ + Options :\n\ +- -n, --name=NAME NAME of the container\n", ++ -n, --name=NAME NAME of the container\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = NULL, + .checker = NULL, +@@ -78,6 +79,15 @@ int main(int argc, char *argv[]) + exit(1); + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ ERROR("Failed to load rcfile"); ++ lxc_container_put(c); ++ exit(1); ++ } ++ } ++ + if (!c->unfreeze(c)) { + ERROR("Failed to unfreeze %s:%s", my_args.lxcpath[0], my_args.name); + lxc_container_put(c); +diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c +index 712ba52..deeff98 100644 +--- a/src/lxc/tools/lxc_wait.c ++++ b/src/lxc/tools/lxc_wait.c +@@ -72,7 +72,8 @@ Options :\n\ + -s, --state=STATE ORed states to wait for\n\ + STOPPED, STARTING, RUNNING, STOPPING,\n\ + ABORTING, FREEZING, FROZEN, THAWED\n\ +- -t, --timeout=TMO Seconds to wait for state changes\n", ++ -t, --timeout=TMO Seconds to wait for state changes\n\ ++ --rcfile=FILE Load configuration file FILE\n", + .options = my_longopts, + .parser = my_parser, + .checker = my_checker, +@@ -104,6 +105,15 @@ int main(int argc, char *argv[]) + return 1; + } + ++ if (my_args.rcfile) { ++ c->clear_config(c); ++ if (!c->load_config(c, my_args.rcfile)) { ++ fprintf(stderr, "Failed to load rcfile\n"); ++ lxc_container_put(c); ++ return 1; ++ } ++ } ++ + if (!c->wait(c, my_args.states, my_args.timeout)) { + lxc_container_put(c); + return 1; +-- +2.1.4 + diff --git a/debian/patches/0002-tools-set-configfile-after-load_config.patch b/debian/patches/0002-tools-set-configfile-after-load_config.patch new file mode 100644 index 0000000..b32b49e --- /dev/null +++ b/debian/patches/0002-tools-set-configfile-after-load_config.patch @@ -0,0 +1,245 @@ +From fb259e5b431260c61a2afcee862f7e836d7d8cf9 Mon Sep 17 00:00:00 2001 +From: Wolfgang Bumiller +Date: Fri, 12 Aug 2016 14:49:37 +0200 +Subject: [PATCH 2/3] tools: set configfile after load_config + +In order to cause c->is_defined() to become true. + +Signed-off-by: Wolfgang Bumiller +--- + src/lxc/tools/lxc_attach.c | 6 ++++++ + src/lxc/tools/lxc_cgroup.c | 6 ++++++ + src/lxc/tools/lxc_checkpoint.c | 6 ++++++ + src/lxc/tools/lxc_console.c | 6 ++++++ + src/lxc/tools/lxc_copy.c | 5 +++++ + src/lxc/tools/lxc_destroy.c | 6 ++++++ + src/lxc/tools/lxc_device.c | 5 +++++ + src/lxc/tools/lxc_freeze.c | 6 ++++++ + src/lxc/tools/lxc_info.c | 6 ++++++ + src/lxc/tools/lxc_snapshot.c | 6 ++++++ + src/lxc/tools/lxc_stop.c | 5 +++++ + src/lxc/tools/lxc_unfreeze.c | 6 ++++++ + src/lxc/tools/lxc_wait.c | 6 ++++++ + 13 files changed, 75 insertions(+) + +diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c +index 14c724a..e436ae9 100644 +--- a/src/lxc/tools/lxc_attach.c ++++ b/src/lxc/tools/lxc_attach.c +@@ -384,6 +384,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(EXIT_FAILURE); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ ERROR("Out of memory setting new config filename"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_cgroup.c b/src/lxc/tools/lxc_cgroup.c +index c644501..4dc2682 100644 +--- a/src/lxc/tools/lxc_cgroup.c ++++ b/src/lxc/tools/lxc_cgroup.c +@@ -92,6 +92,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + return 1; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ ERROR("Out of memory setting new config filename"); ++ lxc_container_put(c); ++ return 1; ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_checkpoint.c b/src/lxc/tools/lxc_checkpoint.c +index bc18b80..6de3d23 100644 +--- a/src/lxc/tools/lxc_checkpoint.c ++++ b/src/lxc/tools/lxc_checkpoint.c +@@ -222,6 +222,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(1); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ exit(1); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_console.c b/src/lxc/tools/lxc_console.c +index 8a4d1c0..829c908 100644 +--- a/src/lxc/tools/lxc_console.c ++++ b/src/lxc/tools/lxc_console.c +@@ -120,6 +120,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(EXIT_FAILURE); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_copy.c b/src/lxc/tools/lxc_copy.c +index c81c077..f7dc8b2 100644 +--- a/src/lxc/tools/lxc_copy.c ++++ b/src/lxc/tools/lxc_copy.c +@@ -217,6 +217,11 @@ int main(int argc, char *argv[]) + fprintf(stderr, "Failed to load rcfile\n"); + goto out; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ goto out; ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_destroy.c b/src/lxc/tools/lxc_destroy.c +index 50fd708..3f46415 100644 +--- a/src/lxc/tools/lxc_destroy.c ++++ b/src/lxc/tools/lxc_destroy.c +@@ -96,6 +96,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(EXIT_FAILURE); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_device.c b/src/lxc/tools/lxc_device.c +index 0f1ee8b..49af062 100644 +--- a/src/lxc/tools/lxc_device.c ++++ b/src/lxc/tools/lxc_device.c +@@ -132,6 +132,11 @@ int main(int argc, char *argv[]) + ERROR("Failed to load rcfile"); + goto err1; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ ERROR("Out of memory setting new config filename"); ++ goto err1; ++ } + } + + if (!c->is_running(c)) { +diff --git a/src/lxc/tools/lxc_freeze.c b/src/lxc/tools/lxc_freeze.c +index d0239bf..ac0802e 100644 +--- a/src/lxc/tools/lxc_freeze.c ++++ b/src/lxc/tools/lxc_freeze.c +@@ -82,6 +82,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(1); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ ERROR("Out of memory setting new config filename"); ++ lxc_container_put(c); ++ exit(1); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_info.c b/src/lxc/tools/lxc_info.c +index e833697..08c698d 100644 +--- a/src/lxc/tools/lxc_info.c ++++ b/src/lxc/tools/lxc_info.c +@@ -303,6 +303,12 @@ static int print_info(const char *name, const char *lxcpath) + lxc_container_put(c); + return -1; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ return -1; ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_snapshot.c b/src/lxc/tools/lxc_snapshot.c +index aa9b6fe..a1166bc 100644 +--- a/src/lxc/tools/lxc_snapshot.c ++++ b/src/lxc/tools/lxc_snapshot.c +@@ -115,6 +115,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(EXIT_FAILURE); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ exit(EXIT_FAILURE); ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_stop.c b/src/lxc/tools/lxc_stop.c +index bbe1f1c..cb7cfe2 100644 +--- a/src/lxc/tools/lxc_stop.c ++++ b/src/lxc/tools/lxc_stop.c +@@ -210,6 +210,11 @@ int main(int argc, char *argv[]) + fprintf(stderr, "Failed to load rcfile\n"); + goto out; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ goto out; ++ } + } + + if (!c->may_control(c)) { +diff --git a/src/lxc/tools/lxc_unfreeze.c b/src/lxc/tools/lxc_unfreeze.c +index b7bbea6..24faf5e 100644 +--- a/src/lxc/tools/lxc_unfreeze.c ++++ b/src/lxc/tools/lxc_unfreeze.c +@@ -86,6 +86,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + exit(1); + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ ERROR("Out of memory setting new config filename"); ++ lxc_container_put(c); ++ exit(1); ++ } + } + + if (!c->unfreeze(c)) { +diff --git a/src/lxc/tools/lxc_wait.c b/src/lxc/tools/lxc_wait.c +index deeff98..61fd869 100644 +--- a/src/lxc/tools/lxc_wait.c ++++ b/src/lxc/tools/lxc_wait.c +@@ -112,6 +112,12 @@ int main(int argc, char *argv[]) + lxc_container_put(c); + return 1; + } ++ c->configfile = strdup(my_args.rcfile); ++ if (!c->configfile) { ++ fprintf(stderr, "Out of memory setting new config filename\n"); ++ lxc_container_put(c); ++ return 1; ++ } + } + + if (!c->wait(c, my_args.states, my_args.timeout)) { +-- +2.1.4 + diff --git a/debian/patches/0003-doc-add-rcfile-to-common-opts.patch b/debian/patches/0003-doc-add-rcfile-to-common-opts.patch new file mode 100644 index 0000000..7b974cc --- /dev/null +++ b/debian/patches/0003-doc-add-rcfile-to-common-opts.patch @@ -0,0 +1,39 @@ +From 2e62657e65daad24f4c11744ce133e8c4d75df02 Mon Sep 17 00:00:00 2001 +From: Wolfgang Bumiller +Date: Fri, 12 Aug 2016 14:55:42 +0200 +Subject: [PATCH 3/3] doc: add --rcfile to common opts + +Signed-off-by: Wolfgang Bumiller +--- + doc/common_options.sgml.in | 15 +++++++++++++++ + 1 file changed, 15 insertions(+) + +diff --git a/doc/common_options.sgml.in b/doc/common_options.sgml.in +index 38783dd..978c0ba 100644 +--- a/doc/common_options.sgml.in ++++ b/doc/common_options.sgml.in +@@ -107,6 +107,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + + + ++ ++ ++ ++ Specify the configuration file to configure the virtualization ++ and isolation functionalities for the container. ++ ++ ++ This configuration file if present will be used even if there is ++ already a configuration file present in the previously created ++ container (via lxc-create). ++ ++ ++ ++ ++ + + + +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 72bfbb4..4a9c82a 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -6,4 +6,6 @@ include-linux-sched.patch use-var-lib-vz-as-default-dir.patch #do-not-use-config-path-for-rootfs.patch run-lxcnetaddbr.patch -0001-conf-set-pty_info-to-NULL-after-free.patch +0001-tools-move-rcfile-to-the-common-options-list.patch +0002-tools-set-configfile-after-load_config.patch +0003-doc-add-rcfile-to-common-opts.patch diff --git a/lxc.tgz b/lxc.tgz index 7622560..0bbda7a 100644 Binary files a/lxc.tgz and b/lxc.tgz differ