]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Do not use umask() since it change the umask for the entire process, not just
authordrh <drh@noemail.net>
Fri, 4 Jan 2013 20:45:13 +0000 (20:45 +0000)
committerdrh <drh@noemail.net>
Fri, 4 Jan 2013 20:45:13 +0000 (20:45 +0000)
the thread using SQLite.  Make whatever permission changes are needed using
fchmod() after the file is created, instead.

FossilOrigin-Name: 6c4c2b7dbadedac384d380efd54f12f6ccbf4ca9

manifest
manifest.uuid
src/os_unix.c
test/pager1.test
test/tkt3457.test

index 06dd34b3aac6d4e24e1b891f8c4ec43ce923cd3a..fc4287150fb263cca5a7c2b37678921521f704b9 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\san\sout-of-order\slocal\svariable\sdeclaration\sin\stest_regexp.c.
-D 2013-01-04T19:22:33.550
+C Do\snot\suse\sumask()\ssince\sit\schange\sthe\sumask\sfor\sthe\sentire\sprocess,\snot\sjust\nthe\sthread\susing\sSQLite.\s\sMake\swhatever\spermission\schanges\sare\sneeded\susing\nfchmod()\safter\sthe\sfile\sis\screated,\sinstead.
+D 2013-01-04T20:45:13.018
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in a48faa9e7dd7d556d84f5456eabe5825dd8a6282
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -160,7 +160,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30
 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
 F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57
 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
-F src/os_unix.c ad459bb62eb6f3f6aae26d97b1a28fbac7bf0260
+F src/os_unix.c dfdc04b126f7b05dcb2e2cc5c1262f98acbb49d9
 F src/os_win.c ce1f5db8a7bb4d6f2092b1b2cb9631bec54a6320
 F src/pager.c 4092c907222cfd451c74fe6bd2fd64b342f7190f
 F src/pager.h 1109a06578ec5574dc2c74cf8d9f69daf36fe3e0
@@ -643,7 +643,7 @@ F test/openv2.test 0d3040974bf402e19b7df4b783e447289d7ab394
 F test/orderby1.test f33968647da5c546528fe4d2bf86c6a6a2e5a7ae
 F test/orderby2.test bc11009f7cd99d96b1b11e57b199b00633eb5b04
 F test/oserror.test 50417780d0e0d7cd23cf12a8277bb44024765df3
-F test/pager1.test f4c57e14583da2183fe31555c67fb32feda96092
+F test/pager1.test 8e14e7cfd2fbfe65eabead73af10ceeb2fc676aa
 F test/pager2.test 745b911dde3d1f24ae0870bd433dfa83d7c658c1
 F test/pager3.test 3856d9c80839be0668efee1b74811b1b7f7fc95f
 F test/pagerfault.test 452f2cc23e3bfcfa935f4442aec1da4fe1dc0442
@@ -854,7 +854,7 @@ F test/tkt3357.test 77c37c6482b526fe89941ce951c22d011f5922ed
 F test/tkt3419.test 1bbf36d7ea03b638c15804251287c2391f5c1f6b
 F test/tkt3424.test 61f831bd2b071bd128fa5d00fbda57e656ca5812
 F test/tkt3442.test 0adb70e9fe9cb750a702065a68ad647409dbc158
-F test/tkt3457.test eb68bb3b19c8677cff06c639ff15d206dbf17fd6
+F test/tkt3457.test 9399bb34a42b4fd9d2152d3911059da6bcb9ed58
 F test/tkt3461.test 228ea328a5a21e8663f80ee3d212a6ad92549a19
 F test/tkt3493.test 1686cbde85f8721fc1bdc0ee72f2ef2f63139218
 F test/tkt3508.test d75704db9501625c7f7deec119fcaf1696aefb7d
@@ -1031,7 +1031,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac
-P 357231ec970adb5dfcdaf9665499141004cb1198
-R a527dbc47b1658d5a418c0dfd6c81b54
+P 8285b15a058811a9a8b452837f52e6a065868115
+R b31d73bc3af8c64e681b0e111a88b9c8
 U drh
-Z 08645dc8f534cbd544c716793612e513
+Z f0d816558f207d702a01b8e7c2fe1c14
index 49fe6447effd595bf8a90b0eb7368a539d818077..e93f7f4616b721aaa3f86b5ea11f88e3887d79b9 100644 (file)
@@ -1 +1 @@
-8285b15a058811a9a8b452837f52e6a065868115
\ No newline at end of file
+6c4c2b7dbadedac384d380efd54f12f6ccbf4ca9
\ No newline at end of file
index 315f15018887f93c2b8e01684d608ccd6e028bc6..dc13be186e4064e1b20e2ed121e47702e71e9e2b 100644 (file)
@@ -412,11 +412,7 @@ static struct unix_syscall {
 #define osPwrite64  ((ssize_t(*)(int,const void*,size_t,off_t))\
                     aSyscall[13].pCurrent)
 
-#if SQLITE_ENABLE_LOCKING_STYLE
   { "fchmod",       (sqlite3_syscall_ptr)fchmod,     0  },
-#else
-  { "fchmod",       (sqlite3_syscall_ptr)0,          0  },
-#endif
 #define osFchmod    ((int(*)(int,mode_t))aSyscall[14].pCurrent)
 
 #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE
@@ -441,9 +437,6 @@ static struct unix_syscall {
   { "fchown",       (sqlite3_syscall_ptr)posixFchown,     0 },
 #define osFchown    ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)
 
-  { "umask",        (sqlite3_syscall_ptr)umask,           0 },
-#define osUmask     ((mode_t(*)(mode_t))aSyscall[21].pCurrent)
-
 }; /* End of the overrideable system calls */
 
 /*
@@ -548,14 +541,7 @@ static const char *unixNextSystemCall(sqlite3_vfs *p, const char *zName){
 */
 static int robust_open(const char *z, int f, mode_t m){
   int fd;
-  mode_t m2;
-  mode_t origM = 0;
-  if( m==0 ){
-    m2 = SQLITE_DEFAULT_FILE_PERMISSIONS;
-  }else{
-    m2 = m;
-    origM = osUmask(0);
-  }
+  mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS;
   do{
 #if defined(O_CLOEXEC)
     fd = osOpen(z,f|O_CLOEXEC,m2);
@@ -563,12 +549,17 @@ static int robust_open(const char *z, int f, mode_t m){
     fd = osOpen(z,f,m2);
 #endif
   }while( fd<0 && errno==EINTR );
-  if( m ){
-    osUmask(origM);
-  }
+  if( fd>=0 ){
+    if( m!=0 ){
+      struct stat statbuf;
+      if( osFstat(fd, &statbuf)==0 && (statbuf.st_mode&0777)!=m ){
+        osFchmod(fd, m);
+      }
+    }
 #if defined(FD_CLOEXEC) && (!defined(O_CLOEXEC) || O_CLOEXEC==0)
-  if( fd>=0 ) osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+    osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
 #endif
+  }
   return fd;
 }
 
@@ -6994,7 +6985,7 @@ int sqlite3_os_init(void){
 
   /* Double-check that the aSyscall[] array has been constructed
   ** correctly.  See ticket [bb3a86e890c8e96ab] */
-  assert( ArraySize(aSyscall)==22 );
+  assert( ArraySize(aSyscall)==21 );
 
   /* Register all VFSes defined in the aVfs[] array */
   for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){
index 6849e55bbd496b6381a2d1d1e8b894d1bae2a293..6eafa1124448dd1d76a9ce579a718ce9dab68726 100644 (file)
@@ -883,12 +883,20 @@ do_execsql_test pager1.4.7.1 {
 tv filter {}
 db close
 tv delete 
+catch {
+  test_syscall install fchmod
+  test_syscall fault 1 1
+}
 do_test pager1.4.7.2 {
   faultsim_restore_and_reopen
   catch {file attributes test.db-journal -permissions r--------}
   catch {file attributes test.db-journal -readonly 1}
   catchsql { SELECT * FROM t1 }
 } {1 {unable to open database file}}
+catch {
+  test_syscall reset
+  test_syscall fault 0 0
+}
 do_test pager1.4.7.3 {
   db close
   catch {file attributes test.db-journal -permissions rw-rw-rw-}
index 7b9a1b35a34ba35e9d1af7308dff54e29a3ad5b7..bb279027a1ceea1cdab5e63f6b0116e6a08c8bf2 100644 (file)
@@ -32,7 +32,7 @@ if {$tcl_platform(platform) != "unix"} {
 #   tkt3457-1.3: Application has write but not read permission on
 #                the hot-journal file. Result: SQLITE_CANTOPEN.
 #
-#   tkt3457-1.4: Application has read but not write permission on
+#   tkt3457-1.4: Application has read but not write permission ongrep
 #                the hot-journal file. Result: SQLITE_CANTOPEN.
 #
 #   tkt3457-1.5: Application has read/write permission on the hot-journal 
@@ -62,6 +62,14 @@ do_test tkt3457-1.1 {
   execsql COMMIT
 } {}
 
+# Disable fchmod to make sure SQLite itself does not try to change the
+# permission bits on us
+#
+catch {
+  test_syscall install fchmod
+  test_syscall fault 1 1
+}
+
 do_test tkt3457-1.2 {
   forcecopy bak.db-journal test.db-journal
   file attributes test.db-journal -permissions ---------
@@ -84,4 +92,10 @@ do_test tkt3457-1.5 {
   catchsql { SELECT * FROM t1 }
 } {0 {1 2 3 4 5 6}}
 
+# Reenable fchmod
+catch {
+  test_syscall uninstall
+  test_syscall fault 0 0
+}
+
 finish_test