Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Do not use umask() since it change the umask for the entire process, not just the thread using SQLite. Make whatever permission changes are needed using fchmod() after the file is created, instead. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
6c4c2b7dbadedac384d380efd54f12f6 |
User & Date: | drh 2013-01-04 20:45:13 |
Context
2013-01-04
| ||
22:26 | Remove superfluous text from a comment. (check-in: e9ac5339 user: mistachkin tags: trunk) | |
20:45 | Do not use umask() since it change the umask for the entire process, not just the thread using SQLite. Make whatever permission changes are needed using fchmod() after the file is created, instead. (check-in: 6c4c2b7d user: drh tags: trunk) | |
19:22 | Fix an out-of-order local variable declaration in test_regexp.c. (check-in: 8285b15a user: drh tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
408 409 410 411 412 413 414 | { "pwrite64", (sqlite3_syscall_ptr)pwrite64, 0 }, #else { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, #endif #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ aSyscall[13].pCurrent) | < < < < | 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 | { "pwrite64", (sqlite3_syscall_ptr)pwrite64, 0 }, #else { "pwrite64", (sqlite3_syscall_ptr)0, 0 }, #endif #define osPwrite64 ((ssize_t(*)(int,const void*,size_t,off_t))\ aSyscall[13].pCurrent) { "fchmod", (sqlite3_syscall_ptr)fchmod, 0 }, #define osFchmod ((int(*)(int,mode_t))aSyscall[14].pCurrent) #if defined(HAVE_POSIX_FALLOCATE) && HAVE_POSIX_FALLOCATE { "fallocate", (sqlite3_syscall_ptr)posix_fallocate, 0 }, #else { "fallocate", (sqlite3_syscall_ptr)0, 0 }, #endif |
︙ | ︙ | |||
437 438 439 440 441 442 443 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) { "fchown", (sqlite3_syscall_ptr)posixFchown, 0 }, #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) | < < < | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) { "fchown", (sqlite3_syscall_ptr)posixFchown, 0 }, #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) }; /* End of the overrideable system calls */ /* ** This is the xSetSystemCall() method of sqlite3_vfs for all of the ** "unix" VFSes. Return SQLITE_OK opon successfully updating the ** system call pointer, or SQLITE_NOTFOUND if there is no configurable ** system call named zName. |
︙ | ︙ | |||
544 545 546 547 548 549 550 | ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a ** transaction crashes and leaves behind hot journals, then any ** process that is able to write to the database will also be able to ** recover the hot journals. */ static int robust_open(const char *z, int f, mode_t m){ int fd; | < < < | < < < < > | > > | | > | > | 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 | ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a ** transaction crashes and leaves behind hot journals, then any ** process that is able to write to the database will also be able to ** recover the hot journals. */ static int robust_open(const char *z, int f, mode_t m){ int fd; mode_t m2 = m ? m : SQLITE_DEFAULT_FILE_PERMISSIONS; do{ #if defined(O_CLOEXEC) fd = osOpen(z,f|O_CLOEXEC,m2); #else fd = osOpen(z,f,m2); #endif }while( fd<0 && errno==EINTR ); 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) osFcntl(fd, F_SETFD, osFcntl(fd, F_GETFD, 0) | FD_CLOEXEC); #endif } return fd; } /* ** Helper functions to obtain and relinquish the global mutex. The ** global mutex is used to protect the unixInodeInfo and ** vxworksFileId objects used by this file, all of which may be |
︙ | ︙ | |||
6990 6991 6992 6993 6994 6995 6996 | UNIXVFS("unix-proxy", proxyIoFinder ), #endif }; unsigned int i; /* Loop counter */ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ | | | 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 | UNIXVFS("unix-proxy", proxyIoFinder ), #endif }; unsigned int i; /* Loop counter */ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ assert( ArraySize(aSyscall)==21 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ sqlite3_vfs_register(&aVfs[i], i==0); } return SQLITE_OK; } |
︙ | ︙ |
Changes to test/pager1.test.
︙ | ︙ | |||
879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | INSERT INTO t1 VALUES('IV', 'sixteen'); INSERT INTO t1 VALUES('V' , 'twentyfive'); COMMIT; } {delete} tv filter {} db close tv delete 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}} do_test pager1.4.7.3 { db close catch {file attributes test.db-journal -permissions rw-rw-rw-} catch {file attributes test.db-journal -readonly 0} delete_file test.db-journal file exists test.db-journal } {0} | > > > > > > > > | 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 | INSERT INTO t1 VALUES('IV', 'sixteen'); INSERT INTO t1 VALUES('V' , 'twentyfive'); COMMIT; } {delete} 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-} catch {file attributes test.db-journal -readonly 0} delete_file test.db-journal file exists test.db-journal } {0} |
︙ | ︙ |
Changes to test/tkt3457.test.
︙ | ︙ | |||
28 29 30 31 32 33 34 | # # tkt3457-1.2: Application has neither read, nor write permission on # the hot-journal file. Result: SQLITE_CANTOPEN. # # tkt3457-1.3: Application has write but not read permission on # the hot-journal file. Result: SQLITE_CANTOPEN. # | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # # tkt3457-1.2: Application has neither read, nor write permission on # the hot-journal file. Result: SQLITE_CANTOPEN. # # 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 ongrep # the hot-journal file. Result: SQLITE_CANTOPEN. # # tkt3457-1.5: Application has read/write permission on the hot-journal # file. Result: SQLITE_OK. # do_test tkt3457-1.1 { execsql { |
︙ | ︙ | |||
57 58 59 60 61 62 63 64 65 66 67 68 69 70 | fconfigure $fd -encoding binary -translation binary seek $fd 0 puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" close $fd execsql COMMIT } {} do_test tkt3457-1.2 { forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions --------- catchsql { SELECT * FROM t1 } } {1 {unable to open database file}} do_test tkt3457-1.3 { | > > > > > > > > | 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | fconfigure $fd -encoding binary -translation binary seek $fd 0 puts -nonewline $fd "\xd9\xd5\x05\xf9\x20\xa1\x63\xd7" close $fd 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 --------- catchsql { SELECT * FROM t1 } } {1 {unable to open database file}} do_test tkt3457-1.3 { |
︙ | ︙ | |||
79 80 81 82 83 84 85 86 87 | } {1 {unable to open database file}} do_test tkt3457-1.5 { forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions rw-rw-rw- catchsql { SELECT * FROM t1 } } {0 {1 2 3 4 5 6}} finish_test | > > > > > > | 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | } {1 {unable to open database file}} do_test tkt3457-1.5 { forcecopy bak.db-journal test.db-journal file attributes test.db-journal -permissions rw-rw-rw- catchsql { SELECT * FROM t1 } } {0 {1 2 3 4 5 6}} # Reenable fchmod catch { test_syscall uninstall test_syscall fault 0 0 } finish_test |