summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2014-02-11 08:50:42 -0500
committerColin Walters <walters@verbum.org>2014-02-11 08:52:04 -0500
commit417653ef58d0682d62d619ab9fabfe4562083017 (patch)
tree300624a3e84e57dba86b2fe2c41ca9bb199de233
parent4221eae06b5cf0156fbeed5a3fd824d5277ca6e2 (diff)
downloadlibgsystem-417653ef58d0682d62d619ab9fabfe4562083017.tar.gz
shutil: Ignore EPERM/ENOTSUP errors while copying xattrs by default
Unprivileged users won't be able to copy e.g. security.selinux; let's ignore this by default, the same way coreutils does.
-rw-r--r--src/gsystem-shutil.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/gsystem-shutil.c b/src/gsystem-shutil.c
index 8029dd9..6cd05c2 100644
--- a/src/gsystem-shutil.c
+++ b/src/gsystem-shutil.c
@@ -136,8 +136,22 @@ cp_internal (GFile *src,
r = fchmod (dest_dfd, g_file_info_get_attribute_uint32 (src_info, "unix::mode"));
while (G_UNLIKELY (r == -1 && errno == EINTR));
- if (!copy_xattrs_from_file_to_fd (src, dest_dfd, cancellable, error))
- goto out;
+ {
+ GError *temp_error = NULL;
+ if (!copy_xattrs_from_file_to_fd (src, dest_dfd, cancellable, &temp_error))
+ {
+ if (g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED) ||
+ g_error_matches (temp_error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED))
+ {
+ g_clear_error (&temp_error);
+ }
+ else
+ {
+ g_propagate_error (error, temp_error);
+ goto out;
+ }
+ }
+ }
if (dest_dfd != -1)
{