]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
In the unix VFS layer, do not attempt to chown() the journal to be the same
authordrh <drh@noemail.net>
Wed, 25 Sep 2019 10:36:31 +0000 (10:36 +0000)
committerdrh <drh@noemail.net>
Wed, 25 Sep 2019 10:36:31 +0000 (10:36 +0000)
as the database if running in 8+3 filename mode.  Also, update the comments
on the chown() attempt to be more precise.

FossilOrigin-Name: ab853724a7e01ca32167d294c3c80d6632e805bdf39b6d56db82226a00ad72dc

manifest
manifest.uuid
src/os_unix.c

index 71dffcf2b9b4b145c1778ac585a5c9abd6641c01..90533824ee28e806ec2fc81576ae05ff819311ef 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Simplifications\sto\sthe\swindow-function\scode.
-D 2019-09-25T02:07:50.126
+C In\sthe\sunix\sVFS\slayer,\sdo\snot\sattempt\sto\schown()\sthe\sjournal\sto\sbe\sthe\ssame\nas\sthe\sdatabase\sif\srunning\sin\s8+3\sfilename\smode.\s\sAlso,\supdate\sthe\scomments\non\sthe\schown()\sattempt\sto\sbe\smore\sprecise.
+D 2019-09-25T10:36:31.568
 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
 F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
@@ -509,7 +509,7 @@ F src/os.c 20f7b32c1e8839999fa7e79756a6cdc3041b44d7fc635c25a1b9399180d1fbd9
 F src/os.h 48388821692e87da174ea198bf96b1b2d9d83be5dfc908f673ee21fafbe0d432
 F src/os_common.h b2f4707a603e36811d9b1a13278bffd757857b85
 F src/os_setup.h 0dbaea40a7d36bf311613d31342e0b99e2536586
-F src/os_unix.c 4ec5b1305ced509ca52c4c0cb3aeabed2ed3972147b4090cf94eb31d48caeb53
+F src/os_unix.c 1397a88988042f62c927112ad1b8f2da237af6481bef7baceba239d5626c0fb6
 F src/os_win.c 035a813cbd17f355bdcad7ab894af214a9c13a1db8aeac902365350b98cd45a7
 F src/os_win.h 7b073010f1451abe501be30d12f6bc599824944a
 F src/pager.c 422fd8cfa59fb9173eff36a95878904a0eeb0dcc62ba49350acc8b1e51c4dc7b
@@ -1845,7 +1845,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 040e196a8be3ca41b9365310ab88c2a3cc84b918a6511c77a6d95d4b4e0da3ed
-R 02b8e74e10c2a3befb5f0a26449e5da2
+P 489a1eb3aa2f1225b97b50a5f8688cf1a4ab0371973da1badc29616d70386c03
+R a970b333f692ae0da1db4b0608810d83
 U drh
-Z 7b42b889d8658d1e92a0c5a1635cb7d8
+Z 345f1a3a9cf94b0b740b8d6356f31b97
index 373391ba94b2c45a270ff0bbd8c43511c75b2c81..b8ec073444b2042b2a4ad9ee27c8cf8ae93397b8 100644 (file)
@@ -1 +1 @@
-489a1eb3aa2f1225b97b50a5f8688cf1a4ab0371973da1badc29616d70386c03
\ No newline at end of file
+ab853724a7e01ca32167d294c3c80d6632e805bdf39b6d56db82226a00ad72dc
\ No newline at end of file
index 3c1d48a4d92533e9d94a12b52fbe7daeba0022fb..ae9356a7178442e61340669aace65d4c9a6f5c93 100644 (file)
@@ -5824,7 +5824,7 @@ static int getFileMode(
 ** If the SQLITE_ENABLE_8_3_NAMES option is enabled, then the
 ** original filename is unavailable.  But 8_3_NAMES is only used for
 ** FAT filesystems and permissions do not matter there, so just use
-** the default permissions.
+** the default permissions.  In 8_3_NAMES mode, leave *pMode set to zero.
 */
 static int findCreateFileMode(
   const char *zPath,              /* Path of file (possibly) being created */
@@ -6059,11 +6059,19 @@ static int unixOpen(
       goto open_finished;
     }
 
-    /* If this process is running as root and if creating a new rollback
-    ** journal or WAL file, set the ownership of the journal or WAL to be
-    ** the same as the original database.
+    /* The owner of the rollback journal or WAL file should always be the
+    ** same as the owner of the database file.  Try to ensure that this is
+    ** the case.  The chown() system call will be a no-op if the current
+    ** process lacks root privileges, be we should at least try.  Without
+    ** this step, if a root process opens a database file, it can leave
+    ** behinds a journal/WAL that is owned by root and hence make the
+    ** database inaccessible to unprivileged processes.
+    **
+    ** If openFlags==0, then that means uid and gid are not set correctly
+    ** (probably because SQLite is configured to use 8+3 filename mode) and
+    ** in that case we do not want to attempt the chown().
     */
-    if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
+    if( openFlags && (flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL))!=0 ){
       robustFchown(fd, uid, gid);
     }
   }