libmount: use O_CLOEXEC everywhere

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2012-08-29 20:08:18 +02:00
parent 49a8f58e48
commit d39c2b438f
2 changed files with 4 additions and 4 deletions

View File

@ -396,7 +396,7 @@ static int lock_mtab(struct libmnt_lock *ml)
sigprocmask(SIG_BLOCK, &sigs, &ml->oldsigmask);
}
i = open(linkfile, O_WRONLY|O_CREAT, S_IRUSR|S_IWUSR);
i = open(linkfile, O_WRONLY|O_CREAT|O_CLOEXEC, S_IRUSR|S_IWUSR);
if (i < 0) {
/* linkfile does not exist (as a file) and we cannot create it.
* Read-only or full filesystem? Too many files open in the system?
@ -428,7 +428,7 @@ static int lock_mtab(struct libmnt_lock *ml)
rc = -errno;
goto failed;
}
ml->lockfile_fd = open(lockfile, O_WRONLY);
ml->lockfile_fd = open(lockfile, O_WRONLY|O_CLOEXEC);
if (ml->lockfile_fd < 0) {
/* Strange... Maybe the file was just deleted? */

View File

@ -610,8 +610,8 @@ static int try_write(const char *filename)
if (!filename)
return -EINVAL;
fd = open(filename, O_RDWR|O_CREAT, S_IWUSR| \
S_IRUSR|S_IRGRP|S_IROTH);
fd = open(filename, O_RDWR|O_CREAT|O_CLOEXEC,
S_IWUSR|S_IRUSR|S_IRGRP|S_IROTH);
if (fd >= 0) {
close(fd);
return 0;