c0fc41f
diff -rup gedit-2.15.5-orig/configure.ac gedit-2.15.5/configure.ac
c0fc41f
--- gedit-2.15.5-orig/configure.ac	2006-08-10 12:25:58.000000000 -0400
c0fc41f
+++ gedit-2.15.5/configure.ac	2006-08-10 15:16:02.000000000 -0400
c0fc41f
@@ -87,6 +87,12 @@ AC_SUBST(PSPELL_LIBS)
c0fc41f
 
c0fc41f
 
c0fc41f
 dnl ================================================================
c0fc41f
+dnl libattr checks
c0fc41f
+dnl ================================================================
c0fc41f
+
c0fc41f
+AC_CHECK_LIB(attr, attr_copy_fd)
c0fc41f
+
c0fc41f
+dnl ================================================================
c0fc41f
 dnl Start of pkg-config checks
c0fc41f
 dnl ================================================================
c0fc41f
 
c0fc41f
Only in gedit-2.15.5: configure.ac.xattrs
c0fc41f
diff -rup gedit-2.15.5-orig/gedit/gedit-document-saver.c gedit-2.15.5/gedit/gedit-document-saver.c
c0fc41f
--- gedit-2.15.5-orig/gedit/gedit-document-saver.c	2006-05-18 18:55:16.000000000 -0400
c0fc41f
+++ gedit-2.15.5/gedit/gedit-document-saver.c	2006-08-10 15:16:08.000000000 -0400
c0fc41f
@@ -42,6 +42,12 @@
c0fc41f
 #include <glib/gfileutils.h>
c0fc41f
 #include <libgnomevfs/gnome-vfs.h>
c0fc41f
 
c0fc41f
+#ifdef HAVE_LIBATTR
c0fc41f
+# include <attr/libattr.h>
c0fc41f
+#else
c0fc41f
+# define attr_copy_fd(x1, x2, x3, x4, x5, x6) (errno = ENOSYS, -1)
c0fc41f
+#endif
c0fc41f
+
c0fc41f
 #include "gedit-document-saver.h"
c0fc41f
 #include "gedit-debug.h"
c0fc41f
 #include "gedit-convert.h"
c0fc41f
@@ -457,6 +463,15 @@ get_slow_mime_type (const char *text_uri
c0fc41f
 
c0fc41f
 /* ----------- local files ----------- */
c0fc41f
 
c0fc41f
+#ifdef HAVE_LIBATTR
c0fc41f
+static int all_xattrs(const char *xattr, struct error_context *err)
c0fc41f
+{ /* Save everything: user/root xattrs, SELinux, ACLs. */
c0fc41f
+  (void)xattr;
c0fc41f
+  (void)err;
c0fc41f
+  return 1;
c0fc41f
+}
c0fc41f
+#endif
c0fc41f
+
c0fc41f
 static gboolean
c0fc41f
 save_existing_local_file (GeditDocumentSaver *saver)
c0fc41f
 {
c0fc41f
@@ -597,6 +612,22 @@ save_existing_local_file (GeditDocumentS
c0fc41f
 			goto fallback_strategy;
c0fc41f
 		}
c0fc41f
 
c0fc41f
+                /* copy the xattrs, like user.mime_type, over. Also ACLs and
c0fc41f
+                   SELinux context. */
c0fc41f
+                if ((attr_copy_fd (saver->priv->local_path, saver->priv->fd,
c0fc41f
+                                   tmp_filename, tmpfd,
c0fc41f
+                                   all_xattrs, NULL) == -1) &&
c0fc41f
+                    (errno != EOPNOTSUPP) && (errno != ENOSYS))
c0fc41f
+                {
c0fc41f
+			gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
c0fc41f
+
c0fc41f
+			close (tmpfd);
c0fc41f
+			unlink (tmp_filename);
c0fc41f
+			g_free (tmp_filename);
c0fc41f
+
c0fc41f
+			goto fallback_strategy;
c0fc41f
+                }
c0fc41f
+
c0fc41f
 		if (!write_document_contents (tmpfd,
c0fc41f
 					      GTK_TEXT_BUFFER (saver->priv->document),
c0fc41f
 			 	 	      saver->priv->encoding,
c0fc41f
@@ -751,6 +782,18 @@ save_existing_local_file (GeditDocumentS
c0fc41f
 			}
c0fc41f
 		}
c0fc41f
 
c0fc41f
+                /* copy the xattrs, like user.mime_type, over. Also ACLs and
c0fc41f
+                   SELinux context. */
c0fc41f
+                if ((attr_copy_fd (saver->priv->local_path, saver->priv->fd,
c0fc41f
+                                   backup_filename, bfd,
c0fc41f
+                                   all_xattrs, NULL) == -1) &&
c0fc41f
+                    (errno != EOPNOTSUPP) && (errno != ENOSYS))
c0fc41f
+                {
c0fc41f
+			gedit_debug_message (DEBUG_SAVER, "could not set xattrs");
c0fc41f
+
c0fc41f
+			goto out; /* is it better to save or not save? */
c0fc41f
+                }
c0fc41f
+
c0fc41f
 		if (!copy_file_data (saver->priv->fd, bfd, NULL))
c0fc41f
 		{
c0fc41f
 				gedit_debug_message (DEBUG_SAVER, "could not copy data into the backup");
c0fc41f
Only in gedit-2.15.5/gedit: gedit-document-saver.c.xattrs