lxc_list_init(&new->keepcaps);
lxc_list_init(&new->id_map);
lxc_list_init(&new->includes);
+ lxc_list_init(&new->aliens);
for (i=0; i<NUM_LXC_HOOKS; i++)
lxc_list_init(&new->hooks[i]);
lxc_list_init(&new->groups);
free(conf->saved_nics);
}
+static inline void lxc_clear_aliens(struct lxc_conf *conf)
+{
+ struct lxc_list *it,*next;
+
+ lxc_list_for_each_safe(it, &conf->aliens, next) {
+ lxc_list_del(it);
+ free(it->elem);
+ free(it);
+ }
+}
+
static inline void lxc_clear_includes(struct lxc_conf *conf)
{
struct lxc_list *it,*next;
/* list of included files */
struct lxc_list includes;
+ /* config entries which are not "lxc.*" are aliens */
+ struct lxc_list aliens;
};
int run_lxc_hooks(const char *name, char *hook, struct lxc_conf *conf,
return 0;
}
+static int store_martian_option(char *line, void *data)
+{
+ struct lxc_conf *conf = data;
+ char *str;
+ struct lxc_list *list;
+ size_t len = strlen(line);
+
+ if (!conf->unexpanded)
+ return 0;
+ list = malloc(sizeof(*list));
+ if (!list)
+ return -1;
+ lxc_list_init(list);
+ str = malloc(len+1);
+ if (!str) {
+ free(list);
+ return -1;
+ }
+ strncpy(str, line, len);
+ len[len] = '\0';
+ list->elem = str;
+ lxc_list_add_tail(&conf->aliens, list);
+ return 0;
+}
+
static int parse_line(char *buffer, void *data)
{
struct lxc_config_t *config;
line += lxc_char_left_gc(line, strlen(line));
- /* martian option - ignoring it, the commented lines beginning by '#'
- * fall in this case
- */
- if (strncmp(line, "lxc.", 4))
+ /* ignore comments */
+ if (line[0] == '#')
goto out;
+ /* martian option - save it in the unexpanded config only */
+ if (strncmp(line, "lxc.", 4)) {
+ ret = store_martian_option(line, data);
+ goto out;
+ }
+
ret = -1;
dot = strstr(line, "=");
struct lxc_list *it;
int i;
+ /* first write any includes */
lxc_list_for_each(it, &c->includes) {
fprintf(fout, "lxc.include = %s\n", (char *)it->elem);
}
+ /* now write any aliens */
+ lxc_list_for_each(it, &c->aliens) {
+ fprintf(fout, "%s\n", (char *)it->elem);
+ }
+
if (c->fstab)
fprintf(fout, "lxc.mount = %s\n", c->fstab);
lxc_list_for_each(it, &c->mount_list) {