conf: check for successful mount entry parse

Since liblxc is completely in control of the mount entry file we should only consider a parse successful when EOF is reached. Closes #2798. Signed-off-by: 's avatarChristian Brauner <christian.brauner@ubuntu.com>
parent 3309e10c
...@@ -2336,11 +2336,12 @@ static int mount_file_entries(const struct lxc_conf *conf, ...@@ -2336,11 +2336,12 @@ static int mount_file_entries(const struct lxc_conf *conf,
const struct lxc_rootfs *rootfs, FILE *file, const struct lxc_rootfs *rootfs, FILE *file,
const char *lxc_name, const char *lxc_path) const char *lxc_name, const char *lxc_path)
{ {
char buf[4096]; char buf[PATH_MAX];
struct mntent mntent; struct mntent mntent;
int ret = -1;
while (getmntent_r(file, &mntent, buf, sizeof(buf))) { while (getmntent_r(file, &mntent, buf, sizeof(buf))) {
int ret;
if (!rootfs->path) if (!rootfs->path)
ret = mount_entry_on_systemfs(&mntent); ret = mount_entry_on_systemfs(&mntent);
else if (mntent.mnt_dir[0] != '/') else if (mntent.mnt_dir[0] != '/')
...@@ -2348,14 +2349,17 @@ static int mount_file_entries(const struct lxc_conf *conf, ...@@ -2348,14 +2349,17 @@ static int mount_file_entries(const struct lxc_conf *conf,
lxc_name, lxc_path); lxc_name, lxc_path);
else else
ret = mount_entry_on_absolute_rootfs(&mntent, rootfs, ret = mount_entry_on_absolute_rootfs(&mntent, rootfs,
lxc_name, lxc_path); lxc_name, lxc_path);
if (ret < 0) if (ret < 0)
return -1; return -1;
} }
ret = 0;
INFO("Finished setting up mounts"); if (!feof(file) || ferror(file)) {
return ret; ERROR("Failed to parse mount entries");
return -1;
}
return 0;
} }
static int setup_mount(const struct lxc_conf *conf, static int setup_mount(const struct lxc_conf *conf,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment