diff --git a/docs/manual/treefile.md b/docs/manual/treefile.md index 54bbaf9f..a4fdef3c 100644 --- a/docs/manual/treefile.md +++ b/docs/manual/treefile.md @@ -67,7 +67,8 @@ It supports the following parameters: * `initramfs-args`: Array of strings, optional. Passed to the initramfs generation program (presently `dracut`). An example use case for this with Dracut is `--filesystems xfs,ext4` to ensure - specific filesystem drivers are included. + specific filesystem drivers are included. If not specified, + `--no-hostonly` will be used. * `remove-files`: Array of files to delete from the generated tree. diff --git a/src/libpriv/rpmostree-json-parsing.c b/src/libpriv/rpmostree-json-parsing.c index ebbf6d3c..decc8d27 100644 --- a/src/libpriv/rpmostree-json-parsing.c +++ b/src/libpriv/rpmostree-json-parsing.c @@ -32,16 +32,18 @@ _rpmostree_jsonutil_object_get_optional_string_member (JsonObject *object, const char **out_value, GError **error) { - JsonNode *node = json_object_get_member (object, member_name); + *out_value = NULL; + if (!object) + return TRUE; + + JsonNode *node = json_object_get_member (object, member_name); if (node != NULL) { *out_value = json_node_get_string (node); if (!*out_value) return glnx_throw (error, "Member '%s' is not a string", member_name); } - else - *out_value = NULL; return TRUE; } @@ -78,8 +80,14 @@ _rpmostree_jsonutil_object_get_optional_int_member (JsonObject *object, gboolean *found, GError **error) { - JsonNode *node = json_object_get_member (object, member_name); + if (found) + *found = FALSE; + *out_value = 0; + if (!object) + return TRUE; + + JsonNode *node = json_object_get_member (object, member_name); if (node != NULL) { if (!_jsonutil_node_check_int (node)) @@ -88,12 +96,6 @@ _rpmostree_jsonutil_object_get_optional_int_member (JsonObject *object, *found = TRUE; *out_value = json_node_get_int (node); } - else - { - if (found) - *found = FALSE; - *out_value = 0; - } return TRUE; } @@ -118,8 +120,10 @@ _rpmostree_jsonutil_object_get_optional_boolean_member (JsonObject *object, gboolean *out_value, GError **error) { - JsonNode *node = json_object_get_member (object, member_name); + if (!object) + return TRUE; + JsonNode *node = json_object_get_member (object, member_name); if (node != NULL) { if (json_node_get_value_type (node) != G_TYPE_BOOLEAN) diff --git a/src/libpriv/rpmostree-postprocess.c b/src/libpriv/rpmostree-postprocess.c index 2dda6e04..f548d74a 100644 --- a/src/libpriv/rpmostree-postprocess.c +++ b/src/libpriv/rpmostree-postprocess.c @@ -359,7 +359,7 @@ process_kernel_and_initramfs (int rootfs_dfd, /* Run dracut with our chosen arguments (commonly at least --no-hostonly) */ g_autoptr(GPtrArray) dracut_argv = g_ptr_array_new (); - if (json_object_has_member (treefile, "initramfs-args")) + if (treefile && json_object_has_member (treefile, "initramfs-args")) { JsonArray *initramfs_args = json_object_get_array_member (treefile, "initramfs-args"); guint len = json_array_get_length (initramfs_args); @@ -372,6 +372,11 @@ process_kernel_and_initramfs (int rootfs_dfd, g_ptr_array_add (dracut_argv, (char*)arg); } } + else + { + /* Default to this for treecomposes */ + g_ptr_array_add (dracut_argv, (char*)"--no-hostonly"); + } g_ptr_array_add (dracut_argv, NULL); g_auto(GLnxTmpfile) initramfs_tmpf = { 0, }; @@ -872,7 +877,7 @@ postprocess_final (int rootfs_dfd, return FALSE; g_autoptr(GHashTable) preserve_groups_set = NULL; - if (json_object_has_member (treefile, "etc-group-members")) + if (treefile && json_object_has_member (treefile, "etc-group-members")) { JsonArray *etc_group_members = json_object_get_array_member (treefile, "etc-group-members"); preserve_groups_set = _rpmostree_jsonutil_jsarray_strings_to_set (etc_group_members);