]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Fix the writefile() SQL function implemented by ext/misc/fileio.c such that
authordrh <drh@noemail.net>
Mon, 25 Mar 2019 15:06:16 +0000 (15:06 +0000)
committerdrh <drh@noemail.net>
Mon, 25 Mar 2019 15:06:16 +0000 (15:06 +0000)
any directories created have standard umask permissions, not permissions
of the file that is to be written.

FossilOrigin-Name: f11c89595dc65f89be6df62830c8cddd3933acfd4baaecd348ecd99e71db5831

ext/misc/fileio.c
manifest
manifest.uuid

index 7bb8c5efbe963fbf783b36ba307779484c1df145..8f0fe3084d02ee31539bd744446a30293c5c6a11 100644 (file)
@@ -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);
     }
   }
index ea0eb78148b9381464a53bfba8625ee5cd31644f..ceaa2d1074dc828898110493496e9ff463f67581 100644 (file)
--- 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
index 1994a593521981defd91c5c0969a890f5ceeef04..cbd19755634c525b7a99f77b6426f331fb1afb4b 100644 (file)
@@ -1 +1 @@
-191a023ae708490eca61b3a42a3df41bb6709079f3905881abb82ebd46182607
\ No newline at end of file
+f11c89595dc65f89be6df62830c8cddd3933acfd4baaecd348ecd99e71db5831
\ No newline at end of file