Revert "xattrs: Use /proc/self/fd path in glnx_fd_set_all_xattrs"

We can't use fsetxattr() to get the extended attributes of a symlink via
the magic symlink in /proc/self/fd, because opening with O_NOFOLLOW
would try to set the extended attributes on the magic symlink
/proc/self/fd/N, and opening without O_NOFOLLOW would dereference the
symlink.

This reverts commit 128578be4d.

Helps: https://github.com/flatpak/flatpak/issues/6818
Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie committed 2026-09-18 15:16:45 +01:00
1 parent 846e1757fd
commit 54c1928683
1 file changed
+17 -4
+17 -4
View File
@@ -338,12 +338,25 @@ glnx_dfd_name_set_all_xattrs (int dfd,
gboolean
glnx_fd_set_all_xattrs (int fd,
GVariant *xattrs,
GCancellable *cancellable,
G_GNUC_UNUSED GCancellable *cancellable,
GError **error)
{
char buf[PATH_MAX];
snprintf (buf, sizeof (buf), "/proc/self/fd/%d", fd);
return set_all_xattrs_for_path (buf, xattrs, cancellable, error);
const guint n = g_variant_n_children (xattrs);
for (guint i = 0; i < n; i++)
{
const guint8* name;
g_autoptr(GVariant) value = NULL;
g_variant_get_child (xattrs, i, "(^&ay@ay)",
&name, &value);
gsize value_len;
const guint8* value_data = g_variant_get_fixed_array (value, &value_len, 1);
if (TEMP_FAILURE_RETRY (fsetxattr (fd, (char*)name, (char*)value_data, value_len, 0)) < 0)
return glnx_throw_errno_prefix (error, "Setting xattrs: fsetxattr(%s)", name);
}
return TRUE;
}
/**