Skip to content

Commit 737b8f3

Browse files
committed
Allow mapset ownership test to be skipped
git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54264 15284696-431f-4ddb-bdfa-cd5b030d7da7
1 parent 62af5fd commit 737b8f3

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

lib/gis/mapset_msc.c

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,22 @@ int G__make_mapset_element_misc(const char *dir, const char *name)
8888
return G__make_mapset_element(buf);
8989
}
9090

91+
static int check_owner(const STRUCT_STAT *info)
92+
{
93+
#if defined(__MINGW32__) || defined(SKIP_MAPSET_OWN_CHK)
94+
return 1;
95+
#else
96+
const char *check = getenv("GRASS_SKIP_MAPSET_OWNER_CHECK");
97+
if (check && *check)
98+
return 1;
99+
if (info->st_uid != getuid())
100+
return 0;
101+
if (info->st_uid != geteuid())
102+
return 0;
103+
return 1;
104+
#endif
105+
}
106+
91107
/*!
92108
\brief Check for user mapset permission
93109
@@ -109,12 +125,8 @@ int G__mapset_permissions(const char *mapset)
109125
if (!S_ISDIR(info.st_mode))
110126
return -1;
111127

112-
#ifndef __MINGW32__
113-
if (info.st_uid != getuid())
128+
if (!check_owner(&info))
114129
return 0;
115-
if (info.st_uid != geteuid())
116-
return 0;
117-
#endif
118130

119131
return 1;
120132
}
@@ -143,16 +155,8 @@ int G__mapset_permissions2(const char *gisdbase, const char *location,
143155
if (!S_ISDIR(info.st_mode))
144156
return -1;
145157

146-
#ifndef SKIP_MAPSET_OWN_CHK
147-
148-
#ifndef __MINGW32__
149-
if (info.st_uid != getuid())
150-
return 0;
151-
if (info.st_uid != geteuid())
158+
if (!check_owner(&info))
152159
return 0;
153-
#endif
154-
155-
#endif
156160

157161
return 1;
158162
}

0 commit comments

Comments
 (0)