Set FD_CLOEXEC on all open files under Unix. Ticket #2475. (CVS 4146)

FossilOrigin-Name: f1e5fed8eb0fb92bd0f040666c017850afe3cf9f
This commit is contained in:
drh 2007-06-29 12:04:26 +00:00
parent 6bd00bfda7
commit e78669b6b8
3 changed files with 17 additions and 10 deletions

View File

@ -1,5 +1,5 @@
C Add\sa\stest\scase\sto\sverify\sthat\sticket\s#2470\shas\sbeen\sfixed.\s(CVS\s4145) C Set\sFD_CLOEXEC\son\sall\sopen\sfiles\sunder\sUnix.\s\sTicket\s#2475.\s(CVS\s4146)
D 2007-06-27T23:52:18 D 2007-06-29T12:04:26
F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe F Makefile.in 0c0e53720f658c7a551046442dd7afba0b72bfbe
F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499 F Makefile.linux-gcc 65241babba6faf1152bf86574477baab19190499
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028 F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@ -93,7 +93,7 @@ F src/os_os2.c 2ce97909b926a598823f97338027dbec1dcf4165
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3 F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3 F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 113ae3557500a0a04f78b02bb1290262ede6bbf8 F src/os_unix.c 4099d05dc4b01997e80a289f3c6a220688e5cff5
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c d868d5f9e95ec9c1b9e2a30c54c996053db6dddd F src/os_win.c d868d5f9e95ec9c1b9e2a30c54c996053db6dddd
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
@ -517,7 +517,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 57840eba6a4380a0b71dc9514cdda41e2c455bb0 P b3f442698e01ad55666703025c4457445f2efc9b
R d0d6e08a4eb10c3e13819067c7061aec R 32ae689340efe4ebbf465449d4fc6cf6
U drh U drh
Z 97914bdcc06bf549188d2ae1e30f9e9f Z 1010b88245cb62615c48bcce03c46f90

View File

@ -1 +1 @@
b3f442698e01ad55666703025c4457445f2efc9b f1e5fed8eb0fb92bd0f040666c017850afe3cf9f

View File

@ -918,15 +918,19 @@ static int unixOpenDirectory(
OsFile *id, OsFile *id,
const char *zDirname const char *zDirname
){ ){
int h;
unixFile *pFile = (unixFile*)id; unixFile *pFile = (unixFile*)id;
assert( pFile!=0 ); assert( pFile!=0 );
SET_THREADID(pFile); SET_THREADID(pFile);
assert( pFile->dirfd<0 ); assert( pFile->dirfd<0 );
pFile->dirfd = open(zDirname, O_RDONLY|O_BINARY, 0); pFile->dirfd = h = open(zDirname, O_RDONLY|O_BINARY, 0);
if( pFile->dirfd<0 ){ if( h<0 ){
return SQLITE_CANTOPEN; return SQLITE_CANTOPEN;
} }
OSTRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname); #ifdef FD_CLOEXEC
fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
#endif
OSTRACE3("OPENDIR %-3d %s\n", h, zDirname);
return SQLITE_OK; return SQLITE_OK;
} }
@ -2577,6 +2581,9 @@ static int allocateUnixFile(
unixFile f; unixFile f;
int rc; int rc;
#ifdef FD_CLOEXEC
fcntl(h, F_SETFD, fcntl(h, F_GETFD, 0) | FD_CLOEXEC);
#endif
memset(&f, 0, sizeof(f)); memset(&f, 0, sizeof(f));
sqlite3OsEnterMutex(); sqlite3OsEnterMutex();
rc = findLockInfo(h, &f.pLock, &f.pOpen); rc = findLockInfo(h, &f.pLock, &f.pOpen);