[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: gaf.git: branch: master updated (1.7.1-20110619-164-g2298561)



The branch, master has been updated
       via  22985618d999e1b54009b7a3e4f07b27b449f91d (commit)
      from  19bf47f7ca84bb4a9a19460fff9bbbf378bc2dab (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 libgeda/src/a_basic.c |   13 +++++++++++++
 libgeda/src/f_basic.c |   11 +++++++++++
 2 files changed, 24 insertions(+), 0 deletions(-)


=================
 Commit Messages
=================

commit 22985618d999e1b54009b7a3e4f07b27b449f91d
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make sure File->Save respects file permissions.
    
    Added g_access calls to f_save and o_save to abort saving if the
    destination file is read-only.
    
    Closes-bug: lp-698565
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

:100644 100644 2868891... 9be1f1b... M	libgeda/src/a_basic.c
:100644 100644 a843b33... 5438530... M	libgeda/src/f_basic.c

=========
 Changes
=========

commit 22985618d999e1b54009b7a3e4f07b27b449f91d
Author: Peter TB Brett <peter@xxxxxxxxxxxxx>
Commit: Peter TB Brett <peter@xxxxxxxxxxxxx>

    libgeda: Make sure File->Save respects file permissions.
    
    Added g_access calls to f_save and o_save to abort saving if the
    destination file is read-only.
    
    Closes-bug: lp-698565
    Reviewed-by: Peter TB Brett <peter@xxxxxxxxxxxxx>

diff --git a/libgeda/src/a_basic.c b/libgeda/src/a_basic.c
index 2868891..9be1f1b 100644
--- a/libgeda/src/a_basic.c
+++ b/libgeda/src/a_basic.c
@@ -215,6 +215,10 @@ gchar *o_save_objects (TOPLEVEL *toplevel, const GList *object_list, gboolean sa
 /*! \brief Save a file
  *  \par Function Description
  *  This function saves the data in a libgeda format to a file
+ *
+ *  \bug g_access introduces a race condition in certain cases, but
+ *  solves bug #698565 in the normal use-case
+ *
  *  \param [in] toplevel    The current TOPLEVEL.
  *  \param [in] object_list The head of a GList of OBJECTs to save.
  *  \param [in] filename    The filename to save the data to.
@@ -226,6 +230,15 @@ int o_save (TOPLEVEL *toplevel, const GList *object_list,
 {
   char *buffer;
 
+  /* Check to see if real filename is writable; if file doesn't exists
+     we assume all is well */
+  if (g_file_test(filename, G_FILE_TEST_EXISTS) && 
+      g_access(filename, W_OK) != 0) {
+    g_set_error (err, G_FILE_ERROR, G_FILE_ERROR_PERM,
+                 _("File %s is read-only"), filename);
+    return 0;      
+  }
+
   buffer = o_save_buffer (toplevel, object_list);
   if (!g_file_set_contents (filename, buffer, strlen(buffer), err)) {
     g_free (buffer);
diff --git a/libgeda/src/f_basic.c b/libgeda/src/f_basic.c
index a843b33..5438530 100644
--- a/libgeda/src/f_basic.c
+++ b/libgeda/src/f_basic.c
@@ -347,6 +347,9 @@ void f_close(TOPLEVEL *toplevel)
  *  \par Function Description
  *  This function saves the current schematic file in the toplevel object.
  *
+ *  \bug g_access introduces a race condition in certain cases, but
+ *  solves bug #698565 in the normal use-case
+ *
  *  \param [in,out] toplevel  The TOPLEVEL object containing the schematic.
  *  \param [in]      filename  The file name to save the schematic to.
  *  \param [in,out] err       #GError structure for error reporting, or
@@ -373,6 +376,14 @@ int f_save(TOPLEVEL *toplevel, PAGE *page, const char *filename, GError **err)
                  tmp_err->message);
     return 0;
   }
+
+  /* Check to see if filename is writable */
+  if (g_file_test(filename, G_FILE_TEST_EXISTS) && 
+      g_access(filename, W_OK) != 0) {
+    g_set_error (err, G_FILE_ERROR, G_FILE_ERROR_PERM,
+                 _("File %s is read-only"), filename);
+    return 0;      
+  }
   
   /* Get the directory in which the real filename lives */
   dirname = g_path_get_dirname (real_filename);




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs