Skip to content

Commit

Permalink
run: assume a bind mount if the mount type is unknown
Browse files Browse the repository at this point in the history
"runc spec --rootless" generates a config.json file that has "type" :
"none" for the bind mount of "/sys" from the host.

Reported here: https://lists.projectatomic.io/projectatomic-archives/atomic-devel/2018-February/msg00079.html

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #17
Approved by: muayyad-alsadi
  • Loading branch information
giuseppe authored and rh-atomic-bot committed Feb 25, 2018
1 parent b66bf8f commit 54e6b1c
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions run.c
Original file line number Diff line number Diff line change
Expand Up @@ -454,20 +454,6 @@ do_mounts (struct context *con, JsonNode *rootval)
else
collect_options (con, "--tmpfs", destinationval, NULL);
}
else if (g_strcmp0 (typeval, "bind") == 0)
{
const char *sourceval = NULL;
GVariant *source, *options;
gboolean readonly = FALSE;

source = g_variant_lookup_value (variant, "source", G_VARIANT_TYPE_STRING);
if (! source)
error (EXIT_FAILURE, 0, "invalid source for bind mount\n");
sourceval = g_variant_get_string (source, NULL);
options = g_variant_lookup_value (variant, "options", G_VARIANT_TYPE_ARRAY);
readonly = find_child_value (options, "ro");
collect_options (con, readonly ? "--ro-bind" : "--bind", sourceval, destinationval, NULL);
}
else if (g_strcmp0 (typeval, "devtmpfs") == 0)
collect_options (con, "--dev", destinationval, NULL);
else if (g_strcmp0 (typeval, "cgroup") == 0)
Expand All @@ -488,8 +474,20 @@ do_mounts (struct context *con, JsonNode *rootval)
readonly = find_child_value (options, "ro");
collect_options (con, readonly ? "--ro-bind" : "--bind", "/sys", destinationval, NULL);
}
else
error (EXIT_FAILURE, 0, "unknown mount type %s\n", typeval);
else /* assume it is a bind mount. */
{
const char *sourceval = NULL;
GVariant *source, *options;
gboolean readonly = FALSE;

source = g_variant_lookup_value (variant, "source", G_VARIANT_TYPE_STRING);
if (! source)
error (EXIT_FAILURE, 0, "invalid source for bind mount\n");
sourceval = g_variant_get_string (source, NULL);
options = g_variant_lookup_value (variant, "options", G_VARIANT_TYPE_ARRAY);
readonly = find_child_value (options, "ro");
collect_options (con, readonly ? "--ro-bind" : "--bind", sourceval, destinationval, NULL);
}
}

check_required_mounts (con, explicit_mounts);
Expand Down

0 comments on commit 54e6b1c

Please sign in to comment.