diff options
-rw-r--r-- | libmount/src/lock.c | 4 | ||||
-rw-r--r-- | libmount/src/tab_parse.c | 8 | ||||
-rw-r--r-- | libmount/src/tab_update.c | 2 | ||||
-rw-r--r-- | libmount/src/utils.c | 6 |
4 files changed, 10 insertions, 10 deletions
diff --git a/libmount/src/lock.c b/libmount/src/lock.c index e5393d0a4..9e583cc06 100644 --- a/libmount/src/lock.c +++ b/libmount/src/lock.c @@ -558,7 +558,7 @@ void increment_data(const char *filename, int verbose, int loopno) FILE *f; char buf[256]; - if (!(f = fopen(filename, "r"))) + if (!(f = fopen(filename, "r" UL_CLOEXECSTR))) err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename); if (!fgets(buf, sizeof(buf), f)) @@ -567,7 +567,7 @@ void increment_data(const char *filename, int verbose, int loopno) fclose(f); num = atol(buf) + 1; - if (!(f = fopen(filename, "w"))) + if (!(f = fopen(filename, "w" UL_CLOEXECSTR))) err(EXIT_FAILURE, "%d: failed to open: %s", getpid(), filename); fprintf(f, "%ld", num); diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index b4b647075..7368d8c98 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -579,7 +579,7 @@ int mnt_table_parse_file(struct libmnt_table *tb, const char *filename) if (!filename || !tb) return -EINVAL; - f = fopen(filename, "r"); + f = fopen(filename, "r" UL_CLOEXECSTR); if (f) { rc = mnt_table_parse_stream(tb, f, filename); fclose(f); @@ -639,7 +639,7 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) !S_ISREG(st.st_mode)) continue; - f = fopen_at(dd, ".", d->d_name, O_RDONLY, "r"); + f = fopen_at(dd, ".", d->d_name, O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); if (f) { mnt_table_parse_stream(tb, f, d->d_name); fclose(f); @@ -679,8 +679,8 @@ static int __mnt_table_parse_dir(struct libmnt_table *tb, const char *dirname) !S_ISREG(st.st_mode)) continue; - f = fopen_at(dirfd(dir), _PATH_MNTTAB_DIR, - d->d_name, O_RDONLY, "r"); + f = fopen_at(dirfd(dir), _PATH_MNTTAB_DIR, d->d_name, + O_RDONLY|O_CLOEXEC, "r" UL_CLOEXECSTR); if (f) { mnt_table_parse_stream(tb, f, d->d_name); fclose(f); diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c index 7ae540abf..044a13f5e 100644 --- a/libmount/src/tab_update.c +++ b/libmount/src/tab_update.c @@ -514,7 +514,7 @@ static int update_table(struct libmnt_update *upd, struct libmnt_table *tb) if (fd < 0) return fd; /* error */ - f = fdopen(fd, "w"); + f = fdopen(fd, "w" UL_CLOEXECSTR); if (f) { struct stat st; struct libmnt_iter itr; diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 5453789e3..c910035df 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -462,7 +462,7 @@ static int get_filesystems(const char *filename, char ***filesystems, const char FILE *f; char line[128]; - f = fopen(filename, "r"); + f = fopen(filename, "r" UL_CLOEXECSTR); if (!f) return 1; @@ -837,7 +837,7 @@ int mnt_open_uniq_filename(const char *filename, char **name) */ oldmode = umask(S_IRGRP|S_IWGRP|S_IXGRP| S_IROTH|S_IWOTH|S_IXOTH); - fd = mkstemp(n); + fd = mkostemp(n, O_RDWR|O_CREAT|O_EXCL|O_CLOEXEC); umask(oldmode); if (fd >= 0 && name) @@ -949,7 +949,7 @@ char *mnt_get_kernel_cmdline_option(const char *name) if (!path) path = _PATH_PROC_CMDLINE; #endif - f = fopen(path, "r"); + f = fopen(path, "r" UL_CLOEXECSTR); if (!f) return NULL; |