[libgsystem] shutil: Ignore EPERM/ENOTSUP errors while copying xattrs by default



commit 417653ef58d0682d62d619ab9fabfe4562083017
Author: Colin Walters <walters verbum org>
Date:   Tue Feb 11 08:50:42 2014 -0500

    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.

 src/gsystem-shutil.c |   18 ++++++++++++++++--
 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)
         {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]