diff options
author | drh <drh@noemail.net> | 2019-03-25 15:06:16 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2019-03-25 15:06:16 +0000 |
commit | e7476115ad9c9090cc3be93fb5bfc42bcd60961e (patch) | |
tree | 4ba5ca241a7f47aba9d4f9c5b1ae0d6a39448ff3 /ext/misc/fileio.c | |
parent | b17ea9123063ef103e177f0578394f951b3524d8 (diff) | |
download | sqlite-e7476115ad9c9090cc3be93fb5bfc42bcd60961e.tar.gz sqlite-e7476115ad9c9090cc3be93fb5bfc42bcd60961e.zip |
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
Diffstat (limited to 'ext/misc/fileio.c')
-rw-r--r-- | ext/misc/fileio.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/misc/fileio.c b/ext/misc/fileio.c index 7bb8c5efb..8f0fe3084 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); } } |