2002-07-21 Christian Stimming <stimming@tuhh.de>

* src/backend/file/gnc-backend-file.c: File permission fix by Matt
	Brubeck <mbrubeck@cs.hmc.edu>


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@7121 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Christian Stimming 2002-07-21 21:33:29 +00:00
parent d9acfb3341
commit 0ca1681638
2 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2002-07-21 Christian Stimming <stimming@tuhh.de>
* src/backend/file/gnc-backend-file.c: File permission fix by Matt
Brubeck <mbrubeck@cs.hmc.edu>
2002-07-11 Derek Atkins <derek@ihtfp.com> 2002-07-11 Derek Atkins <derek@ihtfp.com>
* change gncEntry->account into gncEntry->invAccount and * change gncEntry->account into gncEntry->invAccount and

View File

@ -626,6 +626,8 @@ gnc_file_be_write_to_file(FileBackend *be, gboolean make_backup)
const gchar *datafile; const gchar *datafile;
char *tmp_name; char *tmp_name;
GNCBook *book; GNCBook *book;
struct stat statbuf;
int rc;
book = gnc_session_get_book (be->session); book = gnc_session_get_book (be->session);
@ -651,6 +653,20 @@ gnc_file_be_write_to_file(FileBackend *be, gboolean make_backup)
if(gnc_book_write_to_xml_file_v2(book, tmp_name)) 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) if(unlink(datafile) != 0 && errno != ENOENT)
{ {
xaccBackendSetError((Backend*)be, ERR_BACKEND_MISC); xaccBackendSetError((Backend*)be, ERR_BACKEND_MISC);