summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmount/src/lock.c4
-rw-r--r--libmount/src/utils.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/libmount/src/lock.c b/libmount/src/lock.c
index 9f04725d6..b149b6f8b 100644
--- a/libmount/src/lock.c
+++ b/libmount/src/lock.c
@@ -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? */
diff --git a/libmount/src/utils.c b/libmount/src/utils.c
index 63d1079d0..245a3b25d 100644
--- a/libmount/src/utils.c
+++ b/libmount/src/utils.c
@@ -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;