Skip to content

Commit

Permalink
repo/commit: Support group-writable files for bare-user-only
Browse files Browse the repository at this point in the history
These exist in the wild for flatpak, and aren't really a problem.
The canonical permissions are still `0{6,7}44`, we just support
the additional writable bit for the group now to avoid breaking
some flatpak content.
  • Loading branch information
cgwalters committed Jun 7, 2017
1 parent 0ba2efc commit 1d90598
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,10 @@ commit_loose_object_trusted (OstreeRepo *self,
self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY
&& !object_is_symlink)
{
guint32 invalid_modebits = (mode & ~S_IFMT) & ~0755;
guint32 invalid_modebits = (mode & ~S_IFMT) & ~0775;
if (invalid_modebits > 0)
return glnx_throw (error, "Invalid mode 0%04o with bits 0%04o in bare-user-only repository",
mode, invalid_modebits);
mode, invalid_modebits);

if (fchmod (fd, mode) < 0)
return glnx_throw_errno_prefix (error, "fchmod");
Expand Down
12 changes: 12 additions & 0 deletions tests/test-basic-user-only.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,15 @@ if $CMD_PREFIX ostree pull-local --repo=repo repo-input 2>err.txt; then
fi
assert_file_has_content err.txt "Invalid mode.*with bits 040.*in bare-user-only"
echo "ok failed to commit suid"

cd ${test_tmpdir}
rm repo-input -rf
ostree --repo=repo-input init --mode=archive
rm files -rf && mkdir files
echo "a group writable file" > files/some-group-writable
chmod 0664 files/some-group-writable
$CMD_PREFIX ostree --repo=repo-input commit -b content-with-group-writable --tree=dir=files
$CMD_PREFIX ostree pull-local --repo=repo repo-input
$CMD_PREFIX ostree --repo=repo checkout -U -H content-with-group-writable groupwritable-co
assert_file_has_mode groupwritable-co/some-group-writable 0664
echo "ok supported group writable"

0 comments on commit 1d90598

Please sign in to comment.