diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libostree/ostree-repo-commit.c | 29 | ||||
-rw-r--r-- | src/libostree/ostree-repo.h | 6 |
2 files changed, 26 insertions, 9 deletions
diff --git a/src/libostree/ostree-repo-commit.c b/src/libostree/ostree-repo-commit.c index c07526fc..249e792c 100644 --- a/src/libostree/ostree-repo-commit.c +++ b/src/libostree/ostree-repo-commit.c @@ -3286,22 +3286,35 @@ _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. */ + if (self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY) + canonicalize_perms = TRUE; + + if (modifier != NULL) + { + if ((modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) != 0) + canonicalize_perms = TRUE; + if (modifier->filter != NULL) + has_filter = TRUE; + } + + 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)) @@ -3618,8 +3631,8 @@ write_content_to_mtree_internal (OstreeRepo *self, /* Load flags into boolean constants for ease of readability (we also need to * NULL-check modifier) */ - const gboolean canonical_permissions = modifier && - (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS); + const gboolean canonical_permissions = self->mode == OSTREE_REPO_MODE_BARE_USER_ONLY || + (modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS)); const gboolean devino_canonical = modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL); /* We currently only honor the CONSUME flag in the dfd_iter case to avoid even diff --git a/src/libostree/ostree-repo.h b/src/libostree/ostree-repo.h index 5f3093df..bbec1a37 100644 --- a/src/libostree/ostree-repo.h +++ b/src/libostree/ostree-repo.h @@ -678,10 +678,14 @@ typedef OstreeRepoCommitFilterResult (*OstreeRepoCommitFilter) (OstreeRepo *r * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE: No special flags * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS: Do not process extended attributes * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES: Generate size information. - * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS: Canonicalize permissions for bare-user-only mode. + * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS: Canonicalize permissions. * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_ERROR_ON_UNLABELED: Emit an error if configured SELinux policy does not provide a label * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CONSUME: Delete added files/directories after commit; Since: 2017.13 * @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_DEVINO_CANONICAL: If a devino cache hit is found, skip modifier filters (non-directories only); Since: 2017.14 + * + * Flags modifying commit behavior. In bare-user-only mode, @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS + * is automatically enabled. + * */ typedef enum { OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE = 0, |