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