]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: use O_CLOEXEC
authorKarel Zak <kzak@redhat.com>
Wed, 3 Apr 2013 14:14:15 +0000 (16:14 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Apr 2013 14:14:15 +0000 (16:14 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/config.c
libblkid/src/devname.c
libblkid/src/devno.c
libblkid/src/evaluate.c
libblkid/src/read.c
libblkid/src/save.c
libblkid/src/superblocks/ext.c
libblkid/src/topology/dm.c
libblkid/src/topology/lvm.c

index edad6cd7ccabb62211c55ef4c4acf0db9a3682d4..0b2ef20c300b0849f29d3c473696a701d5dea7c7 100644 (file)
@@ -128,7 +128,7 @@ struct blkid_config *blkid_read_config(const char *filename)
        DBG(DEBUG_CONFIG, fprintf(stderr,
                "reading config file: %s.\n", filename));
 
-       f = fopen(filename, "r");
+       f = fopen(filename, "r" UL_CLOEXECSTR);
        if (!f) {
                DBG(DEBUG_CONFIG, fprintf(stderr,
                        "%s: does not exist, using built-in default\n", filename));
index dc2e0caa638b6f2aa6f72d3d88cdd2a2ac3fb5fa..68270d911775ee03135942653e5656983ed3cf39 100644 (file)
@@ -259,7 +259,7 @@ static dev_t lvm_get_devno(const char *lvm_device)
        dev_t ret = 0;
 
        DBG(DEBUG_DEVNAME, printf("opening %s\n", lvm_device));
-       if ((lvf = fopen(lvm_device, "r")) == NULL) {
+       if ((lvf = fopen(lvm_device, "r" UL_CLOEXECSTR)) == NULL) {
                DBG(DEBUG_DEVNAME, printf("%s: (%d) %m\n", lvm_device, errno));
                return 0;
        }
@@ -347,7 +347,7 @@ evms_probe_all(blkid_cache cache, int only_if_new)
        FILE *procpt;
        char device[110];
 
-       procpt = fopen(PROC_EVMS_VOLUMES, "r");
+       procpt = fopen(PROC_EVMS_VOLUMES, "r" UL_CLOEXECSTR);
        if (!procpt)
                return 0;
        while (fgets(line, sizeof(line), procpt)) {
@@ -446,7 +446,7 @@ static int probe_all(blkid_cache cache, int only_if_new)
 #endif
        ubi_probe_all(cache, only_if_new);
 
-       proc = fopen(PROC_PARTITIONS, "r");
+       proc = fopen(PROC_PARTITIONS, "r" UL_CLOEXECSTR);
        if (!proc)
                return -BLKID_ERR_PROC;
 
index 906c91fcd6767b20c3a5f2130522068ccade27b5..cdf3d5bfc61bdf17e512aaeac60a0444b030d48e 100644 (file)
@@ -300,7 +300,7 @@ int blkid_driver_has_major(const char *drvname, int major)
        char buf[128];
        int match = 0;
 
-       f = fopen(_PATH_PROC_DEVICES, "r");
+       f = fopen(_PATH_PROC_DEVICES, "r" UL_CLOEXECSTR);
        if (!f)
                return 0;
 
index 2e1ca574daa42851e6db461a3d230dcd57d76b1d..e0337075068a6a427879d0ff1cef39f398aedbad 100644 (file)
@@ -118,7 +118,7 @@ int blkid_send_uevent(const char *devname, const char *action)
        snprintf(uevent, sizeof(uevent), "/sys/dev/block/%d:%d/uevent",
                        major(st.st_rdev), minor(st.st_rdev));
 
-       f = fopen(uevent, "w");
+       f = fopen(uevent, "w" UL_CLOEXECSTR);
        if (f) {
                rc = 0;
                if (fputs(action, f) >= 0)
index 8914cad695fd8c87eec29bc1b305a8bbab556b8d..0065b4854299dd2356a9751e736eaa211fffc059 100644 (file)
@@ -412,7 +412,7 @@ void blkid_read_cache(blkid_cache cache)
        DBG(DEBUG_CACHE, printf("reading cache file %s\n",
                                cache->bic_filename));
 
-       file = fdopen(fd, "r");
+       file = fdopen(fd, "r" UL_CLOEXECSTR);
        if (!file)
                goto errout;
 
index c94cc2a82d51cec0546610d89a8b4581c908428e..849632f794120a5c6fced91c0d0a4d0605e89bee 100644 (file)
@@ -113,11 +113,11 @@ int blkid_flush_cache(blkid_cache cache)
                tmp = malloc(strlen(filename) + 8);
                if (tmp) {
                        sprintf(tmp, "%s-XXXXXX", filename);
-                       fd = mkstemp(tmp);
+                       fd = mkostemp(tmp, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC);
                        if (fd >= 0) {
                                if (fchmod(fd, 0644) != 0)
                                        DBG(DEBUG_SAVE, printf("%s: fchmod failed\n", filename));
-                               else if ((file = fdopen(fd, "w")))
+                               else if ((file = fdopen(fd, "w" UL_CLOEXECSTR)))
                                        opened = tmp;
                                if (!file)
                                        close(fd);
@@ -126,7 +126,7 @@ int blkid_flush_cache(blkid_cache cache)
        }
 
        if (!file) {
-               file = fopen(filename, "w");
+               file = fopen(filename, "w" UL_CLOEXECSTR);
                opened = filename;
        }
 
index eff96a066b2dbbf1aa3ef9ddffcc719a7b7be82d..f36556bca2a8aa235a555e70d2e855093f44b343 100644 (file)
@@ -140,7 +140,7 @@ static int fs_proc_check(const char *fs_name)
        FILE    *f;
        char    buf[80], *cp, *t;
 
-       f = fopen("/proc/filesystems", "r");
+       f = fopen("/proc/filesystems", "r" UL_CLOEXECSTR);
        if (!f)
                return 0;
        while (!feof(f)) {
@@ -184,7 +184,7 @@ static int check_for_modules(const char *fs_name)
                return 0;
        snprintf(buf, sizeof(buf), "/lib/modules/%s/modules.dep", uts.release);
 
-       f = fopen(buf, "r");
+       f = fopen(buf, "r" UL_CLOEXECSTR);
        if (!f)
                return 0;
 
index 72ec9bd8e25f6fa4e65ac73c5e7d7c7c30c1eea3..dd058536c60e81fdd1e4ff4d05f2aa215d48680b 100644 (file)
@@ -104,7 +104,7 @@ static int probe_dm_tp(blkid_probe pr,
                break;
        }
 
-       stream = fdopen(dmpipe[0], "r");
+       stream = fdopen(dmpipe[0], "r" UL_CLOEXECSTR);
        if (!stream)
                goto nothing;
 
index 632c42b713118331b3e885f55fa58c29ce377f1a..d5bce28fb7f795a72dc9d2f47fd27d31a2302244 100644 (file)
@@ -107,7 +107,7 @@ static int probe_lvm_tp(blkid_probe pr,
                break;
        }
 
-       stream = fdopen(lvpipe[0], "r");
+       stream = fdopen(lvpipe[0], "r" UL_CLOEXECSTR);
        if (!stream)
                goto nothing;