Skip to content

Commit

Permalink
main: honor user.overlay. xattrs
Browse files Browse the repository at this point in the history
native overlay uses user.overlay to store the overlay metadata instead
of trusted.overlay, let's honor it as well.

Closes: #328

Signed-off-by: Giuseppe Scrivano <[email protected]>
  • Loading branch information
giuseppe committed Nov 22, 2021
1 parent 85412df commit 5f43fb1
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ open_by_handle_at (int mount_fd, struct file_handle *handle, int flags)
#define ORIGIN_XATTR "user.fuseoverlayfs.origin"
#define OPAQUE_XATTR "user.fuseoverlayfs.opaque"
#define XATTR_CONTAINERS_PREFIX "user.containers."
#define UNPRIVILEGED_XATTR_PREFIX "user.overlay."
#define UNPRIVILEGED_OPAQUE_XATTR "user.overlay.opaque"
#define PRIVILEGED_XATTR_PREFIX "trusted.overlay."
#define PRIVILEGED_OPAQUE_XATTR "trusted.overlay.opaque"
#define PRIVILEGED_ORIGIN_XATTR "trusted.overlay.origin"
Expand Down Expand Up @@ -495,8 +497,9 @@ has_prefix (const char *str, const char *pref)
static bool
can_access_xattr (const char *name)
{
return !has_prefix (name, XATTR_PREFIX) \
&& !has_prefix (name, PRIVILEGED_XATTR_PREFIX);
return !has_prefix (name, XATTR_PREFIX)
&& !has_prefix (name, PRIVILEGED_XATTR_PREFIX)
&& !has_prefix (name, UNPRIVILEGED_XATTR_PREFIX);
}

static ssize_t
Expand Down Expand Up @@ -683,6 +686,8 @@ is_directory_opaque (struct ovl_layer *l, const char *path)
ssize_t s;

s = l->ds->getxattr (l, path, PRIVILEGED_OPAQUE_XATTR, b, sizeof (b));
if (s < 0 && errno == ENODATA)
s = l->ds->getxattr (l, path, UNPRIVILEGED_OPAQUE_XATTR, b, sizeof (b));
if (s < 0 && errno == ENODATA)
s = l->ds->getxattr (l, path, OPAQUE_XATTR, b, sizeof (b));

Expand Down

0 comments on commit 5f43fb1

Please sign in to comment.