Fossil SCM
Update to the latest version of SQLite, which among other things, includes the fix for unix whereby the umask is ignored when creating journal files. That means that any process that has write permission on a repository should be able to recover hot journals.
Commit
0a72346109624fec7b85481bfe8227b4fb14cd7f
Parent
7716c9852063a7d…
2 files changed
+55
-34
+1
-1
+55
-34
| --- src/sqlite3.c | ||
| +++ src/sqlite3.c | ||
| @@ -657,11 +657,11 @@ | ||
| 657 | 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | 659 | */ |
| 660 | 660 | #define SQLITE_VERSION "3.7.11" |
| 661 | 661 | #define SQLITE_VERSION_NUMBER 3007011 |
| 662 | -#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" | |
| 662 | +#define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130" | |
| 663 | 663 | |
| 664 | 664 | /* |
| 665 | 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | 667 | ** |
| @@ -15156,16 +15156,12 @@ | ||
| 15156 | 15156 | ** the malloc_usable_size() interface exists |
| 15157 | 15157 | ** on the target platform. Or, this symbol |
| 15158 | 15158 | ** can be set manually, if desired. |
| 15159 | 15159 | ** If an equivalent interface exists by |
| 15160 | 15160 | ** a different name, using a separate -D |
| 15161 | -** option to rename it. This symbol will | |
| 15162 | -** be enabled automatically on windows | |
| 15163 | -** systems, and malloc_usable_size() will | |
| 15164 | -** be redefined to _msize(), unless the | |
| 15165 | -** SQLITE_WITHOUT_MSIZE macro is defined. | |
| 15166 | -** | |
| 15161 | +** option to rename it. | |
| 15162 | +** | |
| 15167 | 15163 | ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone |
| 15168 | 15164 | ** memory allocator. Set this symbol to enable |
| 15169 | 15165 | ** building on older macs. |
| 15170 | 15166 | ** |
| 15171 | 15167 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| @@ -15180,17 +15176,15 @@ | ||
| 15180 | 15176 | ** macros. |
| 15181 | 15177 | */ |
| 15182 | 15178 | #ifdef SQLITE_SYSTEM_MALLOC |
| 15183 | 15179 | |
| 15184 | 15180 | /* |
| 15185 | -** Windows systems have malloc_usable_size() but it is called _msize(). | |
| 15181 | +** The MSVCRT has malloc_usable_size() but it is called _msize(). | |
| 15186 | 15182 | ** The use of _msize() is automatic, but can be disabled by compiling |
| 15187 | 15183 | ** with -DSQLITE_WITHOUT_MSIZE |
| 15188 | 15184 | */ |
| 15189 | -#if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN \ | |
| 15190 | - && !defined(SQLITE_WITHOUT_MSIZE) | |
| 15191 | -# define HAVE_MALLOC_USABLE_SIZE 1 | |
| 15185 | +#if defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE) | |
| 15192 | 15186 | # define SQLITE_MALLOCSIZE _msize |
| 15193 | 15187 | #endif |
| 15194 | 15188 | |
| 15195 | 15189 | #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) |
| 15196 | 15190 | |
| @@ -15216,11 +15210,12 @@ | ||
| 15216 | 15210 | */ |
| 15217 | 15211 | #define SQLITE_MALLOC(x) malloc(x) |
| 15218 | 15212 | #define SQLITE_FREE(x) free(x) |
| 15219 | 15213 | #define SQLITE_REALLOC(x,y) realloc((x),(y)) |
| 15220 | 15214 | |
| 15221 | -#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE) | |
| 15215 | +#if (defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)) \ | |
| 15216 | + || (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE)) | |
| 15222 | 15217 | # include <malloc.h> /* Needed for malloc_usable_size on linux */ |
| 15223 | 15218 | #endif |
| 15224 | 15219 | #ifdef HAVE_MALLOC_USABLE_SIZE |
| 15225 | 15220 | # ifndef SQLITE_MALLOCSIZE |
| 15226 | 15221 | # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) |
| @@ -25388,10 +25383,16 @@ | ||
| 25388 | 25383 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25389 | 25384 | |
| 25390 | 25385 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25391 | 25386 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25392 | 25387 | |
| 25388 | + { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, | |
| 25389 | +#define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) | |
| 25390 | + | |
| 25391 | + { "umask", (sqlite3_syscall_ptr)umask, 0 }, | |
| 25392 | +#define osUmask ((mode_t(*)(mode_t))aSyscall[21].pCurrent) | |
| 25393 | + | |
| 25393 | 25394 | }; /* End of the overrideable system calls */ |
| 25394 | 25395 | |
| 25395 | 25396 | /* |
| 25396 | 25397 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25397 | 25398 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -25474,15 +25475,40 @@ | ||
| 25474 | 25475 | } |
| 25475 | 25476 | return 0; |
| 25476 | 25477 | } |
| 25477 | 25478 | |
| 25478 | 25479 | /* |
| 25479 | -** Retry open() calls that fail due to EINTR | |
| 25480 | +** Invoke open(). Do so multiple times, until it either succeeds or | |
| 25481 | +** files for some reason other than EINTR. | |
| 25482 | +** | |
| 25483 | +** If the file creation mode "m" is 0 then set it to the default for | |
| 25484 | +** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally | |
| 25485 | +** 0644) as modified by the system umask. If m is not 0, then | |
| 25486 | +** make the file creation mode be exactly m ignoring the umask. | |
| 25487 | +** | |
| 25488 | +** The m parameter will be non-zero only when creating -wal, -journal, | |
| 25489 | +** and -shm files. We want those files to have *exactly* the same | |
| 25490 | +** permissions as their original database, unadulterated by the umask. | |
| 25491 | +** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a | |
| 25492 | +** transaction crashes and leaves behind hot journals, then any | |
| 25493 | +** process that is able to write to the database will also be able to | |
| 25494 | +** recover the hot journals. | |
| 25480 | 25495 | */ |
| 25481 | -static int robust_open(const char *z, int f, int m){ | |
| 25496 | +static int robust_open(const char *z, int f, mode_t m){ | |
| 25482 | 25497 | int rc; |
| 25483 | - do{ rc = osOpen(z,f,m); }while( rc<0 && errno==EINTR ); | |
| 25498 | + mode_t m2; | |
| 25499 | + mode_t origM; | |
| 25500 | + if( m==0 ){ | |
| 25501 | + m2 = SQLITE_DEFAULT_FILE_PERMISSIONS; | |
| 25502 | + }else{ | |
| 25503 | + m2 = m; | |
| 25504 | + origM = osUmask(0); | |
| 25505 | + } | |
| 25506 | + do{ rc = osOpen(z,f,m2); }while( rc<0 && errno==EINTR ); | |
| 25507 | + if( m ){ | |
| 25508 | + osUmask(origM); | |
| 25509 | + } | |
| 25484 | 25510 | return rc; |
| 25485 | 25511 | } |
| 25486 | 25512 | |
| 25487 | 25513 | /* |
| 25488 | 25514 | ** Helper functions to obtain and relinquish the global mutex. The |
| @@ -28826,12 +28852,11 @@ | ||
| 28826 | 28852 | if( pShmNode==0 ){ |
| 28827 | 28853 | struct stat sStat; /* fstat() info for database file */ |
| 28828 | 28854 | |
| 28829 | 28855 | /* Call fstat() to figure out the permissions on the database file. If |
| 28830 | 28856 | ** a new *-shm file is created, an attempt will be made to create it |
| 28831 | - ** with the same permissions. The actual permissions the file is created | |
| 28832 | - ** with are subject to the current umask setting. | |
| 28857 | + ** with the same permissions. | |
| 28833 | 28858 | */ |
| 28834 | 28859 | if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ |
| 28835 | 28860 | rc = SQLITE_IOERR_FSTAT; |
| 28836 | 28861 | goto shm_open_err; |
| 28837 | 28862 | } |
| @@ -28882,11 +28907,11 @@ | ||
| 28882 | 28907 | ** the original owner will not be able to connect. If this process is |
| 28883 | 28908 | ** not root, the following fchown() will fail, but we don't care. The |
| 28884 | 28909 | ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler |
| 28885 | 28910 | ** warnings. |
| 28886 | 28911 | */ |
| 28887 | - if( fchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ | |
| 28912 | + if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ | |
| 28888 | 28913 | pDbFd->ctrlFlags |= UNIXFILE_CHOWN; |
| 28889 | 28914 | } |
| 28890 | 28915 | |
| 28891 | 28916 | /* Check to see if another process is holding the dead-man switch. |
| 28892 | 28917 | ** If not, truncate the file to zero length. |
| @@ -29858,16 +29883,14 @@ | ||
| 29858 | 29883 | ** to create new files with. If no error occurs, then SQLITE_OK is returned |
| 29859 | 29884 | ** and a value suitable for passing as the third argument to open(2) is |
| 29860 | 29885 | ** written to *pMode. If an IO error occurs, an SQLite error code is |
| 29861 | 29886 | ** returned and the value of *pMode is not modified. |
| 29862 | 29887 | ** |
| 29863 | -** If the file being opened is a temporary file, it is always created with | |
| 29864 | -** the octal permissions 0600 (read/writable by owner only). If the file | |
| 29865 | -** is a database or master journal file, it is created with the permissions | |
| 29866 | -** mask SQLITE_DEFAULT_FILE_PERMISSIONS. | |
| 29867 | -** | |
| 29868 | -** Finally, if the file being opened is a WAL or regular journal file, then | |
| 29888 | +** In most cases cases, this routine sets *pMode to 0, which will become | |
| 29889 | +** an indication to robust_open() to create the file using | |
| 29890 | +** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask. | |
| 29891 | +** But if the file being opened is a WAL or regular journal file, then | |
| 29869 | 29892 | ** this function queries the file-system for the permissions on the |
| 29870 | 29893 | ** corresponding database file and sets *pMode to this value. Whenever |
| 29871 | 29894 | ** possible, WAL and journal files are created using the same permissions |
| 29872 | 29895 | ** as the associated database file. |
| 29873 | 29896 | ** |
| @@ -29882,11 +29905,11 @@ | ||
| 29882 | 29905 | mode_t *pMode, /* OUT: Permissions to open file with */ |
| 29883 | 29906 | uid_t *pUid, /* OUT: uid to set on the file */ |
| 29884 | 29907 | gid_t *pGid /* OUT: gid to set on the file */ |
| 29885 | 29908 | ){ |
| 29886 | 29909 | int rc = SQLITE_OK; /* Return Code */ |
| 29887 | - *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; | |
| 29910 | + *pMode = 0; | |
| 29888 | 29911 | *pUid = 0; |
| 29889 | 29912 | *pGid = 0; |
| 29890 | 29913 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 29891 | 29914 | char zDb[MAX_PATHNAME+1]; /* Database file path */ |
| 29892 | 29915 | int nDb; /* Number of valid bytes in zDb */ |
| @@ -30098,11 +30121,11 @@ | ||
| 30098 | 30121 | ** then the fchown() call will fail, but that's ok. The "if(){}" and |
| 30099 | 30122 | ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler |
| 30100 | 30123 | ** warnings from gcc. |
| 30101 | 30124 | */ |
| 30102 | 30125 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 30103 | - if( fchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } | |
| 30126 | + if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } | |
| 30104 | 30127 | } |
| 30105 | 30128 | } |
| 30106 | 30129 | assert( fd>=0 ); |
| 30107 | 30130 | if( pOutFlags ){ |
| 30108 | 30131 | *pOutFlags = flags; |
| @@ -30826,21 +30849,21 @@ | ||
| 30826 | 30849 | if( !pUnused ){ |
| 30827 | 30850 | return SQLITE_NOMEM; |
| 30828 | 30851 | } |
| 30829 | 30852 | } |
| 30830 | 30853 | if( fd<0 ){ |
| 30831 | - fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); | |
| 30854 | + fd = robust_open(path, openFlags, 0); | |
| 30832 | 30855 | terrno = errno; |
| 30833 | 30856 | if( fd<0 && errno==ENOENT && islockfile ){ |
| 30834 | 30857 | if( proxyCreateLockPath(path) == SQLITE_OK ){ |
| 30835 | - fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); | |
| 30858 | + fd = robust_open(path, openFlags, 0); | |
| 30836 | 30859 | } |
| 30837 | 30860 | } |
| 30838 | 30861 | } |
| 30839 | 30862 | if( fd<0 ){ |
| 30840 | 30863 | openFlags = O_RDONLY; |
| 30841 | - fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); | |
| 30864 | + fd = robust_open(path, openFlags, 0); | |
| 30842 | 30865 | terrno = errno; |
| 30843 | 30866 | } |
| 30844 | 30867 | if( fd<0 ){ |
| 30845 | 30868 | if( islockfile ){ |
| 30846 | 30869 | return SQLITE_BUSY; |
| @@ -30960,12 +30983,11 @@ | ||
| 30960 | 30983 | if( readLen<PROXY_PATHINDEX ){ |
| 30961 | 30984 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 30962 | 30985 | goto end_breaklock; |
| 30963 | 30986 | } |
| 30964 | 30987 | /* write it out to the temporary break file */ |
| 30965 | - fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), | |
| 30966 | - SQLITE_DEFAULT_FILE_PERMISSIONS); | |
| 30988 | + fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); | |
| 30967 | 30989 | if( fd<0 ){ |
| 30968 | 30990 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 30969 | 30991 | goto end_breaklock; |
| 30970 | 30992 | } |
| 30971 | 30993 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| @@ -31238,12 +31260,11 @@ | ||
| 31238 | 31260 | int fd; |
| 31239 | 31261 | if( pFile->h>=0 ){ |
| 31240 | 31262 | robust_close(pFile, pFile->h, __LINE__); |
| 31241 | 31263 | } |
| 31242 | 31264 | pFile->h = -1; |
| 31243 | - fd = robust_open(pCtx->dbPath, pFile->openFlags, | |
| 31244 | - SQLITE_DEFAULT_FILE_PERMISSIONS); | |
| 31265 | + fd = robust_open(pCtx->dbPath, pFile->openFlags, 0); | |
| 31245 | 31266 | OSTRACE(("TRANSPROXY: OPEN %d\n", fd)); |
| 31246 | 31267 | if( fd>=0 ){ |
| 31247 | 31268 | pFile->h = fd; |
| 31248 | 31269 | }else{ |
| 31249 | 31270 | rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called |
| @@ -31808,11 +31829,11 @@ | ||
| 31808 | 31829 | }; |
| 31809 | 31830 | unsigned int i; /* Loop counter */ |
| 31810 | 31831 | |
| 31811 | 31832 | /* Double-check that the aSyscall[] array has been constructed |
| 31812 | 31833 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31813 | - assert( ArraySize(aSyscall)==20 ); | |
| 31834 | + assert( ArraySize(aSyscall)==22 ); | |
| 31814 | 31835 | |
| 31815 | 31836 | /* Register all VFSes defined in the aVfs[] array */ |
| 31816 | 31837 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31817 | 31838 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31818 | 31839 | } |
| 31819 | 31840 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -657,11 +657,11 @@ | |
| 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | */ |
| 660 | #define SQLITE_VERSION "3.7.11" |
| 661 | #define SQLITE_VERSION_NUMBER 3007011 |
| 662 | #define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" |
| 663 | |
| 664 | /* |
| 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | ** |
| @@ -15156,16 +15156,12 @@ | |
| 15156 | ** the malloc_usable_size() interface exists |
| 15157 | ** on the target platform. Or, this symbol |
| 15158 | ** can be set manually, if desired. |
| 15159 | ** If an equivalent interface exists by |
| 15160 | ** a different name, using a separate -D |
| 15161 | ** option to rename it. This symbol will |
| 15162 | ** be enabled automatically on windows |
| 15163 | ** systems, and malloc_usable_size() will |
| 15164 | ** be redefined to _msize(), unless the |
| 15165 | ** SQLITE_WITHOUT_MSIZE macro is defined. |
| 15166 | ** |
| 15167 | ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone |
| 15168 | ** memory allocator. Set this symbol to enable |
| 15169 | ** building on older macs. |
| 15170 | ** |
| 15171 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| @@ -15180,17 +15176,15 @@ | |
| 15180 | ** macros. |
| 15181 | */ |
| 15182 | #ifdef SQLITE_SYSTEM_MALLOC |
| 15183 | |
| 15184 | /* |
| 15185 | ** Windows systems have malloc_usable_size() but it is called _msize(). |
| 15186 | ** The use of _msize() is automatic, but can be disabled by compiling |
| 15187 | ** with -DSQLITE_WITHOUT_MSIZE |
| 15188 | */ |
| 15189 | #if !defined(HAVE_MALLOC_USABLE_SIZE) && SQLITE_OS_WIN \ |
| 15190 | && !defined(SQLITE_WITHOUT_MSIZE) |
| 15191 | # define HAVE_MALLOC_USABLE_SIZE 1 |
| 15192 | # define SQLITE_MALLOCSIZE _msize |
| 15193 | #endif |
| 15194 | |
| 15195 | #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) |
| 15196 | |
| @@ -15216,11 +15210,12 @@ | |
| 15216 | */ |
| 15217 | #define SQLITE_MALLOC(x) malloc(x) |
| 15218 | #define SQLITE_FREE(x) free(x) |
| 15219 | #define SQLITE_REALLOC(x,y) realloc((x),(y)) |
| 15220 | |
| 15221 | #if defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE) |
| 15222 | # include <malloc.h> /* Needed for malloc_usable_size on linux */ |
| 15223 | #endif |
| 15224 | #ifdef HAVE_MALLOC_USABLE_SIZE |
| 15225 | # ifndef SQLITE_MALLOCSIZE |
| 15226 | # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) |
| @@ -25388,10 +25383,16 @@ | |
| 25388 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25389 | |
| 25390 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25391 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25392 | |
| 25393 | }; /* End of the overrideable system calls */ |
| 25394 | |
| 25395 | /* |
| 25396 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25397 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -25474,15 +25475,40 @@ | |
| 25474 | } |
| 25475 | return 0; |
| 25476 | } |
| 25477 | |
| 25478 | /* |
| 25479 | ** Retry open() calls that fail due to EINTR |
| 25480 | */ |
| 25481 | static int robust_open(const char *z, int f, int m){ |
| 25482 | int rc; |
| 25483 | do{ rc = osOpen(z,f,m); }while( rc<0 && errno==EINTR ); |
| 25484 | return rc; |
| 25485 | } |
| 25486 | |
| 25487 | /* |
| 25488 | ** Helper functions to obtain and relinquish the global mutex. The |
| @@ -28826,12 +28852,11 @@ | |
| 28826 | if( pShmNode==0 ){ |
| 28827 | struct stat sStat; /* fstat() info for database file */ |
| 28828 | |
| 28829 | /* Call fstat() to figure out the permissions on the database file. If |
| 28830 | ** a new *-shm file is created, an attempt will be made to create it |
| 28831 | ** with the same permissions. The actual permissions the file is created |
| 28832 | ** with are subject to the current umask setting. |
| 28833 | */ |
| 28834 | if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ |
| 28835 | rc = SQLITE_IOERR_FSTAT; |
| 28836 | goto shm_open_err; |
| 28837 | } |
| @@ -28882,11 +28907,11 @@ | |
| 28882 | ** the original owner will not be able to connect. If this process is |
| 28883 | ** not root, the following fchown() will fail, but we don't care. The |
| 28884 | ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler |
| 28885 | ** warnings. |
| 28886 | */ |
| 28887 | if( fchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ |
| 28888 | pDbFd->ctrlFlags |= UNIXFILE_CHOWN; |
| 28889 | } |
| 28890 | |
| 28891 | /* Check to see if another process is holding the dead-man switch. |
| 28892 | ** If not, truncate the file to zero length. |
| @@ -29858,16 +29883,14 @@ | |
| 29858 | ** to create new files with. If no error occurs, then SQLITE_OK is returned |
| 29859 | ** and a value suitable for passing as the third argument to open(2) is |
| 29860 | ** written to *pMode. If an IO error occurs, an SQLite error code is |
| 29861 | ** returned and the value of *pMode is not modified. |
| 29862 | ** |
| 29863 | ** If the file being opened is a temporary file, it is always created with |
| 29864 | ** the octal permissions 0600 (read/writable by owner only). If the file |
| 29865 | ** is a database or master journal file, it is created with the permissions |
| 29866 | ** mask SQLITE_DEFAULT_FILE_PERMISSIONS. |
| 29867 | ** |
| 29868 | ** Finally, if the file being opened is a WAL or regular journal file, then |
| 29869 | ** this function queries the file-system for the permissions on the |
| 29870 | ** corresponding database file and sets *pMode to this value. Whenever |
| 29871 | ** possible, WAL and journal files are created using the same permissions |
| 29872 | ** as the associated database file. |
| 29873 | ** |
| @@ -29882,11 +29905,11 @@ | |
| 29882 | mode_t *pMode, /* OUT: Permissions to open file with */ |
| 29883 | uid_t *pUid, /* OUT: uid to set on the file */ |
| 29884 | gid_t *pGid /* OUT: gid to set on the file */ |
| 29885 | ){ |
| 29886 | int rc = SQLITE_OK; /* Return Code */ |
| 29887 | *pMode = SQLITE_DEFAULT_FILE_PERMISSIONS; |
| 29888 | *pUid = 0; |
| 29889 | *pGid = 0; |
| 29890 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 29891 | char zDb[MAX_PATHNAME+1]; /* Database file path */ |
| 29892 | int nDb; /* Number of valid bytes in zDb */ |
| @@ -30098,11 +30121,11 @@ | |
| 30098 | ** then the fchown() call will fail, but that's ok. The "if(){}" and |
| 30099 | ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler |
| 30100 | ** warnings from gcc. |
| 30101 | */ |
| 30102 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 30103 | if( fchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } |
| 30104 | } |
| 30105 | } |
| 30106 | assert( fd>=0 ); |
| 30107 | if( pOutFlags ){ |
| 30108 | *pOutFlags = flags; |
| @@ -30826,21 +30849,21 @@ | |
| 30826 | if( !pUnused ){ |
| 30827 | return SQLITE_NOMEM; |
| 30828 | } |
| 30829 | } |
| 30830 | if( fd<0 ){ |
| 30831 | fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 30832 | terrno = errno; |
| 30833 | if( fd<0 && errno==ENOENT && islockfile ){ |
| 30834 | if( proxyCreateLockPath(path) == SQLITE_OK ){ |
| 30835 | fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 30836 | } |
| 30837 | } |
| 30838 | } |
| 30839 | if( fd<0 ){ |
| 30840 | openFlags = O_RDONLY; |
| 30841 | fd = robust_open(path, openFlags, SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 30842 | terrno = errno; |
| 30843 | } |
| 30844 | if( fd<0 ){ |
| 30845 | if( islockfile ){ |
| 30846 | return SQLITE_BUSY; |
| @@ -30960,12 +30983,11 @@ | |
| 30960 | if( readLen<PROXY_PATHINDEX ){ |
| 30961 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 30962 | goto end_breaklock; |
| 30963 | } |
| 30964 | /* write it out to the temporary break file */ |
| 30965 | fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), |
| 30966 | SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 30967 | if( fd<0 ){ |
| 30968 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 30969 | goto end_breaklock; |
| 30970 | } |
| 30971 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| @@ -31238,12 +31260,11 @@ | |
| 31238 | int fd; |
| 31239 | if( pFile->h>=0 ){ |
| 31240 | robust_close(pFile, pFile->h, __LINE__); |
| 31241 | } |
| 31242 | pFile->h = -1; |
| 31243 | fd = robust_open(pCtx->dbPath, pFile->openFlags, |
| 31244 | SQLITE_DEFAULT_FILE_PERMISSIONS); |
| 31245 | OSTRACE(("TRANSPROXY: OPEN %d\n", fd)); |
| 31246 | if( fd>=0 ){ |
| 31247 | pFile->h = fd; |
| 31248 | }else{ |
| 31249 | rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called |
| @@ -31808,11 +31829,11 @@ | |
| 31808 | }; |
| 31809 | unsigned int i; /* Loop counter */ |
| 31810 | |
| 31811 | /* Double-check that the aSyscall[] array has been constructed |
| 31812 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31813 | assert( ArraySize(aSyscall)==20 ); |
| 31814 | |
| 31815 | /* Register all VFSes defined in the aVfs[] array */ |
| 31816 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31817 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31818 | } |
| 31819 |
| --- src/sqlite3.c | |
| +++ src/sqlite3.c | |
| @@ -657,11 +657,11 @@ | |
| 657 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 658 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 659 | */ |
| 660 | #define SQLITE_VERSION "3.7.11" |
| 661 | #define SQLITE_VERSION_NUMBER 3007011 |
| 662 | #define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130" |
| 663 | |
| 664 | /* |
| 665 | ** CAPI3REF: Run-Time Library Version Numbers |
| 666 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 667 | ** |
| @@ -15156,16 +15156,12 @@ | |
| 15156 | ** the malloc_usable_size() interface exists |
| 15157 | ** on the target platform. Or, this symbol |
| 15158 | ** can be set manually, if desired. |
| 15159 | ** If an equivalent interface exists by |
| 15160 | ** a different name, using a separate -D |
| 15161 | ** option to rename it. |
| 15162 | ** |
| 15163 | ** SQLITE_WITHOUT_ZONEMALLOC Some older macs lack support for the zone |
| 15164 | ** memory allocator. Set this symbol to enable |
| 15165 | ** building on older macs. |
| 15166 | ** |
| 15167 | ** SQLITE_WITHOUT_MSIZE Set this symbol to disable the use of |
| @@ -15180,17 +15176,15 @@ | |
| 15176 | ** macros. |
| 15177 | */ |
| 15178 | #ifdef SQLITE_SYSTEM_MALLOC |
| 15179 | |
| 15180 | /* |
| 15181 | ** The MSVCRT has malloc_usable_size() but it is called _msize(). |
| 15182 | ** The use of _msize() is automatic, but can be disabled by compiling |
| 15183 | ** with -DSQLITE_WITHOUT_MSIZE |
| 15184 | */ |
| 15185 | #if defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE) |
| 15186 | # define SQLITE_MALLOCSIZE _msize |
| 15187 | #endif |
| 15188 | |
| 15189 | #if defined(__APPLE__) && !defined(SQLITE_WITHOUT_ZONEMALLOC) |
| 15190 | |
| @@ -15216,11 +15210,12 @@ | |
| 15210 | */ |
| 15211 | #define SQLITE_MALLOC(x) malloc(x) |
| 15212 | #define SQLITE_FREE(x) free(x) |
| 15213 | #define SQLITE_REALLOC(x,y) realloc((x),(y)) |
| 15214 | |
| 15215 | #if (defined(_MSC_VER) && !defined(SQLITE_WITHOUT_MSIZE)) \ |
| 15216 | || (defined(HAVE_MALLOC_H) && defined(HAVE_MALLOC_USABLE_SIZE)) |
| 15217 | # include <malloc.h> /* Needed for malloc_usable_size on linux */ |
| 15218 | #endif |
| 15219 | #ifdef HAVE_MALLOC_USABLE_SIZE |
| 15220 | # ifndef SQLITE_MALLOCSIZE |
| 15221 | # define SQLITE_MALLOCSIZE(x) malloc_usable_size(x) |
| @@ -25388,10 +25383,16 @@ | |
| 25383 | #define osMkdir ((int(*)(const char*,mode_t))aSyscall[18].pCurrent) |
| 25384 | |
| 25385 | { "rmdir", (sqlite3_syscall_ptr)rmdir, 0 }, |
| 25386 | #define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent) |
| 25387 | |
| 25388 | { "fchown", (sqlite3_syscall_ptr)fchown, 0 }, |
| 25389 | #define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent) |
| 25390 | |
| 25391 | { "umask", (sqlite3_syscall_ptr)umask, 0 }, |
| 25392 | #define osUmask ((mode_t(*)(mode_t))aSyscall[21].pCurrent) |
| 25393 | |
| 25394 | }; /* End of the overrideable system calls */ |
| 25395 | |
| 25396 | /* |
| 25397 | ** This is the xSetSystemCall() method of sqlite3_vfs for all of the |
| 25398 | ** "unix" VFSes. Return SQLITE_OK opon successfully updating the |
| @@ -25474,15 +25475,40 @@ | |
| 25475 | } |
| 25476 | return 0; |
| 25477 | } |
| 25478 | |
| 25479 | /* |
| 25480 | ** Invoke open(). Do so multiple times, until it either succeeds or |
| 25481 | ** files for some reason other than EINTR. |
| 25482 | ** |
| 25483 | ** If the file creation mode "m" is 0 then set it to the default for |
| 25484 | ** SQLite. The default is SQLITE_DEFAULT_FILE_PERMISSIONS (normally |
| 25485 | ** 0644) as modified by the system umask. If m is not 0, then |
| 25486 | ** make the file creation mode be exactly m ignoring the umask. |
| 25487 | ** |
| 25488 | ** The m parameter will be non-zero only when creating -wal, -journal, |
| 25489 | ** and -shm files. We want those files to have *exactly* the same |
| 25490 | ** permissions as their original database, unadulterated by the umask. |
| 25491 | ** In that way, if a database file is -rw-rw-rw or -rw-rw-r-, and a |
| 25492 | ** transaction crashes and leaves behind hot journals, then any |
| 25493 | ** process that is able to write to the database will also be able to |
| 25494 | ** recover the hot journals. |
| 25495 | */ |
| 25496 | static int robust_open(const char *z, int f, mode_t m){ |
| 25497 | int rc; |
| 25498 | mode_t m2; |
| 25499 | mode_t origM; |
| 25500 | if( m==0 ){ |
| 25501 | m2 = SQLITE_DEFAULT_FILE_PERMISSIONS; |
| 25502 | }else{ |
| 25503 | m2 = m; |
| 25504 | origM = osUmask(0); |
| 25505 | } |
| 25506 | do{ rc = osOpen(z,f,m2); }while( rc<0 && errno==EINTR ); |
| 25507 | if( m ){ |
| 25508 | osUmask(origM); |
| 25509 | } |
| 25510 | return rc; |
| 25511 | } |
| 25512 | |
| 25513 | /* |
| 25514 | ** Helper functions to obtain and relinquish the global mutex. The |
| @@ -28826,12 +28852,11 @@ | |
| 28852 | if( pShmNode==0 ){ |
| 28853 | struct stat sStat; /* fstat() info for database file */ |
| 28854 | |
| 28855 | /* Call fstat() to figure out the permissions on the database file. If |
| 28856 | ** a new *-shm file is created, an attempt will be made to create it |
| 28857 | ** with the same permissions. |
| 28858 | */ |
| 28859 | if( osFstat(pDbFd->h, &sStat) && pInode->bProcessLock==0 ){ |
| 28860 | rc = SQLITE_IOERR_FSTAT; |
| 28861 | goto shm_open_err; |
| 28862 | } |
| @@ -28882,11 +28907,11 @@ | |
| 28907 | ** the original owner will not be able to connect. If this process is |
| 28908 | ** not root, the following fchown() will fail, but we don't care. The |
| 28909 | ** if(){..} and the UNIXFILE_CHOWN flag are purely to silence compiler |
| 28910 | ** warnings. |
| 28911 | */ |
| 28912 | if( osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid)==0 ){ |
| 28913 | pDbFd->ctrlFlags |= UNIXFILE_CHOWN; |
| 28914 | } |
| 28915 | |
| 28916 | /* Check to see if another process is holding the dead-man switch. |
| 28917 | ** If not, truncate the file to zero length. |
| @@ -29858,16 +29883,14 @@ | |
| 29883 | ** to create new files with. If no error occurs, then SQLITE_OK is returned |
| 29884 | ** and a value suitable for passing as the third argument to open(2) is |
| 29885 | ** written to *pMode. If an IO error occurs, an SQLite error code is |
| 29886 | ** returned and the value of *pMode is not modified. |
| 29887 | ** |
| 29888 | ** In most cases cases, this routine sets *pMode to 0, which will become |
| 29889 | ** an indication to robust_open() to create the file using |
| 29890 | ** SQLITE_DEFAULT_FILE_PERMISSIONS adjusted by the umask. |
| 29891 | ** But if the file being opened is a WAL or regular journal file, then |
| 29892 | ** this function queries the file-system for the permissions on the |
| 29893 | ** corresponding database file and sets *pMode to this value. Whenever |
| 29894 | ** possible, WAL and journal files are created using the same permissions |
| 29895 | ** as the associated database file. |
| 29896 | ** |
| @@ -29882,11 +29905,11 @@ | |
| 29905 | mode_t *pMode, /* OUT: Permissions to open file with */ |
| 29906 | uid_t *pUid, /* OUT: uid to set on the file */ |
| 29907 | gid_t *pGid /* OUT: gid to set on the file */ |
| 29908 | ){ |
| 29909 | int rc = SQLITE_OK; /* Return Code */ |
| 29910 | *pMode = 0; |
| 29911 | *pUid = 0; |
| 29912 | *pGid = 0; |
| 29913 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 29914 | char zDb[MAX_PATHNAME+1]; /* Database file path */ |
| 29915 | int nDb; /* Number of valid bytes in zDb */ |
| @@ -30098,11 +30121,11 @@ | |
| 30121 | ** then the fchown() call will fail, but that's ok. The "if(){}" and |
| 30122 | ** the setting of the UNIXFILE_CHOWN flag are purely to silence compiler |
| 30123 | ** warnings from gcc. |
| 30124 | */ |
| 30125 | if( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){ |
| 30126 | if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; } |
| 30127 | } |
| 30128 | } |
| 30129 | assert( fd>=0 ); |
| 30130 | if( pOutFlags ){ |
| 30131 | *pOutFlags = flags; |
| @@ -30826,21 +30849,21 @@ | |
| 30849 | if( !pUnused ){ |
| 30850 | return SQLITE_NOMEM; |
| 30851 | } |
| 30852 | } |
| 30853 | if( fd<0 ){ |
| 30854 | fd = robust_open(path, openFlags, 0); |
| 30855 | terrno = errno; |
| 30856 | if( fd<0 && errno==ENOENT && islockfile ){ |
| 30857 | if( proxyCreateLockPath(path) == SQLITE_OK ){ |
| 30858 | fd = robust_open(path, openFlags, 0); |
| 30859 | } |
| 30860 | } |
| 30861 | } |
| 30862 | if( fd<0 ){ |
| 30863 | openFlags = O_RDONLY; |
| 30864 | fd = robust_open(path, openFlags, 0); |
| 30865 | terrno = errno; |
| 30866 | } |
| 30867 | if( fd<0 ){ |
| 30868 | if( islockfile ){ |
| 30869 | return SQLITE_BUSY; |
| @@ -30960,12 +30983,11 @@ | |
| 30983 | if( readLen<PROXY_PATHINDEX ){ |
| 30984 | sqlite3_snprintf(sizeof(errmsg),errmsg,"read error (len %d)",(int)readLen); |
| 30985 | goto end_breaklock; |
| 30986 | } |
| 30987 | /* write it out to the temporary break file */ |
| 30988 | fd = robust_open(tPath, (O_RDWR|O_CREAT|O_EXCL), 0); |
| 30989 | if( fd<0 ){ |
| 30990 | sqlite3_snprintf(sizeof(errmsg), errmsg, "create failed (%d)", errno); |
| 30991 | goto end_breaklock; |
| 30992 | } |
| 30993 | if( osPwrite(fd, buf, readLen, 0) != (ssize_t)readLen ){ |
| @@ -31238,12 +31260,11 @@ | |
| 31260 | int fd; |
| 31261 | if( pFile->h>=0 ){ |
| 31262 | robust_close(pFile, pFile->h, __LINE__); |
| 31263 | } |
| 31264 | pFile->h = -1; |
| 31265 | fd = robust_open(pCtx->dbPath, pFile->openFlags, 0); |
| 31266 | OSTRACE(("TRANSPROXY: OPEN %d\n", fd)); |
| 31267 | if( fd>=0 ){ |
| 31268 | pFile->h = fd; |
| 31269 | }else{ |
| 31270 | rc=SQLITE_CANTOPEN_BKPT; /* SQLITE_BUSY? proxyTakeConch called |
| @@ -31808,11 +31829,11 @@ | |
| 31829 | }; |
| 31830 | unsigned int i; /* Loop counter */ |
| 31831 | |
| 31832 | /* Double-check that the aSyscall[] array has been constructed |
| 31833 | ** correctly. See ticket [bb3a86e890c8e96ab] */ |
| 31834 | assert( ArraySize(aSyscall)==22 ); |
| 31835 | |
| 31836 | /* Register all VFSes defined in the aVfs[] array */ |
| 31837 | for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ |
| 31838 | sqlite3_vfs_register(&aVfs[i], i==0); |
| 31839 | } |
| 31840 |
+1
-1
| --- src/sqlite3.h | ||
| +++ src/sqlite3.h | ||
| @@ -107,11 +107,11 @@ | ||
| 107 | 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | 109 | */ |
| 110 | 110 | #define SQLITE_VERSION "3.7.11" |
| 111 | 111 | #define SQLITE_VERSION_NUMBER 3007011 |
| 112 | -#define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" | |
| 112 | +#define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130" | |
| 113 | 113 | |
| 114 | 114 | /* |
| 115 | 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | 117 | ** |
| 118 | 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.11" |
| 111 | #define SQLITE_VERSION_NUMBER 3007011 |
| 112 | #define SQLITE_SOURCE_ID "2012-02-11 21:21:17 b022547389a40930cf0d2a75f5eb293acc9fbfe0" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |
| --- src/sqlite3.h | |
| +++ src/sqlite3.h | |
| @@ -107,11 +107,11 @@ | |
| 107 | ** [sqlite3_libversion_number()], [sqlite3_sourceid()], |
| 108 | ** [sqlite_version()] and [sqlite_source_id()]. |
| 109 | */ |
| 110 | #define SQLITE_VERSION "3.7.11" |
| 111 | #define SQLITE_VERSION_NUMBER 3007011 |
| 112 | #define SQLITE_SOURCE_ID "2012-02-13 20:16:37 84b324606adc8437338c086404eb157f30f04130" |
| 113 | |
| 114 | /* |
| 115 | ** CAPI3REF: Run-Time Library Version Numbers |
| 116 | ** KEYWORDS: sqlite3_version, sqlite3_sourceid |
| 117 | ** |
| 118 |