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:
parent
cac4f2133b
commit
c6b72f527b
|
|
@ -984,6 +984,9 @@ ostree_checksum_file_at (int dfd,
|
||||||
|
|
||||||
g_autoptr(GFileInfo) file_info = _ostree_stbuf_to_gfileinfo (stbuf);
|
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;
|
g_autoptr(GInputStream) in = NULL;
|
||||||
if (S_ISREG (stbuf->st_mode))
|
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))
|
if (!glnx_openat_rdonly (dfd, path, FALSE, &fd, error))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
in = g_unix_input_stream_new (glnx_steal_fd (&fd), TRUE);
|
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))
|
else if (S_ISLNK (stbuf->st_mode))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -460,12 +460,21 @@ gboolean ostree_break_hardlink (int dfd,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OstreeChecksumFlags:
|
* 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
|
* Since: 2017.13
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OSTREE_CHECKSUM_FLAGS_NONE = 0,
|
OSTREE_CHECKSUM_FLAGS_NONE = 0,
|
||||||
OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS = (1 << 0),
|
OSTREE_CHECKSUM_FLAGS_IGNORE_XATTRS = (1 << 0),
|
||||||
|
OSTREE_CHECKSUM_FLAGS_CANONICAL_PERMISSIONS = (1 << 1),
|
||||||
} OstreeChecksumFlags;
|
} OstreeChecksumFlags;
|
||||||
|
|
||||||
_OSTREE_PUBLIC
|
_OSTREE_PUBLIC
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue