Skip to content

lxc-attach --rcfile: original config file is loaded before given config file #3656

Description

@r10r

Required information

lxc version: 4.0.0-devel

Issue description

The original configuration file is loaded first, even when an alternate config file is specified.
I think the original configuration file should never be loaded when an alternate config file is specified.

While testing backwards compatibility for a new setting that introduced a new config key (e.g lxc.init.groups)
I noticed that it is not possible to use lxc-attach --rcfile <rcfile without new config key> to load an alternate config file without that config key, because the original config file is always loaded first.

The following test case should explain it:

lxc-create -n test-lxc-attach -t busybox
lxc-start -n test-lxc-attach
cd /var/lib/lxc/test-lxc-attach
cp config config.old
# modify the configuration to simulate a new configuration key
echo 'lxc.new.setting = foobar' >> config
# try to attach without the new configuration key
lxc-attach -n test-lxc-attach --rcfile ./config.old
lxc-attach: test-lxc-attach: confile.c: parse_line: 2912 Invalid argument - Unknown configuration key "lxc.new.setting"
lxc-attach: test-lxc-attach: parse.c: lxc_file_for_each_line_mmap: 131 Failed to parse config file "/usr/local/var/lib/lxc/test-lxc-attach/config" at line "lxc.new.setting = foobar"
Failed to load config for test-lxc-attach

I assume that this affects other tools as well, but this has to be investigated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugConfirmed to be a bugEasyGood for new contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions