]> git.ipfire.org Git - thirdparty/lxc.git/commit
config: fix the handling of lxc.hook and hwaddrs in unexpanded config
authorSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 1 Sep 2014 20:01:20 +0000 (20:01 +0000)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 19 Sep 2014 20:54:33 +0000 (16:54 -0400)
commit67702c2129c462b5e8124020a496fbf6b7ae5540
treed38ecbe366231cd185f552dba15ccd83907a1721
parentde9a4bfc2c488aef0055a25af834be9b22738cf0
config: fix the handling of lxc.hook and hwaddrs in unexpanded config

And add a testcase.

The code to update hwaddrs in a clone was walking through the container
configuration and re-printing all network entries.  However network
entries from an include file which should not be printed out were being
added to the unexpanded config.  With this patch, at clone we simply
update the hwaddr in-place in the unexpanded configuration file, making
sure to make the same update to the expanded network configuration.

The code to update out lxc.hook statements had the same problem.
We also update it in-place in the unexpanded configuration, though
we mirror the logic we use when updating the expanded configuration.
(Perhaps that should be changed, to simplify future updates)

This code isn't particularly easy to review, so testcases are added
to make sure that (1) extra lxc.network entries are not added (or
removed), even if they are present in an included file, (2) lxc.hook
entries are not added, (3) hwaddr entries are updated, and (4)
the lxc.hook entries are properly updated (only when they should be).

Reported-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
src/lxc/confile.c
src/lxc/confile.h
src/lxc/lxccontainer.c
src/tests/Makefile.am
src/tests/lxc-test-cloneconfig [new file with mode: 0755]