[Gnucash-changes] r12132 - gnucash/trunk - Don't chown() the owner,

Christian Stimming cstim at cvs.gnucash.org
Mon Dec 5 15:39:35 EST 2005


Author: cstim
Date: 2005-12-05 15:39:34 -0500 (Mon, 05 Dec 2005)
New Revision: 12132
Trac: http://svn.gnucash.org/trac/changeset/12132

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/backend/file/gnc-backend-file.c
Log:
Don't chown() the owner,
only root can do that. Ignore errors on chown() since that means
the save completed successful anyway.


Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2005-12-05 14:51:50 UTC (rev 12131)
+++ gnucash/trunk/ChangeLog	2005-12-05 20:39:34 UTC (rev 12132)
@@ -1,3 +1,9 @@
+2005-12-05  Christian Stimming  <stimming at tuhh.de>
+
+	* src/backend/file/gnc-backend-file.c: Don't chown() the owner,
+	only root can do that. Ignore errors on chown() since that means
+	the save completed successful anyway.
+
 2005-12-04  Derek Atkins  <derek at ihtfp.com>
 
 	* configure.in: fix some of the output strings

Modified: gnucash/trunk/src/backend/file/gnc-backend-file.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-backend-file.c	2005-12-05 14:51:50 UTC (rev 12131)
+++ gnucash/trunk/src/backend/file/gnc-backend-file.c	2005-12-05 20:39:34 UTC (rev 12132)
@@ -552,23 +552,32 @@
             if(chmod(tmp_name, statbuf.st_mode) != 0)
             {
                 qof_backend_set_error(be, ERR_BACKEND_PERM);
+		/* FIXME: Even if the chmod did fail, the save
+		   nevertheless completed successfully. It is
+		   therefore wrong to signal the ERR_BACKEND_PERM
+		   error here which implies that the saving itself
+		   failed! What should we do? */
                 PWARN("unable to chmod filename %s: %s",
-                        datafile ? datafile : "(null)", 
+                        tmp_name ? tmp_name : "(null)", 
                         strerror(errno) ? strerror(errno) : ""); 
 #if VFAT_DOESNT_SUCK  /* chmod always fails on vfat fs */
                 g_free(tmp_name);
                 return FALSE;
 #endif
             }
-            if(chown(tmp_name, statbuf.st_uid, statbuf.st_gid) != 0)
+	    /* Don't try to change the owner. Only root can do
+	       that. */
+            if(chown(tmp_name, -1, statbuf.st_gid) != 0)
             {
-                qof_backend_set_error(be, ERR_BACKEND_PERM);
+	        /* qof_backend_set_error(be, ERR_BACKEND_PERM); */
+	        /* A failed chown doesn't mean that the saving itself
+		   failed. So don't abort with an error here! */
                 PWARN("unable to chown filename %s: %s",
-                        datafile ? datafile : "(null)", 
+                        tmp_name ? tmp_name : "(null)", 
                         strerror(errno) ? strerror(errno) : ""); 
 #if VFAT_DOESNT_SUCK /* chown always fails on vfat fs */
-                g_free(tmp_name);
-                return FALSE;
+                /* g_free(tmp_name);
+		   return FALSE; */
 #endif
             }
         }



More information about the gnucash-changes mailing list