Fix bug 2999830: do not report failed chown() on copy.
authorVladislav Naumov <vnaum@vnaum.com>
Thu, 16 Dec 2010 20:55:03 +0000 (21:55 +0100)
committerVladimir Nadvornik <nadvornik@suse.cz>
Tue, 27 Sep 2011 12:19:01 +0000 (14:19 +0200)
Debian bug 574853 reported by Ian Zimmerman <itz@buug.org>

I was trying to copy images from my camera which is mounted as a USB
mass storage device.  The files on the mount are owned by root, and
geeqie tries to chown (and chgrp) the copy, fails, and displays an
error message.  This is only mildly annoying when copying a single
file, but when I want to copy multiple files the failure stops the
operation after the first file.

Patch by Vladislav Naumov <vnaum@vnaum.com>

This patch ignores chown errors, while still doing chown
(so root still can copy files preserving ownership).

http://sourceforge.net/tracker/?func=detail&aid=2999830&group_id=222125&atid=1054680
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=574853 (original report)

src/ui_fileops.c

index aa3cc8d..33c6560 100644 (file)
@@ -490,8 +490,14 @@ gboolean copy_file_attributes(const gchar *s, const gchar *t, gint perms, gint m
 
                /* set the dest file attributes to that of source (ignoring errors) */
 
-               if (perms && chown(tl, st.st_uid, st.st_gid) < 0) ret = FALSE;
-               if (perms && chmod(tl, st.st_mode) < 0) ret = FALSE;
+               if (perms)
+                       {
+                       ret = chown(tl, st.st_uid, st.st_gid);
+                       /* Ignores chown errors, while still doing chown
+                          (so root still can copy files preserving ownership) */
+                       ret = TRUE;
+                       if (chmod(tl, st.st_mode) < 0) ret = FALSE;
+                       }
 
                tb.actime = st.st_atime;
                tb.modtime = st.st_mtime;