Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 181944 - media-libs/jpeg: exifautotran destroys file mode when transforming
Summary: media-libs/jpeg: exifautotran destroys file mode when transforming
Status: RESOLVED DUPLICATE of bug 206285
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High enhancement (vote)
Assignee: Gentoo Graphics Project
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-06-13 20:10 UTC by Eric Svensson
Modified: 2008-02-05 10:06 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Svensson 2007-06-13 20:10:39 UTC
After running exifautotran some files (the files which have been transformed) do not have the file mode (file permissions) they had before transformation unless the file mode was 600.

Reproducible: Always

Steps to reproduce:

1. Find a JPEG file where the EXIF data says the image requires rotation (<http://www.ferretporn.se/~mrlemming/bugs/MVI_0216.jpg>)
2. Find another JPEG file where the EXIF data says the image does not require rotation (<http://www.ferretporn.se/~mrlemming/bugs/MVI_0216-rotated.jpg>)
3. Set file modes to 644 on the two JPEG files
4. Run exifautotran on the two JPEG files

Actual results:
The file modes of the two files differ from each other and, in the case of the JPEG file which underwent transformation, is different (600) from the original file mode (644).

Expected results:
The file modes are the same for all JPEG files, and the same as they were before the transformation (644).

Some suggestions on fixes (none of which suppress any messages or display warnings if commands fail) follow:

Simple fix to use chmod before mv:

--- /usr/bin/exifautotran       2007-02-27 20:31:07.000000000 +0100
+++ /home/mrlemming/bin/exifautotran    2007-06-13 21:36:13.000000000 +0200
@@ -43,6 +43,7 @@
   if test $? -ne 0; then
    echo Error while transforming $i - skipped. >&2
   else
+   chmod "$tempfile" --reference="$i"
    if mv "$tempfile" "$i"; then
      jpegexiforient -1 "$i" > /dev/null
    fi

More complicated (and slightly more secure) fix which runs stat before and chmod after mv:

--- /usr/bin/exifautotran       2007-02-27 20:31:07.000000000 +0100
+++ /home/mrlemming/bin/exifautotran    2007-06-13 21:49:51.000000000 +0200
@@ -43,7 +43,12 @@
   if test $? -ne 0; then
    echo Error while transforming $i - skipped. >&2
   else
+   oldmode=`stat -c%a "$i"`
+   oldmode_rc=$?
    if mv "$tempfile" "$i"; then
+     if test $oldmode_rc -eq 0; then
+       chmod $oldmode "$i"
+     fi
      jpegexiforient -1 "$i" > /dev/null
    fi
   fi
Comment 1 Jakub Moc (RETIRED) gentoo-dev 2008-02-05 10:06:08 UTC

*** This bug has been marked as a duplicate of bug 206285 ***