When creating a journal file on unix, attempt to create it with the same permissions as the associated database file.
FossilOrigin-Name: a121cd80c5ac94e5977bc3164d2500e0ea132fed
This commit is contained in:
parent
473c1bf241
commit
c74e4ef4c7
15
manifest
15
manifest
@ -1,5 +1,5 @@
|
||||
C Change\sa\scomment\sinside\sa\sblock\sof\scode\sin\sparse.y\sfrom\sC++\sto\sC\sstyle.
|
||||
D 2010-07-15T11:14:21
|
||||
C When\screating\sa\sjournal\sfile\son\sunix,\sattempt\sto\screate\sit\swith\sthe\ssame\spermissions\sas\sthe\sassociated\sdatabase\sfile.
|
||||
D 2010-07-15T14:59:38
|
||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||
F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
|
||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||
@ -154,7 +154,7 @@ F src/os.c 60178f518c4d6c0dcb59f7292232281d7bea2dcf
|
||||
F src/os.h 9dbed8c2b9c1f2f2ebabc09e49829d4777c26bf9
|
||||
F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
|
||||
F src/os_os2.c 665876d5eec7585226b0a1cf5e18098de2b2da19
|
||||
F src/os_unix.c fd7706aaec6ad9e424c95f3fb2c7d2444507295d
|
||||
F src/os_unix.c 73cce1696c0c9e27a6277946b016e4f2077e365e
|
||||
F src/os_win.c 61734aad7f50b28f3c76eb4b19b63472f6d825d9
|
||||
F src/pager.c 78ca1e1f3315c8227431c403c04d791dccf242fb
|
||||
F src/pager.h 879fdde5a102d2f21a3135d6f647530b21c2796c
|
||||
@ -467,7 +467,8 @@ F test/join4.test 1a352e4e267114444c29266ce79e941af5885916
|
||||
F test/join5.test 86675fc2919269aa923c84dd00ee4249b97990fe
|
||||
F test/join6.test bf82cf3f979e9eade83ad0d056a66c5ed71d1901
|
||||
F test/journal1.test 36f2d1bb9bf03f790f43fbdb439e44c0657fab19
|
||||
F test/journal2.test c59fec987580f74b94aa0b98f7f2402302424ba5
|
||||
F test/journal2.test 50a3604768494d4a337f194f0a9480e7c57dcb72
|
||||
F test/journal3.test ff175219be1b02d2f7e54297ad7e491b7533edb6
|
||||
F test/jrnlmode.test 2d5a8b6d68de8512f522532731d90ca96912f3b7
|
||||
F test/jrnlmode2.test a19e28de1a6ec898067e46a122f1b71c9323bf00
|
||||
F test/jrnlmode3.test cfcdb12b90e640a23b92785a002d96c0624c8710
|
||||
@ -835,7 +836,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||
P e1e7312580a8b19825b0c52fa8af6c9382f99f22
|
||||
R 84215f67e32b4dc7cd2cfa6cd094b1ee
|
||||
P dea7d33b2d7d25280a31a2b9c1573f4292b81187
|
||||
R 68b8490911573c353c565f7397abe3e4
|
||||
U dan
|
||||
Z 730d67b6e48588ae98c6eb9e72b28f71
|
||||
Z 3d98b70e949007093904a9e0327dbd7d
|
||||
|
@ -1 +1 @@
|
||||
dea7d33b2d7d25280a31a2b9c1573f4292b81187
|
||||
a121cd80c5ac94e5977bc3164d2500e0ea132fed
|
@ -4311,13 +4311,14 @@ static UnixUnusedFd *findReusableFd(const char *zPath, int flags){
|
||||
**
|
||||
** If the file being opened is a temporary file, it is always created with
|
||||
** the octal permissions 0600 (read/writable by owner only). If the file
|
||||
** is a database, journal or master journal file, it is created with the
|
||||
** permissions mask SQLITE_DEFAULT_FILE_PERMISSIONS.
|
||||
** is a database or master journal file, it is created with the permissions
|
||||
** mask SQLITE_DEFAULT_FILE_PERMISSIONS.
|
||||
**
|
||||
** Finally, if the file being opened is a WAL file, then this function
|
||||
** queries the file-system for the permissions on the corresponding database
|
||||
** file and sets *pMode to this value. Whenever possible, WAL files are
|
||||
** created using the same permissions as the associated database file.
|
||||
** Finally, if the file being opened is a WAL or regular journal file, then
|
||||
** this function queries the file-system for the permissions on the
|
||||
** corresponding database file and sets *pMode to this value. Whenever
|
||||
** possible, WAL and journal files are created using the same permissions
|
||||
** as the associated database file.
|
||||
*/
|
||||
static int findCreateFileMode(
|
||||
const char *zPath, /* Path of file (possibly) being created */
|
||||
@ -4325,12 +4326,12 @@ static int findCreateFileMode(
|
||||
mode_t *pMode /* OUT: Permissions to open file with */
|
||||
){
|
||||
int rc = SQLITE_OK; /* Return Code */
|
||||
if( flags & SQLITE_OPEN_WAL ){
|
||||
if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
|
||||
char zDb[MAX_PATHNAME+1]; /* Database file path */
|
||||
int nDb; /* Number of valid bytes in zDb */
|
||||
struct stat sStat; /* Output of stat() on database file */
|
||||
|
||||
nDb = sqlite3Strlen30(zPath) - 4;
|
||||
nDb = sqlite3Strlen30(zPath) - ((flags & SQLITE_OPEN_WAL) ? 4 : 8);
|
||||
memcpy(zDb, zPath, nDb);
|
||||
zDb[nDb] = '\0';
|
||||
if( 0==stat(zDb, &sStat) ){
|
||||
@ -4473,6 +4474,7 @@ static int unixOpen(
|
||||
rc = findCreateFileMode(zName, flags, &openMode);
|
||||
if( rc!=SQLITE_OK ){
|
||||
assert( !p->pUnused );
|
||||
assert( eType==SQLITE_OPEN_WAL || eType==SQLITE_OPEN_MAIN_JOURNAL );
|
||||
return rc;
|
||||
}
|
||||
fd = open(zName, openFlags, openMode);
|
||||
|
@ -8,7 +8,8 @@
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
# This file implements regression tests for SQLite library. Specifically,
|
||||
# it tests SQLite when using a VFS that claims the SAFE_DELETE property.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
|
60
test/journal3.test
Normal file
60
test/journal3.test
Normal file
@ -0,0 +1,60 @@
|
||||
# 2010 July 15
|
||||
#
|
||||
# The author disclaims copyright to this source code. In place of
|
||||
# a legal notice, here is a blessing:
|
||||
#
|
||||
# May you do good and not evil.
|
||||
# May you find forgiveness for yourself and forgive others.
|
||||
# May you share freely, never taking more than you give.
|
||||
#
|
||||
#***********************************************************************
|
||||
# This file implements regression tests for SQLite library.
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# If a connection is required to create a journal file, it creates it with
|
||||
# the same file-system permissions as the database file itself. Test this.
|
||||
#
|
||||
if {$::tcl_platform(platform) == "unix"} {
|
||||
|
||||
set umask [exec /bin/sh -c umask]
|
||||
faultsim_delete_and_reopen
|
||||
do_test journal3-1.1 { execsql { CREATE TABLE tx(y, z) } } {}
|
||||
|
||||
foreach {tn permissions} {
|
||||
1 00644
|
||||
2 00666
|
||||
3 00600
|
||||
4 00755
|
||||
} {
|
||||
db close
|
||||
set effective [format %.5o [expr $permissions & ~$umask]]
|
||||
do_test journal3-1.2.$tn.1 {
|
||||
catch { file delete -force test.db-journal }
|
||||
file attributes test.db -permissions $permissions
|
||||
file attributes test.db -permissions
|
||||
} $permissions
|
||||
do_test journal3-1.2.$tn.2 { file exists test.db-journal } {0}
|
||||
do_test journal3-1.2.$tn.3 {
|
||||
sqlite3 db test.db
|
||||
execsql {
|
||||
BEGIN;
|
||||
INSERT INTO tx DEFAULT VALUES;
|
||||
}
|
||||
file exists test.db-journal
|
||||
} {1}
|
||||
do_test journal3-1.2.$tn.4 {
|
||||
file attr test.db-journal -perm
|
||||
} $effective
|
||||
do_execsql_test journal3-1.2.$tn.5 { ROLLBACK } {}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
finish_test
|
Loading…
x
Reference in New Issue
Block a user