The following pull request was submitted through Github.
It can be accessed and reviewed at: https://github.com/lxc/lxc/pull/1114

This e-mail was sent by the LXC bot, direct replies will not reach the author
unless they happen to be subscribed to this list.

=== Description (from pull-request) ===
Attaching to a container with a configuration file in a non standard path used to work. We used it for template building. With the pty allocation changes this stopped because that part of the code uses the configuration struct, and has a new check which then errors with `container XY is not defined`. This patch copies over the `-f` switch from `lxc-start`. Alternatively it might be possible to restore support for the old config-less variant, but it seems to make more sense to just provide the same config path as was used with `lxc-start`.
From 7f062284cd63a4a5b04689d89ffbcfb705dfa0c3 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <[email protected]>
Date: Thu, 4 Aug 2016 11:23:54 +0200
Subject: [PATCH 1/2] add -f option to lxc-attach

Otherwise a container with a non-standard configuration file
can be started but not attached to.
Fixes the following case:
 # lxc-start -n ct -f /different/path/my.config
 # lxc-attach -n ct
 Error: container ct is not defined
---
 src/lxc/tools/lxc_attach.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c
index 58f658b..7116885 100644
--- a/src/lxc/tools/lxc_attach.c
+++ b/src/lxc/tools/lxc_attach.c
@@ -65,6 +65,7 @@ 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
 };
 
@@ -153,6 +154,7 @@ static int my_parser(struct lxc_arguments* args, int c, 
char* arg)
        case 'L':
                args->console_log = arg;
                break;
+       case 'f': args->rcfile = arg; break;
        }
 
        return 0;
@@ -202,7 +204,10 @@ Options :\n\
                     multiple times.\n\
       --keep-var    Keep an additional environment variable. Only\n\
                     applicable if --clear-env is specified. May be used\n\
-                    multiple times.\n",
+                    multiple times.\n\
+  -f, --rcfile=FILE\n\
+                    Load configuration file FILE\n\
+",
        .options  = my_longopts,
        .parser   = my_parser,
        .checker  = NULL,
@@ -373,6 +378,15 @@ int main(int argc, char *argv[])
        if (!c)
                exit(EXIT_FAILURE);
 
+       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(EXIT_FAILURE);
+               }
+       }
+
        if (!c->may_control(c)) {
                fprintf(stderr, "Insufficent privileges to control %s\n", 
c->name);
                lxc_container_put(c);

From 994d1cf043f5c96f0b6b3eec362e5a5b4b36cd94 Mon Sep 17 00:00:00 2001
From: Wolfgang Bumiller <[email protected]>
Date: Thu, 4 Aug 2016 11:28:37 +0200
Subject: [PATCH 2/2] whitespace cleanup

The rest of this block uses spaces instead of tabs already.
---
 src/lxc/tools/lxc_attach.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/lxc/tools/lxc_attach.c b/src/lxc/tools/lxc_attach.c
index 7116885..281f97a 100644
--- a/src/lxc/tools/lxc_attach.c
+++ b/src/lxc/tools/lxc_attach.c
@@ -198,7 +198,7 @@ Options :\n\
                     is the current default behaviour, but is likely to\n\
                     change in the future.\n\
   -L, --pty-log=FILE\n\
-                   Log pty output to FILE\n\
+                    Log pty output to FILE\n\
   -v, --set-var     Set an additional variable that is seen by the\n\
                     attached program in the container. May be specified\n\
                     multiple times.\n\
_______________________________________________
lxc-devel mailing list
[email protected]
http://lists.linuxcontainers.org/listinfo/lxc-devel

Reply via email to