summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Golle2021-07-14 16:47:22 +0000
committerDaniel Golle2021-07-15 17:08:03 +0000
commit15997e67a559d3477d34613062725689fbfeab93 (patch)
treed55b0e273fcb5808433d94171ea1a45f33697d71
parent92aba532aae5d8650ca7d2ee1104e206d1e91c5d (diff)
downloadprocd-15997e67a559d3477d34613062725689fbfeab93.tar.gz
jail: allow rootfs to be a symbolic link
Follow symbolic link to rootfs so we can use autofs symlinks in /mnt to reference volumes in config.json. Signed-off-by: Daniel Golle <daniel@makrotopia.org>
-rw-r--r--jail/jail.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/jail/jail.c b/jail/jail.c
index b8878b5..dca3992 100644
--- a/jail/jail.c
+++ b/jail/jail.c
@@ -1325,6 +1325,8 @@ static const struct blobmsg_policy oci_root_policy[] = {
static int parseOCIroot(const char *jsonfile, struct blob_attr *msg)
{
static char extroot[PATH_MAX] = { 0 };
+ char buf[PATH_MAX];
+ ssize_t len;
struct blob_attr *tb[__OCI_ROOT_MAX];
char *cur;
char *root_path;
@@ -1349,6 +1351,21 @@ static int parseOCIroot(const char *jsonfile, struct blob_attr *msg)
strncat(extroot, root_path, PATH_MAX - (strlen(extroot) + 1));
+ /* follow symbolic link(s) */
+ while ((len = readlink(extroot, buf, sizeof(buf)-1)) != -1) {
+ buf[len] = '\0';
+ if (buf[0] != '/') {
+ cur = strrchr(extroot, '/');
+ if (!cur)
+ return ENOTDIR;
+
+ *(++cur) = '\0';
+ strncat(extroot, buf, sizeof(extroot)-1);
+ } else {
+ strncpy(extroot, buf, sizeof(extroot)-1);
+ }
+ }
+
opts.extroot = extroot;
if (tb[OCI_ROOT_READONLY])