From: Karel Zak Date: Wed, 29 Aug 2012 18:08:18 +0000 (+0200) Subject: libmount: use O_CLOEXEC everywhere X-Git-Tag: v2.23-rc1~743 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d39c2b438f0f99481f4b14d01b859dd0ea4c6d03;p=thirdparty%2Futil-linux.git libmount: use O_CLOEXEC everywhere Signed-off-by: Karel Zak --- diff --git a/libmount/src/lock.c b/libmount/src/lock.c index 9f04725d6e..b149b6f8b4 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 63d1079d04..245a3b25d3 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;