diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index caa5103f..b20f277a 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -385,7 +385,7 @@ write_object (OstreeRepo *self, if (!(temp_file_is_regular || is_symlink)) { - g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, "Unsupported file type %u", g_file_info_get_file_type (file_info)); goto out; } @@ -1785,9 +1785,25 @@ write_directory_to_mtree_internal (OstreeRepo *self, if (filter_result == OSTREE_REPO_COMMIT_FILTER_ALLOW) { + GFileType file_type; + child = g_file_get_child (dir, name); - if (g_file_info_get_file_type (child_info) == G_FILE_TYPE_DIRECTORY) + file_type = g_file_info_get_file_type (child_info); + switch (file_type) + { + case G_FILE_TYPE_DIRECTORY: + case G_FILE_TYPE_SYMBOLIC_LINK: + case G_FILE_TYPE_REGULAR: + break; + default: + g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED, + "Unsupported file type: '%s'", + gs_file_get_path_cached (child)); + goto out; + } + + if (file_type == G_FILE_TYPE_DIRECTORY) { if (!ostree_mutable_tree_ensure_dir (mtree, name, &child_mtree, error)) goto out; diff --git a/tests/test-basic.sh b/tests/test-basic.sh index 2ac197f3..0a9908de 100755 --- a/tests/test-basic.sh +++ b/tests/test-basic.sh @@ -317,3 +317,14 @@ stat '--format=%Y' test2-checkout/baz/cow > cow-mtime assert_file_has_content cow-mtime 0 echo "ok content mtime" +cd ${test_tmpdir} +rm -rf test2-checkout +mkdir -p test2-checkout +cd test2-checkout +mkfifo afifo +if $OSTREE commit -b test2 -s "Attempt to commit a FIFO" 2>../errmsg; then + assert_not_reached "Committing a FIFO unexpetedly succeeded!" + assert_file_has_content ../errmsg "Unsupported file type" +fi +echo "ok commit of fifo was rejected" +