]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
When extracting links from sqlar archives, clobber any existing file or link, and...
authordan <Dan Kennedy>
Mon, 6 May 2024 20:21:31 +0000 (20:21 +0000)
committerdan <Dan Kennedy>
Mon, 6 May 2024 20:21:31 +0000 (20:21 +0000)
FossilOrigin-Name: 2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782

ext/misc/fileio.c
manifest
manifest.uuid
test/shell8.test

index 70546adfcaa7d51939a9e588c558b6eb4d507ca0..ca8090ed2e9c19c1713393f0be12985e86840b10 100644 (file)
@@ -372,7 +372,9 @@ static int writeFile(
 #if !defined(_WIN32) && !defined(WIN32)
   if( S_ISLNK(mode) ){
     const char *zTo = (const char*)sqlite3_value_text(pData);
-    if( zTo==0 || symlink(zTo, zFile)<0 ) return 1;
+    if( zTo==0 ) return 1;
+    unlink(zFile);
+    if( symlink(zTo, zFile)<0 ) return 1;
   }else
 #endif
   {
@@ -458,13 +460,19 @@ static int writeFile(
       return 1;
     }
 #else
-    /* Legacy unix */
-    struct timeval times[2];
-    times[0].tv_usec = times[1].tv_usec = 0;
-    times[0].tv_sec = time(0);
-    times[1].tv_sec = mtime;
-    if( utimes(zFile, times) ){
-      return 1;
+    /* Legacy unix. 
+    **
+    ** Do not use utimes() on a symbolic link - it sees through the link and
+    ** modifies the timestamps on the target. Or fails if the target does 
+    ** not exist.  */
+    if( 0==S_ISLNK(mode) ){
+      struct timeval times[2];
+      times[0].tv_usec = times[1].tv_usec = 0;
+      times[0].tv_sec = time(0);
+      times[1].tv_sec = mtime;
+      if( utimes(zFile, times) ){
+        return 1;
+      }
     }
 #endif
   }
index adb660aa80e206077a9c02171a07d513bacfad3e..1414eb97567e0cb1079abea453084ec21e8b248b 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Omit\sredundant\sunary\s+\soperators\sfrom\sthe\sAST.
-D 2024-05-06T20:18:30.134
+C When\sextracting\slinks\sfrom\ssqlar\sarchives,\sclobber\sany\sexisting\sfile\sor\slink,\sand\sdo\snot\scall\sutimes()\sto\sset\sthe\stimestamp\s-\sit\slooks\sthrough\sthe\slink\sand\soperates\son\sthe\starget.
+D 2024-05-06T20:21:31.369
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -391,7 +391,7 @@ F ext/misc/dbdump.c b8592f6f2da292c62991a13864a60d6c573c47a9cc58362131b9e6a64f82
 F ext/misc/decimal.c 172cf81a8634e6a0f0bedaf71a8372fee63348cf5a3c4e1b78bb233c35889fdc
 F ext/misc/eval.c 04bc9aada78c888394204b4ed996ab834b99726fb59603b0ee3ed6e049755dc1
 F ext/misc/explain.c 606100185fb90d6a1eade1ed0414d53503c86820d8956a06e3b0a56291894f2b
-F ext/misc/fileio.c d88e60f63557d76d4e38acffda5556b2ab42e98f5d830897f22aba65930d975c
+F ext/misc/fileio.c 916638042f318701460485032e33981056747d0f92e6757aa9499f2363ea7047
 F ext/misc/fossildelta.c 8c026e086e406e2b69947f1856fa3b848fff5379962276430d10085b8756b05a
 F ext/misc/fuzzer.c 8b28acf1a7e95d50e332bdd47e792ff27054ad99d3f9bc2e91273814d4b31a5a
 F ext/misc/ieee754.c 62a90978204d2c956d5036eb89e548e736ca5fac0e965912867ddd7bb833256d
@@ -1615,7 +1615,7 @@ F test/shell4.test 522fdc628c55eff697b061504fb0a9e4e6dfc5d9087a633ab0f3dd11bcc4f
 F test/shell5.test 5b2ab1c0540217773f939927c24163a56257446da3f564d4724042620bfea762
 F test/shell6.test e3b883b61d4916b6906678a35f9d19054861123ad91b856461e0a456273bdbb8
 F test/shell7.test 753c6ece5361df50025a50cadf378ea36db9cc05fb23d7a96cff7fa130626ef9
-F test/shell8.test 9b71d56a6f6fc62edd9163534ac21eaa328ad95f1b9026e7bd08d5b4621eacf6
+F test/shell8.test aea51ecbcd4494c746b096aeff51d841d04d5f0dc4b62eb42427f16109b87acd
 F test/shell9.test 8742a5b390cdcef6369f5aa223e415aa4255a4129ef249b177887dc635a87209
 F test/shmlock.test 3dbf017d34ab0c60abe6a44e447d3552154bd0c87b41eaf5ceacd408dd13fda5
 F test/shortread1.test bb591ef20f0fd9ed26d0d12e80eee6d7ac8897a3
@@ -2189,8 +2189,8 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P 70abc144ca90a58ea25dc2d90683545246c084d961215c20ec070b0abe640371
-R 6e7646721881518bcc2dce999a09299b
-U drh
-Z 6285aee0842c44c0bef4e5561a9995b3
+P f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8
+R 11a1bb72646a7cee54c6968ddd222fda
+U dan
+Z 139d76aa50084d40f26f43b610be1a4e
 # Remove this line to create a well-formed Fossil manifest.
index 1eabb503c33acdc02c0d2f62079644cf772889ec..2c00a6909fe5700588df6bc29ddf344db1d5429c 100644 (file)
@@ -1 +1 @@
-f81cc149e5e308785502b36e83eaaf3d31c72520793e0596d5496abd70f9cda8
\ No newline at end of file
+2bf8c3f99ad8b74f707d17272fa12b674bec66082d3e8349ebef3dac42ba0782
\ No newline at end of file
index 944173a2a129a0c1c08c45ac36e2c5269882299e..ca37598e93c1be303e769a37c5edece4ff713710 100644 (file)
@@ -165,7 +165,7 @@ foreach {tn tcl} {
   #
   # Because it is slow, only do this for $tn==1.
   if {$tn==1} {
-    do_test 1.$tn.1 {
+    do_test 1.$tn.4 {
       catchcmd test_ar.db $c1
       file delete -force ar1
       after 2000
@@ -194,4 +194,29 @@ do_test 2.1.1 {
   regsub -all {ar4} [dir_content ar4] ar2
 } {ar2/file1 ar2/file2 ar2/junk1}
 
+# Test symbolic links.
+#
+if {$tcl_platform(platform)=="unix"} {
+  populate_dir ar2 {
+    file1 "1234" 
+    file2 "3456"
+  }
+  file link ar2/link1 file1
+
+  forcedelete shell8.db
+  forcedelete link1
+
+  do_test 3.1 {
+    catchcmd shell8.db {.ar -C ar2 -c file2 link1 }
+  } {0 {}}
+
+  do_test 3.2 {
+    catchcmd shell8.db {.ar -x} 
+  } {0 {}}
+
+  do_test 3.3 {
+    catchcmd shell8.db {.ar -x} 
+  } {0 {}}
+}
+
 finish_test