lib/core/checksum: add flag to use canonical permissions

This adds a new `OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS`
checksumming flag, which is needed in bare-user-only mode
to ignore local IDs.
This commit is contained in:
Luca BRUNO 2021-08-19 13:50:21 +00:00
parent cac4f2133b
commit c6b72f527b
No known key found for this signature in database
GPG Key ID: A9834A2252078E4E
2 changed files with 17 additions and 0 deletions

View File

@ -984,6 +984,9 @@ ostree_checksum_file_at (int dfd,
g_autoptr(GFileInfo) file_info = _ostree_stbuf_to_gfileinfo (stbuf);
const gboolean canonicalize_perms =
((flags & OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS) != 0);
g_autoptr(GInputStream) in = NULL;
if (S_ISREG (stbuf->st_mode))
{
@ -991,6 +994,11 @@ ostree_checksum_file_at (int dfd,
if (!glnx_openat_rdonly (dfd, path, FALSE, &fd, error))
return FALSE;
in = g_unix_input_stream_new (glnx_steal_fd (&fd), TRUE);
if (canonicalize_perms)
{
g_file_info_set_attribute_uint32 (file_info, "unix::uid", 0);
g_file_info_set_attribute_uint32 (file_info, "unix::gid", 0);
}
}
else if (S_ISLNK (stbuf->st_mode))
{

View File

@ -460,12 +460,21 @@ gboolean ostree_break_hardlink (int dfd,
/**
* OstreeChecksumFlags:
* @OSTREE_CHECKSUM_FLAGS_NONE: Default checksumming without tweaks.
* (Since: 2017.13.)
* @OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS: Ignore xattrs when checksumming.
* (Since: 2017.13.)
* @OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS: Use canonical uid/gid/mode
* values, for bare-user-only mode. (Since: 2021.4.)
*
* Flags influencing checksumming logic.
*
* Since: 2017.13
*/
typedef enum {
OSTREE_CHECKSUM_FLAGS_NONE = 0,
OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS = (1 << 0),
OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS = (1 << 1),
} OstreeChecksumFlags;
_OSTREE_PUBLIC