mirror of
https://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
synced 2024-11-28 04:23:45 +08:00
Set FD_CLOEXEC on the /dev/random file descriptor used by libuuid
This avoids a fd leak across an execve() which was causing problems for the LVM tools. (Addresses Debian Bug: #345832) Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
parent
22fe674da4
commit
2adc320f01
@ -1,3 +1,9 @@
|
||||
2006-01-06 Theodore Ts'o <tytso@mit.edu>
|
||||
|
||||
* gen_uuid.c (get_random_fd): Set the FD_CLOEXEC flag on the file
|
||||
descriptor so that it will get closed across an execve().
|
||||
(Addresses Debian Bug #345832)
|
||||
|
||||
2005-12-10 Theodore Ts'o <tytso@mit.edu>
|
||||
|
||||
* Makefile.in: Add a dependency to make sure that the
|
||||
|
@ -88,6 +88,11 @@ static int get_random_fd(void)
|
||||
fd = open("/dev/urandom", O_RDONLY);
|
||||
if (fd == -1)
|
||||
fd = open("/dev/random", O_RDONLY | O_NONBLOCK);
|
||||
if (fd >= 0) {
|
||||
i = fcntl(fd, F_GETFD);
|
||||
if (i >= 0)
|
||||
fcntl(fd, F_SETFD, i | FD_CLOEXEC);
|
||||
}
|
||||
srand((getpid() << 16) ^ getuid() ^ tv.tv_sec ^ tv.tv_usec);
|
||||
}
|
||||
/* Crank the random number generator a few times */
|
||||
|
Loading…
Reference in New Issue
Block a user