commit: Add --canonical-permissions argument
This adds to file permission masks the same bitmask that will be applied to file objects in bare-user* repos. This will be needed in the testsuite to ensure that the things we commit will be expressable in bare-user-only repos. Closes: #750 Approved by: cgwalters
This commit is contained in:
parent
be28c10849
commit
b2d10dcaaa
|
|
@ -2236,17 +2236,33 @@ _ostree_repo_commit_modifier_apply (OstreeRepo *self,
|
||||||
GFileInfo *file_info,
|
GFileInfo *file_info,
|
||||||
GFileInfo **out_modified_info)
|
GFileInfo **out_modified_info)
|
||||||
{
|
{
|
||||||
OstreeRepoCommitFilterResult result;
|
OstreeRepoCommitFilterResult result = OSTREE_REPO_COMMIT_FILTER_ALLOW;
|
||||||
GFileInfo *modified_info;
|
GFileInfo *modified_info;
|
||||||
|
|
||||||
if (modifier == NULL || modifier->filter == NULL)
|
if (modifier == NULL ||
|
||||||
|
(modifier->filter == NULL &&
|
||||||
|
(modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) == 0))
|
||||||
{
|
{
|
||||||
*out_modified_info = g_object_ref (file_info);
|
*out_modified_info = g_object_ref (file_info);
|
||||||
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
|
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
modified_info = g_file_info_dup (file_info);
|
modified_info = g_file_info_dup (file_info);
|
||||||
result = modifier->filter (self, path, modified_info, modifier->user_data);
|
if (modifier->filter)
|
||||||
|
result = modifier->filter (self, path, modified_info, modifier->user_data);
|
||||||
|
|
||||||
|
if ((modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) != 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (g_file_info_get_file_type (file_info) == G_FILE_TYPE_REGULAR)
|
||||||
|
{
|
||||||
|
guint current_mode = g_file_info_get_attribute_uint32 (modified_info, "unix::mode");
|
||||||
|
g_file_info_set_attribute_uint32 (modified_info, "unix::mode", current_mode | 0744);
|
||||||
|
}
|
||||||
|
g_file_info_set_attribute_uint32 (modified_info, "unix::uid", 0);
|
||||||
|
g_file_info_set_attribute_uint32 (modified_info, "unix::gid", 0);
|
||||||
|
}
|
||||||
|
|
||||||
*out_modified_info = modified_info;
|
*out_modified_info = modified_info;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2283,7 +2299,9 @@ apply_commit_filter (OstreeRepo *self,
|
||||||
GFileInfo *file_info,
|
GFileInfo *file_info,
|
||||||
GFileInfo **out_modified_info)
|
GFileInfo **out_modified_info)
|
||||||
{
|
{
|
||||||
if (modifier == NULL || modifier->filter == NULL)
|
if (modifier == NULL ||
|
||||||
|
(modifier->filter == NULL &&
|
||||||
|
(modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS) == 0))
|
||||||
{
|
{
|
||||||
*out_modified_info = g_object_ref (file_info);
|
*out_modified_info = g_object_ref (file_info);
|
||||||
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
|
return OSTREE_REPO_COMMIT_FILTER_ALLOW;
|
||||||
|
|
@ -2312,7 +2330,8 @@ get_modified_xattrs (OstreeRepo *self,
|
||||||
ret_xattrs = modifier->xattr_callback (self, relpath, file_info,
|
ret_xattrs = modifier->xattr_callback (self, relpath, file_info,
|
||||||
modifier->xattr_user_data);
|
modifier->xattr_user_data);
|
||||||
}
|
}
|
||||||
else if (!(modifier && (modifier->flags & OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS) > 0)
|
else if (!(modifier && (modifier->flags & (OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS |
|
||||||
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS)) > 0)
|
||||||
&& !self->disable_xattrs)
|
&& !self->disable_xattrs)
|
||||||
{
|
{
|
||||||
if (path && OSTREE_IS_REPO_FILE (path))
|
if (path && OSTREE_IS_REPO_FILE (path))
|
||||||
|
|
|
||||||
|
|
@ -536,11 +536,13 @@ typedef OstreeRepoCommitFilterResult (*OstreeRepoCommitFilter) (OstreeRepo *r
|
||||||
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE: No special flags
|
* @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_SKIP_XATTRS: Do not process extended attributes
|
||||||
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES: Generate size information.
|
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES: Generate size information.
|
||||||
|
* @OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS: Canonicalize permissions for bare-user-only mode.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE = 0,
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_NONE = 0,
|
||||||
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS = (1 << 0),
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS = (1 << 0),
|
||||||
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES = (1 << 1)
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES = (1 << 1),
|
||||||
|
OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS = (1 << 2),
|
||||||
} OstreeRepoCommitModifierFlags;
|
} OstreeRepoCommitModifierFlags;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,7 @@ static gboolean opt_link_checkout_speedup;
|
||||||
static gboolean opt_skip_if_unchanged;
|
static gboolean opt_skip_if_unchanged;
|
||||||
static gboolean opt_tar_autocreate_parents;
|
static gboolean opt_tar_autocreate_parents;
|
||||||
static gboolean opt_no_xattrs;
|
static gboolean opt_no_xattrs;
|
||||||
|
static gboolean opt_canonical_permissions;
|
||||||
static char **opt_trees;
|
static char **opt_trees;
|
||||||
static gint opt_owner_uid = -1;
|
static gint opt_owner_uid = -1;
|
||||||
static gint opt_owner_gid = -1;
|
static gint opt_owner_gid = -1;
|
||||||
|
|
@ -84,6 +85,7 @@ static GOptionEntry options[] = {
|
||||||
{ "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings, "Add a key/value pair to detached metadata", "KEY=VALUE" },
|
{ "add-detached-metadata-string", 0, 0, G_OPTION_ARG_STRING_ARRAY, &opt_detached_metadata_strings, "Add a key/value pair to detached metadata", "KEY=VALUE" },
|
||||||
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Set file ownership user id", "UID" },
|
{ "owner-uid", 0, 0, G_OPTION_ARG_INT, &opt_owner_uid, "Set file ownership user id", "UID" },
|
||||||
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Set file ownership group id", "GID" },
|
{ "owner-gid", 0, 0, G_OPTION_ARG_INT, &opt_owner_gid, "Set file ownership group id", "GID" },
|
||||||
|
{ "canonical-permissions", 0, 0, G_OPTION_ARG_NONE, &opt_canonical_permissions, "Canonicalize permissions in the same way bare-user does for hardlinked files", NULL },
|
||||||
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes", NULL },
|
{ "no-xattrs", 0, 0, G_OPTION_ARG_NONE, &opt_no_xattrs, "Do not import extended attributes", NULL },
|
||||||
{ "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup, "Optimize for commits of trees composed of hardlinks into the repository", NULL },
|
{ "link-checkout-speedup", 0, 0, G_OPTION_ARG_NONE, &opt_link_checkout_speedup, "Optimize for commits of trees composed of hardlinks into the repository", NULL },
|
||||||
{ "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
|
{ "tar-autocreate-parents", 0, 0, G_OPTION_ARG_NONE, &opt_tar_autocreate_parents, "When loading tar archives, automatically create parent directories as needed", NULL },
|
||||||
|
|
@ -399,6 +401,8 @@ ostree_builtin_commit (int argc, char **argv, GCancellable *cancellable, GError
|
||||||
|
|
||||||
if (opt_no_xattrs)
|
if (opt_no_xattrs)
|
||||||
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
|
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_SKIP_XATTRS;
|
||||||
|
if (opt_canonical_permissions)
|
||||||
|
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_CANONICAL_PERMISSIONS;
|
||||||
if (opt_generate_sizes)
|
if (opt_generate_sizes)
|
||||||
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES;
|
flags |= OSTREE_REPO_COMMIT_MODIFIER_FLAGS_GENERATE_SIZES;
|
||||||
if (opt_disable_fsync)
|
if (opt_disable_fsync)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue