mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Avoid calling fchown() if the process is not running as root.
FossilOrigin-Name: 70c419a434be77b042a23174483d6a411899eb5d
This commit is contained in:
12
manifest
12
manifest
@@ -1,5 +1,5 @@
|
|||||||
C Link\sthe\sNDEBUG\smacro\sto\sSQLITE_DEBUG\sso\sthat\swhen\sSQLITE_DEBUG\sis\sdefined,\nNDEBUG\sis\sautomatically\sundefined\san\sdwhen\sSQLITE_DEBUG\sis\sundefined\nNDEBUG\sis\sautomatically\sdefined.
|
C Avoid\scalling\sfchown()\sif\sthe\sprocess\sis\snot\srunning\sas\sroot.
|
||||||
D 2012-05-29T19:25:20.175
|
D 2012-05-31T13:10:49.376
|
||||||
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
|
||||||
F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf
|
F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf
|
||||||
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
|
||||||
@@ -164,7 +164,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c
|
|||||||
F src/os.h 59beba555b65a450bd1d804220532971d4299f60
|
F src/os.h 59beba555b65a450bd1d804220532971d4299f60
|
||||||
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04
|
||||||
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440
|
||||||
F src/os_unix.c 8a90a7cdfc19ed0f233d76b63825d8effcae302a
|
F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757
|
||||||
F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c
|
F src/os_win.c 412d6434133c7c81dc48b7702f3ea5e61c309e5c
|
||||||
F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36
|
F src/pager.c 9d4d6406512002d9a243ec27b9c01e93fda43e36
|
||||||
F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5
|
F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5
|
||||||
@@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
|
|||||||
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
|
||||||
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
|
F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2
|
||||||
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
|
||||||
P 6fec6cf1fbac881a33a35ea99aac2f5f1cf27c2a
|
P 07935d10d341fe6265cfd3b09e2c4ef4005c4826
|
||||||
R 04c27600577da03816e15c318dd7df31
|
R db0f48be730e02610af744a3fe432e51
|
||||||
U drh
|
U drh
|
||||||
Z 9df1e8f50925fc882f32cc14d2630547
|
Z a3e118b76a7afa02078e1c319e3927b5
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
07935d10d341fe6265cfd3b09e2c4ef4005c4826
|
70c419a434be77b042a23174483d6a411899eb5d
|
||||||
@@ -262,7 +262,6 @@ struct unixFile {
|
|||||||
#define UNIXFILE_DELETE 0x20 /* Delete on close */
|
#define UNIXFILE_DELETE 0x20 /* Delete on close */
|
||||||
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
|
#define UNIXFILE_URI 0x40 /* Filename might have query parameters */
|
||||||
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
|
#define UNIXFILE_NOLOCK 0x80 /* Do no file locking */
|
||||||
#define UNIXFILE_CHOWN 0x100 /* File ownership was changed */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Include code that is common to all os_*.c files
|
** Include code that is common to all os_*.c files
|
||||||
@@ -308,6 +307,15 @@ static int posixOpen(const char *zFile, int flags, int mode){
|
|||||||
return open(zFile, flags, mode);
|
return open(zFile, flags, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** On some systems, calls to fchown() will trigger a message in a security
|
||||||
|
** log if they come from non-root processes. So avoid calling fchown() if
|
||||||
|
** we are not running as root.
|
||||||
|
*/
|
||||||
|
static int posixFchown(int fd, uid_t uid, gid_t gid){
|
||||||
|
return geteuid() ? 0 : fchown(fd,uid,gid);
|
||||||
|
}
|
||||||
|
|
||||||
/* Forward reference */
|
/* Forward reference */
|
||||||
static int openDirectory(const char*, int*);
|
static int openDirectory(const char*, int*);
|
||||||
|
|
||||||
@@ -419,7 +427,7 @@ static struct unix_syscall {
|
|||||||
{ "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
|
{ "rmdir", (sqlite3_syscall_ptr)rmdir, 0 },
|
||||||
#define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
|
#define osRmdir ((int(*)(const char*))aSyscall[19].pCurrent)
|
||||||
|
|
||||||
{ "fchown", (sqlite3_syscall_ptr)fchown, 0 },
|
{ "fchown", (sqlite3_syscall_ptr)posixFchown, 0 },
|
||||||
#define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)
|
#define osFchown ((int(*)(int,uid_t,gid_t))aSyscall[20].pCurrent)
|
||||||
|
|
||||||
{ "umask", (sqlite3_syscall_ptr)umask, 0 },
|
{ "umask", (sqlite3_syscall_ptr)umask, 0 },
|
||||||
@@ -3944,14 +3952,9 @@ static int unixOpenSharedMemory(unixFile *pDbFd){
|
|||||||
|
|
||||||
/* If this process is running as root, make sure that the SHM file
|
/* 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,
|
** 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
|
** the original owner will not be able to connect.
|
||||||
** 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 ){
|
osFchown(pShmNode->h, sStat.st_uid, sStat.st_gid);
|
||||||
pDbFd->ctrlFlags |= UNIXFILE_CHOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Check to see if another process is holding the dead-man switch.
|
/* Check to see if another process is holding the dead-man switch.
|
||||||
** If not, truncate the file to zero length.
|
** If not, truncate the file to zero length.
|
||||||
@@ -5157,13 +5160,10 @@ static int unixOpen(
|
|||||||
|
|
||||||
/* If this process is running as root and if creating a new rollback
|
/* 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
|
** 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,
|
** the same as the original database.
|
||||||
** 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( flags & (SQLITE_OPEN_WAL|SQLITE_OPEN_MAIN_JOURNAL) ){
|
||||||
if( osFchown(fd, uid, gid)==0 ){ p->ctrlFlags |= UNIXFILE_CHOWN; }
|
osFchown(fd, uid, gid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert( fd>=0 );
|
assert( fd>=0 );
|
||||||
|
|||||||
Reference in New Issue
Block a user