Add support for the SQLITE_ACCESS_SYMLINK flag in the Win32 VFS.

FossilOrigin-Name: 175c15008e9f19b8f6762c2fe4a545735128765081980eed01d5e46ca4acb500
This commit is contained in:
mistachkin 2019-11-18 23:48:03 +00:00
parent dc96192eef
commit 3c161e07af
5 changed files with 136 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C Ensure\sall\sfile\snames\spassed\sto\sthe\sVFS\slayer\sare\sdouble-zero\sterminated.
D 2019-11-18T22:34:07.591
C Add\ssupport\sfor\sthe\sSQLITE_ACCESS_SYMLINK\sflag\sin\sthe\sWin32\sVFS.
D 2019-11-18T23:48:03.608
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@ -490,7 +490,7 @@ F src/in-operator.md 10cd8f4bcd225a32518407c2fb2484089112fd71
F src/insert.c 8701d80b3cecd47f0375483c1ef35dfcdc777f3c67e2d3581dd7841b980910a3
F src/legacy.c d7874bc885906868cd51e6c2156698f2754f02d9eee1bae2d687323c3ca8e5aa
F src/loadext.c d74f5e7bd51f3c9d283442473eb65aef359664efd6513591c03f01881c4ae2da
F src/main.c 1505735106a694a6a62f28d912de74c5fe3dfbacdd3aa78a63eb97d0754f8b49
F src/main.c 868ae7db7a54fe859bf2ca8b7a4f24e9fa03a6134abfb7c9801d08411ef5dacb
F src/malloc.c 550021fcae36f0ffe9f8563d83e6385f9df307a854d55d7d0abb7241ee8dbcc6
F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645
F src/mem1.c c12a42539b1ba105e3707d0e628ad70e611040d8f5e38cf942cee30c867083de
@ -511,7 +511,7 @@ F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
F src/os_unix.c ca1cc9524cb3ae8d59529fb37944487bec89df2041da7c3890f96dae389c5719
F src/os_win.c 48513ab173c3f107571c7d886e157ce32c65e6b2adce030469ce488cce8aaa90
F src/os_win.c 87a38901f217d2ea467fbb67b8501727f81592603de0624b86fa1f3221bf40cf
F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
F src/pager.c 49630bdba882b82537fc9fd93b126f566949ef913df99f4c303e5e371d2fb331
F src/pager.h 217921e81eb5fe455caa5cda96061959706bcdd29ddb57166198645ef7822ac3
@ -1389,6 +1389,7 @@ F test/swarmvtab2.test c948cb2fdfc5b01d85e8f6d6504854202dc1a0782ab2a0ed61538f27c
F test/swarmvtab3.test 247aa38b6ebd2b99db2075847ae47e789ac34f1c2ab5c720dfcffd990004c544
F test/swarmvtabfault.test 8a67a9f27c61073a47990829e92bc0c64420a807cb642b15a25f6c788210ed95
F test/symlink.test 72b22238d4405ba34df8e60b335d290a3b1129fd5c260835c944c1e4e77288a9
F test/symlink2.test 9531f475a53d8781c4f81373f87faf2e2aff4f5fb2102ec6386e0c827916a670
F test/sync.test 89539f4973c010eda5638407e71ca7fddbcd8e0594f4c9980229f804d4333092
F test/sync2.test 8f9f7d4f6d5be8ca8941a8dadcc4299e558cb6a1ff653a9469146c7a76ef2039
F test/syscall.test a39d9a36f852ae6e4800f861bc2f2e83f68bbc2112d9399931ecfadeabd2d69d
@ -1849,7 +1850,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 2e98b42fcb7bc38e22808a9dc1d7a4231ed08ffa97c9f08f33e6e8cd8726856c
R 3cc9c5dab6b657ab3fce27b16e2a45d7
P 251230cf43c591cf49cf9d2f392581c57d334b791bc3407814d216b5999c32f4
R 56b7f85a172b558e822b474dc28c8cf9
U mistachkin
Z 2d92c1a1e87a1733fa25d847d72de03a
Z 34494ca0cc8e59abb6f30277bbbb05af

View File

@ -1 +1 @@
251230cf43c591cf49cf9d2f392581c57d334b791bc3407814d216b5999c32f4
175c15008e9f19b8f6762c2fe4a545735128765081980eed01d5e46ca4acb500

View File

@ -1390,6 +1390,7 @@ const char *sqlite3ErrName(int rc){
case SQLITE_CANTOPEN_ISDIR: zName = "SQLITE_CANTOPEN_ISDIR"; break;
case SQLITE_CANTOPEN_FULLPATH: zName = "SQLITE_CANTOPEN_FULLPATH"; break;
case SQLITE_CANTOPEN_CONVPATH: zName = "SQLITE_CANTOPEN_CONVPATH"; break;
case SQLITE_CANTOPEN_SYMLINK: zName = "SQLITE_CANTOPEN_SYMLINK"; break;
case SQLITE_PROTOCOL: zName = "SQLITE_PROTOCOL"; break;
case SQLITE_EMPTY: zName = "SQLITE_EMPTY"; break;
case SQLITE_SCHEMA: zName = "SQLITE_SCHEMA"; break;

View File

@ -80,6 +80,14 @@
# define NTDDI_WINTHRESHOLD 0x06040000
#endif
/*
** This constant is needed by the winAccess function; therefore, define
** it when it is missing from the SDK header files.
*/
#ifndef FILE_ATTRIBUTE_REPARSE_POINT
# define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400
#endif
/*
** Check to see if the GetVersionEx[AW] functions are deprecated on the
** target system. GetVersionEx was first deprecated in Win8.1.
@ -5473,7 +5481,8 @@ static int winAccess(
(attr & FILE_ATTRIBUTE_READONLY)==0;
break;
case SQLITE_ACCESS_SYMLINK:
rc = 0; /* No symlinks on windows */
rc = attr!=INVALID_FILE_ATTRIBUTES &&
(attr & FILE_ATTRIBUTE_REPARSE_POINT)!=0;
break;
default:
assert(!"Invalid flags argument");

116
test/symlink2.test Normal file
View File

@ -0,0 +1,116 @@
# 2019 November 18
#
# 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. The
# focus of this file is testing that SQLite can follow symbolic links.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix symlink2
# This only runs on Windows.
if {$::tcl_platform(platform)!="windows"} {
finish_test
return
}
proc createWin32Symlink { link target } {
exec -- $::env(ComSpec) /c mklink \
[file nativename $link] [file nativename $target]
return ""
}
proc deleteWin32Symlink { link } {
exec -- $::env(ComSpec) /c del [file nativename $link]
return ""
}
proc canCreateWin32Symlink {} {
set link [file join $::testdir lnk[pid].sym]
if {[file exists $link]} { return 0 }
set target [info nameofexecutable]
if {[catch {createWin32Symlink $link $target}] == 0} {
deleteWin32Symlink $link
return 1
}
return 0
}
# Creating symlinks may require administrator privileges on Windows.
if {![canCreateWin32Symlink]} {
finish_test
return
}
# Ensure that test.db has been created.
#
do_execsql_test 1.0 {
CREATE TABLE t1(x, y);
INSERT INTO t1 VALUES(1,9999);
}
do_test 2.0 {
createWin32Symlink link.db test.db
} {}
do_test 2.1 {
file exists test.db
} {1}
do_test 2.2 {
file exists link.db
} {1}
do_test 3.1 {
execsql { SELECT x, y FROM t1; } db
} {1 9999}
do_test 3.2 {
sqlite3 db2 link.db
execsql { SELECT x, y FROM t1; } db2
} {1 9999}
do_test 3.3 {
sqlite3 db3 test.db -nofollow true
execsql { SELECT x, y FROM t1; } db3
} {1 9999}
do_test 3.4 {
db3 close
} {}
do_test 3.5 {
list [catch {
sqlite3 db4 link.db -nofollow true
execsql { SELECT x, y FROM t1; } db4
} res] $res
} {1 {unable to open database file}}
catch {db4 close}
do_test 4.0 {
db2 close
deleteWin32Symlink link.db
} {}
do_test 4.1 {
file exists test.db
} {1}
do_test 4.2 {
file exists link.db
} {0}
do_test 5.1 {
execsql { SELECT x, y FROM t1; } db
} {1 9999}
finish_test