From: drh Date: Mon, 25 Mar 2019 15:06:16 +0000 (+0000) Subject: Fix the writefile() SQL function implemented by ext/misc/fileio.c such that X-Git-Tag: version-3.28.0~96 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e7476115ad9c9090cc3be93fb5bfc42bcd60961e;p=thirdparty%2Fsqlite.git Fix the writefile() SQL function implemented by ext/misc/fileio.c such that any directories created have standard umask permissions, not permissions of the file that is to be written. FossilOrigin-Name: f11c89595dc65f89be6df62830c8cddd3933acfd4baaecd348ecd99e71db5831 --- diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 7bb8c5efbe..8f0fe3084d 100644 --- a/ext/misc/fileio.c +++ b/ext/misc/fileio.c @@ -293,15 +293,15 @@ static int fileLinkStat( ** Argument zFile is the name of a file that will be created and/or written ** by SQL function writefile(). This function ensures that the directory ** zFile will be written to exists, creating it if required. The permissions -** for any path components created by this function are set to (mode&0777). +** for any path components created by this function are set in accordance +** with the current umask. ** ** If an OOM condition is encountered, SQLITE_NOMEM is returned. Otherwise, ** SQLITE_OK is returned if the directory is successfully created, or ** SQLITE_ERROR otherwise. */ static int makeDirectory( - const char *zFile, - mode_t mode + const char *zFile ){ char *zCopy = sqlite3_mprintf("%s", zFile); int rc = SQLITE_OK; @@ -322,7 +322,7 @@ static int makeDirectory( rc2 = fileStat(zCopy, &sStat); if( rc2!=0 ){ - if( mkdir(zCopy, mode & 0777) ) rc = SQLITE_ERROR; + if( mkdir(zCopy, 0777) ) rc = SQLITE_ERROR; }else{ if( !S_ISDIR(sStat.st_mode) ) rc = SQLITE_ERROR; } @@ -480,7 +480,7 @@ static void writefileFunc( res = writeFile(context, zFile, argv[1], mode, mtime); if( res==1 && errno==ENOENT ){ - if( makeDirectory(zFile, mode)==SQLITE_OK ){ + if( makeDirectory(zFile)==SQLITE_OK ){ res = writeFile(context, zFile, argv[1], mode, mtime); } } diff --git a/manifest b/manifest index ea0eb78148..ceaa2d1074 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sthe\s".archive\s--update"\scommand\sin\sthe\sCLI,\sonly\supdate\sfiles\sif\stheir\nmtime\sor\smode\shas\schanged.\s\sTo\sforce\san\supdate,\suse\sthe\snew\s--insert\sinstead. -D 2019-03-25T14:24:19.101 +C Fix\sthe\swritefile()\sSQL\sfunction\simplemented\sby\sext/misc/fileio.c\ssuch\sthat\nany\sdirectories\screated\shave\sstandard\sumask\spermissions,\snot\spermissions\nof\sthe\sfile\sthat\sis\sto\sbe\swritten. +D 2019-03-25T15:06:16.816 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -286,7 +286,7 @@ F ext/misc/csv.c 7f047aeb68f5802e7ce6639292095d622a488bb43526ed04810e0649faa71ce F ext/misc/dbdump.c baf6e37447c9d6968417b1cd34cbedb0b0ab3f91b5329501d8a8d5be3287c336 F ext/misc/eval.c 4b4757592d00fd32e44c7a067e6a0e4839c81a4d57abc4131ee7806d1be3104e F ext/misc/explain.c d5c12962d79913ef774b297006872af1fccda388f61a11d37758f9179a09551f -F ext/misc/fileio.c b8e9421ea5bc10d300230c06f26baff2dc0fc04dcfe007c1258e1411144bda8b +F ext/misc/fileio.c 54dff4a21c4dac784a3daf0bb085f19343b3b7c4e8061f4b1494b691e2e4a301 F ext/misc/fossildelta.c 910510968a30ab77b8ac1a27931f2cb834e9db9fd5ab122f53b6045b4315665d F ext/misc/fuzzer.c c4e27daf41433a64cad5265cd27dbcb891147e9994d0422200ce81ce9a54b625 F ext/misc/ieee754.c f190d0cc5182529acb15babd177781be1ac1718c @@ -1807,7 +1807,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 7a0a26ed380dd0bdda50b0204b30b53bbbbc70f278eba02f91541ac6c691aef2 -R e5d0aae7927eed4a86cf78b0bf846424 +P 191a023ae708490eca61b3a42a3df41bb6709079f3905881abb82ebd46182607 +R 0b42a1a08fa95c825c79a098e3edba8d U drh -Z 1d4ed68130e2fc4467c4c956c87b0a62 +Z cc72a2ef5eb3e08d527f17d5141c1543 diff --git a/manifest.uuid b/manifest.uuid index 1994a59352..cbd1975563 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -191a023ae708490eca61b3a42a3df41bb6709079f3905881abb82ebd46182607 \ No newline at end of file +f11c89595dc65f89be6df62830c8cddd3933acfd4baaecd348ecd99e71db5831 \ No newline at end of file