Sorry, I forgot to mention that my earlier patch was against the 1.6 branch.
Attached is a patch against the CVS HEAD.  This one is properly created using
make-gnucash-patch.
# Remember file permissions when saving book files.
# 
# To apply this patch:
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'applypatch' program with this patch file as input.
#
# If you do not have 'applypatch', it is part of the 'makepatch' package
# that you can fetch from the Comprehensive Perl Archive Network:
# http://www.perl.com/CPAN/authors/Johan_Vromans/makepatch-x.y.tar.gz
# In the above URL, 'x' should be 2 or higher.
#
# To apply this patch without the use of 'applypatch':
# STEP 1: Chdir to the source directory.
# STEP 2: Run the 'patch' program with this file as input.
#
#### End of Preamble ####

#### Patch data follows ####
diff -up 'tmp/gnucash/src/backend/file/gnc-backend-file.c' 
'gnucash/src/backend/file/gnc-backend-file.c'
Index: ./src/backend/file/gnc-backend-file.c
--- ./src/backend/file/gnc-backend-file.c       Wed May  8 10:22:22 2002
+++ ./src/backend/file/gnc-backend-file.c       Tue Jul 16 22:40:49 2002
@@ -626,6 +626,8 @@ gnc_file_be_write_to_file(FileBackend *b
     const gchar *datafile;
     char *tmp_name;
     GNCBook *book;
+    struct stat statbuf;
+    int rc;
 
     book = gnc_session_get_book (be->session);
 
@@ -651,6 +653,20 @@ gnc_file_be_write_to_file(FileBackend *b
   
     if(gnc_book_write_to_xml_file_v2(book, tmp_name)) 
     {
+        /* Record the file's permissions before unlinking it */
+        rc = stat(datafile, &statbuf);
+        if(rc == 0)
+        {
+            /* Use the permissions from the original data file */
+            if(chmod(tmp_name, statbuf.st_mode) != 0)
+            {
+                PWARN("unable to chmod filename %s: %s",
+                        datafile ? datafile : "(null)", 
+                        strerror(errno) ? strerror(errno) : ""); 
+                g_free(tmp_name);
+                return FALSE;
+            }
+        }
         if(unlink(datafile) != 0 && errno != ENOENT)
         {
             xaccBackendSetError((Backend*)be, ERR_BACKEND_MISC);
#### End of Patch data ####

#### ApplyPatch data follows ####
# Data version        : 1.0
# Date generated      : Wed Jul 17 07:00:45 2002
# Generated by        : makepatch 2.00_03
# Recurse directories : Yes
# Excluded files      : (\A|.*/)CVS(/.*|\Z)
#                       (\A|.*/)RCS(/.*|\Z)
#                       ,v\Z
#                       (\A|.*/)SCCS(/.*|\Z)
#                       (\A|.*/)[sp]\..+\Z
# p 'src/backend/file/gnc-backend-file.c' 17486 1026884449 0100640
#### End of ApplyPatch data ####

#### End of Patch kit [created: Wed Jul 17 07:00:45 2002] ####
#### Patch checksum: 51 1922 3075 ####
#### Checksum: 69 2594 59266 ####


Reply via email to