[GRASS-SVN] r55339 - in grass/branches/releasebranch_6_4/lib: gis init

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Mar 12 13:13:51 PDT 2013


Author: martinl
Date: 2013-03-12 13:13:51 -0700 (Tue, 12 Mar 2013)
New Revision: 55339

Modified:
   grass/branches/releasebranch_6_4/lib/gis/mapset_msc.c
   grass/branches/releasebranch_6_4/lib/init/variables.html
Log:
backport GRASS_SKIP_MAPSET_OWNER_CHECK from trunk


Modified: grass/branches/releasebranch_6_4/lib/gis/mapset_msc.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/gis/mapset_msc.c	2013-03-12 19:47:34 UTC (rev 55338)
+++ grass/branches/releasebranch_6_4/lib/gis/mapset_msc.c	2013-03-12 20:13:51 UTC (rev 55339)
@@ -87,6 +87,22 @@
     return G__make_mapset_element(buf);
 }
 
+static int check_owner(const struct stat *info)
+{
+#if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK)
+    return 1;
+#else
+    const char *check = getenv("GRASS_SKIP_MAPSET_OWNER_CHECK");
+    if (check && *check)
+	return 1;
+    if (info->st_uid != getuid())
+	return 0;
+    if (info->st_uid != geteuid())
+	return 0;
+    return 1;
+#endif
+}
+
 /*!
    \brief Check for user mapset permission
 
@@ -108,12 +124,8 @@
     if (!S_ISDIR(info.st_mode))
 	return -1;
 
-#ifndef __MINGW32__
-    if (info.st_uid != getuid())
+    if (!check_owner(&info))
 	return 0;
-    if (info.st_uid != geteuid())
-	return 0;
-#endif
 
     return 1;
 }
@@ -142,12 +154,8 @@
     if (!S_ISDIR(info.st_mode))
 	return -1;
 
-#ifndef __MINGW32__
-    if (info.st_uid != getuid())
+    if (!check_owner(&info))
 	return 0;
-    if (info.st_uid != geteuid())
-	return 0;
-#endif
 
     return 1;
 }

Modified: grass/branches/releasebranch_6_4/lib/init/variables.html
===================================================================
--- grass/branches/releasebranch_6_4/lib/init/variables.html	2013-03-12 19:47:34 UTC (rev 55338)
+++ grass/branches/releasebranch_6_4/lib/init/variables.html	2013-03-12 20:13:51 UTC (rev 55339)
@@ -239,6 +239,11 @@
 	 <br>  set to any value to prevent user mail on error
 	 -->
 
+  <dt>GRASS_SKIP_MAPSET_OWNER_CHECK</dt>
+  <dd>By default it is not possible to work with MAPSETs that are
+    not owned by current user. Setting this variable to any non-empty value
+    allows the check to be skipped.</dd>
+
   <dt>GRASS_SH</dt>
   <dd>[shell scripts on Windows]<br>
     path to bourne shell interpreter used to run shell scripts.</dd>



More information about the grass-commit mailing list