libuuid: Make sure fd's 0, 1, and 2 are valid before exec'ing uuidd

When closing all of the file descriptors before starting uuidd, make
sure file descriptors 0, 1, and 2 are reserved by opening /dev/null.
This prevents strange bugs caused by assumptions regarding file
descriptors <= 2 as being special.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:
Theodore Ts'o 2009-06-29 21:19:28 -04:00
parent 6dc9c350bd
commit 59ca44715a
1 changed files with 4 additions and 1 deletions

View File

@ -461,8 +461,11 @@ static void close_all_fds(void)
max = OPEN_MAX;
#endif
for (i=0; i < max; i++)
for (i=0; i < max; i++) {
close(i);
if (i <= 2)
open("/dev/null", O_RDWR);
}
}
/*