Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Make fchown() an overrideable system call in os_unix.c. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
98efac9630ca96ba0497c8e206dc5022 |
User & Date: | drh 2012-02-11 23:55:15.455 |
Context
2012-02-13
| ||
08:50 | Fix a typo in the type of the fchown() function in os_unix.c. (check-in: bfbfe05b81 user: dan tags: trunk) | |
2012-02-11
| ||
23:55 | Make fchown() an overrideable system call in os_unix.c. (check-in: 98efac9630 user: drh tags: trunk) | |
22:19 | Cleanup some directories and files left by the MinGW build, even when using the MSVC Makefile. (check-in: 3ab89e255d user: mistachkin tags: trunk) | |
Changes
Changes to src/os_unix.c.
︙ | ︙ | |||
415 416 417 418 419 420 421 422 423 424 425 426 427 428 | { "mkdir", (sqlite3_syscall_ptr)mkdir, 0 }, #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].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. | > > > | 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | { "mkdir", (sqlite3_syscall_ptr)mkdir, 0 }, #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, #define osFchown ((int(*)(const char*,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. |
︙ | ︙ | |||
3909 3910 3911 3912 3913 3914 3915 | /* If this process is running as root, make sure that the SHM file ** is owned by the same user that owns the original database. Otherwise, ** the original owner will not be able to connect. If this process is ** not root, the following fchown() will fail, but we don't care. The ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler ** warnings. */ | | | 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 | /* If this process is running as root, make sure that the SHM file ** is owned by the same user that owns the original database. Otherwise, ** the original owner will not be able to connect. If this process is ** not root, the following fchown() will fail, but we don't care. The ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler ** warnings. */ if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ pDbFd->ctrlFlags |= UNIXFILE_CHOWN; } /* Check to see if another process is holding the dead-man switch. ** If not, truncate the file to zero length. */ rc = SQLITE_OK; |
︙ | ︙ | |||
5125 5126 5127 5128 5129 5130 5131 | ** journal or WAL file, set the ownership of the journal or WAL to be ** the same as the original database. If we are not running as root, ** then the fchown() call will fail, but that's ok. The "if(){}" and ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler ** warnings from gcc. */ if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ | | | 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 | ** journal or WAL file, set the ownership of the journal or WAL to be ** the same as the original database. If we are not running as root, ** then the fchown() call will fail, but that's ok. The "if(){}" and ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler ** warnings from gcc. */ if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } } } assert( fd>=0 ); if( pOutFlags ){ *pOutFlags = flags; } |
︙ | ︙ | |||
6835 6836 6837 6838 6839 6840 6841 | UNIXVFS("unix-proxy", proxyIoFinder ), #endif }; unsigned int i; /* Loop counter */ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ | | | 6838 6839 6840 6841 6842 6843 6844 6845 6846 6847 6848 6849 6850 6851 6852 | 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/syscall.test.
︙ | ︙ | |||
56 57 58 59 60 61 62 | #------------------------------------------------------------------------- # Tests for the xNextSystemCall method. # foreach s { open close access getcwd stat fstat ftruncate fcntl read pread write pwrite fchmod fallocate pread64 pwrite64 unlink openDirectory mkdir rmdir | | | 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | #------------------------------------------------------------------------- # Tests for the xNextSystemCall method. # foreach s { open close access getcwd stat fstat ftruncate fcntl read pread write pwrite fchmod fallocate pread64 pwrite64 unlink openDirectory mkdir rmdir statvfs fchown } { if {[test_syscall exists $s]} {lappend syscall_list $s} } do_test 3.1 { lsort [test_syscall list] } [lsort $syscall_list] #------------------------------------------------------------------------- # This test verifies that if a call to open() fails and errno is set to |
︙ | ︙ |