Changeset: 8b97f691d862 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8b97f691d862
Modified Files:
common/utils/mutils.h
gdk/gdk_bbp.c
gdk/gdk_storage.c
monetdb5/mal/mal_profiler.c
sql/backends/monet5/UDF/capi/capi.c
Branch: Apr2019
Log Message:
Trust user's umask setting to protect created files/directories.
Note that monetdbd set umask to 077 (i.e. only access by owner).
This fixes bug 2416.
diffs (97 lines):
diff --git a/common/utils/mutils.h b/common/utils/mutils.h
--- a/common/utils/mutils.h
+++ b/common/utils/mutils.h
@@ -48,13 +48,17 @@ mutils_export char *dirname(char *path);
/* if one doesn't exist, presumably they all don't exist - Not so on MinGW */
#define S_IRUSR 0000400 /* read permission, owner */
#define S_IWUSR 0000200 /* write permission, owner */
+#define S_IXUSR 0000100 /* execute permission, owner */
#define S_IRGRP 0000040 /* read permission, group */
-#define S_IWGRP 0000020 /* write permission, grougroup */
+#define S_IWGRP 0000020 /* write permission, group */
+#define S_IXGRP 0000010 /* execute permission, group */
#define S_IROTH 0000004 /* read permission, other */
#define S_IWOTH 0000002 /* write permission, other */
+#define S_IXOTH 0000001 /* execute permission, other */
#endif
#define MONETDB_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH |
S_IWOTH)
+#define MONETDB_DIRMODE (MONETDB_MODE | S_IXUSR | S_IXGRP |
S_IXOTH)
#define F_TEST 3 /* test a region for other processes locks. */
#define F_TLOCK 2 /* test and lock a region for exclusive
use */
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1241,7 +1241,7 @@ BBPaddfarm(const char *dirname, int role
if (rolemask == 0 || (rolemask & 1 && BBPfarms[0].dirname != NULL)) {
GDKfatal("BBPaddfarm: bad rolemask\n");
}
- if (mkdir(dirname, 0755) < 0) {
+ if (mkdir(dirname, MONETDB_DIRMODE) < 0) {
if (errno == EEXIST) {
if (stat(dirname, &st) == -1 || !S_ISDIR(st.st_mode)) {
GDKfatal("BBPaddfarm: %s: not a directory\n",
dirname);
@@ -3029,7 +3029,7 @@ BBPprepare(bool subcommit)
backup_dir = 0;
ret = BBPrecover(0);
if (ret == GDK_SUCCEED) {
- if (mkdir(bakdirpath, 0755) < 0 && errno != EEXIST) {
+ if (mkdir(bakdirpath, MONETDB_DIRMODE) < 0 && errno !=
EEXIST) {
GDKsyserror("BBPprepare: cannot create
directory %s\n", bakdirpath);
ret = GDK_FAIL;
}
@@ -3039,7 +3039,7 @@ BBPprepare(bool subcommit)
}
if (ret == GDK_SUCCEED && start_subcommit) {
/* make a new SUBDIR (subdir of BAKDIR) */
- if (mkdir(subdirpath, 0755) < 0) {
+ if (mkdir(subdirpath, MONETDB_DIRMODE) < 0) {
GDKsyserror("BBPprepare: cannot create directory %s\n",
subdirpath);
ret = GDK_FAIL;
}
@@ -3425,7 +3425,7 @@ BBPrecover(int farmid)
dstdir = dstpath + j;
IODEBUG fprintf(stderr, "#BBPrecover(start)\n");
- if (mkdir(leftdirpath, 0755) < 0 && errno != EEXIST) {
+ if (mkdir(leftdirpath, MONETDB_DIRMODE) < 0 && errno != EEXIST) {
GDKsyserror("BBPrecover: cannot create directory %s\n",
leftdirpath);
closedir(dirp);
GDKfree(bakdirpath);
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -118,7 +118,7 @@ GDKcreatedir(const char *dir)
#ifdef WIN32
strlen(path) > 3 &&
#endif
- mkdir(path, 0755) < 0) {
+ mkdir(path, MONETDB_DIRMODE) < 0) {
if (errno != EEXIST) {
GDKsyserror("GDKcreatedir: cannot create
directory %s\n", path);
IODEBUG fprintf(stderr, "#GDKcreatedir:
mkdir(%s) failed\n", path);
diff --git a/monetdb5/mal/mal_profiler.c b/monetdb5/mal/mal_profiler.c
--- a/monetdb5/mal/mal_profiler.c
+++ b/monetdb5/mal/mal_profiler.c
@@ -599,7 +599,7 @@ startTrace(str path)
MT_lock_set(&mal_profileLock );
if(eventstream == NULL && offlinestore ==0){
snprintf(buf,FILENAME_MAX,"%s%c%s",GDKgetenv("gdk_dbpath"), DIR_SEP, path);
- if (mkdir(buf, 0755) < 0 && errno != EEXIST) {
+ if (mkdir(buf, MONETDB_DIRMODE) < 0 && errno != EEXIST)
{
MT_lock_unset(&mal_profileLock);
throw(MAL, "profiler.startTrace",
SQLSTATE(42000) "Failed to create directory %s", buf);
}
diff --git a/sql/backends/monet5/UDF/capi/capi.c
b/sql/backends/monet5/UDF/capi/capi.c
--- a/sql/backends/monet5/UDF/capi/capi.c
+++ b/sql/backends/monet5/UDF/capi/capi.c
@@ -693,7 +693,7 @@ static str CUDFeval(Client cntxt, MalBlk
msg = createException(MAL, "cudf.eval",
MAL_MALLOC_FAIL);
goto wrapup;
}
- if (mkdir(deldirpath, 0755) < 0 && errno != EEXIST) {
+ if (mkdir(deldirpath, 0777) < 0 && errno != EEXIST) {
msg = createException(MAL, "cudf.eval",
"cannot
create directory %s\n", deldirpath);
goto wrapup;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list