[GRASS-SVN] r68983 - grass/trunk/display/d.mon

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Jul 15 10:06:47 PDT 2016


Author: martinl
Date: 2016-07-15 10:06:47 -0700 (Fri, 15 Jul 2016)
New Revision: 68983

Modified:
   grass/trunk/display/d.mon/start.c
Log:
d.mon: check for write permission if output is defined

Modified: grass/trunk/display/d.mon/start.c
===================================================================
--- grass/trunk/display/d.mon/start.c	2016-07-15 16:50:46 UTC (rev 68982)
+++ grass/trunk/display/d.mon/start.c	2016-07-15 17:06:47 UTC (rev 68983)
@@ -1,6 +1,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <libgen.h>
 #include <grass/gis.h>
 #include <grass/spawn.h>
 #include <grass/display.h>
@@ -57,7 +58,18 @@
         putenv("GRASS_RENDER_IMMEDIATE=");
     }
     else {
+        char *dir_name;
+        
         output_name = output;
+        /* check write permission */
+        dir_name = G_store(output_name);
+        dirname(dir_name);
+        if (access(dir_name, W_OK) != 0)
+            G_fatal_error(_("Unable to start monitor, don't have "
+                            "write permission for <%s>"), output_name);
+        G_free(dir_name);
+        
+        /* check if file exists */
         if (!update && access(output_name, F_OK) == 0) {
             if (G_get_overwrite()) {
                 G_warning(_("File <%s> already exists and will be overwritten"), output_name);



More information about the grass-commit mailing list