Skip to content

Commit

Permalink
lib/commit: autofix permissions for bare-user-only
Browse files Browse the repository at this point in the history
This tweaks commit logic to detect bare-user-only repositories and
canonicalize permissions automatically.
  • Loading branch information
lucab committed Aug 17, 2021
1 parent 87db562 commit 8dda504
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/libostree/ostree-repo-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -3286,22 +3286,33 @@ _ostree_repo_commit_modifier_apply (OstreeRepo *self,
GFileInfo *file_info,
GFileInfo **out_modified_info)
{
gboolean canonicalize_perms = FALSE;
gboolean has_filter = FALSE;
OstreeRepoCommitFilterResult result = OSTREE_REPO_COMMIT_FILTER_ALLOW;
GFileInfo *modified_info;

if (modifier == NULL ||
(modifier->filter == NULL &&
(modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) == 0))
/* Auto-detect bare-user-only repo, force canonical permissions. */
// XXX(lucab): This seems to break `checkout --union-identical`.
canonicalize_perms |= (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY);

if (modifier != NULL)
{
canonicalize_perms |= ((modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) != 0);
has_filter |= (modifier->filter != NULL);
}

if (!(canonicalize_perms || has_filter))
{
*out_modified_info = g_object_ref (file_info);
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
return OSTREE_REPO_COMMIT_FILTER_ALLOW; /* Note: early return (no actions needed) */
}

modified_info = g_file_info_dup (file_info);
if (modifier->filter)

if (has_filter)
result = modifier->filter (self, path, modified_info, modifier->user_data);

if ((modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) != 0)
if (canonicalize_perms)
{
guint mode = g_file_info_get_attribute_uint32 (modified_info, "unix::mode");
switch (g_file_info_get_file_type (file_info))
Expand Down

0 comments on commit 8dda504

Please sign in to comment.