]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: use O_CLOEXEC everywhere
authorKarel Zak <kzak@redhat.com>
Wed, 29 Aug 2012 18:08:18 +0000 (20:08 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 4 Sep 2012 14:49:28 +0000 (16:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/lock.c
libmount/src/utils.c

index 9f04725d6ed512719c744c807f26780333693976..b149b6f8b423227d48b614cbc0bd0571ec1e7ef4 100644 (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? */
index 63d1079d042b6add2b2f7dc41d4dcc2cdd65f70b..245a3b25d3ad2b235d3f94531705d9048a1bb09f 100644 (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;