[eom] 01/02: debian/patches: Add 0002_fix-permissions-when-saving-the-modified-image.patch. don't change file permissions when saving the modified image (Closes: #769792).

Pablo Barciela zenwalker-guest at moszumanska.debian.org
Sat Apr 22 01:40:28 UTC 2017


This is an automated email from the git hooks/post-receive script.

zenwalker-guest pushed a commit to branch debian/jessie/updates
in repository eom.

commit 1ec4a250c15d7dc721924201ed27307f2f4d0b00
Author: Pablo Barciela <scow at riseup.net>
Date:   Sat Apr 22 02:56:44 2017 +0200

    debian/patches: Add 0002_fix-permissions-when-saving-the-modified-image.patch. don't change file permissions when saving the modified image (Closes: #769792).
---
 ...ermissions-when-saving-the-modified-image.patch | 137 +++++++++++++++++++++
 debian/patches/series                              |   1 +
 2 files changed, 138 insertions(+)

diff --git a/debian/patches/0002_fix-permissions-when-saving-the-modified-image.patch b/debian/patches/0002_fix-permissions-when-saving-the-modified-image.patch
new file mode 100644
index 0000000..d4a7a23
--- /dev/null
+++ b/debian/patches/0002_fix-permissions-when-saving-the-modified-image.patch
@@ -0,0 +1,137 @@
+From 02d0316da724f63026bb804699dcbc6875083911 Mon Sep 17 00:00:00 2001
+From: Monsta <monsta at inbox.ru>
+Date: Thu, 4 Jun 2015 11:19:21 +0300
+Subject: [PATCH] don't change file permissions when saving the modified image
+
+adapted from:
+https://git.gnome.org/browse/eog/commit/?id=4626596c2c179bfe35c4212efced15c38d7337d6
+---
+ src/eom-image.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 1 file changed, 108 insertions(+)
+
+diff --git a/src/eom-image.c b/src/eom-image.c
+index 989f365..3ea28d4 100644
+--- a/src/eom-image.c
++++ b/src/eom-image.c
+@@ -1431,6 +1431,110 @@ transfer_progress_cb (goffset cur_bytes,
+ 	}
+ }
+ 
++static void
++tmp_file_restore_unix_attributes (GFile *temp_file,
++				  GFile *target_file)
++{
++	GFileInfo *file_info;
++	guint      uid;
++	guint      gid;
++	guint      mode;
++	guint      mode_mask = 00600;
++
++	GError    *error = NULL;
++
++	g_return_if_fail (G_IS_FILE (temp_file));
++	g_return_if_fail (G_IS_FILE (target_file));
++
++	/* check if file exists */
++	if (!g_file_query_exists (target_file, NULL)) {
++		eom_debug_message (DEBUG_IMAGE_SAVE,
++				   "Target file doesn't exist. Setting default attributes.");
++		return;
++	}
++
++	/* retrieve UID, GID, and MODE of the original file info */
++	file_info = g_file_query_info (target_file,
++				       "unix::uid,unix::gid,unix::mode",
++				       G_FILE_QUERY_INFO_NONE,
++				       NULL,
++				       &error);
++
++	/* check that there aren't any error */
++	if (error != NULL) {
++		eom_debug_message (DEBUG_IMAGE_SAVE,
++				   "File information not available. Setting default attributes.");
++
++		/* free objects */
++		g_object_unref (file_info);
++		g_clear_error (&error);
++
++		return;
++	}
++
++	/* save UID, GID and MODE values */
++	uid = g_file_info_get_attribute_uint32 (file_info,
++						G_FILE_ATTRIBUTE_UNIX_UID);
++
++	gid = g_file_info_get_attribute_uint32 (file_info,
++						G_FILE_ATTRIBUTE_UNIX_GID);
++
++	mode = g_file_info_get_attribute_uint32 (file_info,
++						 G_FILE_ATTRIBUTE_UNIX_MODE);
++
++	/* apply default mode mask to file mode */
++	mode |= mode_mask;
++
++	/* restore original UID, GID, and MODE into the temporal file */
++	g_file_set_attribute_uint32 (temp_file,
++				     G_FILE_ATTRIBUTE_UNIX_UID,
++				     uid,
++				     G_FILE_QUERY_INFO_NONE,
++				     NULL,
++				     &error);
++
++	/* check that there aren't any error */
++	if (error != NULL) {
++		eom_debug_message (DEBUG_IMAGE_SAVE,
++				   "You do not have the permissions necessary to change the file UID.");
++
++		g_clear_error (&error);
++	}
++
++	g_file_set_attribute_uint32 (temp_file,
++				     G_FILE_ATTRIBUTE_UNIX_GID,
++				     gid,
++				     G_FILE_QUERY_INFO_NONE,
++				     NULL,
++				     &error);
++
++	/* check that there aren't any error */
++	if (error != NULL) {
++		eom_debug_message (DEBUG_IMAGE_SAVE,
++				   "You do not have the permissions necessary to change the file GID. Setting user default GID.");
++
++		g_clear_error (&error);
++	}
++
++	g_file_set_attribute_uint32 (temp_file,
++				     G_FILE_ATTRIBUTE_UNIX_MODE,
++				     mode,
++				     G_FILE_QUERY_INFO_NONE,
++				     NULL,
++				     &error);
++
++	/* check that there aren't any error */
++	if (error != NULL) {
++		eom_debug_message (DEBUG_IMAGE_SAVE,
++				   "You do not have the permissions necessary to change the file MODE.");
++
++		g_clear_error (&error);
++	}
++
++	/* free objects */
++	g_object_unref (file_info);
++}
++
+ static gboolean
+ tmp_file_move_to_uri (EomImage *image,
+ 		      GFile *tmpfile,
+@@ -1441,6 +1545,10 @@ tmp_file_move_to_uri (EomImage *image,
+ 	gboolean result;
+ 	GError *ioerror = NULL;
+ 
++	/* try to restore target file unix attributes */
++	tmp_file_restore_unix_attributes (tmpfile, file);
++
++	/* replace target file with temporal file */
+ 	result = g_file_move (tmpfile,
+ 			      file,
+ 			      (overwrite ? G_FILE_COPY_OVERWRITE : 0) |
diff --git a/debian/patches/series b/debian/patches/series
index ff7f0aa..adc9f6d 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,3 +1,4 @@
 0001_fix-new-windows-dont-get-focus.patch
+0002_fix-permissions-when-saving-the-modified-image.patch
 1001_fix-hyphens-on-man-page.patch
 2001_omit-gfdl-licensed-help-files.patch

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mate/eom.git



More information about the pkg-mate-commits mailing list