diff options
author | Luca BRUNO <luca.bruno@coreos.com> | 2022-03-02 16:45:02 +0000 |
---|---|---|
committer | Luca BRUNO <luca.bruno@coreos.com> | 2022-03-02 16:45:02 +0000 |
commit | 7e79b82ff8b3c3aa7fbe5edfcfa237f9447e2f18 (patch) | |
tree | 7909a7299b9068b57fc118513de218196fff78ad | |
parent | 14a6e6d8d081b11217785d7c37b0c0a8c661000c (diff) | |
download | ostree-7e79b82ff8b3c3aa7fbe5edfcfa237f9447e2f18.tar.gz |
lib/commit: disallow writing content in 'bare-split-xattrs' mode
This prevents writing content into 'bare-split-xattrs` repository,
while carving some space for experimenting via a temporary
`OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS` environment flag.
-rw-r--r-- | src/libostree/ostree-repo-commit.c | 3 | ||||
-rwxr-xr-x | tests/test-basic-bare-split-xattrs.sh | 22 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index 21ce288f..5b16be5b 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -920,6 +920,9 @@ write_content_object (OstreeRepo *self, return FALSE; OstreeRepoMode repo_mode = ostree_repo_get_mode (self); + if (repo_mode == OSTREE_REPO_MODE_BARE_SPLIT_XATTRS && + g_getenv ("OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS") == NULL) + return glnx_throw (error, "Not allowed due to repo mode"); GInputStream *file_input; /* Unowned alias */ g_autoptr(GInputStream) file_input_owned = NULL; /* We need a temporary for bare-user symlinks */ diff --git a/tests/test-basic-bare-split-xattrs.sh b/tests/test-basic-bare-split-xattrs.sh index 8bd6430d..1eeb3039 100755 --- a/tests/test-basic-bare-split-xattrs.sh +++ b/tests/test-basic-bare-split-xattrs.sh @@ -22,4 +22,26 @@ ${OSTREE} fsck --all tap_ok "repo fsck" rm -rf -- repo +cd ${test_tmpdir} +mkdir -p "${test_tmpdir}/files" +touch files/foo +${OSTREE} init --mode "${mode}" +if ${OSTREE} commit --orphan -m "not implemented" files; then + assert_not_reached "commit to bare-split-xattrs should have failed" +fi +${OSTREE} fsck --all +tap_ok "commit not implemented" +rm -rf -- repo files + +cd ${test_tmpdir} +mkdir -p "${test_tmpdir}/files" +touch files/foo +${OSTREE} init --mode "${mode}" +OSTREE_EXP_WRITE_BARE_SPLIT_XATTRS=true ${OSTREE} commit --orphan -m "experimental" files +if ${OSTREE} fsck --all; then + assert_not_reached "fsck should have failed" +fi +tap_ok "commit exp override" +rm -rf -- repo files + tap_end |